Example usage for javax.lang.model.type TypeKind ERROR

List of usage examples for javax.lang.model.type TypeKind ERROR

Introduction

In this page you can find the example usage for javax.lang.model.type TypeKind ERROR.

Prototype

TypeKind ERROR

To view the source code for javax.lang.model.type TypeKind ERROR.

Click Source Link

Document

A class or interface type that could not be resolved.

Usage

From source file:cop.raml.utils.ImportScanner.java

/**
 * Find class root element for given {@code element} and retrieve all imports are used in the java file. All imported elements will be stored in
 * the internal map.//from www . ja  va2  s. co m
 *
 * @param element some element
 */
public void setCurrentElement(@NotNull Element element) {
    element = getClassRootElement(element);
    TypeKind kind = element.asType().getKind();

    if (kind != TypeKind.DECLARED && kind != TypeKind.ERROR)
        return;

    className = element.toString();

    if (imports.containsKey(className))
        return;

    for (String className : SorcererJavacUtils.getImports(element)) {
        if (className.endsWith(".*"))
            rootElements.entrySet().stream()
                    .filter(entry -> entry.getKey().startsWith(className.substring(0, className.length() - 1)))
                    .forEach(entry -> addImport(this.className, entry.getKey(), entry.getValue()));
        else if (rootElements.containsKey(className))
            addImport(this.className, className, rootElements.get(className));
        else {
            TypeElement typeElement = ThreadLocalContext.getElement(className);

            if (typeElement == null)
                continue;
            if (Config.ramlSkipClassName(typeElement.toString()))
                continue;

            // TODO values current project package and include include only related elements

            addImport(this.className, className, typeElement);
            rootElements.putIfAbsent(typeElement.toString(), typeElement);
        }
    }
}

From source file:cop.raml.mocks.MockUtils.java

private static TypeElementMock createCollectionElement() {
    TypeElementMock element = new TypeElementMock("<any>", ElementKind.CLASS);
    element.setType(new TypeMirrorMock(element, TypeKind.ERROR));
    return element;
}

From source file:org.androidannotations.helper.ValidatorHelper.java

public void isSharedPreference(Element element, AnnotationElements validatedElements, IsValid valid) {

    TypeMirror type = element.asType();

    /*/*from www  .j a  v a  2 s .c o  m*/
     * The type is not available yet because it has just been generated
     */
    if (type instanceof ErrorType || type.getKind() == TypeKind.ERROR) {
        String elementTypeName = type.toString();

        boolean sharedPrefValidatedInRound = false;
        if (elementTypeName.endsWith(GENERATION_SUFFIX)) {
            String prefTypeName = elementTypeName.substring(0,
                    elementTypeName.length() - GENERATION_SUFFIX.length());
            prefTypeName = prefTypeName.replace("_.", ".");

            Set<? extends Element> sharedPrefElements = validatedElements
                    .getRootAnnotatedElements(SharedPref.class.getName());

            for (Element sharedPrefElement : sharedPrefElements) {
                TypeElement sharedPrefTypeElement = (TypeElement) sharedPrefElement;

                String sharedPrefQualifiedName = sharedPrefTypeElement.getQualifiedName().toString();

                if (sharedPrefQualifiedName.endsWith(prefTypeName)) {
                    sharedPrefValidatedInRound = true;
                    break;
                }
            }
        }

        if (!sharedPrefValidatedInRound) {
            valid.invalidate();
        }

    } else {
        extendsType(element, SharedPreferencesHelper.class.getName(), valid);
    }

}

From source file:org.versly.rest.wsdoc.AnnotationProcessor.java

private JsonType jsonTypeFromTypeMirror(TypeMirror typeMirror, Collection<String> typeRecursionGuard) {

    JsonType type;//from  w  ww  . j  av a  2 s  . c  om

    if (_memoizedTypeMirrors.containsKey(typeMirror)) {
        return _memoizedTypeMirrors.get(typeMirror);
    }

    if (isJsonPrimitive(typeMirror)) {
        type = new JsonPrimitive(typeMirror.toString());
    } else if (typeMirror.getKind() == TypeKind.DECLARED) {
        // some sort of object... walk it
        DeclaredType declaredType = (DeclaredType) typeMirror;
        type = jsonTypeForDeclaredType(declaredType, declaredType.getTypeArguments(), typeRecursionGuard);
    } else if (typeMirror.getKind() == TypeKind.VOID) {
        type = null;
    } else if (typeMirror.getKind() == TypeKind.ARRAY) {
        TypeMirror componentType = ((ArrayType) typeMirror).getComponentType();
        type = jsonTypeFromTypeMirror(componentType, typeRecursionGuard);
    } else if (typeMirror.getKind() == TypeKind.ERROR) {
        type = new JsonPrimitive("(unresolvable type)");
    } else {
        throw new UnsupportedOperationException(typeMirror.toString());
    }

    _memoizedTypeMirrors.put(typeMirror, type);
    return type;
}