aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDawid Pakuła2018-07-19 11:45:05 -0400
committerDawid Pakuła2018-07-19 11:45:05 -0400
commitf19e5baff96f584388429216b248180bd7dc4c7c (patch)
treeb2d7abec0f87ace682ad813fa2db6946691c44f3
parent425295b867f11424cf1bad61b8db168389d821a4 (diff)
downloadorg.eclipse.pdt-f19e5baff96f584388429216b248180bd7dc4c7c.tar.gz
org.eclipse.pdt-f19e5baff96f584388429216b248180bd7dc4c7c.tar.xz
org.eclipse.pdt-f19e5baff96f584388429216b248180bd7dc4c7c.zip
Bug 536998 - Bad autocompletion in anonymous functions
Signed-off-by: Dawid Pakuła <zulus@w3des.net>
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/contexts/ClassMemberContext.java11
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/VariableReferenceEvaluator.java7
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/codeassist/php53/test536998.pdtt29
3 files changed, 38 insertions, 9 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/contexts/ClassMemberContext.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/contexts/ClassMemberContext.java
index b32674a38..f22c33882 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/contexts/ClassMemberContext.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/contexts/ClassMemberContext.java
@@ -47,10 +47,10 @@ public abstract class ClassMemberContext extends StatementContext {
* Trigger type of the member invocation
*/
public enum Trigger {
- /** Class trigger type: '::' */
- CLASS("::"), //$NON-NLS-1$
- /** Object trigger type: '->' */
- OBJECT("->"),; //$NON-NLS-1$
+ /** Class trigger type: '::' */
+ CLASS("::"), //$NON-NLS-1$
+ /** Object trigger type: '->' */
+ OBJECT("->"),; //$NON-NLS-1$
String name;
@@ -105,6 +105,9 @@ public abstract class ClassMemberContext extends StatementContext {
IModelElement enclosingElement = getEnclosingElement();
while (enclosingElement instanceof IMethod) {
enclosingElement = enclosingElement.getParent();
+ if (enclosingElement instanceof IField) { // anonymous function
+ enclosingElement = enclosingElement.getParent();
+ }
}
if (enclosingElement instanceof IType && PHPFlags.isAnonymous(((IType) enclosingElement).getFlags())) {
tmpTypes.add((IType) enclosingElement);
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/VariableReferenceEvaluator.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/VariableReferenceEvaluator.java
index 4a3a7c8c4..8541359cc 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/VariableReferenceEvaluator.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/VariableReferenceEvaluator.java
@@ -277,11 +277,8 @@ public class VariableReferenceEvaluator extends GoalEvaluator {
protected boolean isInteresting(ASTNode node) {
if (node.sourceStart() <= variableOffset) {
- if (node instanceof Assignment) {
- Assignment tmp = (Assignment) node;
- if (tmp.getValue().start() <= variableOffset && tmp.getValue().end() > variableOffset) {
- return false;
- }
+ if (node instanceof Assignment && ((Assignment) node).getValue() instanceof CloneExpression) {
+ return false;
}
return true;
}
diff --git a/tests/org.eclipse.php.core.tests/workspace/codeassist/php53/test536998.pdtt b/tests/org.eclipse.php.core.tests/workspace/codeassist/php53/test536998.pdtt
new file mode 100644
index 000000000..63e190347
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/codeassist/php53/test536998.pdtt
@@ -0,0 +1,29 @@
+--TEST--
+Bug http://eclip.se/536998
+--PREFERENCES--
+org.eclipse.php.core/contentAssistShowStrictOptions=false
+--FILE--
+<?php
+
+class FormDefinition
+{
+ public function getFields() {}
+}
+
+class FormType
+{
+ public function configureFields()
+ {
+ $configCallback = function ()
+ {
+ $formDefinition = new FormDefinition();
+ return $formDefinition->|;
+ };
+ return [
+ 'callback' => $configCallback
+ ];
+ }
+}
+
+--EXPECT--
+method(getFields) \ No newline at end of file