// Path: dex-reader-api/src/main/java/com/googlecode/d2j/node/DexFileNode.java
// public class DexFileNode extends DexFileVisitor {
//     public List<DexClassNode> clzs = new ArrayList<>();
//     public int dexVersion = DexConstants.DEX_035;
// 
//     @Override
//     public void visitDexFileVersion(int version) {
//         this.dexVersion = version;
//         super.visitDexFileVersion(version);
//     }
// 
//     @Override
//     public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) {
//         DexClassNode cn = new DexClassNode(access_flags, className, superClass, interfaceNames);
//         clzs.add(cn);
//         return cn;
//     }
// 
//     public void accept(DexClassVisitor dcv) {
//         for (DexClassNode cn : clzs) {
//             cn.accept(dcv);
//         }
//     }
// 
//     public void accept(DexFileVisitor dfv) {
//         for (DexClassNode cn : clzs) {
//             cn.accept(dfv);
//         }
//     }
// }
// 
// Path: d2j-smali/src/main/java/com/googlecode/d2j/smali/Smali.java
// public class Smali {
//     public static void smaliFile(Path path, DexFileVisitor dcv) throws IOException {
//         try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
//             ANTLRInputStream is = new ANTLRInputStream(reader);
//             is.name = path.toString();
//             smali0(dcv, is);
//         }
//     }
// 
//     public static void smaliFile(String name, String buff, DexFileVisitor dcv) throws IOException {
//         ANTLRInputStream is = new ANTLRInputStream(buff);
//         is.name = name;
//         smali0(dcv, is);
//     }
// 
//     public static void smaliFile(String name, InputStream in, DexFileVisitor dcv) throws IOException {
//         try (InputStreamReader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) {
//             ANTLRInputStream is = new ANTLRInputStream(reader);
//             is.name = name;
//             smali0(dcv, is);
//         }
//     }
// 
//     public static DexClassNode smaliFile2Node(String name, InputStream in) throws IOException {
//         DexFileNode dfn = new DexFileNode();
//         smaliFile(name, in, dfn);
//         return dfn.clzs.size() > 0 ? dfn.clzs.get(0) : null;
//     }
// 
//     public static DexClassNode smaliFile2Node(String name, String buff) throws IOException {
//         DexFileNode dfn = new DexFileNode();
//         smaliFile(name, buff, dfn);
//         return dfn.clzs.size() > 0 ? dfn.clzs.get(0) : null;
//     }
// 
//     private static void smali0(DexFileVisitor dcv, CharStream is) throws IOException {
//         SmaliLexer lexer = new SmaliLexer(is);
//         CommonTokenStream ts = new CommonTokenStream(lexer);
//         SmaliParser parser = new SmaliParser(ts);
// 
//         for (SmaliParser.SFileContext ctx : parser.sFiles().sFile()) {
//             AntlrSmaliUtil.acceptFile(ctx, dcv);
//         }
//     }
// 
//     public static void smaliFile(String fileName, char[] data, DexFileVisitor dcv) throws IOException {
//         // System.err.println("parsing " + f.getAbsoluteFile());
//         ANTLRInputStream is = new ANTLRInputStream(data, data.length);
//         is.name = fileName;
//         smali0(dcv, is);
//     }
// 
//     public static void smali(Path base, final DexFileVisitor dfv) throws IOException {
//         if (Files.isDirectory(base)) {
//             Files.walkFileTree(base, new SimpleFileVisitor<Path>() {
//                 @Override
//                 public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
//                     Path fn = dir.getFileName();
//                     if (fn != null && fn.toString().startsWith(".")) {
//                         return FileVisitResult.SKIP_SUBTREE;
//                     }
//                     return super.preVisitDirectory(dir, attrs);
//                 }
// 
//                 @Override
//                 public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
//                     smaliFile(file, dfv);
//                     return super.visitFile(file, attrs);
//                 }
//             });
//         } else if (Files.isRegularFile(base)) {
//             smaliFile(base, dfv);
//         }
//     }
// }


