com.sun.tools.javac.code.Types.interfaces()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(178)

本文整理了Java中com.sun.tools.javac.code.Types.interfaces()方法的一些代码示例,展示了Types.interfaces()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.interfaces()方法的具体详情如下:
包路径:com.sun.tools.javac.code.Types
类名称:Types
方法名:interfaces

Types.interfaces介绍

[英]Return the interfaces implemented by this class.
[中]返回该类实现的接口。

代码示例

代码示例来源:origin: google/error-prone

for (Type i : types.interfaces(typeSym.type)) {
 members.addAll(lookup(i.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

for (Type interfaceType : state.getTypes().interfaces(type)) {
 AnnotationInfo interfaceAnnotation = getImmutableAnnotation(interfaceType.tsym, state);
 if (interfaceAnnotation == null) {

代码示例来源:origin: konsoletyper/teavm-javac

public boolean isDirectSuperInterface(TypeSymbol isym, TypeSymbol origin) {
  for (Type i2 : interfaces(origin.type)) {
    if (isym == i2.tsym) return true;
  }
  return false;
}
// </editor-fold>

代码示例来源:origin: konsoletyper/teavm-javac

/**
 * Return the interface types directly implemented by or extended by this
 * parameterized type.
 * Return an empty array if there are no interfaces.
 */
public com.sun.javadoc.Type[] interfaceTypes() {
  return TypeMaker.getTypes(env, env.types.interfaces(type));
}

代码示例来源:origin: sc.fiji/javac

public List<Type> directSupertypes(TypeMirror t) {
  validateTypeNotIn(t, EXEC_OR_PKG);
  Type type = (Type) t;
  Type sup = types.supertype(type);
  return (sup == Type.noType || sup == type || sup == null)
     ? types.interfaces(type)
     : types.interfaces(type).prepend(sup);
}

代码示例来源: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

@Override
  public List<Type> visitTypeVar(TypeVar t, Void ignored) {
    if (t.bound.isCompound())
      return interfaces(t.bound);
    if (t.bound.isInterface())
      return List.of(t.bound);
    return List.nil();
  }
};

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

void addBridges(DiagnosticPosition pos,
        TypeSymbol i,
        ClassSymbol origin,
        ListBuffer<JCTree> bridges) {
  for (Scope.Entry e = i.members().elems; e != null; e = e.sibling)
    addBridgeIfNeeded(pos, e.sym, origin, bridges);
  for (List<Type> l = types.interfaces(i.type); l.nonEmpty(); l = l.tail)
    addBridges(pos, l.head.tsym, origin, bridges);
}

代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac

void addBridges(DiagnosticPosition pos,
        TypeSymbol i,
        ClassSymbol origin,
        ListBuffer<JCTree> bridges) {
  for (Scope.Entry e = i.members().elems; e != null; e = e.sibling)
    addBridgeIfNeeded(pos, e.sym, origin, bridges);
  for (List<Type> l = types.interfaces(i.type); l.nonEmpty(); l = l.tail)
    addBridges(pos, l.head.tsym, origin, bridges);
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

@Override
  public List<Type> visitTypeVar(TypeVar t, Void ignored) {
    if (t.bound.isCompound())
      return interfaces(t.bound);
    if (t.bound.isInterface())
      return List.of(t.bound);
    return List.nil();
  }
};

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-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: 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: sc.fiji/javac

public boolean isDerivedRawInternal(Type t) {
  if (t.isErroneous())
    return false;
  return
    t.isRaw() ||
    supertype(t) != null && isDerivedRaw(supertype(t)) ||
    isDerivedRaw(interfaces(t));
}

代码示例来源:origin: sc.fiji/javac

/** Note that we found an inheritance cycle. */
private void noteCyclic(DiagnosticPosition pos, ClassSymbol c) {
  log.error(pos, "cyclic.inheritance", c);
  for (List<Type> l=types.interfaces(c.type); l.nonEmpty(); l=l.tail)
    l.head = new ErrorType((ClassSymbol)l.head.tsym);
  Type st = types.supertype(c.type);
  if (st.tag == CLASS)
    ((ClassType)c.type).supertype_field = new ErrorType((ClassSymbol)st.tsym);
  c.type = new ErrorType(c);
  c.flags_field |= ACYCLIC;
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

private List<Type> superClosure(Type t, Type s) {
  List<Type> cl = List.nil();
  for (List<Type> l = interfaces(t); l.nonEmpty(); l = l.tail) {
    if (isSubtype(s, erasure(l.head))) {
      cl = insert(cl, l.head);
    } else {
      cl = union(cl, superClosure(l.head, s));
    }
  }
  return cl;
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

/** Note that we found an inheritance cycle. */
private void noteCyclic(DiagnosticPosition pos, ClassSymbol c) {
  log.error(pos, "cyclic.inheritance", c);
  for (List<Type> l=types.interfaces(c.type); l.nonEmpty(); l=l.tail)
    l.head = types.createErrorType((ClassSymbol)l.head.tsym, Type.noType);
  Type st = types.supertype(c.type);
  if (st.hasTag(CLASS))
    ((ClassType)c.type).supertype_field = types.createErrorType((ClassSymbol)st.tsym, Type.noType);
  c.type = types.createErrorType(c, c.type);
  c.flags_field |= ACYCLIC;
}

代码示例来源:origin: sc.fiji/javac

private List<Type> superClosure(Type t, Type s) {
  List<Type> cl = List.nil();
  for (List<Type> l = interfaces(t); l.nonEmpty(); l = l.tail) {
    if (isSubtype(s, erasure(l.head))) {
      cl = insert(cl, l.head);
    } else {
      cl = union(cl, superClosure(l.head, s));
    }
  }
  return cl;
}

相关文章

Types类方法