当前位置: 首页>>代码示例>>Java>>正文


Java Types.directSupertypes方法代码示例

本文整理汇总了Java中javax.lang.model.util.Types.directSupertypes方法的典型用法代码示例。如果您正苦于以下问题:Java Types.directSupertypes方法的具体用法?Java Types.directSupertypes怎么用?Java Types.directSupertypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.lang.model.util.Types的用法示例。


在下文中一共展示了Types.directSupertypes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: replaceWithSuperType

import javax.lang.model.util.Types; //导入方法依赖的package包/类
private void replaceWithSuperType(TreePath path, VariableTree oldVarTree, VariableElement varElement, Element superTypeElement) {
    Types types = workingCopy.getTypes();
    TypeMirror supTypeErasure = types.erasure(superTypeElement.asType());
    DeclaredType varType = (DeclaredType) varElement.asType();
    TypeMirror theType = null;
    List<TypeMirror> supertypes = new LinkedList(types.directSupertypes(varType));
    while(!supertypes.isEmpty()) {
        TypeMirror supertype = supertypes.remove(0);
        if(types.isSameType(types.erasure(supertype), supTypeErasure)) {
            theType = supertype;
            break;
        }
        supertypes.addAll(types.directSupertypes(supertype));
    }
    
    if(theType == null) {
        theType = supTypeErasure;
    }
    Tree superTypeTree = make.Type(theType);
  
    ExpressionTree oldInitTree = oldVarTree.getInitializer();
    ModifiersTree oldModifiers = oldVarTree.getModifiers();
    Tree newTree = make.Variable(oldModifiers, oldVarTree.getName(), 
            superTypeTree, oldInitTree);
    rewrite(oldVarTree, newTree);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:UseSuperTypeRefactoringPlugin.java

示例2: deepSearchTypes

import javax.lang.model.util.Types; //导入方法依赖的package包/类
private boolean deepSearchTypes(DeclaredType currentElement, TypeMirror orig, TypeMirror something, Map<TypeMirror, TypeParameterElement> mappings) {
    Types types = workingCopy.getTypes();
    List<? extends TypeMirror> directSupertypes = types.directSupertypes(currentElement);
    for (TypeMirror superType : directSupertypes) {
        DeclaredType type = (DeclaredType) superType;
        List<? extends TypeMirror> typeArguments = type.getTypeArguments();
        for (int i = 0; i < typeArguments.size(); i++) {
            TypeMirror typeArgument = typeArguments.get(i);
            if (something.equals(typeArgument)) {
                TypeElement asElement = (TypeElement) type.asElement();
                mappings.put(orig, asElement.getTypeParameters().get(i));
                if (types.erasure(targetType.asType()).equals(types.erasure(superType))) {
                    return true;
                }
                if(deepSearchTypes(type, orig, typeArgument, mappings)) {
                    break;
                }
            }
        }
        if (types.erasure(targetType.asType()).equals(types.erasure(superType))) {
            mappings.remove(orig);
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:PullUpTransformer.java

示例3: nonPrivateDeclaredTypes

import javax.lang.model.util.Types; //导入方法依赖的package包/类
/**
 * Finds all types that are declared with non private visibility by the given {@code TypeMirror},
 * any class in its superclass chain, or any interface it implements.
 */
private static Set<TypeMirror> nonPrivateDeclaredTypes(Types typeUtils, TypeMirror type) {
    if (type == null) {
        return new TypeMirrorSet();
    } else {
        Set<TypeMirror> declared = new TypeMirrorSet();
        declared.add(type);
        List<TypeElement> nestedTypes =
                ElementFilter.typesIn(typeUtils.asElement(type).getEnclosedElements());
        for (TypeElement nestedType : nestedTypes) {
            if (!nestedType.getModifiers().contains(PRIVATE)) {
                declared.add(nestedType.asType());
            }
        }
        for (TypeMirror supertype : typeUtils.directSupertypes(type)) {
            declared.addAll(nonPrivateDeclaredTypes(typeUtils, supertype));
        }
        return declared;
    }
}
 
开发者ID:ccheptea,项目名称:auto-value-node,代码行数:24,代码来源:TypeSimplifier.java

示例4: nonPrivateDeclaredTypes

import javax.lang.model.util.Types; //导入方法依赖的package包/类
/**
 * Finds all types that are declared with non private visibility by the given {@code TypeMirror},
 * any class in its superclass chain, or any interface it implements.
 */
private static Set<TypeMirror> nonPrivateDeclaredTypes(Types typeUtils, TypeMirror type) {
  if (type == null) {
    return new TypeMirrorSet();
  } else {
    Set<TypeMirror> declared = new TypeMirrorSet();
    declared.add(type);
    List<TypeElement> nestedTypes =
        ElementFilter.typesIn(typeUtils.asElement(type).getEnclosedElements());
    for (TypeElement nestedType : nestedTypes) {
      if (!nestedType.getModifiers().contains(PRIVATE)) {
        declared.add(nestedType.asType());
      }
    }
    for (TypeMirror supertype : typeUtils.directSupertypes(type)) {
      declared.addAll(nonPrivateDeclaredTypes(typeUtils, supertype));
    }
    return declared;
  }
}
 
开发者ID:sopak,项目名称:auto-value-step-builder,代码行数:24,代码来源:TypeSimplifier.java

示例5: testParentOf

import javax.lang.model.util.Types; //导入方法依赖的package包/类
/**
 * Test if typeElement is a parent of currentElement.
 */
private static boolean testParentOf(Types types, TypeMirror currentElement, TypeMirror typeMirror) {
    List<? extends TypeMirror> directSupertypes = types.directSupertypes(currentElement);
    for (TypeMirror superType : directSupertypes) {
        if (superType.equals(typeMirror)) {
            return true;
        } else {
            boolean isParent = testParentOf(types, superType, typeMirror);
            if (isParent) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ToolTipAnnotation.java

示例6: visitDeclared

import javax.lang.model.util.Types; //导入方法依赖的package包/类
@Override
public Void visitDeclared(DeclaredType t, Types types) {
    t.asElement().getKind(); // ensure class exists
    for (TypeMirror st: types.directSupertypes(t))
        visit(st, types);
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:JavahTask.java

示例7: visitDeclared

import javax.lang.model.util.Types; //导入方法依赖的package包/类
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public Void visitDeclared(DeclaredType t, Types types) {
    t.asElement().getKind(); // ensure class exists
    for (TypeMirror st: types.directSupertypes(t))
        visit(st, types);
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:JavahTask.java


注:本文中的javax.lang.model.util.Types.directSupertypes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。