Skip to content

Commit

Permalink
Apply updated formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 committed Jan 21, 2024
1 parent c608830 commit 5ef5c3e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ private static Optional<SuggestedFix.Builder> constructMethodRef(
LambdaExpressionTree lambdaExpr, Tree subTree) {
return switch (subTree.getKind()) {
case BLOCK -> constructMethodRef(lambdaExpr, (BlockTree) subTree);
case EXPRESSION_STATEMENT -> constructMethodRef(
lambdaExpr, ((ExpressionStatementTree) subTree).getExpression());
case EXPRESSION_STATEMENT ->
constructMethodRef(lambdaExpr, ((ExpressionStatementTree) subTree).getExpression());
case METHOD_INVOCATION -> constructMethodRef(lambdaExpr, (MethodInvocationTree) subTree);
case PARENTHESIZED -> constructMethodRef(
lambdaExpr, ((ParenthesizedTree) subTree).getExpression());
case PARENTHESIZED ->
constructMethodRef(lambdaExpr, ((ParenthesizedTree) subTree).getExpression());
case RETURN -> constructMethodRef(lambdaExpr, ((ReturnTree) subTree).getExpression());
default -> Optional.empty();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState
private static boolean isTypeDerivableFromContext(MethodInvocationTree tree, VisitorState state) {
Tree parent = state.getPath().getParentPath().getLeaf();
return switch (parent.getKind()) {
case VARIABLE -> !ASTHelpers.hasImplicitType((VariableTree) parent, state)
&& MoreASTHelpers.areSameType(tree, parent, state);
case VARIABLE ->
!ASTHelpers.hasImplicitType((VariableTree) parent, state)
&& MoreASTHelpers.areSameType(tree, parent, state);
case ASSIGNMENT -> MoreASTHelpers.areSameType(tree, parent, state);
case RETURN -> MoreASTHelpers.findMethodExitedOnReturn(state)
.filter(m -> MoreASTHelpers.areSameType(tree, m.getReturnType(), state))
.isPresent();
case RETURN ->
MoreASTHelpers.findMethodExitedOnReturn(state)
.filter(m -> MoreASTHelpers.areSameType(tree, m.getReturnType(), state))
.isPresent();
default -> false;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,10 @@ private Optional<ExpressionTree> trySimplify(ExpressionTree tree, VisitorState s
return switch (methodInvocation.getArguments().size()) {
case 0 -> trySimplifyNullaryMethod(methodInvocation, state);
case 1 -> trySimplifyUnaryMethod(methodInvocation, state);
default -> throw new IllegalStateException(
"Cannot simplify method call with two or more arguments: "
+ SourceCode.treeToString(tree, state));
default ->
throw new IllegalStateException(
"Cannot simplify method call with two or more arguments: "
+ SourceCode.treeToString(tree, state));
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState
}

return switch (ASTHelpers.getSymbol(tree).getSimpleName().toString()) {
case "addImport" -> createDescription(
tree, "SuggestedFix.Builder#addImport", "SuggestedFixes#qualifyType");
case "addStaticImport" -> createDescription(
tree, "SuggestedFix.Builder#addStaticImport", "SuggestedFixes#qualifyStaticImport");
case "addImport" ->
createDescription(tree, "SuggestedFix.Builder#addImport", "SuggestedFixes#qualifyType");
case "addStaticImport" ->
createDescription(
tree, "SuggestedFix.Builder#addStaticImport", "SuggestedFixes#qualifyStaticImport");
default -> Description.NO_MATCH;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ private static Optional<SeverityLevel> toSeverityLevel(Severity severity) {
case DEFAULT -> Optional.empty();
case WARN -> Optional.of(WARNING);
case ERROR -> Optional.of(ERROR);
default -> throw new IllegalStateException(
String.format("Unsupported severity='%s'", severity));
default ->
throw new IllegalStateException(String.format("Unsupported severity='%s'", severity));
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@ private static SeverityLevel toSeverityLevel(String compilerDiagnosticsPrefix) {
case "Note" -> SUGGESTION;
case "warning" -> WARNING;
case "error" -> ERROR;
default -> throw new IllegalStateException(
String.format("Unrecognized diagnostics prefix '%s'", compilerDiagnosticsPrefix));
default ->
throw new IllegalStateException(
String.format("Unrecognized diagnostics prefix '%s'", compilerDiagnosticsPrefix));
};
}

Expand Down

0 comments on commit 5ef5c3e

Please sign in to comment.