Skip to content

Commit

Permalink
Address comments: Add test cases and cover more argument types
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamedsamehsalah committed Nov 25, 2023
1 parent 0e262eb commit faaee6e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.LineMap;
import com.sun.source.tree.LiteralTree;
import com.sun.source.tree.MemberSelectTree;
import com.sun.source.tree.MethodInvocationTree;
import com.sun.source.tree.MethodTree;
Expand Down Expand Up @@ -144,7 +145,7 @@ public Description matchCompilationUnit(CompilationUnitTree tree, VisitorState s
SuggestedFix.Builder fixBuilder = SuggestedFix.builder();

reportIncorrectClassName(tree, state);
reportUnSortedElidedTypesAndStaticImports(tree, state, fixBuilder);
reportUnSortedElidedTypesAndStaticImports(tree, fixBuilder, state);

List<Description> matches = new ArrayList<>();
delegate.matchCompilationUnit(
Expand Down Expand Up @@ -187,7 +188,7 @@ private void reportIncorrectClassName(CompilationUnitTree tree, VisitorState sta
}

private void reportUnSortedElidedTypesAndStaticImports(
CompilationUnitTree compilationUnit, VisitorState state, SuggestedFix.Builder fixBuilder) {
CompilationUnitTree compilationUnit, SuggestedFix.Builder fixBuilder, VisitorState state) {
new TreeScanner<@Nullable Void, @Nullable Void>() {
@Override
public @Nullable Void visitMethod(MethodTree tree, @Nullable Void unused) {
Expand Down Expand Up @@ -243,6 +244,9 @@ private static String getArgumentName(ExpressionTree arg, VisitorState state) {
return state.getSourceForNode(((MemberSelectTree) arg).getExpression());
case METHOD_INVOCATION:
return state.getSourceForNode(((MethodInvocationTree) arg).getMethodSelect());
case STRING_LITERAL:
case INT_LITERAL:
return ((LiteralTree) arg).getValue().toString();
default:
return "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ private NonSortedElidedTypesAndStaticImportsTestRules() {}

@Override
public ImmutableSet<Object> elidedTypesAndStaticImports() {
return ImmutableSet.of(Lists.class, assertDoesNotThrow(() -> null), Iterables.class);
return ImmutableSet.of(
Lists.class, 3, "k", assertDoesNotThrow(() -> null), Iterables.class, "K", 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ final class NonSortedElidedTypesAndStaticImportsTestRulesTest
implements RefasterRuleCollectionTestCase {
@Override
public ImmutableSet<Object> elidedTypesAndStaticImports() {
return ImmutableSet.of(Lists.class, assertDoesNotThrow(() -> null), Iterables.class);
return ImmutableSet.of(
Lists.class, 3, "k", assertDoesNotThrow(() -> null), Iterables.class, "K", 1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ final class NonSortedElidedTypesAndStaticImportsTestRulesTest
implements RefasterRuleCollectionTestCase {
@Override
public ImmutableSet<Object> elidedTypesAndStaticImports() {
return ImmutableSet.of(assertDoesNotThrow(() -> null), Iterables.class, Lists.class);
return ImmutableSet.of(
1, 3, assertDoesNotThrow(() -> null), Iterables.class, "k", "K", Lists.class);
}
}

Expand Down

0 comments on commit faaee6e

Please sign in to comment.