Skip to content

Commit

Permalink
refactor: Operator wrapping on end of line
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek and TeamModerne committed Sep 21, 2024
1 parent e1eabde commit a92e695
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,18 @@ public void scan(JCTree tree) {
} else if (((JCIdent) tree).sym.getKind() == ElementKind.ENUM_CONSTANT) {
imports.add(((JCIdent) tree).sym);
}
} else if (tree instanceof JCFieldAccess && ((JCFieldAccess) tree).sym instanceof Symbol.VarSymbol
&& ((JCFieldAccess) tree).selected instanceof JCIdent
&& ((JCIdent) ((JCFieldAccess) tree).selected).sym instanceof Symbol.ClassSymbol) {
} else if (tree instanceof JCFieldAccess && ((JCFieldAccess) tree).sym instanceof Symbol.VarSymbol &&
((JCFieldAccess) tree).selected instanceof JCIdent &&
((JCIdent) ((JCFieldAccess) tree).selected).sym instanceof Symbol.ClassSymbol) {
imports.add(((JCIdent) ((JCFieldAccess) tree).selected).sym);
} else if (tree instanceof JCFieldAccess && ((JCFieldAccess) tree).sym instanceof Symbol.MethodSymbol
&& ((JCFieldAccess) tree).selected instanceof JCIdent
&& ((JCIdent) ((JCFieldAccess) tree).selected).sym instanceof Symbol.ClassSymbol) {
} else if (tree instanceof JCFieldAccess && ((JCFieldAccess) tree).sym instanceof Symbol.MethodSymbol &&
((JCFieldAccess) tree).selected instanceof JCIdent &&
((JCIdent) ((JCFieldAccess) tree).selected).sym instanceof Symbol.ClassSymbol) {
imports.add(((JCIdent) ((JCFieldAccess) tree).selected).sym);
} else if (tree instanceof JCFieldAccess && ((JCFieldAccess) tree).sym instanceof Symbol.ClassSymbol
&& ((JCFieldAccess) tree).selected instanceof JCIdent
&& ((JCIdent) ((JCFieldAccess) tree).selected).sym instanceof Symbol.ClassSymbol
&& !(((JCIdent) ((JCFieldAccess) tree).selected).sym.type instanceof Type.ErrorType)) {
} else if (tree instanceof JCFieldAccess && ((JCFieldAccess) tree).sym instanceof Symbol.ClassSymbol &&
((JCFieldAccess) tree).selected instanceof JCIdent &&
((JCIdent) ((JCFieldAccess) tree).selected).sym instanceof Symbol.ClassSymbol &&
!(((JCIdent) ((JCFieldAccess) tree).selected).sym.type instanceof Type.ErrorType)) {
imports.add(((JCIdent) ((JCFieldAccess) tree).selected).sym);
} else if (tree instanceof JCTree.JCFieldAccess &&
((JCTree.JCFieldAccess) tree).sym instanceof Symbol.ClassSymbol) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,10 +637,10 @@ private String parameters(TemplateDescriptor before, RuleDescriptor descriptor)
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)) {
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)) {
beforeParamOrder.put(((Symbol.MethodSymbol) jcIdent.sym.owner).params.indexOf(jcIdent.sym), beforeParameterOccurrence.getAndIncrement());
}
}
Expand All @@ -654,10 +654,10 @@ public void scan(JCTree jcTree) {
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)) {
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)) {
afterParams.add(beforeParamOrder.get(((Symbol.MethodSymbol) jcIdent.sym.owner).params.indexOf(jcIdent.sym)));
}
}
Expand Down Expand Up @@ -929,9 +929,9 @@ 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")) {
if (valid &&
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 @@ -1049,17 +1049,17 @@ private static List<JCTree.JCAnnotation> getTemplateAnnotations(MethodTree metho
List<JCTree.JCAnnotation> result = new ArrayList<>();
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())) {
if (type.getKind() == Tree.Kind.IDENTIFIER && ((JCTree.JCIdent) type).sym != null &&
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())) {
} 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())) {
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())) {
} 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())) {
result.add((JCTree.JCAnnotation) annotation);
}
}
Expand All @@ -1070,13 +1070,13 @@ private static List<JCTree.JCAnnotation> getTemplateAnnotations(VariableTree par
List<JCTree.JCAnnotation> result = new ArrayList<>();
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())) {
if (type.getKind() == Tree.Kind.IDENTIFIER &&
((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())) {
} 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())) {
result.add((JCTree.JCAnnotation) annotation);
}
}
Expand Down

0 comments on commit a92e695

Please sign in to comment.