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


Java TypeElement.getSuperclass方法代码示例

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


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

示例1: getViewsType

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private Collection<TypeMirror> getViewsType(TypeElement typeElement) {
	TypeMirror superclass = typeElement.asType();

	List<TypeMirror> result = new ArrayList<>();

	while (superclass.getKind() != TypeKind.NONE) {
		TypeElement superclassElement = (TypeElement) ((DeclaredType) superclass).asElement();
		Collection<? extends TypeMirror> interfaces = new HashSet<>(superclassElement.getInterfaces());
		for (TypeMirror typeMirror : interfaces) {
			if (typeMirror instanceof DeclaredType) {
				result.addAll(getViewsType((TypeElement) ((DeclaredType) typeMirror).asElement()));
			}
		}
		result.addAll(interfaces);
		result.add(superclass);

		superclass = superclassElement.getSuperclass();
	}

	return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:PresenterInjectorRules.java

示例2: findViewTypeOfPresenter

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private String findViewTypeOfPresenter(TypeElement presenterElement) {
    TypeElement currentClass = presenterElement;
    while (currentClass != null) {
        if (currentClass.getSuperclass() instanceof DeclaredType) {
            List<? extends TypeMirror> superClassParameters =
                    ((DeclaredType) currentClass.getSuperclass()).getTypeArguments();

            if (superClassParameters.size() == 1) {
                String type = superClassParameters.get(0).toString();
                if (!"V".equals(type)) return type;
            }
        }
        currentClass = getSuperClass(currentClass);
    }
    return "";
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:EasyMVPProcessor.java

示例3: getActivityModel

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private ActivityIntentModel getActivityModel(TypeElement typeElement) {
    ActivityIntentModel activityModel = new ActivityIntentModel(
            elementsUtil.getPackageOf(typeElement).getQualifiedName().toString(),
            typeElement.getSimpleName().toString());

    messager.printMessage(Diagnostic.Kind.NOTE, "\ntype:" + typeElement.getQualifiedName());

    activityModel.addParamModels(getParamModels(typeElement));

    TypeMirror superType = typeElement.getSuperclass();

    while (superType != null && !Object.class.getName().equals(superType.toString())) {
        messager.printMessage(Diagnostic.Kind.NOTE, "\n   superType:" + superType.toString());
        Element element = typesUtil.asElement(superType);
        if (element != null && element instanceof TypeElement) {
            TypeElement superE = (TypeElement) element;
            activityModel.addParamModels(getParamModels(superE));

            superType = superE.getSuperclass();
        } else {
            superType = null;
        }
    }

    return activityModel;
}
 
开发者ID:daawa,项目名称:auto-nav,代码行数:27,代码来源:NavProcessor.java

示例4: visitClass

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
@Override
public Tree visitClass(ClassTree node, Element elementToFind) {
    if (workingCopy.getTreeUtilities().isSynthetic(getCurrentPath())) {
        return super.visitClass(node, elementToFind);
    }
    Trees trees = workingCopy.getTrees();
    Types types = workingCopy.getTypes();
    TypeMirror type2 = elementToFind.asType();
    type2 = types.erasure(type2);
    
    if (recursive) {
        TypeMirror type1 = trees.getTypeMirror(getCurrentPath());
        if (type1 != null) {
            type1 = types.erasure(type1);
            if (isSubtype(type1, type2)) {
                addUsage(getCurrentPath());
            }
        }
    } else {
        TypeElement el = (TypeElement) workingCopy.getTrees().getElement(getCurrentPath());
        if (el != null && el.getSuperclass()!=null && types.isSameType(types.erasure(el.getSuperclass()), type2) || containsType(el.getInterfaces(), type2)) {
            addUsage(getCurrentPath());
        }
    }
    return super.visitClass(node, elementToFind);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:FindSubtypesVisitor.java

示例5: visitType

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
public Boolean visitType(TypeElement arg0, Void arg1) {
    for (TypeParameterElement e : arg0.getTypeParameters()) {
        if (stop) {
            return false;
        }
        
        for (TypeMirror b : e.getBounds()) {
            if (stop) {
                return false;
            }
            
            if (b.accept(this, arg1)) {
                return true;
            }
        }
    }

    TypeMirror superclass = arg0.getSuperclass();
    if (superclass.getKind() == TypeKind.DECLARED) {
        if (!((DeclaredType) superclass).asElement().getKind().isInterface()) {
            return false;
        }
    }

    return superclass.accept(this, arg1);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ExportNonAccessibleElement.java

示例6: getClassHeader

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
 * Get the serializable class heading.
 *
 * @param typeElement the class being processed
 * @return a content tree for the class header
 */
public Content getClassHeader(TypeElement typeElement) {
    Content classLink = (isVisibleClass(typeElement))
            ? getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, typeElement)
                    .label(configuration.getClassName(typeElement)))
            : new StringContent(utils.getFullyQualifiedName(typeElement));
    Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(
            utils.getFullyQualifiedName(typeElement)));
    Content superClassLink = typeElement.getSuperclass() != null
            ? getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.SERIALIZED_FORM,
                    typeElement.getSuperclass()))
            : null;

    //Print the heading.
    Content className = superClassLink == null ?
        configuration.getContent(
        "doclet.Class_0_implements_serializable", classLink) :
        configuration.getContent(
        "doclet.Class_0_extends_implements_serializable", classLink,
        superClassLink);
    li.addContent(HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
            className));
    return li;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:SerializedFormWriterImpl.java

