Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2018-09-28 00:59:08 -0400
committerNathan Ridge2018-10-03 15:20:55 -0400
commitd3b1d7652d6c3e6e262d07118c574bfaae6dd3a9 (patch)
treefd0bcfd5bbeb918df7cb80ef02e0cb84fc4d8c31
parentcf9917029674a63f8edaca05aee634ed537e77f9 (diff)
downloadorg.eclipse.cdt-d3b1d7652d6c3e6e262d07118c574bfaae6dd3a9.tar.gz
org.eclipse.cdt-d3b1d7652d6c3e6e262d07118c574bfaae6dd3a9.tar.xz
org.eclipse.cdt-d3b1d7652d6c3e6e262d07118c574bfaae6dd3a9.zip
Bug 539535 - Originate an accurate lookup point in CPPASTFieldReference.createEvaluation()
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java71
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java16
2 files changed, 54 insertions, 33 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java
index 64bb2e4612..8883237b6d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java
@@ -292,43 +292,48 @@ public class CPPASTFieldReference extends ASTNode
}
private ICPPEvaluation createEvaluation() {
- ICPPEvaluation ownerEval = fOwner.getEvaluation();
- if (!ownerEval.isTypeDependent()) {
- IType ownerType= EvalMemberAccess.getFieldOwnerType(ownerEval.getType(), fIsDeref, null, false);
- if (ownerType != null) {
- IBinding binding = fName.resolvePreBinding();
- if (binding instanceof CPPFunctionSet)
- binding= fName.resolveBinding();
-
- if (binding instanceof IProblemBinding || binding instanceof IType || binding instanceof ICPPConstructor) {
- return EvalFixed.INCOMPLETE;
+ try {
+ CPPSemantics.pushLookupPoint(this);
+ ICPPEvaluation ownerEval = fOwner.getEvaluation();
+ if (!ownerEval.isTypeDependent()) {
+ IType ownerType= EvalMemberAccess.getFieldOwnerType(ownerEval.getType(), fIsDeref, null, false);
+ if (ownerType != null) {
+ IBinding binding = fName.resolvePreBinding();
+ if (binding instanceof CPPFunctionSet)
+ binding= fName.resolveBinding();
+
+ if (binding instanceof IProblemBinding || binding instanceof IType || binding instanceof ICPPConstructor) {
+ return EvalFixed.INCOMPLETE;
+ }
+
+ return new EvalMemberAccess(ownerType, ownerEval.getValueCategory(), binding, ownerEval, fIsDeref, this);
}
-
- return new EvalMemberAccess(ownerType, ownerEval.getValueCategory(), binding, ownerEval, fIsDeref, this);
}
- }
-
- IBinding qualifier= null;
- ICPPTemplateArgument[] args= null;
- IASTName n= fName;
- if (n instanceof ICPPASTQualifiedName) {
- ICPPASTQualifiedName qn= (ICPPASTQualifiedName) n;
- ICPPASTNameSpecifier[] ns= qn.getQualifier();
- if (ns.length < 1)
- return EvalFixed.INCOMPLETE;
- qualifier= ns[ns.length - 1].resolveBinding();
- if (qualifier instanceof IProblemBinding)
- return EvalFixed.INCOMPLETE;
- n= qn.getLastName();
- }
- if (n instanceof ICPPASTTemplateId) {
- try {
- args= CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) n);
- } catch (DOMException e) {
- return EvalFixed.INCOMPLETE;
+
+ IBinding qualifier= null;
+ ICPPTemplateArgument[] args= null;
+ IASTName n= fName;
+ if (n instanceof ICPPASTQualifiedName) {
+ ICPPASTQualifiedName qn= (ICPPASTQualifiedName) n;
+ ICPPASTNameSpecifier[] ns= qn.getQualifier();
+ if (ns.length < 1)
+ return EvalFixed.INCOMPLETE;
+ qualifier= ns[ns.length - 1].resolveBinding();
+ if (qualifier instanceof IProblemBinding)
+ return EvalFixed.INCOMPLETE;
+ n= qn.getLastName();
+ }
+ if (n instanceof ICPPASTTemplateId) {
+ try {
+ args= CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) n);
+ } catch (DOMException e) {
+ return EvalFixed.INCOMPLETE;
+ }
}
+ return new EvalID(ownerEval, qualifier, fName.getSimpleID(), false, true, fIsDeref, args, this);
+ } finally {
+ CPPSemantics.popLookupPoint();
}
- return new EvalID(ownerEval, qualifier, fName.getSimpleID(), false, true, fIsDeref, args, this);
}
public static int getFieldPosition(ICPPField field) {
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java
index 46abaa0e33..388986fb14 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java
@@ -740,4 +740,20 @@ public class SemanticHighlightingTest extends TestCase {
ignoredHighlightings.add(SemanticHighlightings.OVERLOADED_OPERATOR);
makeAssertions(ignoredHighlightings);
}
+
+ // struct S { //$class
+ // int waldo; //$field
+ // };
+ // struct Iter { //$class
+ // S operator*(); //$class,methodDeclaration
+ // };
+ // int main() { //$functionDeclaration
+ // Iter it; //$class,localVariableDeclaration
+ // // TODO: The fact that the opening parenthesis gets its own overloadedOperator
+ // // semantic highlighting is an (unrelated) bug.
+ // 1 + (*it).waldo; //$overloadedOperator,overloadedOperator,localVariable,field
+ // }
+ public void testOverloadedOperatorStar_539535() throws Exception {
+ makeAssertions();
+ }
}

Back to the top