Pass into multiple workspace

This commit is contained in:
jeffcheasey88 2023-09-11 17:23:33 +02:00
parent e328dd12eb
commit efd96c26c3
2 changed files with 22 additions and 5 deletions

View file

@ -45,7 +45,7 @@ public class JavaParser extends Parser<JavaElement> {
longCommentary = false; longCommentary = false;
i++; i++;
} }
System.out.print(c); // System.out.print(c);
continue; continue;
} }
Token token; Token token;
@ -683,8 +683,8 @@ public class JavaParser extends Parser<JavaElement> {
StateTree<JavaElement> clazz_implement = clazz_base.then((validator) -> validator.validate((token) -> token.getValue().equals("implements"))); StateTree<JavaElement> clazz_implement = clazz_base.then((validator) -> validator.validate((token) -> token.getValue().equals("implements")));
StateTree<JavaElement> clazz_implement_name = clazz_implement.then(new RedirectStateTree<>(type, (global, local) -> { StateTree<JavaElement> clazz_implement_name = clazz_implement.then(new RedirectStateTree<>(type, (global, local) -> {
Token token = global.get("implement"); Token token = global.get("implement");
if(token == null) token = local.get(); // if(token == null) token = local.get();
else token = token.concat(local.get()); // else token = token.concat(local.get());
global.set("implement", token); global.set("implement", token);
})); }));
clazz_implement_name.then((validator) -> validator.validate((token) -> token.getValue().equals(","))).then(clazz_implement_name); clazz_implement_name.then((validator) -> validator.validate((token) -> token.getValue().equals(","))).then(clazz_implement_name);

View file

@ -19,7 +19,7 @@ class GlobalCover {
} }
void workspace() throws Exception{ void workspace() throws Exception{
List<File> files = files(new File("C:\\Users\\jeffc\\eclipse-workspace")); List<File> files = load(new File("workspaces.txt"));
long validated = 0; long validated = 0;
long tokens = 0; long tokens = 0;
int count = 0; int count = 0;
@ -31,6 +31,7 @@ class GlobalCover {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
for(File file : files){ for(File file : files){
if(file.getName().endsWith(".java")){ if(file.getName().endsWith(".java")){
System.out.println("try "+file.getAbsolutePath());
BufferedReader reader = new BufferedReader(new FileReader(file)); BufferedReader reader = new BufferedReader(new FileReader(file));
parser.parse(reader, new JavaFile()); parser.parse(reader, new JavaFile());
reader.close(); reader.close();
@ -43,7 +44,7 @@ class GlobalCover {
validated += TokenValidator.MAX_VALIDATE; validated += TokenValidator.MAX_VALIDATE;
tokens += TokenValidator.TOKENS; tokens += TokenValidator.TOKENS;
System.out.println(file+" "+validated+" / "+tokens); System.out.println(validated+" / "+tokens);
TokenValidator.MAX_VALIDATE = 0; TokenValidator.MAX_VALIDATE = 0;
TokenValidator.TOKENS = 0; TokenValidator.TOKENS = 0;
count++; count++;
@ -60,6 +61,22 @@ class GlobalCover {
writer.close(); writer.close();
} }
private List<File> load(File config) throws Exception{
System.out.println("loading "+config.getAbsolutePath());
BufferedReader reader = new BufferedReader(new FileReader(config));
List<File> workspaces = new ArrayList<>();
String line;
while((line = reader.readLine()) != null) workspaces.add(new File(line));
reader.close();
System.out.println("loaded "+workspaces.size()+" workspaces");
List<File> result = new ArrayList<>();
for(File workspace : workspaces){
result.addAll(files(workspace));
System.out.println("Loaded["+result.size()+"] "+workspace.getAbsolutePath());
}
return result;
}
private List<File> files(File dir){ private List<File> files(File dir){
List<File> result = new ArrayList<>(); List<File> result = new ArrayList<>();
if(dir.isDirectory()){ if(dir.isDirectory()){