示例7: enumerateMethods

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private static void enumerateMethods( @Nonnull final TypeElement scope,
                                      @Nonnull final Types typeUtils,
                                      @Nonnull final TypeElement element,
                                      @Nonnull final Map<String, ExecutableElement> methods )
{
  final TypeMirror superclass = element.getSuperclass();
  if ( TypeKind.NONE != superclass.getKind() )
  {
    enumerateMethods( scope, typeUtils, (TypeElement) ( (DeclaredType) superclass ).asElement(), methods );
  }
  for ( final TypeMirror interfaceType : element.getInterfaces() )
  {
    final TypeElement interfaceElement = (TypeElement) ( (DeclaredType) interfaceType ).asElement();
    enumerateMethods( scope, typeUtils, interfaceElement, methods );
  }
  for ( final Element member : element.getEnclosedElements() )
  {
    if ( member.getKind() == ElementKind.METHOD )
    {
      final ExecutableType methodType =
        (ExecutableType) typeUtils.asMemberOf( (DeclaredType) scope.asType(), member );
      methods.put( member.getSimpleName() + methodType.toString(), (ExecutableElement) member );
    }
  }
}
 
开发者ID:arez,项目名称:arez,代码行数:26,代码来源:ProcessorUtil.java

示例8: isSubtypeOfType

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
static boolean isSubtypeOfType(TypeMirror typeMirror, String otherType) {
  if (isTypeEqual(typeMirror, otherType)) {
    return true;
  }
  if (typeMirror.getKind() != TypeKind.DECLARED) {
    return false;
  }
  DeclaredType declaredType = (DeclaredType) typeMirror;
  List<? extends TypeMirror> typeArguments = declaredType.getTypeArguments();
  if (typeArguments.size() > 0) {
    StringBuilder typeString = new StringBuilder(declaredType.asElement().toString());
    typeString.append('<');
    for (int i = 0; i < typeArguments.size(); i++) {
      if (i > 0) {
        typeString.append(',');
      }
      typeString.append('?');
    }
    typeString.append('>');
    if (typeString.toString().equals(otherType)) {
      return true;
    }
  }
  Element element = declaredType.asElement();
  if (!(element instanceof TypeElement)) {
    return false;
  }
  TypeElement typeElement = (TypeElement) element;
  TypeMirror superType = typeElement.getSuperclass();
  if (isSubtypeOfType(superType, otherType)) {
    return true;
  }
  for (TypeMirror interfaceType : typeElement.getInterfaces()) {
    if (isSubtypeOfType(interfaceType, otherType)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:40,代码来源:ButterKnifeProcessor.java

示例9: collectHierarchyMirrors

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private void collectHierarchyMirrors(TypeMirror typeMirror, String stringRepresentation) {
  if (typeMirror.getKind() != TypeKind.DECLARED
      || typeMirror.toString().equals(Object.class.getName())) {
    return;
  }

  DeclaredType declaredType = toDeclaredType(typeMirror);
  TypeElement e = toTypeElement(declaredType);
  TypevarContext context = new TypevarContext(e, stringRepresentation);

  collectInterfacesMirrors(declaredType, context);

  TypeMirror superclassMirror = e.getSuperclass();
  if (superclassMirror.getKind() != TypeKind.NONE) {
    DeclaredType superclass = toDeclaredType(superclassMirror);
    String stringified = stringify(superclass, context);

    if (!stringified.equals(Object.class.getName())) {
      extendedClasses.add(toTypeElement(superclass));
      extendedClassNames.add(stringified);
      collectHierarchyMirrors(superclass, stringified);
    }
  }

  for (TypeMirror m : e.getInterfaces()) {
    collectUnresolvedInterface(m, context);
    collectInterfacesMirrors(m, context);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:TypeHierarchyCollector.java

示例10: ancestorIsAutoParcel

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private boolean ancestorIsAutoParcel(TypeElement type) {
    while (true) {
        TypeMirror parentMirror = type.getSuperclass();
        if (parentMirror.getKind() == TypeKind.NONE) {
            return false;
        }
        TypeElement parentElement = (TypeElement) mTypeUtils.asElement(parentMirror);
        if (MoreElements.isAnnotationPresent(parentElement, AutoMapper.class)) {
            return true;
        }
        type = parentElement;
    }
}
 
开发者ID:foodora,项目名称:android-auto-mapper,代码行数:14,代码来源:AutoMappperProcessor.java

示例11: superTypeHierarchy

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private static Node superTypeHierarchy(
        @NonNull final DeclaredType type,
        @NonNull final ClasspathInfo cpInfo,
        @NonNull final HierarchyFilters filters,
        final int order) {
    final TypeElement element = (TypeElement)type.asElement();
    final TypeMirror superClass = element.getSuperclass();
    final List<? extends TypeMirror> interfaces = element.getInterfaces();
    final List<Node> childNodes = new ArrayList<Node>(interfaces.size()+1);
    int childOrder = 0;
    if (superClass.getKind() != TypeKind.NONE) {
        childNodes.add(superTypeHierarchy((DeclaredType)superClass, cpInfo, filters, childOrder));
    }
    for (TypeMirror superInterface : interfaces) {
        childOrder++;
        childNodes.add(superTypeHierarchy((DeclaredType)superInterface, cpInfo, filters, childOrder));
    }
    final Children cld;
    if (childNodes.isEmpty()) {
        cld = Children.LEAF;
    } else {
        cld = new SuperTypeChildren(filters);
        cld.add(childNodes.toArray(new Node[childNodes.size()]));
    }
    return new TypeNode(
        cld,
        new Description(
            cpInfo,
            ElementHandle.create(element),
            order),
        filters,
        globalActions(filters));
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:Nodes.java

示例12: getSuperClass

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
public TypeElement getSuperClass(TypeElement te) {
    if (isInterface(te) || isAnnotationType(te) ||
            te.asType().equals(getObjectType())) {
        return null;
    }
    TypeMirror superclass = te.getSuperclass();
    if (isNoType(superclass) && isClass(te)) {
        superclass = getObjectType();
    }
    return asTypeElement(superclass);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:Utils.java

示例13: run

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
@Override
public List<Fix> run(CompilationInfo info, String diagnosticKey, int offset, TreePath treePath, Data<Void> data) {
    if (!TreeUtilities.CLASS_TREE_KINDS.contains(treePath.getLeaf().getKind())) return Collections.emptyList();
    
    Element el = info.getTrees().getElement(treePath);
    
    if (el == null || !el.getKind().isClass()) return Collections.emptyList();
    
    TypeElement clazz = (TypeElement) el;
    TypeMirror superType = clazz.getSuperclass();
    
    if (superType.getKind() != TypeKind.DECLARED) return Collections.emptyList();
    
    TypeElement superClazz = (TypeElement) info.getTypes().asElement(superType);
    DeclaredType targetType = (DeclaredType) clazz.asType();
    Scope classScope = info.getTrees().getScope(treePath);
    List<Fix> result = new ArrayList<Fix>();
    
    for (ExecutableElement constr : ElementFilter.constructorsIn(superClazz.getEnclosedElements())) {
        if (!info.getTrees().isAccessible(classScope, constr, (DeclaredType) superType)) continue;
        
        StringBuilder name = new StringBuilder();
        
        name.append(clazz.getSimpleName()).append("(");
        
        ExecutableType target = (ExecutableType) info.getTypes().asMemberOf(targetType, constr);
        boolean firstParam = true;
        
        for (TypeMirror p : target.getParameterTypes()) {
            if (!firstParam) name.append(", ");
            firstParam = false;
            name.append(info.getTypeUtilities().getTypeName(p));
        }
        
        name.append(")");
        result.add(new FixImpl(info, treePath, constr, StringEscapeUtils.escapeHtml(name.toString())).toEditorFix());
    }
    
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:AddConstructor.java

示例14: getSuperclass

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
public TypeElement getSuperclass(TypeElement type) {
    TypeMirror supertype = type.getSuperclass();
    if (TypeKind.DECLARED.equals(supertype.getKind())) {
        Element element = ((DeclaredType)supertype).asElement();
        if (ElementKind.CLASS.equals(element.getKind())) {
            TypeElement superclass = (TypeElement)element;
            if (!superclass.getQualifiedName().contentEquals(
                    Object.class.getCanonicalName())) { 
                return superclass;
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:AnnotationHelper.java

示例15: isSubtypeOfType

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private boolean isSubtypeOfType(TypeMirror typeMirror, String otherType) {
  if (isTypeEqual(typeMirror, otherType)) {
    return true;
  }
  if (typeMirror.getKind() != TypeKind.DECLARED) {
    return false;
  }
  DeclaredType declaredType = (DeclaredType) typeMirror;
  List<? extends TypeMirror> typeArguments = declaredType.getTypeArguments();
  if (typeArguments.size() > 0) {
    StringBuilder typeString = new StringBuilder(declaredType.asElement().toString());
    typeString.append('<');
    for (int i = 0; i < typeArguments.size(); i++) {
      if (i > 0) {
        typeString.append(',');
      }
      typeString.append('?');
    }
    typeString.append('>');
    if (typeString.toString().equals(otherType)) {
      return true;
    }
  }
  Element element = declaredType.asElement();
  if (!(element instanceof TypeElement)) {
    return false;
  }
  TypeElement typeElement = (TypeElement) element;
  TypeMirror superType = typeElement.getSuperclass();
  if (isSubtypeOfType(superType, otherType)) {
    return true;
  }
  for (TypeMirror interfaceType : typeElement.getInterfaces()) {
    if (isSubtypeOfType(interfaceType, otherType)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:quangctkm9207,项目名称:prefpin,代码行数:40,代码来源:PrefPinProcessor.java


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