本文整理汇总了Java中com.sun.tools.javac.code.Type.ClassType.getEnclosingType方法的典型用法代码示例。如果您正苦于以下问题:Java ClassType.getEnclosingType方法的具体用法?Java ClassType.getEnclosingType怎么用?Java ClassType.getEnclosingType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.code.Type.ClassType
的用法示例。
在下文中一共展示了ClassType.getEnclosingType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitClassType
import com.sun.tools.javac.code.Type.ClassType; //导入方法依赖的package包/类
@Override
public String visitClassType(ClassType t, Locale locale) {
StringBuffer buf = new StringBuffer();
if (t.getEnclosingType().tag == CLASS && t.tsym.owner.kind == Kinds.TYP) {
buf.append(visit(t.getEnclosingType(), locale));
buf.append(".");
buf.append(className(t, false, locale));
} else {
buf.append(className(t, true, locale));
}
if (t.getTypeArguments().nonEmpty()) {
buf.append('<');
buf.append(visitTypes(t.getTypeArguments(), locale));
buf.append(">");
}
return buf.toString();
}
示例2: parameterizedTypeToString
import com.sun.tools.javac.code.Type.ClassType; //导入方法依赖的package包/类
static String parameterizedTypeToString(DocEnv env, ClassType cl,
boolean full) {
if (env.legacyDoclet) {
return TypeMaker.getTypeName(cl, full);
}
StringBuilder s = new StringBuilder();
if (!(cl.getEnclosingType().hasTag(CLASS))) { // if not an inner class...
s.append(TypeMaker.getTypeName(cl, full));
} else {
ClassType encl = (ClassType)cl.getEnclosingType();
s.append(parameterizedTypeToString(env, encl, full))
.append('.')
.append(cl.tsym.name.toString());
}
s.append(TypeMaker.typeArgumentsString(env, cl, full));
return s.toString();
}
示例3: parameterizedTypeToString
import com.sun.tools.javac.code.Type.ClassType; //导入方法依赖的package包/类
static String parameterizedTypeToString(DocEnv env, ClassType cl,
boolean full) {
if (env.legacyDoclet) {
return TypeMaker.getTypeName(cl, full);
}
StringBuffer s = new StringBuffer();
if (cl.getEnclosingType().tag != CLASS) { // if not an inner class...
s.append(TypeMaker.getTypeName(cl, full));
} else {
ClassType encl = (ClassType)cl.getEnclosingType();
s.append(parameterizedTypeToString(env, encl, full))
.append('.')
.append(cl.tsym.name.toString());
}
s.append(TypeMaker.typeArgumentsString(env, cl, full));
return s.toString();
}
示例4: mutableEnclosingInstance
import com.sun.tools.javac.code.Type.ClassType; //导入方法依赖的package包/类
/** Returns an enclosing instance for the specified type if it is thread-safe. */
public Type mutableEnclosingInstance(Optional<ClassTree> tree, ClassType type) {
if (tree.isPresent()
&& !CanBeStaticAnalyzer.referencesOuter(
tree.get(), ASTHelpers.getSymbol(tree.get()), state)) {
return null;
}
Type enclosing = type.getEnclosingType();
while (!Type.noType.equals(enclosing)) {
if (getMarkerOrAcceptedAnnotation(enclosing.tsym, state) == null
&& isThreadSafeType(
/* allowContainerTypeParameters= */ false,
/* containerTypeParameters= */ ImmutableSet.of(),
enclosing)
.isPresent()) {
return enclosing;
}
enclosing = enclosing.getEnclosingType();
}
return null;
}
示例5: parameterizedTypeToString
import com.sun.tools.javac.code.Type.ClassType; //导入方法依赖的package包/类
static String parameterizedTypeToString(DocEnv env, ClassType cl,
boolean full) {
if (env.legacyDoclet) {
return TypeMaker.getTypeName(cl, full);
}
StringBuilder s = new StringBuilder();
if (cl.getEnclosingType().tag != CLASS) { // if not an inner class...
s.append(TypeMaker.getTypeName(cl, full));
} else {
ClassType encl = (ClassType)cl.getEnclosingType();
s.append(parameterizedTypeToString(env, encl, full))
.append('.')
.append(cl.tsym.name.toString());
}
s.append(TypeMaker.typeArgumentsString(env, cl, full));
return s.toString();
}
示例6: visitClassType
import com.sun.tools.javac.code.Type.ClassType; //导入方法依赖的package包/类
@Override
public Type visitClassType(ClassType t, Boolean upward) {
if (upward && !t.isCompound() && t.tsym.name.isEmpty()) {
//lift anonymous class type to first supertype (class or interface)
return types.directSupertypes(t).last();
} else if (t.isCompound()) {
List<Type> components = types.directSupertypes(t);
List<Type> components1 = components.map(c -> c.map(this, upward));
if (components == components1) return t;
else return types.makeIntersectionType(components1);
} else {
Type outer = t.getEnclosingType();
Type outer1 = visit(outer, upward);
List<Type> typarams = t.getTypeArguments();
List<Type> typarams1 = typarams.map(ta -> mapTypeArgument(ta, upward));
if (typarams1.stream().anyMatch(ta -> ta.hasTag(BOT))) {
//not defined
return syms.botType;
}
if (outer1 == outer && typarams1 == typarams) return t;
else return new ClassType(outer1, typarams1, t.tsym, t.getMetadata()) {
@Override
protected boolean needsStripping() {
return true;
}
};
}
}