mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 539535 - Originate an accurate lookup point in CPPASTFieldReference.createEvaluation()
Change-Id: I8030d5b304a61d7235a8ca92cf99de2d9a9aff68
This commit is contained in:
parent
fde7476a1a
commit
dcc09f1975
2 changed files with 54 additions and 33 deletions
|
@ -292,43 +292,48 @@ public class CPPASTFieldReference extends ASTNode
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICPPEvaluation createEvaluation() {
|
private ICPPEvaluation createEvaluation() {
|
||||||
ICPPEvaluation ownerEval = fOwner.getEvaluation();
|
try {
|
||||||
if (!ownerEval.isTypeDependent()) {
|
CPPSemantics.pushLookupPoint(this);
|
||||||
IType ownerType= EvalMemberAccess.getFieldOwnerType(ownerEval.getType(), fIsDeref, null, false);
|
ICPPEvaluation ownerEval = fOwner.getEvaluation();
|
||||||
if (ownerType != null) {
|
if (!ownerEval.isTypeDependent()) {
|
||||||
IBinding binding = fName.resolvePreBinding();
|
IType ownerType= EvalMemberAccess.getFieldOwnerType(ownerEval.getType(), fIsDeref, null, false);
|
||||||
if (binding instanceof CPPFunctionSet)
|
if (ownerType != null) {
|
||||||
binding= fName.resolveBinding();
|
IBinding binding = fName.resolvePreBinding();
|
||||||
|
if (binding instanceof CPPFunctionSet)
|
||||||
|
binding= fName.resolveBinding();
|
||||||
|
|
||||||
if (binding instanceof IProblemBinding || binding instanceof IType || binding instanceof ICPPConstructor) {
|
if (binding instanceof IProblemBinding || binding instanceof IType || binding instanceof ICPPConstructor) {
|
||||||
|
return EvalFixed.INCOMPLETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
return EvalFixed.INCOMPLETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new EvalMemberAccess(ownerType, ownerEval.getValueCategory(), binding, ownerEval, fIsDeref, this);
|
|
||||||
}
|
}
|
||||||
|
return new EvalID(ownerEval, qualifier, fName.getSimpleID(), false, true, fIsDeref, args, this);
|
||||||
|
} finally {
|
||||||
|
CPPSemantics.popLookupPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getFieldPosition(ICPPField field) {
|
public static int getFieldPosition(ICPPField field) {
|
||||||
|
|
|
@ -740,4 +740,20 @@ public class SemanticHighlightingTest extends TestCase {
|
||||||
ignoredHighlightings.add(SemanticHighlightings.OVERLOADED_OPERATOR);
|
ignoredHighlightings.add(SemanticHighlightings.OVERLOADED_OPERATOR);
|
||||||
makeAssertions(ignoredHighlightings);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue