diff --git a/javaparser-core-testing/src/test/java/com/github/javaparser/ast/body/ClassOrInterfaceDeclarationTest.java b/javaparser-core-testing/src/test/java/com/github/javaparser/ast/body/ClassOrInterfaceDeclarationTest.java index a1bed1c52a..9586138889 100644 --- a/javaparser-core-testing/src/test/java/com/github/javaparser/ast/body/ClassOrInterfaceDeclarationTest.java +++ b/javaparser-core-testing/src/test/java/com/github/javaparser/ast/body/ClassOrInterfaceDeclarationTest.java @@ -92,7 +92,7 @@ void sealedClass() { assertFalse(x.isInnerClass()); assertFalse(x.isNestedType()); assertFalse(x.isLocalClassDeclaration()); - assertTrue(x.hasModifier(Modifier.Keyword.SEALED)); + assertTrue(x.hasModifier(Modifier.DefaultKeyword.SEALED)); assertEquals(x.getPermittedTypes().size(), 2); assertEquals(x.getPermittedTypes().get(0).getNameAsString(), "Y"); assertEquals(x.getPermittedTypes().get(1).getNameAsString(), "Z"); @@ -106,7 +106,7 @@ void nonSealedClass() { assertFalse(x.isInnerClass()); assertFalse(x.isNestedType()); assertFalse(x.isLocalClassDeclaration()); - assertTrue(x.hasModifier(Modifier.Keyword.NON_SEALED)); + assertTrue(x.hasModifier(Modifier.DefaultKeyword.NON_SEALED)); } } diff --git a/javaparser-core/src/main/java/com/github/javaparser/jml/JmlProcessor.java b/javaparser-core/src/main/java/com/github/javaparser/jml/JmlProcessor.java index 18f09d40cd..5fe04cedab 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/jml/JmlProcessor.java +++ b/javaparser-core/src/main/java/com/github/javaparser/jml/JmlProcessor.java @@ -48,11 +48,12 @@ public void postProcess(ParseResult result, ParserConfiguration if (configuration.isProcessJml()) { final Optional r = result.getResult(); final Optional comments = result.getCommentsCollection(); - ArrayList processedJmlDoc = new ArrayList<>(4096); + ArrayList processedJmlDoc = new ArrayList<>(4096 * 10); if (r.isPresent() && comments.isPresent()) { for (List activeKeys : configuration.getJmlKeys()) { final JmlReplaceVisitor v = new JmlReplaceVisitor(configuration, new TreeSet<>(activeKeys), result.getProblems()); r.get().accept(v, null); + //System.out.format("cap: %d, size: %d, add: %d", 0, processedJmlDoc.size(), v.processedJmlDoc.size()); processedJmlDoc.addAll(v.processedJmlDoc); } } diff --git a/jmlparser-jml-tests/pom.xml b/jmlparser-jml-tests/pom.xml index 9429433ddf..b7fbe3a537 100644 --- a/jmlparser-jml-tests/pom.xml +++ b/jmlparser-jml-tests/pom.xml @@ -2,7 +2,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.3-SNAPSHOT + 3.25.3 4.0.0 diff --git a/jmlparser-jml-tests/src/test/java/com/github/jml/FullExamplesTest.java b/jmlparser-jml-tests/src/test/java/com/github/jml/FullExamplesTest.java index 206990ae0d..28d120f46b 100644 --- a/jmlparser-jml-tests/src/test/java/com/github/jml/FullExamplesTest.java +++ b/jmlparser-jml-tests/src/test/java/com/github/jml/FullExamplesTest.java @@ -13,10 +13,7 @@ import com.github.javaparser.ast.jml.doc.JmlDocType; import com.github.javaparser.ast.visitor.VoidVisitorAdapter; import com.github.javaparser.jml.JmlDocSanitizer; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Assumptions; -import org.junit.jupiter.api.DynamicTest; -import org.junit.jupiter.api.TestFactory; +import org.junit.jupiter.api.*; import java.io.File; import java.io.FileWriter; @@ -35,8 +32,11 @@ * @author Alexander Weigl * @version 1 (7/2/21) */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) class FullExamplesTest { private final JavaParser jpb; + private long lines; + private long time; { //private final StoreJMLComments storeProcessor = new StoreJMLComments() @@ -155,7 +155,14 @@ Stream createTests(Predicate pred) throws IOException { private void testParse(Path p) throws IOException { Assumptions.assumeFalse(isBlocked(p)); System.out.println(p); - ParseResult result = jpb.parse(p); + var content = Files.readString(p); + long start = System.nanoTime(); + ParseResult result = jpb.parse(content); + long stop = System.nanoTime(); + + time += (stop - start); + lines += content.chars().filter(it -> it == '\n').count(); + result.getProblems().forEach(it -> { int line = it.getLocation().map(l -> l.getBegin().getRange().map(r -> r.begin.line).orElse(-1)).orElse(-1); System.out.format("%s\n\t%s:%d\n\n", it.getMessage(), p.toUri(), line); @@ -169,6 +176,11 @@ private boolean isBlocked(Path it) { return blockedPaths.contains(it); } + @AfterAll + public void stat() { + System.out.format("Performance: %d LoCs in %d ns%n", lines, time); + System.out.format("Performance: %.0f LoCs/ms", lines * 1000000.0 / time); + } } diff --git a/jmlparser-jml-tools/pom.xml b/jmlparser-jml-tools/pom.xml index 337ba7c1f8..d2e8575757 100644 --- a/jmlparser-jml-tools/pom.xml +++ b/jmlparser-jml-tools/pom.xml @@ -6,7 +6,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.3-SNAPSHOT + 3.25.3 jmlparser-jml-tools diff --git a/pom.xml b/pom.xml index 878a2072f9..1e179f0213 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,6 @@ javaparser-symbol-solver-testing jmlparser-jml-tests jmlparser-jml-tools - io.github.jmltoolkit