Transformador now takes a file/dir and transforms that

This commit is contained in:
Carlos Galindo 2019-03-26 23:26:21 +01:00
parent c768ffb7d3
commit 6be592fbd1
Signed by untrusted user who does not match committer: kauron
GPG Key ID: 83E68706DEE119A3
1 changed files with 20 additions and 2 deletions

View File

@ -7,12 +7,30 @@ import com.github.javaparser.ast.comments.Comment;
import com.github.javaparser.ast.visitor.VoidVisitor;
import java.io.File;
import java.io.FileNotFoundException;
public class Transformador {
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws FileNotFoundException {
File file = new File(args[0]);
if (file.isDirectory())
analyzeDir(file);
else
analyzeFile(file);
}
public static void analyzeDir(File dir) throws FileNotFoundException {
for (File f : dir.listFiles()) {
if (f.isDirectory())
analyzeDir(f);
else if (f.getName().endsWith(".java"))
analyzeFile(f);
}
}
public static void analyzeFile(File file) throws FileNotFoundException {
// Ruta del fichero con el programa que vamos a transformar
String ruta = "./src/test/res/ejemplos/Test_1";
String ruta = file.getPath().substring(0, file.getPath().lastIndexOf(".java"));
// Abrimos el fichero original (un ".java")
File original = new File(ruta + ".java");