import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.junit.Assert;
import org.junit.runner.Description;
import org.junit.runner.RunWith;
import org.junit.runner.Runner;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.ParentRunner;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.Statement;
import com.googlecode.d2j.node.DexClassNode;
import com.googlecode.d2j.node.DexFileNode;
import com.googlecode.d2j.smali.Smali;
            URL url = testClass.getResource("/smalis/writeString.smali");
            System.out.println("url is " + url);
            Assert.assertNotNull(url);

            final String file = url.getFile();
            Assert.assertNotNull(file);

            Path dirxpath = new File(file).toPath();

            final Path basePath = dirxpath.getParent();

            final Set<Path> files = new TreeSet<>();
            try {
                Files.walkFileTree(basePath, new SimpleFileVisitor<Path>() {
                    @Override
                    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                        if (file.getFileName().toString().endsWith(".smali")) {
                            files.add(file);
                        }
                        return super.visitFile(file, attrs);
                    }
                });
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            List<Runner> runners = new ArrayList<>();
            for (final Path p : files) {

                Smali smali = new Smali();
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/node/DexFileNode.java
// public class DexFileNode extends DexFileVisitor {
//     public List<DexClassNode> clzs = new ArrayList<>();
//     public int dexVersion = DexConstants.DEX_035;
// 
//     @Override
//     public void visitDexFileVersion(int version) {
//         this.dexVersion = version;
//         super.visitDexFileVersion(version);
//     }
// 
//     @Override
//     public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) {
//         DexClassNode cn = new DexClassNode(access_flags, className, superClass, interfaceNames);
//         clzs.add(cn);
//         return cn;
//     }
// 
//     public void accept(DexClassVisitor dcv) {
//         for (DexClassNode cn : clzs) {
//             cn.accept(dcv);
//         }
//     }
// 
//     public void accept(DexFileVisitor dfv) {
//         for (DexClassNode cn : clzs) {
//             cn.accept(dfv);
//         }
//     }
// }
// 
// Path: d2j-smali/src/main/java/com/googlecode/d2j/smali/Smali.java
// public class Smali {
//     public static void smaliFile(Path path, DexFileVisitor dcv) throws IOException {
//         try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
//             ANTLRInputStream is = new ANTLRInputStream(reader);
//             is.name = path.toString();
//             smali0(dcv, is);
//         }
//     }
// 
//     public static void smaliFile(String name, String buff, DexFileVisitor dcv) throws IOException {
//         ANTLRInputStream is = new ANTLRInputStream(buff);
//         is.name = name;
//         smali0(dcv, is);
//     }
// 
//     public static void smaliFile(String name, InputStream in, DexFileVisitor dcv) throws IOException {
//         try (InputStreamReader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) {
//             ANTLRInputStream is = new ANTLRInputStream(reader);
//             is.name = name;
//             smali0(dcv, is);
//         }
//     }
// 
//     public static DexClassNode smaliFile2Node(String name, InputStream in) throws IOException {
//         DexFileNode dfn = new DexFileNode();
//         smaliFile(name, in, dfn);
//         return dfn.clzs.size() > 0 ? dfn.clzs.get(0) : null;
//     }
// 
//     public static DexClassNode smaliFile2Node(String name, String buff) throws IOException {
//         DexFileNode dfn = new DexFileNode();
//         smaliFile(name, buff, dfn);
//         return dfn.clzs.size() > 0 ? dfn.clzs.get(0) : null;
//     }
// 
//     private static void smali0(DexFileVisitor dcv, CharStream is) throws IOException {
//         SmaliLexer lexer = new SmaliLexer(is);
//         CommonTokenStream ts = new CommonTokenStream(lexer);
//         SmaliParser parser = new SmaliParser(ts);
// 
//         for (SmaliParser.SFileContext ctx : parser.sFiles().sFile()) {
//             AntlrSmaliUtil.acceptFile(ctx, dcv);
//         }
//     }
// 
//     public static void smaliFile(String fileName, char[] data, DexFileVisitor dcv) throws IOException {
//         // System.err.println("parsing " + f.getAbsoluteFile());
//         ANTLRInputStream is = new ANTLRInputStream(data, data.length);
//         is.name = fileName;
//         smali0(dcv, is);
//     }
// 
//     public static void smali(Path base, final DexFileVisitor dfv) throws IOException {
//         if (Files.isDirectory(base)) {
//             Files.walkFileTree(base, new SimpleFileVisitor<Path>() {
//                 @Override
//                 public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
//                     Path fn = dir.getFileName();
//                     if (fn != null && fn.toString().startsWith(".")) {
//                         return FileVisitResult.SKIP_SUBTREE;
//                     }
//                     return super.preVisitDirectory(dir, attrs);
//                 }
// 
//                 @Override
//                 public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
//                     smaliFile(file, dfv);
//                     return super.visitFile(file, attrs);
//                 }
//             });
//         } else if (Files.isRegularFile(base)) {
//             smaliFile(base, dfv);
//         }
//     }
// }


// Path: dex-translator/src/test/java/com/googlecode/dex2jar/test/Smali2jTest.java
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.junit.Assert;
import org.junit.runner.Description;
import org.junit.runner.RunWith;
import org.junit.runner.Runner;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.ParentRunner;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.Statement;
import com.googlecode.d2j.node.DexClassNode;
import com.googlecode.d2j.node.DexFileNode;
import com.googlecode.d2j.smali.Smali;

            URL url = testClass.getResource("/smalis/writeString.smali");
            System.out.println("url is " + url);
            Assert.assertNotNull(url);

            final String file = url.getFile();
            Assert.assertNotNull(file);

            Path dirxpath = new File(file).toPath();

            final Path basePath = dirxpath.getParent();

            final Set<Path> files = new TreeSet<>();
            try {
                Files.walkFileTree(basePath, new SimpleFileVisitor<Path>() {
                    @Override
                    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                        if (file.getFileName().toString().endsWith(".smali")) {
                            files.add(file);
                        }
                        return super.visitFile(file, attrs);
                    }
                });
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            List<Runner> runners = new ArrayList<>();
            for (final Path p : files) {

                Smali smali = new Smali();
                final DexFileNode fileNode = new DexFileNode();