Search in sources :

Example 46 with TypeElement

use of javax.lang.model.element.TypeElement in project buck by facebook.

the class TreeBackedTypesTest method testIsSameTypeJavacTypeTopLevelNoGenerics.

@Test
public void testIsSameTypeJavacTypeTopLevelNoGenerics() throws IOException {
    initCompiler();
    TypeElement objectElement = elements.getTypeElement("java.lang.Object");
    TypeMirror objectTypeMirror = types.getDeclaredType(objectElement);
    TypeMirror objectTypeMirror2 = types.getDeclaredType(objectElement);
    assertSameType(objectTypeMirror, objectTypeMirror2);
}
Also used : TypeMirror(javax.lang.model.type.TypeMirror) TypeElement(javax.lang.model.element.TypeElement) Test(org.junit.Test)

Example 47 with TypeElement

use of javax.lang.model.element.TypeElement in project RoboBinding by RoboBinding.

the class WrappedTypeElement method typeElementOf.

private WrappedTypeElement typeElementOf(DeclaredType declaredType) {
    WrappedDeclaredType type = typeWrapper.wrap(declaredType);
    TypeElement element = (TypeElement) types.asElement(declaredType);
    return new WrappedTypeElement(element, type, typeWrapper, loggerFactory, elements, wrapper, types);
}
Also used : TypeElement(javax.lang.model.element.TypeElement) WrappedDeclaredType(org.robobinding.codegen.apt.type.WrappedDeclaredType)

Example 48 with TypeElement

use of javax.lang.model.element.TypeElement in project RoboBinding by RoboBinding.

the class ElementWrapperTest method unsupportedElements.

@DataPoints("unsupportedElements")
public static Element[] unsupportedElements() {
    Elements elements = compilation.getElements();
    PackageElement packageElement = elements.getPackageElement("java.lang");
    TypeElement typeElement = elements.getTypeElement(MethodsAndFields.class.getName());
    VariableElement variableElement = ElementFilter.fieldsIn(typeElement.getEnclosedElements()).get(0);
    return new Element[] { packageElement, variableElement };
}
Also used : TypeElement(javax.lang.model.element.TypeElement) PackageElement(javax.lang.model.element.PackageElement) ExecutableElement(javax.lang.model.element.ExecutableElement) VariableElement(javax.lang.model.element.VariableElement) Element(javax.lang.model.element.Element) TypeElement(javax.lang.model.element.TypeElement) PackageElement(javax.lang.model.element.PackageElement) VariableElement(javax.lang.model.element.VariableElement) Elements(javax.lang.model.util.Elements) FromDataPoints(org.junit.experimental.theories.FromDataPoints) DataPoints(org.junit.experimental.theories.DataPoints)

Example 49 with TypeElement

use of javax.lang.model.element.TypeElement in project RoboBinding by RoboBinding.

the class ElementWrapperTest method supportedElements.

@DataPoints("supportedElements")
public static ElementToWrapped[] supportedElements() {
    Elements elements = compilation.getElements();
    TypeElement typeElement = elements.getTypeElement(MethodsAndFields.class.getName());
    ExecutableElement methodElement = ElementFilter.methodsIn(typeElement.getEnclosedElements()).get(0);
    return new ElementToWrapped[] { a(typeElement).itsWrapped(WrappedTypeElement.class), a(methodElement).itsWrapped(MethodElement.class) };
}
Also used : TypeElement(javax.lang.model.element.TypeElement) ExecutableElement(javax.lang.model.element.ExecutableElement) Elements(javax.lang.model.util.Elements) FromDataPoints(org.junit.experimental.theories.FromDataPoints) DataPoints(org.junit.experimental.theories.DataPoints)

Example 50 with TypeElement

use of javax.lang.model.element.TypeElement in project neo4j by neo4j.

the class DuplicatedProcedureValidatorTest method procedureMethod.

private Element procedureMethod(String name) {
    TypeElement typeElement = elements.getTypeElement(name);
    Collection<Element> procedures = findProcedures(typeElement);
    if (procedures.size() != 1) {
        throw new AssertionError("Test procedure class should only have 1 defined procedure");
    }
    return procedures.iterator().next();
}
Also used : TypeElement(javax.lang.model.element.TypeElement) Element(javax.lang.model.element.Element) TypeElement(javax.lang.model.element.TypeElement)

Aggregations

TypeElement (javax.lang.model.element.TypeElement)1562 ExecutableElement (javax.lang.model.element.ExecutableElement)517 Element (javax.lang.model.element.Element)502 TypeMirror (javax.lang.model.type.TypeMirror)420 VariableElement (javax.lang.model.element.VariableElement)333 DeclaredType (javax.lang.model.type.DeclaredType)201 ArrayList (java.util.ArrayList)177 PackageElement (javax.lang.model.element.PackageElement)159 AnnotationMirror (javax.lang.model.element.AnnotationMirror)151 Test (org.junit.Test)136 HashMap (java.util.HashMap)118 HashSet (java.util.HashSet)109 Elements (javax.lang.model.util.Elements)101 Map (java.util.Map)98 IOException (java.io.IOException)97 List (java.util.List)97 ClassName (com.squareup.javapoet.ClassName)88 Test (org.junit.jupiter.api.Test)80 MethodSpec (com.squareup.javapoet.MethodSpec)72 TypeSpec (com.squareup.javapoet.TypeSpec)63