private boolean isOwnedBy(Symbol sym, Symbol owner, Types types) { if (sym.owner == owner) { return true; } if (owner instanceof TypeSymbol) { return sym.isMemberOf((TypeSymbol) owner, types); } return false; }
/** * Returns the owner if the given member is declared in a lexically enclosing scope, and * {@code null} otherwise. */ private ClassSymbol isEnclosedIn(ClassSymbol startingClass, Symbol member, Types types) { for (ClassSymbol scope = startingClass.owner.enclClass(); scope != null; scope = scope.owner.enclClass()) { if (member.isMemberOf(scope.type.tsym, types)) { return scope; } } return null; } };
/** Is sym a non-static member of an enclosing class of currentClass? */ private static boolean memberOfEnclosing(Symbol owner, VisitorState state, Symbol sym) { if (sym == null || !sym.hasOuterInstance()) { return false; } for (ClassSymbol encl = owner.owner.enclClass(); encl != null; encl = encl.owner != null ? encl.owner.enclClass() : null) { if (sym.isMemberOf(encl, state.getTypes())) { return true; } } return false; }
break; if (member.isMemberOf(start, types)) { members.add(member);
EnumSet.of(TypeKind.INT, TypeKind.LONG) .contains(state.getTypes().unboxedTypeOrType(x.asType()).getKind())) .noneMatch(arg -> arg.isMemberOf(enclosing.enclClass(), state.getTypes()))) { arg -> arg.getSimpleName().contentEquals("this") && arg.isMemberOf(enclosing.enclClass(), state.getTypes()))) {
/** * Normalizes the receiver of a select expression so that accesses on 'this' are divided * into type names (for static accesses), qualified this accesses (for members of a * lexically enclosing scope), or simple this accesses for members of the current class. */ private GuardedByExpression normalizeBase( BinderContext context, Symbol symbol, GuardedByExpression base) { if (symbol.isStatic()) { return F.typeLiteral(symbol.owner.enclClass()); } if (base != null && base.kind() != GuardedByExpression.Kind.THIS) { return base; } if (symbol.isMemberOf(context.thisClass.type.tsym, context.types)) { return F.thisliteral(); } Symbol lexicalOwner = isEnclosedIn(context.thisClass, symbol, context.types); if (lexicalOwner != null) { return F.qualifiedThis(context.names, context.thisClass, lexicalOwner); } throw new IllegalGuardedBy("Could not find the implicit receiver."); }
state.getTypes().erasure(ASTHelpers.getType(declaration)).tsym; if (ASTHelpers.getSymbol(toReplace).isMemberOf(variableTypeSymbol, state.getTypes())) { if (toReplace.getKind() == Kind.IDENTIFIER) { return SuggestedFix.prefixWith(toReplace, declaration.getName() + ".");
private boolean isOwnedBy(Symbol sym, Symbol owner, Types types) { if (sym.owner == owner) { return true; } if (owner instanceof TypeSymbol) { return sym.isMemberOf((TypeSymbol) owner, types); } return false; }
public boolean isMemberOf(Element e, TypeElement type) { return ((Symbol)e).isMemberOf((TypeSymbol)type, jctypes); }
public boolean isMemberOf(TypeSymbol clazz, Types types) { return other.isMemberOf(clazz, types); } public boolean isEnclosedBy(ClassSymbol clazz) { return other.isEnclosedBy(clazz); }
public boolean isMemberOf(TypeSymbol clazz, Types types) { return other.isMemberOf(clazz, types); } public boolean isEnclosedBy(ClassSymbol clazz) { return other.isEnclosedBy(clazz); }
public boolean isMemberOf(TypeSymbol clazz, Types types) { return other.isMemberOf(clazz, types); } public boolean isEnclosedBy(ClassSymbol clazz) { return other.isEnclosedBy(clazz); }
public boolean isMemberOf(TypeSymbol clazz, Types types) { return other.isMemberOf(clazz, types); } public boolean isEnclosedBy(ClassSymbol clazz) { return other.isEnclosedBy(clazz); }
/** * Returns the owner if the given member is declared in a lexically enclosing scope, and * {@code null} otherwise. */ private ClassSymbol isEnclosedIn(ClassSymbol startingClass, Symbol member, Types types) { for (ClassSymbol scope = startingClass.owner.enclClass(); scope != null; scope = scope.owner.enclClass()) { if (member.isMemberOf(scope.type.tsym, types)) { return scope; } } return null; } };
/** Is sym a non-static member of an enclosing class of currentClass? */ private static boolean memberOfEnclosing(Symbol owner, VisitorState state, Symbol sym) { if (sym == null || !sym.hasOuterInstance()) { return false; } for (ClassSymbol encl = owner.owner.enclClass(); encl != null; encl = encl.owner != null ? encl.owner.enclClass() : null) { if (sym.isMemberOf(encl, state.getTypes())) { return true; } } return false; }
void importFrom(TypeSymbol tsym) { if (tsym == null || !processed.add(tsym)) return; // also import inherited names importFrom(types.supertype(tsym.type).tsym); for (Type t : types.interfaces(tsym.type)) importFrom(t.tsym); final Scope fromScope = tsym.members(); for (Scope.Entry e = fromScope.elems; e != null; e = e.sibling) { Symbol sym = e.sym; if (sym.isStatic() && sym.kind != TYP && staticImportAccessible(sym, packge) && !toScope.includes(sym) && sym.isMemberOf(origin, types)) { toScope.enter(sym, fromScope, origin.members()); } } } public void enterAnnotation() {
void importFrom(TypeSymbol tsym) { if (tsym == null || !processed.add(tsym)) return; // also import inherited names importFrom(types.supertype(tsym.type).tsym); for (Type t : types.interfaces(tsym.type)) importFrom(t.tsym); final Scope fromScope = tsym.members(); for (Scope.Entry e = fromScope.elems; e != null; e = e.sibling) { Symbol sym = e.sym; if (sym.isStatic() && sym.kind != TYP && staticImportAccessible(sym, packge) && !toScope.includes(sym) && sym.isMemberOf(origin, types)) { toScope.enter(sym, fromScope, origin.members()); } } } public void enterAnnotation() {
void importFrom(TypeSymbol tsym) { if (tsym == null || !processed.add(tsym)) return; // also import inherited names importFrom(types.supertype(tsym.type).tsym); for (Type t : types.interfaces(tsym.type)) importFrom(t.tsym); final Scope fromScope = tsym.members(); for (Scope.Entry e = fromScope.elems; e != null; e = e.sibling) { Symbol sym = e.sym; if (sym.kind == TYP && (sym.flags() & STATIC) != 0 && staticImportAccessible(sym, packge) && sym.isMemberOf(origin, types) && !toScope.includes(sym)) toScope.enter(sym, fromScope, origin.members(), true); } } }.importFrom(tsym);
void importFrom(TypeSymbol tsym) { if (tsym == null || !processed.add(tsym)) return; // also import inherited names importFrom(types.supertype(tsym.type).tsym); for (Type t : types.interfaces(tsym.type)) importFrom(t.tsym); final Scope fromScope = tsym.members(); for (Scope.Entry e = fromScope.elems; e != null; e = e.sibling) { Symbol sym = e.sym; if (sym.isStatic() && sym.kind != TYP && staticImportAccessible(sym, packge) && !toScope.includes(sym) && sym.isMemberOf(origin, types)) { toScope.enter(sym, fromScope, origin.members(), true); } } } public void run() {
void importFrom(TypeSymbol tsym) { if (tsym == null || !processed.add(tsym)) return; // also import inherited names importFrom(types.supertype(tsym.type).tsym); for (Type t : types.interfaces(tsym.type)) importFrom(t.tsym); final Scope fromScope = tsym.members(); for (Scope.Entry e = fromScope.elems; e != null; e = e.sibling) { Symbol sym = e.sym; if (sym.kind == TYP && (sym.flags() & STATIC) != 0 && staticImportAccessible(sym, packge) && sym.isMemberOf(origin, types) && !toScope.includes(sym)) toScope.enter(sym, fromScope, origin.members()); } } }.importFrom(tsym);