Package com.strobel.decompiler.languages.java.ast

Examples of com.strobel.decompiler.languages.java.ast.CompilationUnit


    public void run(final AstNode root) {
        if (!(root instanceof CompilationUnit) || _settings.getForceExplicitImports()) {
            return;
        }

        final CompilationUnit compilationUnit = (CompilationUnit) root;
        final AstNodeCollection<ImportDeclaration> imports = compilationUnit.getImports();

        if (imports.isEmpty())
            return;

        final Set<String> newImports = new LinkedHashSet<>();
        final List<ImportDeclaration> removedImports = new ArrayList<>();

        for (final ImportDeclaration oldImport : imports) {
            final Identifier importedType = oldImport.getImportIdentifier();

            if (importedType != null && !importedType.isNull()) {
                final TypeReference type = oldImport.getUserData(Keys.TYPE_REFERENCE);

                if (type != null) {
                    final String packageName = type.getPackageName();

                    if (!StringUtilities.isNullOrEmpty(packageName)) {
                        newImports.add(packageName);
                    }

                    removedImports.add(oldImport);
                }
            }
        }

        if (removedImports.isEmpty()) {
            return;
        }

        final ImportDeclaration lastRemoved = removedImports.get(removedImports.size() - 1);

        for (final String packageName : newImports) {
            compilationUnit.insertChildAfter(
                lastRemoved,
                new ImportDeclaration(PackageReference.parse(packageName)),
                CompilationUnit.IMPORT_ROLE
            );
        }
View Full Code Here


  }
 
  protected String getDeclarationToken( Entry entry )
  {
    // decompile the class
    CompilationUnit tree = m_deobfuscator.getSourceTree( entry.getClassName() );
    // DEBUG
    //tree.acceptVisitor( new TreeDumpVisitor( new File( "tree." + entry.getClassName().replace( '/', '.' ) + ".txt" ) ), null );
    String source = m_deobfuscator.getSource( tree );
    SourceIndex index = m_deobfuscator.getSourceIndex( tree, source );
   
View Full Code Here

 
  @SuppressWarnings( "unchecked" )
  protected Collection<String> getReferenceTokens( EntryReference<? extends Entry,? extends Entry> reference )
  {
    // decompile the class
    CompilationUnit tree = m_deobfuscator.getSourceTree( reference.context.getClassName() );
    String source = m_deobfuscator.getSource( tree );
    SourceIndex index = m_deobfuscator.getSourceIndex( tree, source );
   
    // get the token values
    List<String> values = Lists.newArrayList();
View Full Code Here

   
    for( ClassEntry obfClassEntry : classEntries )
    {
      try
      {
        CompilationUnit tree = deobfuscator.getSourceTree( obfClassEntry.getName() );
        String source = deobfuscator.getSource( tree );
        deobfuscator.getSourceIndex( tree, source );
      }
      catch( Throwable t )
      {
View Full Code Here

    {
      @Override
      public void run( )
      {
        // decompile,deobfuscate the bytecode
        CompilationUnit sourceTree = m_deobfuscator.getSourceTree( classEntry.getClassName() );
        if( sourceTree == null )
        {
          // decompilation of this class is not supported
          m_gui.setSource("Unable to find class: " + classEntry);
          return;
View Full Code Here

TOP

Related Classes of com.strobel.decompiler.languages.java.ast.CompilationUnit

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.