com.sun.tools.javac.code.Type.ErrorType Java Examples

The following examples show how to use com.sun.tools.javac.code.Type.ErrorType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavacTrees.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the original type from the ErrorType object.
 * @param errorType The errorType for which we want to get the original type.
 * @returns TypeMirror corresponding to the original type, replaced by the ErrorType.
 *          noType (type.tag == NONE) is returned if there is no original type.
 */
public TypeMirror getOriginalType(javax.lang.model.type.ErrorType errorType) {
    if (errorType instanceof com.sun.tools.javac.code.Type.ErrorType) {
        return ((com.sun.tools.javac.code.Type.ErrorType)errorType).getOriginalType();
    }

    return com.sun.tools.javac.code.Type.noType;
}
 
Example #2
Source File: HandleExtensionMethod.java    From EasyMPermission with MIT License 5 votes vote down vote up
private void handleMethodCall(final JCMethodInvocation methodCall) {
	JavacNode methodCallNode = annotationNode.getAst().get(methodCall);
	
	if (methodCallNode == null) {
		// This should mean the node does not exist in the source at all. This is the case for generated nodes, such as implicit super() calls.
		return;
	}
	
	JavacNode surroundingType = upToTypeNode(methodCallNode);
	
	TypeSymbol surroundingTypeSymbol = ((JCClassDecl)surroundingType.get()).sym;
	JCExpression receiver = receiverOf(methodCall);
	String methodName = methodNameOf(methodCall);
	
	if ("this".equals(methodName) || "super".equals(methodName)) return;
	Type resolvedMethodCall = CLASS_AND_METHOD.resolveMember(methodCallNode, methodCall);
	if (resolvedMethodCall == null) return;
	if (!suppressBaseMethods && !(resolvedMethodCall instanceof ErrorType)) return;
	Type receiverType = CLASS_AND_METHOD.resolveMember(methodCallNode, receiver);
	if (receiverType == null) return;
	if (receiverType.tsym.toString().endsWith(receiver.toString())) return;
	
	Types types = Types.instance(annotationNode.getContext());
	for (Extension extension : extensions) {
		TypeSymbol extensionProvider = extension.extensionProvider;
		if (surroundingTypeSymbol == extensionProvider) continue;
		for (MethodSymbol extensionMethod : extension.extensionMethods) {
			if (!methodName.equals(extensionMethod.name.toString())) continue;
			Type extensionMethodType = extensionMethod.type;
			if (!MethodType.class.isInstance(extensionMethodType) && !ForAll.class.isInstance(extensionMethodType)) continue;
			Type firstArgType = types.erasure(extensionMethodType.asMethodType().argtypes.get(0));
			if (!types.isAssignable(receiverType, firstArgType)) continue;
			methodCall.args = methodCall.args.prepend(receiver);
			methodCall.meth = chainDotsString(annotationNode, extensionProvider.toString() + "." + methodName);
			return;
		}
	}
}
 
Example #3
Source File: JavacTrees.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the original type from the ErrorType object.
 * @param errorType The errorType for which we want to get the original type.
 * @returns TypeMirror corresponding to the original type, replaced by the ErrorType.
 *          noType (type.tag == NONE) is returned if there is no original type.
 */
public TypeMirror getOriginalType(javax.lang.model.type.ErrorType errorType) {
    if (errorType instanceof com.sun.tools.javac.code.Type.ErrorType) {
        return ((com.sun.tools.javac.code.Type.ErrorType)errorType).getOriginalType();
    }

    return com.sun.tools.javac.code.Type.noType;
}
 
Example #4
Source File: JavacTrees.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the original type from the ErrorType object.
 * @param errorType The errorType for which we want to get the original type.
 * @returns TypeMirror corresponding to the original type, replaced by the ErrorType.
 *          noType (type.tag == NONE) is returned if there is no original type.
 */
public TypeMirror getOriginalType(javax.lang.model.type.ErrorType errorType) {
    if (errorType instanceof com.sun.tools.javac.code.Type.ErrorType) {
        return ((com.sun.tools.javac.code.Type.ErrorType)errorType).getOriginalType();
    }

    return com.sun.tools.javac.code.Type.noType;
}
 
