From 72507343cc3fe8e864c07c934ba513790e7c57c3 Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Thu, 23 May 2024 18:16:31 +0200 Subject: [PATCH] missing jml delimiters in pretty printing --- javaparser-core-generators/pom.xml | 2 +- javaparser-core-metamodel-generator/pom.xml | 2 +- javaparser-core-serialization/pom.xml | 2 +- javaparser-core-testing-bdd/pom.xml | 2 +- javaparser-core-testing/pom.xml | 2 +- javaparser-core/pom.xml | 2 +- .../javaparser/printer/DefaultPrettyPrinterVisitor.java | 5 ++++- javaparser-symbol-solver-core/pom.xml | 2 +- javaparser-symbol-solver-testing/pom.xml | 2 +- jmlparser-jml-tests/pom.xml | 2 +- .../src/test/java/com/github/jml/FullExamplesTest.java | 3 +++ .../key/heap/permissions/lockspec/src/LockSpec.java | 4 ++-- pom.xml | 2 +- 13 files changed, 19 insertions(+), 13 deletions(-) diff --git a/javaparser-core-generators/pom.xml b/javaparser-core-generators/pom.xml index ee6b1c6b47..cd13079ee1 100644 --- a/javaparser-core-generators/pom.xml +++ b/javaparser-core-generators/pom.xml @@ -4,7 +4,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.10-b3-SNAPSHOT + 3.25.10-b6-SNAPSHOT 4.0.0 diff --git a/javaparser-core-metamodel-generator/pom.xml b/javaparser-core-metamodel-generator/pom.xml index 808890a48d..7e2d3c385f 100644 --- a/javaparser-core-metamodel-generator/pom.xml +++ b/javaparser-core-metamodel-generator/pom.xml @@ -4,7 +4,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.10-b3-SNAPSHOT + 3.25.10-b6-SNAPSHOT 4.0.0 diff --git a/javaparser-core-serialization/pom.xml b/javaparser-core-serialization/pom.xml index 8dd343dedc..3332e4b117 100644 --- a/javaparser-core-serialization/pom.xml +++ b/javaparser-core-serialization/pom.xml @@ -3,7 +3,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.10-b3-SNAPSHOT + 3.25.10-b6-SNAPSHOT 4.0.0 diff --git a/javaparser-core-testing-bdd/pom.xml b/javaparser-core-testing-bdd/pom.xml index f80b0f019b..8c2f920f0f 100644 --- a/javaparser-core-testing-bdd/pom.xml +++ b/javaparser-core-testing-bdd/pom.xml @@ -3,7 +3,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.10-b3-SNAPSHOT + 3.25.10-b6-SNAPSHOT 4.0.0 diff --git a/javaparser-core-testing/pom.xml b/javaparser-core-testing/pom.xml index 55138b40a5..4eeaa21a72 100644 --- a/javaparser-core-testing/pom.xml +++ b/javaparser-core-testing/pom.xml @@ -3,7 +3,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.10-b3-SNAPSHOT + 3.25.10-b6-SNAPSHOT 4.0.0 diff --git a/javaparser-core/pom.xml b/javaparser-core/pom.xml index 2c3dc7c520..749abc376e 100644 --- a/javaparser-core/pom.xml +++ b/javaparser-core/pom.xml @@ -3,7 +3,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.10-b3-SNAPSHOT + 3.25.10-b6-SNAPSHOT 4.0.0 diff --git a/javaparser-core/src/main/java/com/github/javaparser/printer/DefaultPrettyPrinterVisitor.java b/javaparser-core/src/main/java/com/github/javaparser/printer/DefaultPrettyPrinterVisitor.java index b1930988e6..d2cb8c74a2 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/printer/DefaultPrettyPrinterVisitor.java +++ b/javaparser-core/src/main/java/com/github/javaparser/printer/DefaultPrettyPrinterVisitor.java @@ -973,6 +973,8 @@ public void visit(JmlRepresentsDeclaration n, Void arg) { @Override public void visit(JmlContract n, Void arg) { printOrphanCommentsBeforeThisChildNode(n); + boolean openedJml = inJmlComment(); + if (!openedJml) startJmlComment(false, n.getJmlTags()); printModifiers(n.getModifiers()); printer.print(" "); printer.print(n.getBehavior().jmlSymbol()); @@ -982,12 +984,13 @@ public void visit(JmlContract n, Void arg) { printer.indent(); printList(n.getSubContracts(), "", "", "", "{|\n", "|}"); printer.unindent().unindent(); + if (!openedJml) endJmlComment(); } private void endJmlComment() { assert inJmlComment() && inJmlSingleComment != inJmlMultiComment; if (inJmlSingleComment) { - printer.print(""); + printer.println(""); } else { printer.println("*/"); } diff --git a/javaparser-symbol-solver-core/pom.xml b/javaparser-symbol-solver-core/pom.xml index 398c61c3e4..935498a6e8 100644 --- a/javaparser-symbol-solver-core/pom.xml +++ b/javaparser-symbol-solver-core/pom.xml @@ -4,7 +4,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.10-b3-SNAPSHOT + 3.25.10-b6-SNAPSHOT 4.0.0 diff --git a/javaparser-symbol-solver-testing/pom.xml b/javaparser-symbol-solver-testing/pom.xml index 3f57bfab4d..722b7db2f8 100644 --- a/javaparser-symbol-solver-testing/pom.xml +++ b/javaparser-symbol-solver-testing/pom.xml @@ -4,7 +4,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.10-b3-SNAPSHOT + 3.25.10-b6-SNAPSHOT 4.0.0 diff --git a/jmlparser-jml-tests/pom.xml b/jmlparser-jml-tests/pom.xml index 745bd77d85..61a6ac454c 100644 --- a/jmlparser-jml-tests/pom.xml +++ b/jmlparser-jml-tests/pom.xml @@ -2,7 +2,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.10-b3-SNAPSHOT + 3.25.10-b6-SNAPSHOT 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 8755108217..45c1e5fd13 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 @@ -16,6 +16,7 @@ import com.github.javaparser.jml.JmlDocSanitizer; import com.google.common.truth.Truth; import org.junit.jupiter.api.*; +import org.junit.jupiter.params.provider.CsvSource; import java.io.File; import java.io.FileWriter; @@ -174,6 +175,8 @@ private void testParse(Path p) throws IOException { Assertions.assertTrue(result.isSuccessful(), "parsing failed"); testParentAndChild(result.getResult().get()); + + System.out.println(result.getResult().get().toString()); } private void testParentAndChild(Node node) { diff --git a/jmlparser-jml-tests/src/test/resources/fullexamples/key/heap/permissions/lockspec/src/LockSpec.java b/jmlparser-jml-tests/src/test/resources/fullexamples/key/heap/permissions/lockspec/src/LockSpec.java index 0d3c5806f4..1f41bf31b8 100644 --- a/jmlparser-jml-tests/src/test/resources/fullexamples/key/heap/permissions/lockspec/src/LockSpec.java +++ b/jmlparser-jml-tests/src/test/resources/fullexamples/key/heap/permissions/lockspec/src/LockSpec.java @@ -66,7 +66,7 @@ public interface Lock { ensures spec.lockTransfer(); assignable \strictly_nothing; assignable spec.fpPerm(); @*/ - public /*@ helper @*/ native void lock(); + public /*@ helper @*/ void lock(); /*@ normal_behavior requires spec.lockStatus(\dl_TRUE()); @@ -74,7 +74,7 @@ public interface Lock { ensures spec.unlockTransfer(); assignable spec.fp(); // should be done by the prover assignable spec.fpPerm(); @*/ - public /*@ helper @*/ native void unlock(); + public /*@ helper @*/ void unlock(); } public class Counter implements LockSpec { diff --git a/pom.xml b/pom.xml index c4d27f6701..71eda3ca76 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ io.github.jmltoolkit jmlparser-parent pom - 3.25.10-b3-SNAPSHOT + 3.25.10-b6-SNAPSHOT jmlparser-parent https://github.com/wadoon/jmlparser