Integrate partial java parser reset. Rewrite parser logging
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2022 VMware, Inc.
|
||||
* Copyright (c) 2022, 2023 VMware, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -295,10 +295,13 @@ public class ORAstUtils {
|
||||
InMemoryExecutionContext ctx = new InMemoryExecutionContext(ORAstUtils::logExceptionWhileParsing);
|
||||
ctx.putMessage(JavaParser.SKIP_SOURCE_SET_TYPE_GENERATION, true);
|
||||
List<CompilationUnit> cus = Collections.emptyList();
|
||||
long start = System.currentTimeMillis();
|
||||
synchronized (parser) {
|
||||
cus = parser.parseInputs(inputs, null, ctx);
|
||||
}
|
||||
log.info("Rewrite parser: " + (System.currentTimeMillis() - start));
|
||||
List<J.CompilationUnit> finalCus = new ArrayList<>(cus.size());
|
||||
start = System.currentTimeMillis();
|
||||
for (CompilationUnit cu : cus) {
|
||||
J.CompilationUnit newCu = (J.CompilationUnit) new UpdateSourcePositions().getVisitor().visit(cu, ctx);
|
||||
if (newCu == null) {
|
||||
@@ -307,6 +310,7 @@ public class ORAstUtils {
|
||||
finalCus.add(newCu);
|
||||
}
|
||||
}
|
||||
log.info("Positions Update: " + (System.currentTimeMillis() - start));
|
||||
return finalCus;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -89,8 +90,8 @@ public class RewriteCompilationUnitCache implements DocumentContentProvider, Dis
|
||||
|
||||
JavaParser parser = javaParsers.getIfPresent(project.get().getLocationUri());
|
||||
if (parser != null) {
|
||||
// parser.reset(List.of(uri));
|
||||
parser.reset();
|
||||
parser.reset(List.of(uri));
|
||||
// parser.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -222,9 +223,10 @@ public class RewriteCompilationUnitCache implements DocumentContentProvider, Dis
|
||||
|
||||
private CompilationUnit doParse(IJavaProject project, URI uri) throws Exception {
|
||||
boolean newParser = javaParsers.getIfPresent(project) == null;
|
||||
JavaParser javaParser = null;;
|
||||
try {
|
||||
logger.debug("Parsing CU {}", uri);
|
||||
JavaParser javaParser = loadJavaParser(project);
|
||||
javaParser = loadJavaParser(project);
|
||||
|
||||
Path sourcePath = Paths.get(uri);
|
||||
javaParser.setSourceSet(ORAstUtils.getSourceSetName(project, sourcePath));
|
||||
@@ -250,7 +252,11 @@ public class RewriteCompilationUnitCache implements DocumentContentProvider, Dis
|
||||
javaParsers.invalidate(project);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
} finally {
|
||||
if (javaParser != null) {
|
||||
javaParser.reset(Collections.emptyList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user