use of javax.lang.model.element.TypeElement in project buck by facebook.
the class TreeBackedTypeElementTest method testGetSuperclassOfInterfaceIsNoneType.
@Test
public void testGetSuperclassOfInterfaceIsNoneType() throws IOException {
compile("interface Foo extends java.lang.Runnable { }");
TypeElement fooElement = elements.getTypeElement("Foo");
assertSame(TypeKind.NONE, fooElement.getSuperclass().getKind());
}
use of javax.lang.model.element.TypeElement in project buck by facebook.
the class TreeBackedTypeElementTest method testGetSuperclassNoSuperclassIsObject.
@Test
public void testGetSuperclassNoSuperclassIsObject() throws IOException {
compile("class Foo { }");
TypeElement fooElement = elements.getTypeElement("Foo");
DeclaredType superclass = (DeclaredType) fooElement.getSuperclass();
TypeElement objectElement = elements.getTypeElement("java.lang.Object");
assertSame(objectElement, superclass.asElement());
}
use of javax.lang.model.element.TypeElement in project buck by facebook.
the class TreeBackedTypeElementTest method testGetQualifiedNameUnnamedPackage.
@Test
public void testGetQualifiedNameUnnamedPackage() throws IOException {
compile("public class Foo {}");
TypeElement element = elements.getTypeElement("Foo");
assertNameEquals("Foo", element.getQualifiedName());
}
use of javax.lang.model.element.TypeElement in project buck by facebook.
the class TreeBackedTypeElementTest method testToString.
@Test
public void testToString() throws IOException {
compile(Joiner.on('\n').join("package com.facebook.buck;", "public class Foo<T> {}"));
TypeElement element = elements.getTypeElement("com.facebook.buck.Foo");
assertEquals("com.facebook.buck.Foo", element.toString());
}
use of javax.lang.model.element.TypeElement in project buck by facebook.
the class TreeBackedTypeElementTest method testGetEnclosingElementForBuiltInTopLevelClasses.
@Ignore("TODO(jkeljo): Need to wrap elements coming out of javac to ensure callers always get" + "our PackageElement impl instead of javac's.")
@Test
public void testGetEnclosingElementForBuiltInTopLevelClasses() throws IOException {
initCompiler();
TypeElement stringElement = elements.getTypeElement("java.lang.String");
PackageElement javaLangElement = elements.getPackageElement("java.lang");
assertSame(javaLangElement, stringElement.getEnclosingElement());
}
Aggregations