diff options
author | Nathan Ridge | 2016-01-31 08:00:01 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-02-12 01:04:21 +0000 |
commit | 01a74ee5f739297a923cd6b0e67c4632bda73b08 (patch) | |
tree | 7d4ca3a72e024827a0f478b01b663f5cc25d4163 | |
parent | bab94bb9d08b8d8da3eb71687eb84bd9b92caa06 (diff) | |
download | org.eclipse.cdt-01a74ee5f739297a923cd6b0e67c4632bda73b08.tar.gz org.eclipse.cdt-01a74ee5f739297a923cd6b0e67c4632bda73b08.tar.xz org.eclipse.cdt-01a74ee5f739297a923cd6b0e67c4632bda73b08.zip |
Bug 472818 - HeuristicResolver: reuse code between findConcreteScopeForType() and resolveUnknownType()
Change-Id: Ie840609aca27fed218ee7ea649c1fd55e33fce59
-rw-r--r-- | core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/HeuristicResolver.java | 41 |
1 files changed, 5 insertions, 36 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/HeuristicResolver.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/HeuristicResolver.java index a1b3233fec1..b9e7f1b082f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/HeuristicResolver.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/HeuristicResolver.java @@ -16,7 +16,6 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IEnumerator; -import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IScope; @@ -40,42 +39,12 @@ public class HeuristicResolver { * @param point the point of instantiation for name lookups */ public static IScope findConcreteScopeForType(IType type, IASTNode point) { - if (type instanceof ICPPDeferredClassInstance) { - // If this scope is for a deferred-class-instance, use the scope of the primary template. - ICPPDeferredClassInstance instance = (ICPPDeferredClassInstance) type; - return instance.getClassTemplate().getCompositeScope(); - } else if (type instanceof TypeOfDependentExpression) { - // If this scope is for the id-expression of a field reference, and the field owner - // is a deferred-class-instance, look up the field in the scope of the primary template, - // and use the scope of the resulting field type. - ICPPEvaluation evaluation = ((TypeOfDependentExpression) type).getEvaluation(); - if (evaluation instanceof EvalID) { - EvalID evalId = (EvalID) evaluation; - ICPPEvaluation fieldOwner = evalId.getFieldOwner(); - if (fieldOwner != null) { - IType fieldOwnerType = fieldOwner.getType(point); - if (fieldOwnerType instanceof ICPPDeferredClassInstance) { - ICPPDeferredClassInstance instance = (ICPPDeferredClassInstance) fieldOwnerType; - IScope scope = instance.getClassTemplate().getCompositeScope(); - LookupData lookup = new LookupData(evalId.getName(), evalId.getTemplateArgs(), point); - lookup.qualified = evalId.isQualified(); - try { - CPPSemantics.lookup(lookup, scope); - } catch (DOMException e) { - return null; - } - IBinding[] bindings = lookup.getFoundBindings(); - if (bindings.length == 1 && bindings[0] instanceof IField) { - IType fieldType = ((IField) bindings[0]).getType(); - if (fieldType instanceof ICompositeType) { - return ((ICompositeType) fieldType).getCompositeScope(); - } - } - } - } - } + if (type instanceof ICPPUnknownType) { + type = resolveUnknownType((ICPPUnknownType) type, point); + } + if (type instanceof ICompositeType) { + return ((ICompositeType) type).getCompositeScope(); } - // TODO(nathanridge): Handle more cases. return null; } |