| Summary: | Classes not recognized when using absolute namespace name | ||
|---|---|---|---|
| Product: | [Applications] kdevelop | Reporter: | Jan Pavlicek <jan.pavlicek> |
| Component: | Language Support: PHP | Assignee: | kdevelop-bugs-null |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | 5.0.3 | ||
| Target Milestone: | --- | ||
| Platform: | Arch Linux | ||
| OS: | Linux | ||
| Latest Commit: | https://commits.kde.org/kdev-php/488b24571de92a7ed7c9c55365384c8c9295bab5 | Version Fixed/Implemented In: | 5.3.0 |
| Sentry Crash Report: | |||
Git commit 488b24571de92a7ed7c9c55365384c8c9295bab5 by Heinz Wiesinger. Committed on 17/08/2018 at 09:53. Pushed by wiesinger into branch '5.3'. Improve resolution of namespaced identifiers. Summary: The PST has problems matching qualified identifiers explicitely set to global with declarations. To work around this we normalize the namespaced identifier to be always absolute. This means that namespace resolution inside findDeclarationImportHelper should be correct now, but may need several calls to find the declaration we're looking for according to the correct rules. Unfortunately, the rules are different for classes, use declarations, functions, constants, etc. That's why it really needs to be call-side decision on what fallbacks can or can't be used. FIXED-IN: 5.3.0 Reviewers: brauch Reviewed By: brauch Subscribers: brauch, kdevelop-devel Tags: #kdevelop Differential Revision: https://phabricator.kde.org/D14839 M +7 -1 duchain/builders/contextbuilder.cpp M +1 -1 duchain/builders/contextbuilder.h M +18 -2 duchain/builders/declarationbuilder.cpp M +5 -2 duchain/builders/typebuilder.cpp M +25 -1 duchain/builders/usebuilder.cpp M +9 -1 duchain/expressionvisitor.cpp M +15 -18 duchain/helper.cpp M +5 -0 duchain/helper.h M +37 -0 duchain/tests/duchain_multiplefiles.cpp M +1 -0 duchain/tests/duchain_multiplefiles.h https://commits.kde.org/kdev-php/488b24571de92a7ed7c9c55365384c8c9295bab5 |
When using a class from another namespace in file that is also in a namespace, one needs to prepend the full class name with a backslash to indicate absolute path. But KDevelop fails to recognize the class with the backslash. When I remove the backslash, class is recognized (is colored and can be jumped to), but the code no longer works, because the class does not exist (it's path is resolved relative to current namespace). Demonstration: file1.php <?php namespace Test; class A { } ?> file2.php - working PHP code, but new \Test\A; is not recognized <?php namespace Test2; class B { public $class_a; public function __construct() { $this->class_a = new \Test\A; } } ?> file3.php - non working PHP code (class gets resolved to Test2\Test\A, which does not exist), but new \Test\A; is recognized as Test\A by KDevelop <?php namespace Test2; class B { public $class_a; public function __construct() { $this->class_a = new Test\A; } } ?>