Example #5
Source File: JavacTrees.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the original type from the ErrorType object.
 * @param errorType The errorType for which we want to get the original type.
 * @returns TypeMirror corresponding to the original type, replaced by the ErrorType.
 *          noType (type.tag == NONE) is returned if there is no original type.
 */
public TypeMirror getOriginalType(javax.lang.model.type.ErrorType errorType) {
    if (errorType instanceof com.sun.tools.javac.code.Type.ErrorType) {
        return ((com.sun.tools.javac.code.Type.ErrorType)errorType).getOriginalType();
    }

    return com.sun.tools.javac.code.Type.noType;
}
 
Example #6
Source File: JavacTrees.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the original type from the ErrorType object.
 * @param errorType The errorType for which we want to get the original type.
 * @return TypeMirror corresponding to the original type, replaced by the ErrorType.
 *         noType (type.tag == NONE) is returned if there is no original type.
 */
@Override @DefinedBy(Api.COMPILER_TREE)
public TypeMirror getOriginalType(javax.lang.model.type.ErrorType errorType) {
    if (errorType instanceof com.sun.tools.javac.code.Type.ErrorType) {
        return ((com.sun.tools.javac.code.Type.ErrorType)errorType).getOriginalType();
    }

    return com.sun.tools.javac.code.Type.noType;
}
 
Example #7
Source File: JavacTrees.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the original type from the ErrorType object.
 * @param errorType The errorType for which we want to get the original type.
 * @returns TypeMirror corresponding to the original type, replaced by the ErrorType.
 *          noType (type.tag == NONE) is returned if there is no original type.
 */
public TypeMirror getOriginalType(javax.lang.model.type.ErrorType errorType) {
    if (errorType instanceof com.sun.tools.javac.code.Type.ErrorType) {
        return ((com.sun.tools.javac.code.Type.ErrorType)errorType).getOriginalType();
    }

    return com.sun.tools.javac.code.Type.noType;
}
 
Example #8
Source File: TreeFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public ExpressionTree Type(TypeMirror type) {
    Type t = (Type) type;
    JCExpression tp;
    switch (type.getKind()) {
        case WILDCARD: {
            WildcardType a = ((WildcardType) type);
            tp = make.at(NOPOS).Wildcard(make.at(NOPOS).TypeBoundKind(a.kind), (JCExpression) Type(a.type));
            break;
        }
        case ERROR:
            if (t.hasTag(TypeTag.ERROR)) {
                tp = make.at(NOPOS).Ident(((ErrorType) type).tsym.name);
                break;
            }
        case DECLARED:
            JCExpression clazz = (JCExpression) QualIdent(t.tsym);
            tp = t.getTypeArguments().isEmpty()
            ? clazz
                    : make.at(NOPOS).TypeApply(clazz, Types(t.getTypeArguments()));
            break;
        case ARRAY:
            
            tp = make.at(NOPOS).TypeArray((JCExpression) Type(((ArrayType) type).getComponentType()));
            break;
        case NULL:
            tp = make.at(NOPOS).Literal(TypeTag.BOT, null);
            break;
        default:
            return make.at(NOPOS).Type((Type)type);
    }

    return tp.setType(t);
}
 
Example #9
Source File: TypeEnter.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
ClassSymbol synthesizeClass(Name name, Symbol owner) {
    int flags = interfaceExpected ? INTERFACE : 0;
    ClassSymbol c = new ClassSymbol(flags, name, owner);
    c.members_field = new Scope.ErrorScope(c);
    c.type = new ErrorType(originalType, c) {
        @Override @DefinedBy(Api.LANGUAGE_MODEL)
        public List<Type> getTypeArguments() {
            return typarams_field;
        }
    };
    synthesizedSymbols = synthesizedSymbols.prepend(c);
    return c;
}
 
Example #10
Source File: TypeEnter.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected Type modelMissingTypes(Env<AttrContext> env, Type t, final JCExpression tree, final boolean interfaceExpected) {
    if (!t.hasTag(ERROR))
        return t;

    return new ErrorType(t.getOriginalType(), t.tsym) {
        private Type modelType;

        @Override
        public Type getModelType() {
            if (modelType == null)
                modelType = new Synthesizer(env.toplevel.modle, getOriginalType(), interfaceExpected).visit(tree);
            return modelType;
        }
    };
}
 
