From 168bc89a29ba8eaf167a33c96ea3f679e3935e0d Mon Sep 17 00:00:00 2001 From: Michael Ernst Date: Mon, 1 May 2023 15:41:09 -0700 Subject: [PATCH] Define `toStringVerbose()` --- ...holeProgramInferenceJavaParserStorage.java | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/org/checkerframework/common/wholeprograminference/WholeProgramInferenceJavaParserStorage.java b/framework/src/main/java/org/checkerframework/common/wholeprograminference/WholeProgramInferenceJavaParserStorage.java index 4989a66f9d9..bc7d3e64c8d 100644 --- a/framework/src/main/java/org/checkerframework/common/wholeprograminference/WholeProgramInferenceJavaParserStorage.java +++ b/framework/src/main/java/org/checkerframework/common/wholeprograminference/WholeProgramInferenceJavaParserStorage.java @@ -54,6 +54,8 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.StringJoiner; +import java.util.TreeMap; import java.util.TreeSet; import java.util.stream.Collectors; import javax.lang.model.element.AnnotationMirror; @@ -1256,6 +1258,21 @@ public void transferAnnotations(BaseTypeChecker checker) { public TypeDeclaration getClassOrInterfaceDeclarationByName(String name) { return JavaParserUtil.getTypeDeclarationByName(compilationUnit, name); } + + /** + * Returns a verbose printed representation of this. + * + * @return a verbose printed representation of this + */ + @SuppressWarnings("UnusedMethod") + public String toStringVerbose() { + StringJoiner sb = new StringJoiner(System.lineSeparator()); + sb.add("CompilationUnitAnnos:"); + for (ClassOrInterfaceAnnos type : types) { + sb.add(type.toStringVerbose()); + } + return sb.toString(); + } } /** @@ -1351,12 +1368,24 @@ public void transferAnnotations() { @Override public String toString() { - return "ClassOrInterfaceAnnos [callableDeclarations=" - + callableDeclarations + return "ClassOrInterfaceAnnos [" + + classDeclaration.getName() + + ": callableDeclarations=" + // For deterministic output + + new TreeMap<>(callableDeclarations) + ", fields=" + fields + "]"; } + + /** + * Returns a verbose printed representation of this. + * + * @return a verbose printed representation of this + */ + public String toStringVerbose() { + return toString(); + } } /**