本文整理匯總了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;
}
示例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 );
}
}
}
示例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 );
}
}
}
示例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;
}
}
示例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 );
}
}
}
示例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;
}
示例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);
}
示例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 "";
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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));
}
示例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);
}