use of com.google.devtools.j2objc.ast.CompilationUnit 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.CompilationUnit 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.CompilationUnit in project j2objc by google.
the class PackageInfoLookupTest method testReflectionSupportAnnotation.
public void testReflectionSupportAnnotation() throws IOException {
addSourceFile("@ReflectionSupport(value = ReflectionSupport.Level.FULL) package foo;" + "import com.google.j2objc.annotations.ReflectionSupport;", "foo/package-info.java");
CompilationUnit unit = translateType("foo.A", "package foo; public class A {}");
PackageInfoLookup packageInfoLookup = unit.getEnv().options().getPackageInfoLookup();
assert packageInfoLookup.getReflectionSupportLevel("foo") == ReflectionSupport.Level.FULL;
addSourceFile("@ReflectionSupport(ReflectionSupport.Level.FULL) package bar;" + "import com.google.j2objc.annotations.*;", "bar/package-info.java");
unit = translateType("bar.A", "package bar; public class A {}");
packageInfoLookup = unit.getEnv().options().getPackageInfoLookup();
assert packageInfoLookup.getReflectionSupportLevel("bar") == ReflectionSupport.Level.FULL;
addSourceFile("@com.google.j2objc.annotations.ReflectionSupport" + "(com.google.j2objc.annotations.ReflectionSupport.Level.NATIVE_ONLY) package baz;", "baz/package-info.java");
unit = translateType("baz.A", "package baz; public class A {}");
packageInfoLookup = unit.getEnv().options().getPackageInfoLookup();
assert packageInfoLookup.getReflectionSupportLevel("baz") == ReflectionSupport.Level.NATIVE_ONLY;
// Verify that ReflectionSupport annotation can be parsed from class files
String jarFilePath = getResourceAsFile("packageInfoLookupTest.jar");
options.fileUtil().getClassPathEntries().add(jarFilePath);
unit = translateType("com.google.test.packageInfoLookupTest.A", "package com.google.test.packageInfoLookupTest; public class A {}");
packageInfoLookup = unit.getEnv().options().getPackageInfoLookup();
assert packageInfoLookup.getReflectionSupportLevel(unit.getPackage().getName().toString()) == ReflectionSupport.Level.FULL;
}
use of com.google.devtools.j2objc.ast.CompilationUnit 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()));
}
use of com.google.devtools.j2objc.ast.CompilationUnit in project j2objc by google.
the class PackagePrefixesTest method testGetFullNameWithInnerClassAndPrefix.
// Verify inner class name with prefix.
public void testGetFullNameWithInnerClassAndPrefix() {
String source = "package foo.bar; public class SomeClass { static class Inner {}}";
options.getPackagePrefixes().addPrefix("foo.bar", "FB");
CompilationUnit unit = translateType("SomeClass", source);
NameTable nameTable = unit.getEnv().nameTable();
AbstractTypeDeclaration decl = unit.getTypes().get(1);
assertEquals("FBSomeClass_Inner", nameTable.getFullName(decl.getTypeElement()));
}
Aggregations