本文整理了Java中com.sun.tools.javac.code.Types.supertype()
方法的一些代码示例,展示了Types.supertype()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.supertype()
方法的具体详情如下:
包路径:com.sun.tools.javac.code.Types
类名称:Types
方法名:supertype
暂无
代码示例来源:origin: google/error-prone
Type currType = state.getTypes().supertype(method.owner.type);
while (currType != null
&& currType.tsym != null
list.add((MethodSymbol) sym);
currType = state.getTypes().supertype(currType);
代码示例来源:origin: google/error-prone
Type type = getType(exception);
do {
type = state.getTypes().supertype(type);
exceptionsBySuper.put(type.tsym, exception);
} while (!state.getTypes().isSameType(type, state.getSymtab().objectType));
代码示例来源:origin: google/error-prone
private static boolean knownNonNullMethod(
MethodSymbol methodSymbol, ClassSymbol clazzSymbol, @Nullable Types types) {
if (types == null) {
return false;
}
// Proto getters are not null
if (methodSymbol.name.toString().startsWith("get")
&& methodSymbol.params().isEmpty()
&& !methodSymbol.isStatic()) {
Type type = clazzSymbol.type;
while (type != null) {
TypeSymbol typeSymbol = type.asElement();
if (typeSymbol == null) {
break;
}
if (typeSymbol
.getQualifiedName()
.contentEquals("com.google.protobuf.AbstractMessageLite")) {
return true;
}
type = types.supertype(type);
}
}
return false;
}
代码示例来源:origin: google/error-prone
members.addAll(lookup(types.supertype(typeSym.type).tsym, start, identifier, types, pkg));
代码示例来源:origin: google/error-prone
/** 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();
}
代码示例来源:origin: google/error-prone
private Violation checkSuper(ImmutableSet<String> immutableTyParams, ClassType type) {
ClassType superType = (ClassType) state.getTypes().supertype(type);
if (superType.getKind() == TypeKind.NONE
|| state.getTypes().isSameType(state.getSymtab().objectType, superType)) {
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
public void printscopes(Type t) {
while (t.tag == CLASS) {
printscopes(t.tsym.members());
t = types.supertype(t);
}
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
/** Is exc an exception type that need not be declared?
*/
boolean isUnchecked(Type exc) {
return
(exc.tag == TYPEVAR) ? isUnchecked(types.supertype(exc)) :
(exc.tag == CLASS) ? isUnchecked((ClassSymbol)exc.tsym) :
exc.tag == BOT;
}
代码示例来源:origin: sc.fiji/javac
/** Compute all the supertypes of t, indexed by type symbol (except thise in typesSkip). */
private void closure(Type t, Map<TypeSymbol,Type> typesSkip, Map<TypeSymbol,Type> typeMap) {
if (t.tag != CLASS) return;
if (typesSkip.get(t.tsym) != null) return;
if (typeMap.put(t.tsym, t) == null) {
closure(types.supertype(t), typesSkip, typeMap);
for (Type i : types.interfaces(t))
closure(i, typesSkip, typeMap);
}
}
代码示例来源:origin: sc.fiji/javac
/** Compute all the supertypes of t, indexed by type symbol. */
private void closure(Type t, Map<TypeSymbol,Type> typeMap) {
if (t.tag != CLASS) return;
if (typeMap.put(t.tsym, t) == null) {
closure(types.supertype(t), typeMap);
for (Type i : types.interfaces(t))
closure(i, typeMap);
}
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/** Compute all the supertypes of t, indexed by type symbol (except thise in typesSkip). */
private void closure(Type t, Map<TypeSymbol,Type> typesSkip, Map<TypeSymbol,Type> typeMap) {
if (!t.hasTag(CLASS)) return;
if (typesSkip.get(t.tsym) != null) return;
if (typeMap.put(t.tsym, t) == null) {
closure(types.supertype(t), typesSkip, typeMap);
for (Type i : types.interfaces(t))
closure(i, typesSkip, typeMap);
}
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
public boolean isDerivedRawInternal(Type t) {
if (t.isErroneous())
return false;
return
t.isRaw() ||
supertype(t) != null && isDerivedRaw(supertype(t)) ||
isDerivedRaw(interfaces(t));
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
public void visitSwitch(JCSwitch tree) {
Type selsuper = types.supertype(tree.selector.type);
boolean enumSwitch = selsuper != null &&
selsuper.tsym == syms.enumSym;
Type target = enumSwitch ? erasure(tree.selector.type) : syms.intType;
tree.selector = translate(tree.selector, target);
tree.cases = translateCases(tree.cases);
result = tree;
}
代码示例来源:origin: sc.fiji/javac
/** Enter members for a class.
*/
void finishClass(JCClassDecl tree, Env<AttrContext> env) {
if ((tree.mods.flags & Flags.ENUM) != 0 &&
(types.supertype(tree.sym.type).tsym.flags() & Flags.ENUM) == 0) {
addEnumMembers(tree, env);
}
memberEnter(tree.defs, env);
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
@Override
public Type visitArrayType(ArrayType t, Void ignored) {
if (t.elemtype.isPrimitive() || isSameType(t.elemtype, syms.objectType))
return arraySuperType();
else
return new ArrayType(supertype(t.elemtype), t.tsym);
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
public void visitSwitch(JCSwitch tree) {
Type selsuper = types.supertype(tree.selector.type);
boolean enumSwitch = selsuper != null &&
selsuper.tsym == syms.enumSym;
Type target = enumSwitch ? erasure(tree.selector.type) : syms.intType;
tree.selector = translate(tree.selector, target);
tree.cases = translateCases(tree.cases);
result = tree;
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
public void printscopes(Type t) {
while (t.hasTag(CLASS)) {
printscopes(t.tsym.members());
t = types.supertype(t);
}
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
@Override
public Type visitArrayType(ArrayType t, Void ignored) {
if (t.elemtype.isPrimitive() || isSameType(t.elemtype, syms.objectType))
return arraySuperType();
else
return new ArrayType(supertype(t.elemtype), t.tsym);
}
代码示例来源:origin: konsoletyper/teavm-javac
private void assertConvertible(JCTree tree, Type actual, Type formal, Warner warn) {
if (types.isConvertible(actual, formal, warn))
return;
if (formal.isCompound()
&& types.isSubtype(actual, types.supertype(formal))
&& types.isSubtypeUnchecked(actual, types.interfaces(formal), warn))
return;
}
代码示例来源:origin: konsoletyper/teavm-javac
/** Is exc an exception type that need not be declared?
*/
boolean isUnchecked(Type exc) {
return
(exc.hasTag(TYPEVAR)) ? isUnchecked(types.supertype(exc)) :
(exc.hasTag(CLASS)) ? isUnchecked((ClassSymbol)exc.tsym) :
exc.hasTag(BOT);
}
内容来源于网络,如有侵权,请联系作者删除!