Skip to content

Commit

Permalink
Revert formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jevanlingen committed Dec 16, 2024
1 parent 1e53f66 commit 87bd944
Showing 1 changed file with 44 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ private void writeRecipeClass(JCTree.JCClassDecl classDecl, boolean outerClassRe
.collect(joining(",\n"));
out.write(
" @Override\n" +
" public List<Recipe> getRecipeList() {\n" +
" return Arrays.asList(\n" +
recipesAsList + '\n' +
" );\n" +
" }\n\n");
" public List<Recipe> getRecipeList() {\n" +
" return Arrays.asList(\n" +
recipesAsList + '\n' +
" );\n" +
" }\n\n");

for (String r : recipes.values()) {
out.write(r.replaceAll("(?m)^(.+)$", " $1"));
Expand Down Expand Up @@ -414,7 +414,7 @@ private String generateVisitMethod(Map<String, TemplateDescriptor> beforeTemplat
List<String> embedOptions = new ArrayList<>();
JCTree.JCExpression afterReturn = getReturnExpression(descriptor.afterTemplate.method);
if (afterReturn instanceof JCTree.JCParens ||
afterReturn instanceof JCTree.JCUnary && ((JCTree.JCUnary) afterReturn).getExpression() instanceof JCTree.JCParens) {
afterReturn instanceof JCTree.JCUnary && ((JCTree.JCUnary) afterReturn).getExpression() instanceof JCTree.JCParens) {
embedOptions.add("REMOVE_PARENS");
}
// TODO check if after template contains type or member references
Expand Down Expand Up @@ -537,28 +537,28 @@ private String recipeDescriptor(JCTree.JCClassDecl classDecl, String defaultDisp
}

String recipeDescriptor = " @Override\n" +
" public String getDisplayName() {\n" +
" return \"" + displayName + "\";\n" +
" }\n" +
"\n" +
" @Override\n" +
" public String getDescription() {\n" +
" return \"" + description + "\";\n" +
" }\n" +
"\n";
" public String getDisplayName() {\n" +
" return \"" + displayName + "\";\n" +
" }\n" +
"\n" +
" @Override\n" +
" public String getDescription() {\n" +
" return \"" + description + "\";\n" +
" }\n" +
"\n";

if (tags.size() == 1) {
recipeDescriptor += " @Override\n" +
" public Set<String> getTags() {\n" +
" return Collections.singleton(\"" + String.join("\", \"", tags) + "\");\n" +
" }\n" +
"\n";
" public Set<String> getTags() {\n" +
" return Collections.singleton(\"" + String.join("\", \"", tags) + "\");\n" +
" }\n" +
"\n";
} else if (tags.size() > 1) {
recipeDescriptor += " @Override\n" +
" public Set<String> getTags() {\n" +
" return new HashSet<>(Arrays.asList(\"" + String.join("\", \"", tags) + "\"));\n" +
" }\n" +
"\n";
" public Set<String> getTags() {\n" +
" return new HashSet<>(Arrays.asList(\"" + String.join("\", \"", tags) + "\"));\n" +
" }\n" +
"\n";
}

return recipeDescriptor;
Expand Down Expand Up @@ -644,9 +644,9 @@ public void scan(JCTree jcTree) {
if (jcTree instanceof JCTree.JCIdent) {
JCTree.JCIdent jcIdent = (JCTree.JCIdent) jcTree;
if (jcIdent.sym instanceof Symbol.VarSymbol &&
jcIdent.sym.owner instanceof Symbol.MethodSymbol &&
((Symbol.MethodSymbol) jcIdent.sym.owner).params.contains(jcIdent.sym) &&
seenParams.add(jcIdent.sym)) {
jcIdent.sym.owner instanceof Symbol.MethodSymbol &&
((Symbol.MethodSymbol) jcIdent.sym.owner).params.contains(jcIdent.sym) &&
seenParams.add(jcIdent.sym)) {
beforeParamOrder.put(((Symbol.MethodSymbol) jcIdent.sym.owner).params.indexOf(jcIdent.sym), beforeParameterOccurrence.getAndIncrement());
}
}
Expand All @@ -661,9 +661,9 @@ public void scan(JCTree jcTree) {
if (jcTree instanceof JCTree.JCIdent) {
JCTree.JCIdent jcIdent = (JCTree.JCIdent) jcTree;
if (jcIdent.sym instanceof Symbol.VarSymbol &&
jcIdent.sym.owner instanceof Symbol.MethodSymbol &&
((Symbol.MethodSymbol) jcIdent.sym.owner).params.contains(jcIdent.sym) &&
seenParams.add(jcIdent.sym)) {
jcIdent.sym.owner instanceof Symbol.MethodSymbol &&
((Symbol.MethodSymbol) jcIdent.sym.owner).params.contains(jcIdent.sym) &&
seenParams.add(jcIdent.sym)) {
afterParams.add(beforeParamOrder.get(((Symbol.MethodSymbol) jcIdent.sym.owner).params.indexOf(jcIdent.sym)));
}
}
Expand Down Expand Up @@ -739,7 +739,7 @@ public RuleDescriptor(JCTree.JCClassDecl classDecl, JCCompilationUnit cu, Contex

for (JCTree member : classDecl.getMembers()) {
if (member instanceof JCTree.JCMethodDecl && beforeTemplates.stream().noneMatch(t -> t.method == member) &&
(afterTemplate == null || member != afterTemplate.method)) {
(afterTemplate == null || member != afterTemplate.method)) {
for (JCTree.JCAnnotation annotation : getTemplateAnnotations(((JCTree.JCMethodDecl) member), UNSUPPORTED_ANNOTATIONS::contains)) {
printNoteOnce("@" + annotation.annotationType + " is currently not supported", classDecl.sym);
return null;
Expand Down Expand Up @@ -818,7 +818,7 @@ private boolean isAnyOfCall(JCTree.JCMethodInvocation call) {
if (meth instanceof JCTree.JCFieldAccess) {
JCTree.JCFieldAccess fieldAccess = (JCTree.JCFieldAccess) meth;
return fieldAccess.name.toString().equals("anyOf") &&
((JCTree.JCIdent) fieldAccess.selected).name.toString().equals("Refaster");
((JCTree.JCIdent) fieldAccess.selected).name.toString().equals("Refaster");
}
return false;
}
Expand Down Expand Up @@ -922,7 +922,7 @@ boolean validate(JCTree tree) {
@Override
public void visitSelect(JCTree.JCFieldAccess jcFieldAccess) {
if (jcFieldAccess.selected.type.tsym.toString().equals("com.google.errorprone.refaster.Refaster") &&
jcFieldAccess.name.toString().equals("anyOf")) {
jcFieldAccess.name.toString().equals("anyOf")) {
// exception for `Refaster.anyOf()`
if (++anyOfCount > 1) {
printNoteOnce("Refaster.anyOf() can only be used once per template", classDecl.sym);
Expand All @@ -936,8 +936,8 @@ public void visitSelect(JCTree.JCFieldAccess jcFieldAccess) {
@Override
public void visitIdent(JCTree.JCIdent jcIdent) {
if (valid &&
jcIdent.sym != null &&
jcIdent.sym.packge().getQualifiedName().contentEquals("com.google.errorprone.refaster")) {
jcIdent.sym != null &&
jcIdent.sym.packge().getQualifiedName().contentEquals("com.google.errorprone.refaster")) {
printNoteOnce(jcIdent.type.tsym.getQualifiedName() + " is currently not supported", classDecl.sym);
valid = false;
}
Expand Down Expand Up @@ -1056,16 +1056,16 @@ private static List<JCTree.JCAnnotation> getTemplateAnnotations(MethodTree metho
for (AnnotationTree annotation : method.getModifiers().getAnnotations()) {
Tree type = annotation.getAnnotationType();
if (type.getKind() == Tree.Kind.IDENTIFIER && ((JCTree.JCIdent) type).sym != null &&
typePredicate.test(((JCTree.JCIdent) type).sym.getQualifiedName().toString())) {
typePredicate.test(((JCTree.JCIdent) type).sym.getQualifiedName().toString())) {
result.add((JCTree.JCAnnotation) annotation);
} else if (type.getKind() == Tree.Kind.IDENTIFIER && ((JCTree.JCAnnotation) annotation).attribute != null &&
((JCTree.JCAnnotation) annotation).attribute.type instanceof Type.ClassType &&
((JCTree.JCAnnotation) annotation).attribute.type.tsym != null &&
typePredicate.test(((JCTree.JCAnnotation) annotation).attribute.type.tsym.getQualifiedName().toString())) {
((JCTree.JCAnnotation) annotation).attribute.type instanceof Type.ClassType &&
((JCTree.JCAnnotation) annotation).attribute.type.tsym != null &&
typePredicate.test(((JCTree.JCAnnotation) annotation).attribute.type.tsym.getQualifiedName().toString())) {
result.add((JCTree.JCAnnotation) annotation);
} else if (type.getKind() == Tree.Kind.MEMBER_SELECT && type instanceof JCTree.JCFieldAccess &&
((JCTree.JCFieldAccess) type).sym != null &&
typePredicate.test(((JCTree.JCFieldAccess) type).sym.getQualifiedName().toString())) {
((JCTree.JCFieldAccess) type).sym != null &&
typePredicate.test(((JCTree.JCFieldAccess) type).sym.getQualifiedName().toString())) {
result.add((JCTree.JCAnnotation) annotation);
}
}
Expand All @@ -1077,12 +1077,12 @@ private static List<JCTree.JCAnnotation> getTemplateAnnotations(VariableTree par
for (AnnotationTree annotation : parameter.getModifiers().getAnnotations()) {
Tree type = annotation.getAnnotationType();
if (type.getKind() == Tree.Kind.IDENTIFIER &&
((JCTree.JCIdent) type).sym != null &&
typePredicate.test(((JCTree.JCIdent) type).sym.getQualifiedName().toString())) {
((JCTree.JCIdent) type).sym != null &&
typePredicate.test(((JCTree.JCIdent) type).sym.getQualifiedName().toString())) {
result.add((JCTree.JCAnnotation) annotation);
} else if (type.getKind() == Tree.Kind.MEMBER_SELECT && type instanceof JCTree.JCFieldAccess &&
((JCTree.JCFieldAccess) type).sym != null &&
typePredicate.test(((JCTree.JCFieldAccess) type).sym.getQualifiedName().toString())) {
((JCTree.JCFieldAccess) type).sym != null &&
typePredicate.test(((JCTree.JCFieldAccess) type).sym.getQualifiedName().toString())) {
result.add((JCTree.JCAnnotation) annotation);
}
}
Expand Down

0 comments on commit 87bd944

Please sign in to comment.