Search in sources :

Example 1 with TypeDeclaration

use of com.strobel.decompiler.languages.java.ast.TypeDeclaration in project j2objc by google.

the class PackageInfoLookup method parseDataFromClassFile.

private PackageData parseDataFromClassFile(InputFile file) throws IOException {
    PackageDataBuilder builder = new PackageDataBuilder();
    ClassFile classFile = ClassFile.create(file);
    TypeDeclaration typeDecl = classFile.getType();
    for (Annotation annotation : typeDecl.getAnnotations()) {
        String signature = annotation.getType().toTypeReference().getErasedSignature();
        if (signature.equals("Lcom/google/j2objc/annotations/ObjectiveCName;")) {
            for (Expression expr : annotation.getArguments()) {
                if (expr instanceof MemberReferenceExpression) {
                    String value = ((MemberReferenceExpression) expr).getMemberName();
                    builder.setObjectiveCName(value);
                } else if (expr instanceof PrimitiveExpression) {
                    Object value = ((PrimitiveExpression) expr).getValue();
                    builder.setObjectiveCName((String) value);
                }
            }
        } else if (signature.equals("Ljavax/annotation/ParametersAreNonnullByDefault;")) {
            builder.setParametersAreNonnullByDefault();
        } else if (signature.equals("Lcom/google/j2objc/annotations/ReflectionSupport;")) {
            for (Expression expr : annotation.getArguments()) {
                if (expr instanceof MemberReferenceExpression) {
                    String value = ((MemberReferenceExpression) expr).getMemberName();
                    builder.setReflectionSupportLevel(ReflectionSupport.Level.valueOf(value));
                }
            }
        }
    }
    return builder.build();
}
Also used : MemberReferenceExpression(com.strobel.decompiler.languages.java.ast.MemberReferenceExpression) Expression(com.strobel.decompiler.languages.java.ast.Expression) PrimitiveExpression(com.strobel.decompiler.languages.java.ast.PrimitiveExpression) MemberReferenceExpression(com.strobel.decompiler.languages.java.ast.MemberReferenceExpression) TypeDeclaration(com.strobel.decompiler.languages.java.ast.TypeDeclaration) PrimitiveExpression(com.strobel.decompiler.languages.java.ast.PrimitiveExpression) Annotation(com.strobel.decompiler.languages.java.ast.Annotation)

Aggregations

Annotation (com.strobel.decompiler.languages.java.ast.Annotation)1 Expression (com.strobel.decompiler.languages.java.ast.Expression)1 MemberReferenceExpression (com.strobel.decompiler.languages.java.ast.MemberReferenceExpression)1 PrimitiveExpression (com.strobel.decompiler.languages.java.ast.PrimitiveExpression)1 TypeDeclaration (com.strobel.decompiler.languages.java.ast.TypeDeclaration)1