Search in sources :

Example 1 with ElementUtil

use of com.google.devtools.j2objc.util.ElementUtil in project j2objc by google.

the class AnonymousClassConverterTest method testAnonymousClassExtracted.

/**
   * Verify that an anonymous class is moved to the compilation unit's types list.
   */
public void testAnonymousClassExtracted() {
    List<TypeDeclaration> types = translateClassBody("Object test() { return new java.util.Enumeration<Object>() { " + "public boolean hasMoreElements() { return false; } " + "public Object nextElement() { return null; } }; }");
    assertEquals(2, types.size());
    TypeDeclaration type = types.get(1);
    ElementUtil elementUtil = TreeUtil.getCompilationUnit(type).getEnv().elementUtil();
    assertEquals("Test$1", elementUtil.getBinaryName(type.getTypeElement()));
}
Also used : ElementUtil(com.google.devtools.j2objc.util.ElementUtil) TypeDeclaration(com.google.devtools.j2objc.ast.TypeDeclaration) AbstractTypeDeclaration(com.google.devtools.j2objc.ast.AbstractTypeDeclaration)

Aggregations

AbstractTypeDeclaration (com.google.devtools.j2objc.ast.AbstractTypeDeclaration)1 TypeDeclaration (com.google.devtools.j2objc.ast.TypeDeclaration)1 ElementUtil (com.google.devtools.j2objc.util.ElementUtil)1