Java 类javax.lang.model.type.ErrorType 实例源码

项目:incubator-netbeans    文件:JavaSymbolProvider.java   
@Override
public StringBuilder visitError(ErrorType t, Boolean p) {
    Element e = t.asElement();
    if (e instanceof TypeElement) {
        TypeElement te = (TypeElement)e;
        return DEFAULT_VALUE.append((p ? te.getQualifiedName() : te.getSimpleName()).toString());
    }
    return DEFAULT_VALUE;
}
项目:incubator-netbeans    文件:TypeUtilities.java   
private static TypeMirror resolveCapturedType(CompilationInfo info, TypeMirror tm) {
    if (tm == null) {
        return tm;
    }
    if (tm.getKind() == TypeKind.ERROR) {
        tm = info.getTrees().getOriginalType((ErrorType) tm);
    }
    TypeMirror type = resolveCapturedTypeInt(info, tm);
    if (type == null) {
        return tm;
    }
    if (type.getKind() == TypeKind.WILDCARD) {
        TypeMirror tmirr = ((WildcardType) type).getExtendsBound();
        if (tmirr != null)
            return tmirr;
        else { //no extends, just '?'
            TypeElement te = info.getElements().getTypeElement("java.lang.Object"); // NOI18N
            return te == null ? null : te.asType();
        }

    }

    return type;
}
项目:incubator-netbeans    文件:TypeUtilities.java   
@Override
public StringBuilder visitError(ErrorType t, Boolean p) {
    Element e = t.asElement();
    if (e instanceof TypeElement) {
        TypeElement te = (TypeElement)e;
        return DEFAULT_VALUE.append((p ? te.getQualifiedName() : te.getSimpleName()).toString());
    }
    return DEFAULT_VALUE;
}
项目:incubator-netbeans    文件:SpringXMLConfigCompletionItem.java   
@Override
public StringBuilder visitError(ErrorType t, Boolean p) {
    Element e = t.asElement();
    if (e instanceof TypeElement) {
        TypeElement te = (TypeElement)e;
        return DEFAULT_VALUE.append((p ? te.getQualifiedName() : te.getSimpleName()).toString());
    }
    return DEFAULT_VALUE;
}
项目:incubator-netbeans    文件:Utilities.java   
public static TypeMirror resolveCapturedType(CompilationInfo info, TypeMirror tm) {
    if (tm == null) {
        return tm;
    }
    if (tm.getKind() == TypeKind.ERROR) {
        tm = info.getTrees().getOriginalType((ErrorType) tm);
    }
    TypeMirror type = resolveCapturedTypeInt(info, tm);
    if (type == null) {
        return tm;
    }
    if (type.getKind() == TypeKind.WILDCARD) {
        TypeMirror tmirr = ((WildcardType) type).getExtendsBound();
        if (tmirr != null)
            return tmirr;
        else { //no extends, just '?'
            TypeElement te = info.getElements().getTypeElement("java.lang.Object"); // NOI18N
            return te == null ? null : te.asType();
        }

    }

    return type;
}
项目:incubator-netbeans    文件:AutoImport.java   
@Override
public Void visitError(ErrorType type, Void p) {
    Element e = type.asElement();
    if (e instanceof TypeElement) {
        TypeElement te = (TypeElement)e;
        builder.append(te.getSimpleName());            
    }
    return null;
}
项目:incubator-netbeans    文件:MethodModelSupport.java   
@Override
public StringBuilder visitError(ErrorType t, Boolean p) {
    Element e = t.asElement();
    if (e instanceof TypeElement) {
        TypeElement te = (TypeElement)e;
        return DEFAULT_VALUE.append((p ? te.getQualifiedName() : te.getSimpleName()).toString());
    }
    return DEFAULT_VALUE;
}
项目:RetroFacebook    文件:TypeSimplifierTest.java   
public void testErrorTypes() {
  TypeElement extendsUndefinedType =
      processingEnv.getElementUtils().getTypeElement("ExtendsUndefinedType");
  ErrorType errorType = (ErrorType) extendsUndefinedType.getSuperclass();
  TypeMirror javaLangObject = typeMirrorOf("java.lang.Object");
  TypeElement list = typeElementOf("java.util.List");
  TypeMirror listOfError = typeUtil.getDeclaredType(list, errorType);
  TypeMirror queryExtendsError = typeUtil.getWildcardType(errorType, null);
  TypeMirror listOfQueryExtendsError = typeUtil.getDeclaredType(list, queryExtendsError);
  TypeMirror querySuperError = typeUtil.getWildcardType(null, errorType);
  TypeMirror listOfQuerySuperError = typeUtil.getDeclaredType(list, querySuperError);
  TypeMirror arrayOfError = typeUtil.getArrayType(errorType);
  TypeMirror[] typesWithErrors = {
      errorType, listOfError, listOfQueryExtendsError, listOfQuerySuperError, arrayOfError
  };
  for (TypeMirror typeWithError : typesWithErrors) {
    try {
      new TypeSimplifier(typeUtil, "foo.bar", ImmutableSet.of(typeWithError), javaLangObject);
      fail("Expected exception for type: " + typeWithError);
    } catch (MissingTypeException expected) {
    }
  }
}
项目:RetroFacebook    文件:TypeSimplifierTest.java   
public void testErrorTypes() {
  TypeElement extendsUndefinedType =
      processingEnv.getElementUtils().getTypeElement("ExtendsUndefinedType");
  ErrorType errorType = (ErrorType) extendsUndefinedType.getSuperclass();
  TypeMirror javaLangObject = typeMirrorOf("java.lang.Object");
  TypeElement list = typeElementOf("java.util.List");
  TypeMirror listOfError = typeUtil.getDeclaredType(list, errorType);
  TypeMirror queryExtendsError = typeUtil.getWildcardType(errorType, null);
  TypeMirror listOfQueryExtendsError = typeUtil.getDeclaredType(list, queryExtendsError);
  TypeMirror querySuperError = typeUtil.getWildcardType(null, errorType);
  TypeMirror listOfQuerySuperError = typeUtil.getDeclaredType(list, querySuperError);
  TypeMirror arrayOfError = typeUtil.getArrayType(errorType);
  TypeMirror[] typesWithErrors = {
      errorType, listOfError, listOfQueryExtendsError, listOfQuerySuperError, arrayOfError
  };
  for (TypeMirror typeWithError : typesWithErrors) {
    try {
      new TypeSimplifier(typeUtil, "foo.bar", ImmutableSet.of(typeWithError), javaLangObject);
      fail("Expected exception for type: " + typeWithError);
    } catch (MissingTypeException expected) {
    }
  }
}
项目:FreeBuilder    文件:Analyser.java   
/**
 * Any reference to the as-yet-ungenerated builder should be an unresolved ERROR.
 * Similarly for many copy-and-paste errors
 */
