Skip to content

Commit

Permalink
Define toStringVerbose() (#5830)
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst authored May 2, 2023
1 parent afdd30a commit ea0fca0
Showing 1 changed file with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1257,6 +1259,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();
}
}

/**
Expand Down Expand Up @@ -1352,12 +1369,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();
}
}

/**
Expand Down

0 comments on commit ea0fca0

Please sign in to comment.