Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDawid Pakuła2019-08-03 10:48:08 -0400
committerDawid Pakuła2019-08-03 10:48:08 -0400
commitc22b3ca4fd1d55beb87986f716516051cfe14f1f (patch)
tree3070d038ed9335202383a1f0618cbcac7eb423d5
parent15f7abf53f6c63b03e73e7563d43a6436f809662 (diff)
downloadorg.eclipse.pdt-c22b3ca4fd1d55beb87986f716516051cfe14f1f.tar.gz
org.eclipse.pdt-c22b3ca4fd1d55beb87986f716516051cfe14f1f.tar.xz
org.eclipse.pdt-c22b3ca4fd1d55beb87986f716516051cfe14f1f.zip
Bug 549308 - No property / method proposal for array of objects
Change-Id: I8d58cac58ac57dd9d578fd730a6627c08b163172 Signed-off-by: Dawid Pakuła <zulus@w3des.net>
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/TypeReferenceEvaluator.java14
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/codeassist/php53/test549308.pdtt32
2 files changed, 43 insertions, 3 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/TypeReferenceEvaluator.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/TypeReferenceEvaluator.java
index 4c4bd9be4..4f120e0bc 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/TypeReferenceEvaluator.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/TypeReferenceEvaluator.java
@@ -29,6 +29,7 @@ import org.eclipse.dltk.ast.references.SimpleReference;
import org.eclipse.dltk.ast.references.TypeReference;
import org.eclipse.dltk.core.*;
import org.eclipse.dltk.evaluation.types.AmbiguousType;
+import org.eclipse.dltk.evaluation.types.MultiTypeType;
import org.eclipse.dltk.evaluation.types.UnknownType;
import org.eclipse.dltk.internal.core.ImportDeclaration;
import org.eclipse.dltk.ti.GoalState;
@@ -186,9 +187,9 @@ public class TypeReferenceEvaluator extends GoalEvaluator {
elementType = ((FullyQualifiedReference) typeReference).getElementType();
} else {
fullyQualifiedName = typeReference.getName();
+ fullyQualifiedName = PHPEvaluationUtils.extractArrayType(fullyQualifiedName);
- elementName = PHPEvaluationUtils.extractArrayType(fullyQualifiedName);
- elementName = PHPModelUtils.extractElementName(elementName);
+ elementName = PHPModelUtils.extractElementName(fullyQualifiedName);
}
ISourceModule sourceModule = ((ISourceModuleContext) context).getSourceModule();
int offset = typeReference.sourceStart();
@@ -239,7 +240,8 @@ public class TypeReferenceEvaluator extends GoalEvaluator {
parentNamespace = extractedNamespace;
// See also code from PHPClassType.fromTypeName(...) and
// PHPClassType.fromTraitName(...)
- elementName = PHPModelUtils.getRealName(extractedNamespace, fullyQualifiedName, sourceModule, offset, elementName);
+ elementName = PHPModelUtils.getRealName(extractedNamespace, fullyQualifiedName, sourceModule, offset,
+ elementName);
}
if (PHPModelUtils.isInUseTraitStatement(((ISourceModuleContext) context).getRootNode(),
typeReference.sourceStart())) {
@@ -261,6 +263,12 @@ public class TypeReferenceEvaluator extends GoalEvaluator {
result = new PHPClassType(elementName);
}
}
+ if (PHPEvaluationUtils.isArrayType(typeReference.getName())) {
+ // XXX Quick Fix for bug 549308
+ MultiTypeType tmp = new MultiTypeType();
+ tmp.addType(result);
+ result = tmp;
+ }
}
return IGoal.NO_GOALS;
diff --git a/tests/org.eclipse.php.core.tests/workspace/codeassist/php53/test549308.pdtt b/tests/org.eclipse.php.core.tests/workspace/codeassist/php53/test549308.pdtt
new file mode 100644
index 000000000..5f0c40a38
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/codeassist/php53/test549308.pdtt
@@ -0,0 +1,32 @@
+--TEST--
+Fix bug 549308
+--PREFERENCES--
+org.eclipse.php.core/contentAssistShowStrictOptions=true
+--FILE--
+<?php
+namespace App\Tmp;
+
+use App\Foo;
+
+class Bar
+{
+ public function test()
+ {
+ /** @var Foo[] $list */
+ $list = $this->getList();
+
+ foreach ($list as $item) {
+ $item->|
+ }
+ }
+
+}
+--FILE0--
+<?php
+namespace App;
+final class Foo
+{
+ public function getText() {}
+}
+--EXPECT--
+method(getText)

Back to the top