@Override
public Boolean visitError(ErrorType t, Void p) {
  if (typeParameters.isEmpty()) {
    // For non-generic types, the ErrorType will have the correct name.
    String simpleName = t.toString();
    return equal(simpleName, superclass.getSimpleName());
  }
  // For generic types, we'll just have to hope for the best.
  // TODO: Revalidate in a subsequent round?
  return true;
}
项目:AutoCursor    文件:TypeSimplifierTest.java   
public void testErrorTypes() {
  TypeElement extendsUndefinedType =
      processingEnv.getElementUtils().getTypeElement("ExtendsUndefinedType");
  ErrorType errorType = (ErrorType) extendsUndefinedType.getSuperclass();
  TypeMirror javaLangObject = typeMirrorOf("java.lang.Object");
  TypeElement list = typeElementOf("java.util.List");
  TypeMirror listOfError = typeUtil.getDeclaredType(list, errorType);
  TypeMirror queryExtendsError = typeUtil.getWildcardType(errorType, null);
  TypeMirror listOfQueryExtendsError = typeUtil.getDeclaredType(list, queryExtendsError);
  TypeMirror querySuperError = typeUtil.getWildcardType(null, errorType);
  TypeMirror listOfQuerySuperError = typeUtil.getDeclaredType(list, querySuperError);
  TypeMirror arrayOfError = typeUtil.getArrayType(errorType);
  TypeMirror[] typesWithErrors = {
      errorType, listOfError, listOfQueryExtendsError, listOfQuerySuperError, arrayOfError
  };
  for (TypeMirror typeWithError : typesWithErrors) {
    try {
      new TypeSimplifier(typeUtil, "foo.bar", ImmutableSet.of(typeWithError), javaLangObject);
      fail("Expected exception for type: " + typeWithError);
    } catch (MissingTypeException expected) {
    }
  }
}
项目:retrofit2.bak    文件:TypeSimplifierTest.java   
public void testErrorTypes() {
  TypeElement extendsUndefinedType =
      processingEnv.getElementUtils().getTypeElement("ExtendsUndefinedType");
  ErrorType errorType = (ErrorType) extendsUndefinedType.getSuperclass();
  TypeMirror javaLangObject = typeMirrorOf("java.lang.Object");
  TypeElement list = typeElementOf("java.util.List");
  TypeMirror listOfError = typeUtil.getDeclaredType(list, errorType);
  TypeMirror queryExtendsError = typeUtil.getWildcardType(errorType, null);
  TypeMirror listOfQueryExtendsError = typeUtil.getDeclaredType(list, queryExtendsError);
  TypeMirror querySuperError = typeUtil.getWildcardType(null, errorType);
  TypeMirror listOfQuerySuperError = typeUtil.getDeclaredType(list, querySuperError);
  TypeMirror arrayOfError = typeUtil.getArrayType(errorType);
  TypeMirror[] typesWithErrors = {
      errorType, listOfError, listOfQueryExtendsError, listOfQuerySuperError, arrayOfError
  };
  for (TypeMirror typeWithError : typesWithErrors) {
    try {
      new TypeSimplifier(typeUtil, "foo.bar", ImmutableSet.of(typeWithError), javaLangObject);
      fail("Expected exception for type: " + typeWithError);
    } catch (MissingTypeException expected) {
    }
  }
}
项目:SimpleWeibo    文件:TypeSimplifierTest.java   
public void testErrorTypes() {
  TypeElement extendsUndefinedType =
      processingEnv.getElementUtils().getTypeElement("ExtendsUndefinedType");
  ErrorType errorType = (ErrorType) extendsUndefinedType.getSuperclass();
  TypeMirror javaLangObject = typeMirrorOf("java.lang.Object");
  TypeElement list = typeElementOf("java.util.List");
  TypeMirror listOfError = typeUtil.getDeclaredType(list, errorType);
  TypeMirror queryExtendsError = typeUtil.getWildcardType(errorType, null);
  TypeMirror listOfQueryExtendsError = typeUtil.getDeclaredType(list, queryExtendsError);
  TypeMirror querySuperError = typeUtil.getWildcardType(null, errorType);
  TypeMirror listOfQuerySuperError = typeUtil.getDeclaredType(list, querySuperError);
  TypeMirror arrayOfError = typeUtil.getArrayType(errorType);
  TypeMirror[] typesWithErrors = {
      errorType, listOfError, listOfQueryExtendsError, listOfQuerySuperError, arrayOfError
  };
  for (TypeMirror typeWithError : typesWithErrors) {
    try {
      new TypeSimplifier(typeUtil, "foo.bar", ImmutableSet.of(typeWithError), javaLangObject);
      fail("Expected exception for type: " + typeWithError);
    } catch (MissingTypeException expected) {
    }
  }
}
项目:AutoJson    文件:TypeSimplifierTest.java   
public void testErrorTypes() {
  TypeElement extendsUndefinedType =
      processingEnv.getElementUtils().getTypeElement("ExtendsUndefinedType");
  ErrorType errorType = (ErrorType) extendsUndefinedType.getSuperclass();
  TypeMirror javaLangObject = typeMirrorOf("java.lang.Object");
  TypeElement list = typeElementOf("java.util.List");
  TypeMirror listOfError = typeUtil.getDeclaredType(list, errorType);
  TypeMirror queryExtendsError = typeUtil.getWildcardType(errorType, null);
  TypeMirror listOfQueryExtendsError = typeUtil.getDeclaredType(list, queryExtendsError);
  TypeMirror querySuperError = typeUtil.getWildcardType(null, errorType);
  TypeMirror listOfQuerySuperError = typeUtil.getDeclaredType(list, querySuperError);
  TypeMirror arrayOfError = typeUtil.getArrayType(errorType);
  TypeMirror[] typesWithErrors = {
      errorType, listOfError, listOfQueryExtendsError, listOfQuerySuperError, arrayOfError
  };
  for (TypeMirror typeWithError : typesWithErrors) {
    try {
      new TypeSimplifier(typeUtil, "foo.bar", ImmutableSet.of(typeWithError), javaLangObject);
      fail("Expected exception for type: " + typeWithError);
    } catch (MissingTypeException expected) {
    }
  }
}
项目:tiny-serializer-java    文件:AnnotationValues.java   
public Value<TypeMirror> getTypeMirror(final String key) {
  final AnnotationValue annotationValue = values.get(key);

  if (annotationValue == null) {
    throw new IllegalArgumentException(key);
  }

  final TypeMirror typeMirror = toTypeMirror(annotationValue);

  if (typeMirror == null) {
    throw brokenValue("Could not resolve type", element, annotation, annotationValue);
  }

  if (typeMirror instanceof ErrorType) {
    throw brokenValue("Could not resolve type", element, annotation, annotationValue);
  }

  return new Value<>(annotationValue, typeMirror);
}
项目:dew    文件:TypeUtilities.java   
@Override
public StringBuilder visitError(ErrorType t, Boolean p) {
    Element e = t.asElement();
    if (e instanceof TypeElement) {
        TypeElement te = (TypeElement)e;
        return DEFAULT_VALUE.append((p ? te.getQualifiedName() : te.getSimpleName()).toString());
    }
    return DEFAULT_VALUE;
}
项目:incubator-netbeans    文件:CompletionFilter.java   
@Override
public TypeMirror getOriginalType(ErrorType et) {
    return delegate.getOriginalType(et);
}
项目:incubator-netbeans    文件:ChangeMethodReturnType.java   
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.resolveTypeForDeclaration(info, targetType);
}
项目:incubator-netbeans    文件:ExpectedTypeResolver.java   
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);
}
项目:android-auto-mapper    文件:MoreTypes.java   
/**
 * Returns a {@link ExecutableType} if the {@link TypeMirror} represents an executable type such
 * as may result from missing code, or bad compiles or throws an {@link IllegalArgumentException}.
 */
