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


Java TypeKind.NONE属性代码示例

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


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

示例1: getViewsType

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,代码行数:21,代码来源:PresenterInjectorRules.java

示例2: enumerateMethods

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:react4j,项目名称:react4j,代码行数:25,代码来源:ProcessorUtil.java

示例3: enumerateFields

private static void enumerateFields( @Nonnull final TypeElement scope,
                                     @Nonnull final Types typeUtils,
                                     @Nonnull final TypeElement element,
                                     @Nonnull final Map<String, TypeMirror> fields )
{
  final TypeMirror superclass = element.getSuperclass();
  if ( TypeKind.NONE != superclass.getKind() )
  {
    enumerateFields( scope, typeUtils, (TypeElement) ( (DeclaredType) superclass ).asElement(), fields );
  }
  for ( final Element member : element.getEnclosedElements() )
  {
    if ( member.getKind() == ElementKind.FIELD )
    {
      final TypeMirror fieldType = typeUtils.asMemberOf( (DeclaredType) scope.asType(), member );
      fields.put( member.getSimpleName().toString(), fieldType );
    }
  }
}
 
开发者ID:react4j,项目名称:react4j,代码行数:19,代码来源:ProcessorUtil.java

示例4: enclosedBy

private boolean enclosedBy(TypeMirror t1, TypeMirror t2) {
    if(t1.getKind() == TypeKind.DECLARED) {
        if(workingCopy.getTypes().isSameType(t1, t2)) {
            return true;
        }
        DeclaredType dt = (DeclaredType) t1;
        TypeMirror enclosingType = dt.getEnclosingType();
        if(enclosingType.getKind() == TypeKind.NONE) {
            return false;
        } else {
            return enclosedBy(enclosingType, t2);
        }
    } else {
        return false;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:MoveMembersTransformer.java

示例5: enumerateFieldElements

private static void enumerateFieldElements( @Nonnull final TypeElement element,
                                            @Nonnull final Map<String, VariableElement> fields )
{
  final TypeMirror superclass = element.getSuperclass();
  if ( TypeKind.NONE != superclass.getKind() )
  {
    enumerateFieldElements( (TypeElement) ( (DeclaredType) superclass ).asElement(), fields );
  }
  for ( final Element member : element.getEnclosedElements() )
  {
    if ( member.getKind() == ElementKind.FIELD )
    {
      fields.put( member.getSimpleName().toString(), (VariableElement) member );
    }
  }
}
 
开发者ID:react4j,项目名称:react4j,代码行数:16,代码来源:ProcessorUtil.java

示例6: searchInterfacesAncestry

private boolean searchInterfacesAncestry(TypeMirror rootIface, TypeMirror target) {
  TypeElement rootIfaceElement = (TypeElement) typeUtils.asElement(rootIface);
  // check if it implements valid interfaces
  for (TypeMirror iface : rootIfaceElement.getInterfaces()) {
    TypeElement ifaceElement = (TypeElement) typeUtils.asElement(rootIface);
    while (iface.getKind() != TypeKind.NONE) {
      if (typeUtils.isSameType(iface, target)) {
        return true;
      }
      // go up
      if (searchInterfacesAncestry(iface, target)) {
        return true;
      }
      // then move on
      iface = ifaceElement.getSuperclass();
    }
  }
  return false;
}
 
开发者ID:hzsweers,项目名称:inspector,代码行数:19,代码来源:InspectorFactoryProcessor.java

示例7: AddParameterOrLocalFix

public AddParameterOrLocalFix(CompilationInfo info,
                              TypeMirror type, String name,
                              ElementKind kind,
                              int /*!!!Position*/ unresolvedVariable) {
    this.file = info.getFileObject();
    if (type.getKind() == TypeKind.NULL || type.getKind() == TypeKind.NONE) {
        TypeElement te = info.getElements().getTypeElement("java.lang.Object"); // NOI18N
        if (te != null) {
            type = te.asType();
            this.type = TypeMirrorHandle.create(type);
        } else {
            this.type = null;
        }
    } else {
        this.type = TypeMirrorHandle.create(type);
    }
    this.name = name;
    this.kind = kind;

    TreePath treePath = info.getTreeUtilities().pathFor(unresolvedVariable + 1);
    tpHandle = new TreePathHandle[1];
    tpHandle[0] = TreePathHandle.create(treePath, info);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:AddParameterOrLocalFix.java

示例8: getViewClassFromGeneric

private String getViewClassFromGeneric(TypeElement typeElement) {
	TypeMirror superclass = typeElement.asType();

	Map<String, String> parentTypes = Collections.emptyMap();

	if (!typeElement.getTypeParameters().isEmpty()) {
		MvpCompiler.getMessager().printMessage(Diagnostic.Kind.WARNING, "Your " + typeElement.getSimpleName() + " is typed. @InjectViewState may generate wrong code. Your can set view/view state class manually.");
	}

	while (superclass.getKind() != TypeKind.NONE) {
		TypeElement superclassElement = (TypeElement) ((DeclaredType) superclass).asElement();

		final List<? extends TypeMirror> typeArguments = ((DeclaredType) superclass).getTypeArguments();
		final List<? extends TypeParameterElement> typeParameters = superclassElement.getTypeParameters();

		if (typeArguments.size() > typeParameters.size()) {
			throw new IllegalArgumentException("Code generation for interface " + typeElement.getSimpleName() + " failed. Simplify your generics. (" + typeArguments + " vs " + typeParameters + ")");
		}

		Map<String, String> types = new HashMap<>();
		for (int i = 0; i < typeArguments.size(); i++) {
			types.put(typeParameters.get(i).toString(), fillGenerics(parentTypes, typeArguments.get(i)));
		}

		if (superclassElement.toString().equals(MVP_PRESENTER_CLASS)) {
			// MvpPresenter is typed only on View class
			return fillGenerics(parentTypes, typeArguments);
		}

		parentTypes = types;

		superclass = superclassElement.getSuperclass();
	}

	return "";
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:ViewStateProviderClassGenerator.java

示例9: collectHierarchyMirrors

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,代码行数:29,代码来源:TypeHierarchyCollector.java

示例10: checkRealmResultsType

private boolean checkRealmResultsType(VariableElement field) {
    // Only classes implementing RealmModel are allowed since RealmResults field is used only for backlinks.

    // Check for missing generic (default back to Object)
    if (Utils.getGenericTypeQualifiedName(field) == null) {
        Utils.error("No generic type supplied for field", field);
        return false;
    }

    TypeMirror fieldType = field.asType();
    final TypeMirror elementTypeMirror = ((DeclaredType) fieldType).getTypeArguments().get(0);
    if (elementTypeMirror.getKind() == TypeKind.DECLARED /* class or interface*/) {
        TypeElement elementTypeElement = (TypeElement) ((DeclaredType) elementTypeMirror).asElement();
        if (elementTypeElement.getSuperclass().getKind() == TypeKind.NONE) {
            Utils.error(
                    "Only concrete Realm classes are allowed in RealmResults. "
                            + "Neither interfaces nor abstract classes are allowed.",
                    field);
            return false;
        }
    }

    // Check if the actual value class is acceptable
    if (!Utils.isRealmModel(elementTypeMirror)) {
        Utils.error("Element type of RealmResults must be a class implementing 'RealmModel'.", field);
        return false;
    }

    return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:ClassMetaData.java

示例11: purify

private TypeMirror purify(CompilationInfo info, TypeMirror targetType) {
    if (targetType != null && targetType.getKind() == TypeKind.ERROR) {
        targetType = info.getTrees().getOriginalType((ErrorType) targetType);
    }

    if (targetType == null || targetType.getKind() == /*XXX:*/TypeKind.ERROR || targetType.getKind() == TypeKind.NONE || targetType.getKind() == TypeKind.NULL) return null;

    return Utilities.resolveCapturedType(info, targetType);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ExpectedTypeResolver.java

示例12: canBeMissingAnnotations

private static boolean canBeMissingAnnotations(TypeMirror typeMirror) {
    if (typeMirror == null) {
        return false;
    }
    if (typeMirror.getKind() == TypeKind.VOID
            || typeMirror.getKind() == TypeKind.NONE
            || typeMirror.getKind() == TypeKind.PACKAGE) {
        return true;
    }
    if (typeMirror.getKind() == TypeKind.WILDCARD) {
        return canBeMissingAnnotations(((WildcardType) typeMirror).getExtendsBound());
    }
    return typeMirror.getKind() == TypeKind.TYPEVAR;
}
 
开发者ID:PPewt,项目名称:affinechecker,代码行数:14,代码来源:AffinePointerValue.java

示例13: isSubclassOf

private static boolean isSubclassOf(TypeElement subclass, TypeElement superclass) {
    TypeMirror superType = subclass.getSuperclass();
    while (superType.getKind() != TypeKind.NONE) {
        TypeElement superTypeElm = (TypeElement) ((DeclaredType) superType).asElement();
        if (superclass == superTypeElm) {
            return true;
        }
        superType = superTypeElm.getSuperclass();
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:EncapsulateFieldRefactoringPlugin.java

示例14: superTypeHierarchy

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,代码行数:34,代码来源:Nodes.java

示例15: CreateFieldFix

public CreateFieldFix(CompilationInfo info, String name, Set<Modifier> modifiers, TypeElement target, TypeMirror proposedType, FileObject targetFile) {
    this.name = name;
    this.inFQN = Utilities.target2String(target);
    this.cpInfo = info.getClasspathInfo();
    this.modifiers = modifiers;
    this.targetFile = targetFile;
    this.target = ElementHandle.create(target);
    if (proposedType.getKind() == TypeKind.NULL || proposedType.getKind() == TypeKind.NONE) {
        TypeElement te = info.getElements().getTypeElement("java.lang.Object"); // NOI18N
        proposedType = te == null ? null : te.asType();
    }
    this.proposedType = proposedType == null ? null : TypeMirrorHandle.create(proposedType);
    this.remote = !org.openide.util.Utilities.compareObjects(info.getFileObject(), targetFile);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:CreateFieldFix.java


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