Example #11
Source File: JavacTrees.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Returns the original type from the ErrorType object.
 * @param errorType The errorType for which we want to get the original type.
 * @return TypeMirror corresponding to the original type, replaced by the ErrorType.
 *         noType (type.tag == NONE) is returned if there is no original type.
 */
@Override @DefinedBy(Api.COMPILER_TREE)
public TypeMirror getOriginalType(javax.lang.model.type.ErrorType errorType) {
    if (errorType instanceof com.sun.tools.javac.code.Type.ErrorType) {
        return ((com.sun.tools.javac.code.Type.ErrorType)errorType).getOriginalType();
    }

    return com.sun.tools.javac.code.Type.noType;
}
 
Example #12
Source File: JavacTrees.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the original type from the ErrorType object.
 * @param errorType The errorType for which we want to get the original type.
 * @returns TypeMirror corresponding to the original type, replaced by the ErrorType.
 *          noType (type.tag == NONE) is returned if there is no original type.
 */
public TypeMirror getOriginalType(javax.lang.model.type.ErrorType errorType) {
    if (errorType instanceof com.sun.tools.javac.code.Type.ErrorType) {
        return ((com.sun.tools.javac.code.Type.ErrorType)errorType).getOriginalType();
    }

    return com.sun.tools.javac.code.Type.noType;
}
 
Example #13
Source File: JavacTrees.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the original type from the ErrorType object.
 * @param errorType The errorType for which we want to get the original type.
 * @returns TypeMirror corresponding to the original type, replaced by the ErrorType.
 *          noType (type.tag == NONE) is returned if there is no original type.
 */
public TypeMirror getOriginalType(javax.lang.model.type.ErrorType errorType) {
    if (errorType instanceof com.sun.tools.javac.code.Type.ErrorType) {
        return ((com.sun.tools.javac.code.Type.ErrorType)errorType).getOriginalType();
    }

    return com.sun.tools.javac.code.Type.noType;
}
 
Example #14
Source File: JavacTrees.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Boolean visitErrorType(ErrorType t, Type s) {
    return s.hasTag(CLASS)
            && t.tsym.name == ((ClassType) s).tsym.name;
}
 
Example #15
Source File: JavacTrees.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Boolean visitErrorType(ErrorType t, Type s) {
    return s.hasTag(CLASS)
            && t.tsym.name == ((ClassType) s).tsym.name;
}
 
Example #16
Source File: Printer.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Override
public String visitErrorType(ErrorType t, Locale locale) {
    return visitType(t, locale);
}
 
Example #17
Source File: JavacTrees.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Boolean visitErrorType(ErrorType t, Type s) {
    return s.hasTag(CLASS)
            && t.tsym.name == ((ClassType) s).tsym.name;
}
 
Example #18
Source File: JavacTrees.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Boolean visitErrorType(ErrorType t, Type s) {
    return s.hasTag(CLASS)
            && t.tsym.name == ((ClassType) s).tsym.name;
}
 
Example #19
Source File: JavacTrees.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Boolean visitErrorType(ErrorType t, Type s) {
    return s.hasTag(CLASS)
            && t.tsym.name == ((ClassType) s).tsym.name;
}
 
Example #20
Source File: Printer.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
@Override
public String visitErrorType(ErrorType t, Locale locale) {
    return visitType(t, locale);
}
 
Example #21
Source File: JavacTrees.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Boolean visitErrorType(ErrorType t, Type s) {
    return s.hasTag(CLASS)
            && t.tsym.name == ((ClassType) s).tsym.name;
}
 
Example #22
Source File: JavacTrees.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Boolean visitErrorType(ErrorType t, Type s) {
    return s.hasTag(CLASS)
            && t.tsym.name == ((ClassType) s).tsym.name;
}
 
Example #23
Source File: JavacTrees.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Boolean visitErrorType(ErrorType t, Type s) {
    return s.hasTag(CLASS)
            && t.tsym.name == ((ClassType) s).tsym.name;
}
 
Example #24
Source File: JavacTrees.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Boolean visitErrorType(ErrorType t, Type s) {
    return s.hasTag(CLASS)
            && t.tsym.name == ((ClassType) s).tsym.name;
}