List of usage examples for org.eclipse.jdt.internal.compiler.lookup Binding isValidBinding
public final boolean isValidBinding()
From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.MatchLocator.java
License:Open Source License
protected TypeBinding getType(Object typeKey, char[] typeName) { if (this.unitScope == null || typeName == null || typeName.length == 0) return null; // Try to get binding from cache Binding binding = (Binding) this.bindings.get(typeKey); if (binding != null) { if (binding instanceof TypeBinding && binding.isValidBinding()) return (TypeBinding) binding; return null; }/*w ww .ja v a 2 s .co m*/ // Get binding from unit scope char[][] compoundName = CharOperation.splitOn('.', typeName); TypeBinding typeBinding = this.unitScope.getType(compoundName, compoundName.length); if (typeBinding == null || !typeBinding.isValidBinding()) { typeBinding = this.lookupEnvironment.getType(compoundName); } this.bindings.put(typeKey, typeBinding); return typeBinding != null && typeBinding.isValidBinding() ? typeBinding : null; }
From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.MatchLocator.java
License:Open Source License
private MethodBinding getMethodBinding0(MethodPattern methodPattern) { if (this.unitScope == null) return null; // Try to get binding from cache Binding binding = (Binding) this.bindings.get(methodPattern); if (binding != null) { if (binding instanceof MethodBinding && binding.isValidBinding()) return (MethodBinding) binding; return null; }/*w w w . j a v a 2s. c om*/ // Get binding from unit scope char[] typeName = PatternLocator.qualifiedPattern(methodPattern.declaringSimpleName, methodPattern.declaringQualification); if (typeName == null) { if (methodPattern.declaringType == null) return null; typeName = methodPattern.declaringType.getFullyQualifiedName().toCharArray(); } TypeBinding declaringTypeBinding = getType(typeName, typeName); if (declaringTypeBinding != null) { if (declaringTypeBinding.isArrayType()) { declaringTypeBinding = declaringTypeBinding.leafComponentType(); } if (!declaringTypeBinding.isBaseType()) { char[][] parameterTypes = methodPattern.parameterSimpleNames; if (parameterTypes == null) return null; int paramTypeslength = parameterTypes.length; ReferenceBinding referenceBinding = (ReferenceBinding) declaringTypeBinding; MethodBinding[] methods = referenceBinding.getMethods(methodPattern.selector); int methodsLength = methods.length; TypeVariableBinding[] refTypeVariables = referenceBinding.typeVariables(); int typeVarLength = refTypeVariables == null ? 0 : refTypeVariables.length; for (int i = 0; i < methodsLength; i++) { TypeBinding[] methodParameters = methods[i].parameters; int paramLength = methodParameters == null ? 0 : methodParameters.length; TypeVariableBinding[] methodTypeVariables = methods[i].typeVariables; int methTypeVarLength = methodTypeVariables == null ? 0 : methodTypeVariables.length; boolean found = false; if (methodParameters != null && paramLength == paramTypeslength) { for (int p = 0; p < paramLength; p++) { if (CharOperation.equals(methodParameters[p].sourceName(), parameterTypes[p])) { // param erasure match found = true; } else { // type variable found = false; if (refTypeVariables != null) { for (int v = 0; v < typeVarLength; v++) { if (!CharOperation.equals(refTypeVariables[v].sourceName, parameterTypes[p])) { found = false; break; } found = true; } } if (!found && methodTypeVariables != null) { for (int v = 0; v < methTypeVarLength; v++) { if (!CharOperation.equals(methodTypeVariables[v].sourceName, parameterTypes[p])) { found = false; break; } found = true; } } if (!found) break; } } } if (found) { this.bindings.put(methodPattern, methods[i]); return methods[i]; } } } } this.bindings.put(methodPattern, new ProblemMethodBinding(methodPattern.selector, null, ProblemReasons.NotFound)); return null; }
From source file:org.eclipse.jdt.internal.compiler.lookup.Scope.java
License:Open Source License
public Binding getBinding(char[] name, int mask, InvocationSite invocationSite, boolean needResolve) { CompilationUnitScope unitScope = compilationUnitScope(); LookupEnvironment env = unitScope.environment; try {// w w w.j a v a 2s . c om env.missingClassFileLocation = invocationSite; Binding binding = null; FieldBinding problemField = null; if ((mask & Binding.VARIABLE) != 0) { boolean insideStaticContext = false; boolean insideConstructorCall = false; boolean insideTypeAnnotation = false; FieldBinding foundField = null; // can be a problem field which is answered if a valid field is not found ProblemFieldBinding foundInsideProblem = null; // inside Constructor call or inside static context Scope scope = this; int depth = 0; int foundDepth = 0; ReferenceBinding foundActualReceiverType = null; done: while (true) { // done when a COMPILATION_UNIT_SCOPE is found switch (scope.kind) { case METHOD_SCOPE: MethodScope methodScope = (MethodScope) scope; insideStaticContext |= methodScope.isStatic; insideConstructorCall |= methodScope.isConstructorCall; insideTypeAnnotation = methodScope.insideTypeAnnotation; //$FALL-THROUGH$ could duplicate the code below to save a cast - questionable optimization case BLOCK_SCOPE: LocalVariableBinding variableBinding = scope.findVariable(name); // looks in this scope only if (variableBinding != null) { if (foundField != null && foundField.isValidBinding()) return new ProblemFieldBinding(foundField, // closest match foundField.declaringClass, name, ProblemReasons.InheritedNameHidesEnclosingName); if (depth > 0) invocationSite.setDepth(depth); return variableBinding; } break; case CLASS_SCOPE: ClassScope classScope = (ClassScope) scope; ReferenceBinding receiverType = classScope.enclosingReceiverType(); if (!insideTypeAnnotation) { FieldBinding fieldBinding = classScope.findField(receiverType, name, invocationSite, needResolve); // Use next line instead if willing to enable protected access accross inner types // FieldBinding fieldBinding = findField(enclosingType, name, invocationSite); if (fieldBinding != null) { // skip it if we did not find anything if (fieldBinding.problemId() == ProblemReasons.Ambiguous) { if (foundField == null || foundField.problemId() == ProblemReasons.NotVisible) // supercedes any potential InheritedNameHidesEnclosingName problem return fieldBinding; // make the user qualify the field, likely wants the first inherited field (javac generates an ambiguous error instead) return new ProblemFieldBinding(foundField, // closest match foundField.declaringClass, name, ProblemReasons.InheritedNameHidesEnclosingName); } ProblemFieldBinding insideProblem = null; if (fieldBinding.isValidBinding()) { if (!fieldBinding.isStatic()) { if (insideConstructorCall) { insideProblem = new ProblemFieldBinding(fieldBinding, // closest match fieldBinding.declaringClass, name, ProblemReasons.NonStaticReferenceInConstructorInvocation); } else if (insideStaticContext) { insideProblem = new ProblemFieldBinding(fieldBinding, // closest match fieldBinding.declaringClass, name, ProblemReasons.NonStaticReferenceInStaticContext); } } if (receiverType == fieldBinding.declaringClass || compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) { // found a valid field in the 'immediate' scope (i.e. not inherited) // OR in 1.4 mode (inherited shadows enclosing) if (foundField == null) { if (depth > 0) { invocationSite.setDepth(depth); invocationSite.setActualReceiverType(receiverType); } // return the fieldBinding if it is not declared in a superclass of the scope's binding (that is, inherited) return insideProblem == null ? fieldBinding : insideProblem; } if (foundField.isValidBinding()) // if a valid field was found, complain when another is found in an 'immediate' enclosing type (that is, not inherited) // but only if "valid field" was inherited in the first place. if (foundField.declaringClass != fieldBinding.declaringClass && foundField.declaringClass != foundActualReceiverType) // https://bugs.eclipse.org/bugs/show_bug.cgi?id=316956 // i.e. have we found the same field - do not trust field identity yet return new ProblemFieldBinding(foundField, // closest match foundField.declaringClass, name, ProblemReasons.InheritedNameHidesEnclosingName); } } if (foundField == null || (foundField.problemId() == ProblemReasons.NotVisible && fieldBinding.problemId() != ProblemReasons.NotVisible)) { // only remember the fieldBinding if its the first one found or the previous one was not visible & fieldBinding is... foundDepth = depth; foundActualReceiverType = receiverType; foundInsideProblem = insideProblem; foundField = fieldBinding; } } } insideTypeAnnotation = false; depth++; insideStaticContext |= receiverType.isStatic(); // 1EX5I8Z - accessing outer fields within a constructor call is permitted // in order to do so, we change the flag as we exit from the type, not the method // itself, because the class scope is used to retrieve the fields. MethodScope enclosingMethodScope = scope.methodScope(); insideConstructorCall = enclosingMethodScope == null ? false : enclosingMethodScope.isConstructorCall; break; case COMPILATION_UNIT_SCOPE: break done; } scope = scope.parent; } if (foundInsideProblem != null) return foundInsideProblem; if (foundField != null) { if (foundField.isValidBinding()) { if (foundDepth > 0) { invocationSite.setDepth(foundDepth); invocationSite.setActualReceiverType(foundActualReceiverType); } return foundField; } problemField = foundField; foundField = null; } if (compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { // at this point the scope is a compilation unit scope & need to check for imported static fields unitScope.faultInImports(); // ensure static imports are resolved ImportBinding[] imports = unitScope.imports; if (imports != null) { // check single static imports for (int i = 0, length = imports.length; i < length; i++) { ImportBinding importBinding = imports[i]; if (importBinding.isStatic() && !importBinding.onDemand) { if (CharOperation.equals( importBinding.compoundName[importBinding.compoundName.length - 1], name)) { if (unitScope.resolveSingleImport(importBinding, Binding.TYPE | Binding.FIELD | Binding.METHOD) != null && importBinding.resolvedImport instanceof FieldBinding) { foundField = (FieldBinding) importBinding.resolvedImport; ImportReference importReference = importBinding.reference; if (importReference != null && needResolve) { importReference.bits |= ASTNode.Used; } invocationSite.setActualReceiverType(foundField.declaringClass); if (foundField.isValidBinding()) { return foundField; } if (problemField == null) problemField = foundField; } } } } // check on demand imports boolean foundInImport = false; for (int i = 0, length = imports.length; i < length; i++) { ImportBinding importBinding = imports[i]; if (importBinding.isStatic() && importBinding.onDemand) { Binding resolvedImport = importBinding.resolvedImport; if (resolvedImport instanceof ReferenceBinding) { FieldBinding temp = findField((ReferenceBinding) resolvedImport, name, invocationSite, needResolve); if (temp != null) { if (!temp.isValidBinding()) { if (problemField == null) problemField = temp; } else if (temp.isStatic()) { if (foundField == temp) continue; ImportReference importReference = importBinding.reference; if (importReference != null && needResolve) { importReference.bits |= ASTNode.Used; } if (foundInImport) // Answer error binding -- import on demand conflict; name found in two import on demand packages. return new ProblemFieldBinding(foundField, // closest match foundField.declaringClass, name, ProblemReasons.Ambiguous); foundField = temp; foundInImport = true; } } } } } if (foundField != null) { invocationSite.setActualReceiverType(foundField.declaringClass); return foundField; } } } } // We did not find a local or instance variable. if ((mask & Binding.TYPE) != 0) { if ((binding = getBaseType(name)) != null) return binding; binding = getTypeOrPackage(name, (mask & Binding.PACKAGE) == 0 ? Binding.TYPE : Binding.TYPE | Binding.PACKAGE, needResolve); if (binding.isValidBinding() || mask == Binding.TYPE) return binding; // answer the problem type binding if we are only looking for a type } else if ((mask & Binding.PACKAGE) != 0) { unitScope.recordSimpleReference(name); if ((binding = env.getTopLevelPackage(name)) != null) return binding; } if (problemField != null) return problemField; if (binding != null && binding.problemId() != ProblemReasons.NotFound) return binding; // answer the better problem binding return new ProblemBinding(name, enclosingSourceType(), ProblemReasons.NotFound); } catch (AbortCompilation e) { e.updateContext(invocationSite, referenceCompilationUnit().compilationResult); throw e; } finally { env.missingClassFileLocation = null; } }
From source file:org.eclipse.jdt.internal.compiler.lookup.Scope.java
License:Open Source License
public final Binding getPackage(char[][] compoundName) { compilationUnitScope().recordQualifiedReference(compoundName); Binding binding = getTypeOrPackage(compoundName[0], Binding.TYPE | Binding.PACKAGE, true); if (binding == null) { char[][] qName = new char[][] { compoundName[0] }; return new ProblemReferenceBinding(qName, environment().createMissingType(null, compoundName), ProblemReasons.NotFound); }/*from w w w . j a v a 2 s . c o m*/ if (!binding.isValidBinding()) { if (binding instanceof PackageBinding) { /* missing package */ char[][] qName = new char[][] { compoundName[0] }; return new ProblemReferenceBinding(qName, null /* no closest match since search for pkg*/, ProblemReasons.NotFound); } return binding; } if (!(binding instanceof PackageBinding)) return null; // compoundName does not start with a package int currentIndex = 1, length = compoundName.length; PackageBinding packageBinding = (PackageBinding) binding; while (currentIndex < length) { binding = packageBinding.getTypeOrPackage(compoundName[currentIndex++]); if (binding == null) { return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), null /* no closest match since search for pkg*/, ProblemReasons.NotFound); } if (!binding.isValidBinding()) return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), binding instanceof ReferenceBinding ? (ReferenceBinding) ((ReferenceBinding) binding).closestMatch() : null, binding.problemId()); if (!(binding instanceof PackageBinding)) return packageBinding; packageBinding = (PackageBinding) binding; } return new ProblemReferenceBinding(compoundName, null /* no closest match since search for pkg*/, ProblemReasons.NotFound); }
From source file:org.eclipse.jdt.internal.compiler.lookup.Scope.java
License:Open Source License
public final TypeBinding getType(char[] name, PackageBinding packageBinding) { if (packageBinding == null) return getType(name); Binding binding = packageBinding.getTypeOrPackage(name); if (binding == null) { return new ProblemReferenceBinding(CharOperation.arrayConcat(packageBinding.compoundName, name), null, ProblemReasons.NotFound); }// w w w. jav a2 s .co m if (!binding.isValidBinding()) { return new ProblemReferenceBinding( binding instanceof ReferenceBinding ? ((ReferenceBinding) binding).compoundName : CharOperation.arrayConcat(packageBinding.compoundName, name), binding instanceof ReferenceBinding ? (ReferenceBinding) ((ReferenceBinding) binding).closestMatch() : null, binding.problemId()); } ReferenceBinding typeBinding = (ReferenceBinding) binding; if (!typeBinding.canBeSeenBy(this)) return new ProblemReferenceBinding(typeBinding.compoundName, typeBinding, ProblemReasons.NotVisible); return typeBinding; }
From source file:org.eclipse.jdt.internal.core.search.matching.MatchLocator.java
License:Open Source License
protected TypeBinding getType(Object typeKey, char[] typeName) { if (this.unitScope == null || typeName == null || typeName.length == 0) return null; // Try to get binding from cache Binding binding = (Binding) this.bindings.get(typeKey); if (binding != null) { if (binding instanceof TypeBinding && binding.isValidBinding()) return (TypeBinding) binding; return null; }//www .j av a 2 s . c o m // Get binding from unit scope char[][] compoundName = CharOperation.splitOn('.', typeName); TypeBinding typeBinding = this.unitScope.getType(compoundName, compoundName.length); this.bindings.put(typeKey, typeBinding); return typeBinding.isValidBinding() ? typeBinding : null; }
From source file:org.eclipse.jdt.internal.core.search.matching.MatchLocator.java
License:Open Source License
public MethodBinding getMethodBinding(MethodPattern methodPattern) { if (this.unitScope == null) return null; // Try to get binding from cache Binding binding = (Binding) this.bindings.get(methodPattern); if (binding != null) { if (binding instanceof MethodBinding && binding.isValidBinding()) return (MethodBinding) binding; return null; }/*from ww w. ja v a 2s . c o m*/ // Get binding from unit scope char[] typeName = PatternLocator.qualifiedPattern(methodPattern.declaringSimpleName, methodPattern.declaringQualification); if (typeName == null) { if (methodPattern.declaringType == null) return null; typeName = methodPattern.declaringType.getFullyQualifiedName().toCharArray(); } TypeBinding declaringTypeBinding = getType(typeName, typeName); if (declaringTypeBinding != null) { if (declaringTypeBinding.isArrayType()) { declaringTypeBinding = declaringTypeBinding.leafComponentType(); } if (!declaringTypeBinding.isBaseType()) { char[][] parameterTypes = methodPattern.parameterSimpleNames; if (parameterTypes == null) return null; int paramTypeslength = parameterTypes.length; ReferenceBinding referenceBinding = (ReferenceBinding) declaringTypeBinding; MethodBinding[] methods = referenceBinding.getMethods(methodPattern.selector); int methodsLength = methods.length; TypeVariableBinding[] refTypeVariables = referenceBinding.typeVariables(); int typeVarLength = refTypeVariables == null ? 0 : refTypeVariables.length; for (int i = 0; i < methodsLength; i++) { TypeBinding[] methodParameters = methods[i].parameters; int paramLength = methodParameters == null ? 0 : methodParameters.length; TypeVariableBinding[] methodTypeVariables = methods[i].typeVariables; int methTypeVarLength = methodTypeVariables == null ? 0 : methodTypeVariables.length; boolean found = false; if (methodParameters != null && paramLength == paramTypeslength) { for (int p = 0; p < paramLength; p++) { if (CharOperation.equals(methodParameters[p].sourceName(), parameterTypes[p])) { // param erasure match found = true; } else { // type variable found = false; if (refTypeVariables != null) { for (int v = 0; v < typeVarLength; v++) { if (!CharOperation.equals(refTypeVariables[v].sourceName, parameterTypes[p])) { found = false; break; } found = true; } } if (!found && methodTypeVariables != null) { for (int v = 0; v < methTypeVarLength; v++) { if (!CharOperation.equals(methodTypeVariables[v].sourceName, parameterTypes[p])) { found = false; break; } found = true; } } if (!found) break; } } } if (found) { this.bindings.put(methodPattern, methods[i]); return methods[i]; } } } } this.bindings.put(methodPattern, new ProblemMethodBinding(methodPattern.selector, null, ProblemReasons.NotFound)); return null; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.TypeAnchorReference.java
License:Open Source License
ITeamAnchor resolveAnchor(Scope scope, Reference reference) { ITeamAnchor prefix = null;//from ww w. ja va2 s . c o m ITeamAnchor currentAnchor = null; char[] currentToken = null; // for lookup and creation of problem binding // be careful not to trigger fields() which may be where we are called from! if (reference instanceof SingleNameReference) { SingleNameReference singleAnchor = (SingleNameReference) reference; currentToken = singleAnchor.token; currentAnchor = findVariable(scope, currentToken, scope.isStatic(), singleAnchor.sourceStart, singleAnchor.sourceEnd); this.anchor.bits |= (this.bits & DepthMASK); // could be ProblemAnchorBinding } else if (reference instanceof FieldReference) { FieldReference fieldRef = (FieldReference) reference; Expression prefixExpr = fieldRef.receiver; if (!(prefixExpr instanceof Reference)) throw new InternalCompilerError("Unexpected anchor prefix " + prefixExpr); //$NON-NLS-1$ prefix = resolveAnchor(scope, (Reference) prefixExpr); currentToken = fieldRef.token; // fieldRef holds on to problem binding: fieldRef.binding = TypeAnalyzer.findField(((ReferenceBinding) prefix.getResolvedType()).getRealClass(), currentToken, false/*static*/, true/*outer*/); currentAnchor = checkAnchor(scope, reference, currentToken, reference.sourceStart, reference.sourceEnd, fieldRef.binding); } else if (reference instanceof QualifiedBaseReference) { QualifiedBaseReference baseRef = (QualifiedBaseReference) reference; if (scope instanceof BlockScope) baseRef.resolveType((BlockScope) scope); else baseRef.resolveType((ClassScope) scope); currentAnchor = baseRef.baseField; } else if (reference instanceof QualifiedThisReference) { QualifiedThisReference thisRef = (QualifiedThisReference) reference; if (scope instanceof BlockScope) thisRef.resolveType((BlockScope) scope); else thisRef.resolveType((ClassScope) scope); if (thisRef.resolvedType.isTeam()) currentAnchor = ((ReferenceBinding) thisRef.resolvedType).getTeamModel().getTThis(); } else { boolean haveReportedProblem = false; long currentPos = 0; QualifiedNameReference qualifiedAnchor = (QualifiedNameReference) reference; char[][] tokens = qualifiedAnchor.tokens; currentToken = tokens[tokens.length - 1]; // default, so we never use null name for problem binding // check maximal static prefix: Binding staticPrefix = null; int j; for (j = 1; j <= tokens.length; j++) { Binding current = scope.getTypeOrPackage(CharOperation.subarray(tokens, 0, j)); if (current == null || !current.isValidBinding()) break; else staticPrefix = current; } if (j > tokens.length) { scope.problemReporter().typeAnchorReferenceNotAValue(reference); haveReportedProblem = true; } else { // find first field: if (staticPrefix != null) { currentPos = qualifiedAnchor.sourcePositions[j - 1]; currentToken = tokens[j - 1]; if (staticPrefix instanceof ReferenceBinding) { currentAnchor = TypeAnalyzer.findField(((ReferenceBinding) staticPrefix).getRealClass(), currentToken, /*static*/true, /*outer*/true); } else { scope.problemReporter().typeAnchorReferenceNotAnObjectRef((int) (currentPos >>> 32), (int) currentPos); haveReportedProblem = true; } } else { currentPos = qualifiedAnchor.sourcePositions[0]; currentToken = tokens[0]; currentAnchor = findVariable(scope, currentToken, scope.isStatic(), (int) (currentPos >>> 32), (int) currentPos); haveReportedProblem = currentAnchor == null; } if (currentAnchor != null) { if (!currentAnchor.hasValidReferenceType()) { if (j < tokens.length) // would need to process more tokens? currentAnchor = null; // replace with problem binding below } else { // find more fields: for (int i = j; i < tokens.length; i++) { TypeBinding fieldType = currentAnchor.getResolvedType().leafComponentType(); if (fieldType instanceof SourceTypeBinding) { SourceTypeBinding stb = (SourceTypeBinding) fieldType; if ((stb.scope != null) && (stb.scope.compilationUnitScope() != scope.compilationUnitScope()) && (stb.tagBits & (TagBits.BeginHierarchyCheck | TagBits.EndHierarchyCheck)) == (TagBits.BeginHierarchyCheck | TagBits.EndHierarchyCheck) && StateHelper.isReadyToProcess(stb, ITranslationStates.STATE_LENV_DONE_FIELDS_AND_METHODS)) Dependencies.ensureBindingState(stb, ITranslationStates.STATE_LENV_DONE_FIELDS_AND_METHODS); } currentPos = qualifiedAnchor.sourcePositions[i]; currentToken = tokens[i]; FieldBinding nextField = currentAnchor.getFieldOfType(currentToken, /*static*/false, true); if (nextField == null || !nextField.hasValidReferenceType()) { currentAnchor = null; // replace with problem binding below break; } currentAnchor = nextField.setPathPrefix(currentAnchor); } } } } if (!haveReportedProblem) { if (currentAnchor == null) { scope.problemReporter().typeAnchorNotFound(currentToken, (int) (currentPos >>> 32), (int) currentPos); } else if (!currentAnchor.hasValidReferenceType()) { scope.problemReporter().typeAnchorReferenceNotAnObjectRef((int) (currentPos >>> 32), (int) currentPos); } } } if (currentAnchor == null) { currentAnchor = new ProblemFieldBinding(scope.enclosingReceiverType(), currentToken, ProblemReasons.NotFound); ((FieldBinding) currentAnchor).type = reference.resolvedType = new ProblemReferenceBinding( "UnresolvedType".toCharArray(), null, ProblemReasons.NotFound); //$NON-NLS-1$ } else if (currentAnchor.isValidBinding()) { if (prefix != null && !(prefix instanceof TThisBinding)) currentAnchor = currentAnchor.setPathPrefix(prefix); // fill anchor with resolved data: reference.resolvedType = currentAnchor.getResolvedType(); reference.bits &= ~RestrictiveFlagMASK; // clear bits if (currentAnchor instanceof FieldBinding) { reference.bits |= Binding.FIELD; // TODO(SH): must we remember a previous anchor to set this correctly?: if (reference instanceof NameReference) ((NameReference) reference).actualReceiverType = ((FieldBinding) currentAnchor).declaringClass; if (reference instanceof FieldReference) ((FieldReference) reference).actualReceiverType = ((FieldBinding) currentAnchor).declaringClass; } else { reference.bits |= Binding.LOCAL; } reference.constant = Constant.NotAConstant; } if (reference instanceof NameReference) { ((NameReference) reference).binding = (Binding) currentAnchor; ((NameReference) reference).resolveFinished(); } else if (reference instanceof FieldReference) { ((FieldReference) reference).binding = (FieldBinding) currentAnchor; //TODO(SH): this method doesn't exist, is the call needed? //((FieldReference)this.anchor).resolveFinished(); } return currentAnchor; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.TypeAnchorReference.java
License:Open Source License
/** * If this reference has a static prefix return its resolved type. * (obviously only for qualified anchors). *//*from ww w . ja v a2s .co m*/ public ReferenceBinding resolveStaticPart(Scope scope) { // extract from above method: // (but cannot use this above, because more than one local variable // would need to be returned to the caller). if (!(this.anchor instanceof QualifiedNameReference)) return null; QualifiedNameReference qualifiedAnchor = (QualifiedNameReference) this.anchor; char[][] tokens = qualifiedAnchor.tokens; // check maximal static prefix: Binding staticPrefix = null; int j; for (j = 1; j <= tokens.length; j++) { Binding current = scope.getTypeOrPackage(CharOperation.subarray(tokens, 0, j)); if (current == null || !current.isValidBinding()) break; else staticPrefix = current; } if (j > tokens.length) { scope.problemReporter().typeAnchorReferenceNotAValue(this.anchor); return null; } if (staticPrefix instanceof ReferenceBinding) return (ReferenceBinding) staticPrefix; return null; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.CallinPrecedenceAttribute.java
License:Open Source License
public CallinPrecedenceAttribute(ReferenceBinding site, CallinCalloutBinding[] callins) { super(IOTConstants.CALLIN_PRECEDENCE, callins.length, 2); // each element is a name reference int count = 0; for (int i = 0; i < callins.length; i++) { Binding callinBinding = callins[i]; if (callinBinding != null && callinBinding.isValidBinding()) count++;/*from w w w.j a va2 s .c o m*/ } this.callinNames = new char[count][]; this._count = count; count = 0; for (int i = 0; i < callins.length; i++) { CallinCalloutBinding callinBinding = callins[i]; if (callinBinding != null && callinBinding.isValidBinding()) this.callinNames[count++] = getQualifiedName(site, callinBinding); } }