use of com.google.devtools.j2objc.ast.AbstractTypeDeclaration in project j2objc by google.
the class ElementUtilTest method testHasAnnotation.
public void testHasAnnotation() throws IOException {
CompilationUnit unit = translateType("Example", "@com.google.j2objc.annotations.ObjectiveCName(\"E\") class Example {}");
AbstractTypeDeclaration decl = unit.getTypes().get(0);
TypeElement element = decl.getTypeElement();
assertTrue(ElementUtil.hasAnnotation(element, ObjectiveCName.class));
}
use of com.google.devtools.j2objc.ast.AbstractTypeDeclaration in project j2objc by google.
the class NameTableTest method testGetFullNameNoPackage.
// Verify class name without package is unchanged.
public void testGetFullNameNoPackage() {
String source = "public class SomeClass {}";
CompilationUnit unit = translateType("SomeClass", source);
NameTable nameTable = unit.getEnv().nameTable();
AbstractTypeDeclaration decl = unit.getTypes().get(0);
assertEquals("SomeClass", nameTable.getFullName(decl.getTypeElement()));
}
use of com.google.devtools.j2objc.ast.AbstractTypeDeclaration in project j2objc by google.
the class NameTableTest method testGetFullNameEnumWithInnerClasses.
// Verify the name of an inner class of an enum.
public void testGetFullNameEnumWithInnerClasses() {
String source = "package foo.bar; " + "public enum SomeClass { A; static class Inner {} static enum Inner2 { B; }}";
CompilationUnit unit = translateType("SomeClass", source);
NameTable nameTable = unit.getEnv().nameTable();
AbstractTypeDeclaration decl = unit.getTypes().get(1);
// Outer type should not have "Enum" added to name.
assertEquals("FooBarSomeClass_Inner", nameTable.getFullName(decl.getTypeElement()));
// Inner enum should have "Enum" added to name.
decl = unit.getTypes().get(2);
assertEquals("FooBarSomeClass_Inner2", nameTable.getFullName(decl.getTypeElement()));
}
use of com.google.devtools.j2objc.ast.AbstractTypeDeclaration in project j2objc by google.
the class NameTableTest method testGetFullNameWithInnerClass.
// Verify inner class name with package is camel-cased.
public void testGetFullNameWithInnerClass() {
String source = "package foo.bar; public class SomeClass { static class Inner {}}";
CompilationUnit unit = translateType("SomeClass", source);
NameTable nameTable = unit.getEnv().nameTable();
AbstractTypeDeclaration decl = unit.getTypes().get(1);
assertEquals("FooBarSomeClass_Inner", nameTable.getFullName(decl.getTypeElement()));
}
use of com.google.devtools.j2objc.ast.AbstractTypeDeclaration in project j2objc by google.
the class PackagePrefixesTest method testPackageWildcards.
public void testPackageWildcards() throws IOException {
String source = "package foo.bar; public class SomeClass {}";
options.getPackagePrefixes().addPrefix("foo.*", "FB");
CompilationUnit unit = translateType("SomeClass", source);
NameTable nameTable = unit.getEnv().nameTable();
AbstractTypeDeclaration decl = unit.getTypes().get(0);
assertEquals("FBSomeClass", nameTable.getFullName(decl.getTypeElement()));
}
Aggregations