Package com.strobel.assembler.metadata

Examples of com.strobel.assembler.metadata.TypeDefinition


        }
        else {
            type = metadataSystem.lookupType(typeName);
        }

        final TypeDefinition resolvedType;

        if (type == null || (resolvedType = type.resolve()) == null) {
            System.err.printf("!!! ERROR: Failed to load class %s.\n", typeName);
            return;
        }

        if (!includeNested && (resolvedType.isNested() || resolvedType.isAnonymous() || resolvedType.isSynthetic())) {
            return;
        }

        final Writer writer = createWriter(resolvedType, settings);
View Full Code Here


                  String internalName = StringUtilities
                      .removeRight(entry.getName(),
                          ".class");
                  TypeReference type = Model.metadataSystem
                      .lookupType(internalName);
                  TypeDefinition resolvedType = null;
                  if (type == null
                      || ((resolvedType = type.resolve()) == null)) {
                    throw new Exception(
                        "Unable to resolve type.");
                  }
View Full Code Here

  }

  private String extractClassToString(TypeReference type) throws Exception {
    // synchronized: do not accept changes from menu while running
    synchronized (settings) {
      TypeDefinition resolvedType = null;
      if (type == null || ((resolvedType = type.resolve()) == null)) {
        throw new Exception("Unable to resolve type.");
      }
      StringWriter stringwriter = new StringWriter();
      settings.getLanguage().decompileType(resolvedType,
View Full Code Here

      public void run() {
        try {
          Thread.sleep(500);
          String internalName = FindBox.class.getName();
          TypeReference type = metadataSystem.lookupType(internalName);
          TypeDefinition resolvedType = null;
          if ((type == null) || ((resolvedType = type.resolve()) == null)) {
            return;
          }
          StringWriter stringwriter = new StringWriter();
          settings.getLanguage().decompileType(resolvedType,
View Full Code Here

          if(history.add(etn)){
            out.putNextEntry(etn);
            try {
              String internalName = StringUtilities.removeRight(entry.getName(), ".class");
              TypeReference type = metadataSystem.lookupType(internalName);
              TypeDefinition resolvedType = null;
              if ((type == null) || ((resolvedType = type.resolve()) == null)) {
                throw new Exception("Unable to resolve type.");
              }
              Writer writer = new OutputStreamWriter(out);
              settings.getLanguage().decompileType(resolvedType,
View Full Code Here

    DecompilationOptions decompilationOptions = new DecompilationOptions();
    decompilationOptions.setSettings(settings);
    decompilationOptions.setFullDecompilation(true);

    TypeDefinition resolvedType = null;
    if (type == null || ((resolvedType = type.resolve()) == null)) {
      throw new Exception("Unable to resolve type.");
    }
    StringWriter stringwriter = new StringWriter();
    settings.getLanguage().decompileType(resolvedType,
View Full Code Here

    private static void rewriteThisReferences(
        final DecompilerContext context,
        final TypeDeclaration declaration,
        final Map<String, Expression> initializers) {

        final TypeDefinition innerClass = declaration.getUserData(Keys.TYPE_DEFINITION);

        if (innerClass != null) {
            final ContextTrackingVisitor<Void> thisRewriter = new ThisReferenceReplacingVisitor(context, innerClass);

            for (final Expression e : initializers.values()) {
View Full Code Here

    protected ContextTrackingVisitor(final DecompilerContext context) {
        this.context = VerifyArgument.notNull(context, "context");
    }

    public TResult visitTypeDeclaration(final TypeDeclaration typeDeclaration, final Void _) {
        final TypeDefinition oldType = context.getCurrentType();
        final MethodDefinition oldMethod = context.getCurrentMethod();

        try {
            context.setCurrentType(typeDeclaration.getUserData(Keys.TYPE_DEFINITION));
            context.setCurrentMethod(null);
View Full Code Here

    @Override
    public Void visitTypeDeclaration(final TypeDeclaration node, final Void ignored) {
        startNode(node);

        final TypeDefinition type = node.getUserData(Keys.TYPE_DEFINITION);

        final boolean isTrulyAnonymous = type != null &&
                                         type.isAnonymous() &&
                                         node.getParent() instanceof AnonymousObjectCreationExpression;

        if (!isTrulyAnonymous) {
            writeAnnotations(node.getAnnotations(), true);
            writeModifiers(node.getModifiers());

            switch (node.getClassType()) {
                case ENUM:
                    writeKeyword(Roles.ENUM_KEYWORD);
                    break;
                case INTERFACE:
                    writeKeyword(Roles.INTERFACE_KEYWORD);
                    break;
                case ANNOTATION:
                    writeKeyword(Roles.ANNOTATION_KEYWORD);
                    break;
                default:
                    writeKeyword(Roles.CLASS_KEYWORD);
                    break;
            }

            node.getNameToken().acceptVisitor(this, ignored);
            writeTypeParameters(node.getTypeParameters());

            if (!node.getBaseType().isNull()) {
                space();
                writeKeyword(Roles.EXTENDS_KEYWORD);
                space();
                node.getBaseType().acceptVisitor(this, ignored);
            }

            if (any(node.getInterfaces())) {
                final Collection<AstType> interfaceTypes;

                if (node.getClassType() == ClassType.ANNOTATION) {
                    interfaceTypes = new ArrayList<>();

                    for (final AstType t : node.getInterfaces()) {
                        final TypeReference r = t.getUserData(Keys.TYPE_REFERENCE);

                        if (r != null && "java/lang/annotation/Annotation".equals(r.getInternalName())) {
                            continue;
                        }

                        interfaceTypes.add(t);
                    }
                }
                else {
                    interfaceTypes = node.getInterfaces();
                }

                if (any(interfaceTypes)) {
                    space();

                    if (node.getClassType() == ClassType.INTERFACE || node.getClassType() == ClassType.ANNOTATION) {
                        writeKeyword(Roles.EXTENDS_KEYWORD);
                    }
                    else {
                        writeKeyword(Roles.IMPLEMENTS_KEYWORD);
                    }

                    space();
                    writeCommaSeparatedList(node.getInterfaces());
                }
            }
        }

        final BraceStyle braceStyle;
        final AstNodeCollection<EntityDeclaration> members = node.getMembers();

        switch (node.getClassType()) {
            case ENUM:
                braceStyle = policy.EnumBraceStyle;
                break;
            case INTERFACE:
                braceStyle = policy.InterfaceBraceStyle;
                break;
            case ANNOTATION:
                braceStyle = policy.AnnotationBraceStyle;
                break;
            default:
                if (type != null && type.isAnonymous()) {
                    braceStyle = members.isEmpty() ? BraceStyle.BannerStyle : policy.AnonymousClassBraceStyle;
                }
                else {
                    braceStyle = policy.ClassBraceStyle;
                }
                break;
        }

        openBrace(braceStyle);

        boolean first = true;
        EntityDeclaration lastMember = null;

        for (final EntityDeclaration member : members) {
            if (first) {
                first = false;
            }
            else {
                final int blankLines;

                if (member instanceof FieldDeclaration && lastMember instanceof FieldDeclaration) {
                    blankLines = policy.BlankLinesBetweenFields;
                }
                else {
                    blankLines = policy.BlankLinesBetweenMembers;
                }

                for (int i = 0; i < blankLines; i++) {
                    formatter.newLine();
                }
            }
            member.acceptVisitor(this, ignored);
            lastMember = member;
        }

        closeBrace(braceStyle);

        if (type == null || !type.isAnonymous()) {
            optionalSemicolon();
            newLine();
        }

        endNode(node);
View Full Code Here

        if (!arguments.isEmpty()) {
            writeCommaSeparatedListInParenthesis(arguments, policy.SpaceWithinEnumDeclarationParentheses);
        }

        final AstNodeCollection<EntityDeclaration> members = node.getMembers();
        final TypeDefinition enumType = node.getUserData(Keys.TYPE_DEFINITION);

        if (enumType != null && enumType.isAnonymous() || !members.isEmpty()) {
            final BraceStyle braceStyle = policy.AnonymousClassBraceStyle;

            openBrace(braceStyle);

            boolean first = true;
View Full Code Here

TOP

Related Classes of com.strobel.assembler.metadata.TypeDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.