List of usage examples for org.eclipse.jdt.internal.compiler.lookup Scope classScope
public final ClassScope classScope()
From source file:lombok.eclipse.agent.PatchExtensionMethodCompletionProposal.java
License:Open Source License
private static ClassScope getClassScope(CompletionProposalCollector completionProposalCollector) { ClassScope scope = null;/*from w ww . j ava2 s. c om*/ try { InternalCompletionContext context = (InternalCompletionContext) Reflection.contextField .get(completionProposalCollector); InternalExtendedCompletionContext extendedContext = (InternalExtendedCompletionContext) Reflection.extendedContextField .get(context); if (extendedContext != null) { Scope assistScope = ((Scope) Reflection.assistScopeField.get(extendedContext)); if (assistScope != null) { scope = assistScope.classScope(); } } } catch (IllegalAccessException ignore) { // ignore } return scope; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lifting.DeclaredLifting.java
License:Open Source License
private static LocalDeclaration createLiftingStatement(Scope scope, Argument argument) { LiftingTypeReference ltr = (LiftingTypeReference) argument.type; int start = argument.type.sourceStart; int end = argument.type.sourceEnd; AstGenerator gen = new AstGenerator(start, end); // names:// ww w . ja va2 s . co m char[] oldName = argument.name; char[] newName = CharOperation.concat(OT_DOLLAR_NAME, oldName); argument.updateName(newName); // MyRole obj = _OT$liftToMyRole(_OT$obj); (via PotentialLiftExpression) TypeBinding roleType = scope.getType(ltr.roleToken); ReferenceBinding roleRef = (ReferenceBinding) roleType; // using a PotentialLiftExpression allows us to defer type resolution. Expression liftCall = null; // spare the details during completion - see comment regarding local.declaration.initialization inside // InternalExtendedCompletionContext.searchVisibleVariablesAndMethods(Scope, ObjectVector, ObjectVector, ObjectVector, boolean) if (!Config.isUsingAssistParser()) { if (roleRef.isValidBinding() && roleRef.isRole() && (roleRef.tagBits & TagBits.HierarchyHasProblems) == 0 && !RoleModel.hasTagBit(roleRef, RoleModel.BaseclassHasProblems)) { Expression receiverTeam = ThisReference.implicitThis(); ReferenceBinding teamBinding = roleRef.enclosingType(); if (TypeBinding.notEquals(teamBinding, scope.enclosingSourceType())) receiverTeam = gen.qualifiedThisReference(teamBinding); if (roleRef.baseclass() == null) { // static adjustment (OTJLD 2.3.2(a)): ReferenceBinding baseType = null; if (scope.classScope() instanceof OTClassScope) { // try base scope first: CompilationUnitScope baseScope = ((OTClassScope) scope.classScope()) .getBaseImportScope(scope); if (baseScope != null) { baseType = (ReferenceBinding) baseScope.getType(ltr.baseTokens, ltr.baseTokens.length); baseScope.originalScope = null; } } if (baseType == null || !baseType.isValidBinding()) // fall back to normal scope: baseType = (ReferenceBinding) scope.getType(ltr.baseTokens, ltr.baseTokens.length); roleRef = (ReferenceBinding) TeamModel.getRoleToLiftTo(scope, baseType, roleRef, true, ltr); if (baseType.isTypeVariable() && roleRef == null) roleRef = (ReferenceBinding) roleType; // fall back to the declared type } if (roleRef != null) { if (ltr.baseReference.dimensions() > 0) roleType = scope.createArrayType(roleRef, ltr.baseReference.dimensions()); liftCall = new PotentialLiftExpression(receiverTeam, gen.singleNameReference(newName), ltr.roleReference); } // errors are reported by LiftingTypeReference.resolveType(). } } // assemble the variable decl: LocalDeclaration declaration = gen.localVariable(oldName, AstClone.copyTypeReference(ltr.roleReference), liftCall); // store local declaration in lifting type, // which may need to cancel some generated AST after resolve. // (cf. LiftingTypeReference.invalidate()) ltr.fakedArgument = declaration; return declaration; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.util.RoleTypeCreator.java
License:Open Source License
private static boolean isConvertedArgument(ITeamAnchor anchor, Scope scope) { if (!(anchor instanceof VariableBinding)) return false; // impossible/defensive if ((((VariableBinding) anchor).tagBits & TagBits.IsArgument) == 0) return false; return scope.classScope().referenceContext.isConverted; }
From source file:org.eclipse.recommenders.internal.chain.rcp.TypeBindingAnalyzer.java
License:Open Source License
private static Collection<Binding> findFieldsAndMethods(final TypeBinding type, final InvocationSite invocationSite, final Scope scope, final Predicate<FieldBinding> fieldFilter, final Predicate<MethodBinding> methodFilter) { final Map<String, Binding> tmp = Maps.newLinkedHashMap(); final TypeBinding receiverType = scope.classScope().referenceContext.binding; for (final ReferenceBinding cur : findAllSupertypesIncludeingArgument(type)) { for (final MethodBinding method : cur.methods()) { if (methodFilter.apply(method) || !method.canBeSeenBy(invocationSite, scope)) { continue; }/* ww w. j a v a 2 s. c o m*/ final String key = createMethodKey(method); if (!tmp.containsKey(key)) { tmp.put(key, method); } } for (final FieldBinding field : cur.fields()) { if (fieldFilter.apply(field) || !field.canBeSeenBy(receiverType, invocationSite, scope)) { continue; } final String key = createFieldKey(field); if (!tmp.containsKey(key)) { tmp.put(key, field); } } } return tmp.values(); }