public static ErrorType asError(TypeMirror maybeErrorType) {
    return maybeErrorType.accept(new CastingTypeVisitor<ErrorType>() {
        @Override
        public ErrorType visitError(ErrorType type, String p) {
            return type;
        }
    }, "error type");
}
项目:wava    文件:TestAbstractTypes.java   
@Test
public void getErrorType()
{
    ErrorType errorType =
            new DeclaredTypeAsErrorType(getTypes().getDeclaredType(getElement(Set.class)));
    assertThat(TypeName.get(errorType)).isEqualTo(ClassName.get(Set.class));
}
项目:auto-parcel    文件:MoreTypes.java   
@Override
public Element visitError(ErrorType t, Void p) {
    return t.asElement();
}
项目:auto-parcel    文件:MoreTypes.java   
/**
 * Returns a {@link ExecutableType} if the {@link TypeMirror} represents an executable type such
 * as may result from missing code, or bad compiles or throws an {@link IllegalArgumentException}.
 */
public static ErrorType asError(TypeMirror maybeErrorType) {
    return maybeErrorType.accept(new CastingTypeVisitor<ErrorType>() {
        @Override
        public ErrorType visitError(ErrorType type, String p) {
            return type;
        }
    }, "error type");
}
项目:sqlitemagic    文件:Environment.java   
@Override
public Element visitError(ErrorType t, Void p) {
  return t.asElement();
}
项目:zerobuilder    文件:LessTypes.java   
@Override
public Element visitError(ErrorType t, Void p) {
  return t.asElement();
}
项目:RetroFacebook    文件:BuilderSpec.java   
@Override public Element visitError(ErrorType t, Void p) {
  return t.asElement();
}
项目:RetroFacebook    文件:BuilderSpec.java   
@Override public Element visitError(ErrorType t, Void p) {
  return t.asElement();
}
项目:AutoCursor    文件:BuilderSpec.java   
@Override public Element visitError(ErrorType t, Void p) {
  return t.asElement();
}
项目:bsoneer    文件:TypeResolver.java   
@Override
public String visitError(ErrorType t, Void p) {
    return "/* FIXME MetaGen could not process this type: " + t.toString()
            + ". Substituting with Object */ " + Object.class.getName();
}
项目:bsoneer    文件:Property.java   
static public TypeMirror resolveType(TypeMirror tm, Map<TypeMirror, TypeMirror> rawTypeMappings) {
    TypeMirror resolvedType = tm;
    TypeMirror typeMirror = rawTypeMappings.get(resolvedType);
    if (typeMirror != null) {
        resolvedType = typeMirror;
    } else {
        Types types = UtilsProvider.getTypes();
        if (resolvedType instanceof TypeVariable || resolvedType instanceof ErrorType) {
            resolvedType = types.getDeclaredType(UtilsProvider.getElements().getTypeElement(Object.class.getCanonicalName()));
        } else if (resolvedType instanceof ArrayType) {
            TypeMirror componentType = ((ArrayType)resolvedType).getComponentType();
            resolvedType = types.getArrayType(resolveType(componentType, rawTypeMappings));
        } else if (resolvedType instanceof DeclaredType) {
            DeclaredType dt = (DeclaredType) resolvedType;
            List<? extends TypeMirror> typeArguments = dt.getTypeArguments();
            if ( typeArguments != null && !typeArguments.isEmpty() ){
                int size = typeArguments.size();
                TypeMirror[] bakArguments = new TypeMirror[size];
                for(int i=0; i < size; i++){
                    bakArguments[i] = resolveType(typeArguments.get(i), rawTypeMappings);
                }
                resolvedType = types.getDeclaredType((TypeElement)dt.asElement(), bakArguments);
            }
        }
    }
    return resolvedType;
}
项目:squidb    文件:ModelMethodPlugin.java   
private boolean checkFirstArgType(TypeMirror type, DeclaredTypeName generatedClassName) {
    if (type instanceof ErrorType) {
        return true;
    }
    if (!(type instanceof DeclaredType)) {
        return false;
    }

    DeclaredTypeName typeName = (DeclaredTypeName) utils.getTypeNameFromTypeMirror(type);

    return typeName.equals(generatedClassName) || typeName.equals(TypeConstants.ABSTRACT_MODEL);
}
项目:retrofit2.bak    文件:BuilderSpec.java   
@Override public Element visitError(ErrorType t, Void p) {
  return t.asElement();
}
项目:SimpleWeibo    文件:BuilderSpec.java   
@Override public Element visitError(ErrorType t, Void p) {
  return t.asElement();
}
项目:AutoJson    文件:BuilderSpec.java   
@Override public Element visitError(ErrorType t, Void p) {
  return t.asElement();
}
项目:anatlyzer    文件:UnionTypeNamespace.java   
@Override
public Type getOperatorType(String operatorSymbol, Type optionalArgument, LocatedElement node) {
    Type t = super.getOperatorType(operatorSymbol, optionalArgument, node);
    if ( t == null ) {
        // This may generate more than one error, but it is the easiest way by now
        List<Type> types = type.getPossibleTypes().stream().map(possibleType -> {
            ITypeNamespace ns = (ITypeNamespace) possibleType.getMetamodelRef();
            return ns.getOperatorType(operatorSymbol, optionalArgument, node);              
        }).filter(opType -> !(opType instanceof ErrorType)).collect(Collectors.toList());
        return AnalyserContext.getTypingModel().getCommonType(types);
    }
    return t;
}
项目:revapi    文件:ClasspathScanner.java   
@Override
public TypeElement visitError(ErrorType t, Void aVoid) {
    return (TypeElement) t.asElement();
}
项目:java-traits    文件:TraitProcessorAptUtils.java   
private boolean checkReturnType(TraitElement element, ExecutableElement exec) {
    TypeMirror returnType = exec.getReturnType();
    if (returnType instanceof ErrorType) { // It may not exist yet
        return true;
    } else {
        return element.getGeneratedInterfaceName().equals(getTypeNameFromTypeMirror(returnType, null));
    }
}
项目:buck    文件:StandaloneTypeMirror.java   
@Override
public <R, P> R accept(TypeVisitor<R, P> v, P p) {
  switch (kind) {
    case BOOLEAN:
    case BYTE:
    case SHORT:
    case INT:
    case LONG:
    case CHAR:
    case FLOAT:
    case DOUBLE:
      return v.visitPrimitive((PrimitiveType) this, p);
    case PACKAGE:
    case VOID:
    case NONE:
      return v.visitNoType((NoType) this, p);
    case NULL:
      return v.visitNull((NullType) this, p);
    case ARRAY:
      return v.visitArray((ArrayType) this, p);
    case DECLARED:
      return v.visitDeclared((DeclaredType) this, p);
    case ERROR:
      return v.visitError((ErrorType) this, p);
    case TYPEVAR:
      return v.visitTypeVariable((TypeVariable) this, p);
    case WILDCARD:
      return v.visitWildcard((WildcardType) this, p);
    case EXECUTABLE:
      return v.visitExecutable((ExecutableType) this, p);
    case OTHER:
      return v.visit(this, p);
    case UNION:
      return v.visitUnion((UnionType) this, p);
    case INTERSECTION:
      return v.visitIntersection((IntersectionType) this, p);
    default:
      throw new AssertionError(String.format("Unknown TypeKind: %s", kind));
  }
}
项目:buck    文件:SignatureFactory.java   
@Override
public Void visitError(ErrorType t, SignatureVisitor visitor) {
  // We don't really know, but if there's an error type the compilation is going to fail
  // anyway, so just pretend it's Object.
  visitor.visitClassType("java/lang/Object");
  visitor.visitEnd();
  return null;
}
项目:GitHub    文件:TypeExtractor.java   
@Override
public Type visitError(ErrorType t, Type.Parameters p) {
  throw new UnsupportedOperationException("ErrorType type not supported");
}