本文整理匯總了Java中javax.lang.model.type.ErrorType類的典型用法代碼示例。如果您正苦於以下問題:Java ErrorType類的具體用法?Java ErrorType怎麽用?Java ErrorType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ErrorType類屬於javax.lang.model.type包,在下文中一共展示了ErrorType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visitError
import javax.lang.model.type.ErrorType; //導入依賴的package包/類
@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;
}
示例2: resolveCapturedType
import javax.lang.model.type.ErrorType; //導入依賴的package包/類
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;
}
示例3: resolveCapturedType
import javax.lang.model.type.ErrorType; //導入依賴的package包/類
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;
}
示例4: visitError
import javax.lang.model.type.ErrorType; //導入依賴的package包/類
@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;
}
示例5: testErrorTypes
import javax.lang.model.type.ErrorType; //導入依賴的package包/類
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) {
}
}
}
示例6: visitError
import javax.lang.model.type.ErrorType; //導入依賴的package包/類
/**
* 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;
}
示例7: getTypeMirror
import javax.lang.model.type.ErrorType; //導入依賴的package包/類
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);
}
示例8: getOriginalType
import javax.lang.model.type.ErrorType; //導入依賴的package包/類
@Override
public TypeMirror getOriginalType(ErrorType et) {
return delegate.getOriginalType(et);
}
示例9: purify
import javax.lang.model.type.ErrorType; //導入依賴的package包/類
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);
}
示例10: purify
import javax.lang.model.type.ErrorType; //導入依賴的package包/類
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);
}
示例11: asError
import javax.lang.model.type.ErrorType; //導入依賴的package包/類
/**
* 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");
}
示例12: getErrorType
import javax.lang.model.type.ErrorType; //導入依賴的package包/類
@Test
public void getErrorType()
{
ErrorType errorType =
new DeclaredTypeAsErrorType(getTypes().getDeclaredType(getElement(Set.class)));
assertThat(TypeName.get(errorType)).isEqualTo(ClassName.get(Set.class));
}
示例13: visitError
import javax.lang.model.type.ErrorType; //導入依賴的package包/類
@Override
public Element visitError(ErrorType t, Void p) {
return t.asElement();
}
示例14: visitError
import javax.lang.model.type.ErrorType; //導入依賴的package包/類
@Override
public Element visitError(ErrorType t, Void p) {
return t.asElement();
}
示例15: visitError
import javax.lang.model.type.ErrorType; //導入依賴的package包/類
@Override public Element visitError(ErrorType t, Void p) {
return t.asElement();
}