/** Gets a human-friendly name for the given {@link Symbol} to use in diagnostics. */ public String getPrettyName(Symbol sym) { if (!sym.getSimpleName().isEmpty()) { return sym.getSimpleName().toString(); } if (sym.getKind() == ElementKind.ENUM) { // anonymous classes for enum constants are identified by the enclosing constant // declaration return sym.owner.getSimpleName().toString(); } // anonymous classes have an empty name, but a recognizable superclass or interface // e.g. refer to `new Runnable() { ... }` as "Runnable" Type superType = state.getTypes().supertype(sym.type); if (state.getTypes().isSameType(superType, state.getSymtab().objectType)) { superType = Iterables.getFirst(state.getTypes().interfaces(sym.type), superType); } return superType.tsym.getSimpleName().toString(); }
owner.name.isEmpty() ? state.getTypes().directSupertypes(owner.asType()) : ImmutableList.of(owner.asType()),
/** Has this symbol an empty name? This includes anonymous * inner classes. */ public boolean isAnonymous() { return name.isEmpty(); }
/** Has this symbol an empty name? This includes anonymous * inner classes. */ public boolean isAnonymous() { return name.isEmpty(); }
private boolean withinAnonConstr(Env<AttrContext> env) { return env.enclClass.name.isEmpty() && env.enclMethod != null && env.enclMethod.name == names.init; }
public NestingKind getNestingKind() { complete(); if (owner.kind == PCK) return NestingKind.TOP_LEVEL; else if (name.isEmpty()) return NestingKind.ANONYMOUS; else if (owner.kind == MTH) return NestingKind.LOCAL; else return NestingKind.MEMBER; }
public NestingKind getNestingKind() { complete(); if (owner.kind == PCK) return NestingKind.TOP_LEVEL; else if (name.isEmpty()) return NestingKind.ANONYMOUS; else if (owner.kind == MTH) return NestingKind.LOCAL; else return NestingKind.MEMBER; }
public NestingKind getNestingKind() { complete(); if (owner.kind == PCK) return NestingKind.TOP_LEVEL; else if (name.isEmpty()) return NestingKind.ANONYMOUS; else if (owner.kind == MTH) return NestingKind.LOCAL; else return NestingKind.MEMBER; }
public NestingKind getNestingKind() { complete(); if (owner.kind == PCK) return NestingKind.TOP_LEVEL; else if (name.isEmpty()) return NestingKind.ANONYMOUS; else if (owner.kind == MTH) return NestingKind.LOCAL; else return NestingKind.MEMBER; }
/** A Java source description of the location of this symbol; used for * error reporting. * * @return null if the symbol is a package or a toplevel class defined in * the default package; otherwise, the owner symbol is returned */ public Symbol location() { if (owner.name == null || (owner.name.isEmpty() && (owner.flags() & BLOCK) == 0 && owner.kind != PCK && owner.kind != TYP)) { return null; } return owner; }
String strval(Name prefix) { String s = token.stringVal(); return prefix.isEmpty() ? s : prefix + s; }
/** A Java source description of the location of this symbol; used for * error reporting. * * @return null if the symbol is a package or a toplevel class defined in * the default package; otherwise, the owner symbol is returned */ public Symbol location() { if (owner.name == null || (owner.name.isEmpty() && (owner.flags() & BLOCK) == 0 && owner.kind != PCK && owner.kind != TYP)) { return null; } return owner; }
public String className() { if (name.isEmpty()) return Log.getLocalizedString("anonymous.class", flatname); else return fullname.toString(); }
@Override public String visitClassSymbol(ClassSymbol sym, Locale locale) { return sym.name.isEmpty() ? localize(locale, "compiler.misc.anonymous.class", sym.flatname) : sym.fullname.toString(); }
public String className() { if (name.isEmpty()) return Log.getLocalizedString("anonymous.class", flatname); else return fullname.toString(); }
@Override public String visitClassSymbol(ClassSymbol sym, Locale locale) { return sym.name.isEmpty() ? localize(locale, "compiler.misc.anonymous.class", sym.flatname) : sym.fullname.toString(); }
/** * Get package name. */ public String qualifiedName() { if (qualifiedName == null) { Name fullname = sym.getQualifiedName(); // Some bogus tests depend on the interned "" being returned. // See 6457276. qualifiedName = fullname.isEmpty() ? "" : fullname.toString(); } return qualifiedName; }
public Symbol location(Type site, Types types) { if (owner.name == null || owner.name.isEmpty()) { return location(); } if (owner.type.hasTag(CLASS)) { Type ownertype = types.asOuterSuper(site, owner); if (ownertype != null) return ownertype.tsym; } return owner; }
public Symbol location(Type site, Types types) { if (owner.name == null || owner.name.isEmpty()) { return location(); } if (owner.type.hasTag(CLASS)) { Type ownertype = types.asOuterSuper(site, owner); if (ownertype != null) return ownertype.tsym; } return owner; }
public ExpressionTree QualIdent(Element element) { Symbol s = (Symbol) element; if (s.owner != null && (s.owner.kind == Kinds.Kind.MTH || s.owner.name.isEmpty())) { JCIdent result = make.at(NOPOS).Ident(s); result.setType(s.type); return result; } QualIdentTree result = new QualIdentTree(make.at(NOPOS).QualIdent(s.owner), s.name, s); result.setPos(make.pos).setType(s.type); return result; }