Skip to content

Commit

Permalink
431 warnings in the log is enough, we should reduce the amount
Browse files Browse the repository at this point in the history
  • Loading branch information
carstenartur committed Aug 3, 2024
1 parent 6477f23 commit 378e170
Show file tree
Hide file tree
Showing 50 changed files with 212 additions and 213 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public class ControlStatementsFix extends CompilationUnitRewriteOperationsFix {

private final static class ControlStatementFinder extends GenericVisitor {

private final List<CompilationUnitRewriteOperation> fResult;
private final List<CompilationUnitRewriteOperationWithSourceRange> fResult;
private final boolean fFindControlStatementsWithoutBlock;
private final boolean fRemoveUnnecessaryBlocks;
private final boolean fRemoveUnnecessaryBlocksOnlyWhenReturnOrThrow;

public ControlStatementFinder(boolean findControlStatementsWithoutBlock,
boolean removeUnnecessaryBlocks,
boolean removeUnnecessaryBlocksOnlyWhenReturnOrThrow,
List<CompilationUnitRewriteOperation> resultingCollection) {
List<CompilationUnitRewriteOperationWithSourceRange> resultingCollection) {

fFindControlStatementsWithoutBlock= findControlStatementsWithoutBlock;
fRemoveUnnecessaryBlocks= removeUnnecessaryBlocks;
Expand Down Expand Up @@ -487,18 +487,18 @@ public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit,
if (!convertSingleStatementToBlock && !removeUnnecessaryBlock && !removeUnnecessaryBlockContainingReturnOrThrow)
return null;

List<CompilationUnitRewriteOperation> operations= new ArrayList<>();
List<CompilationUnitRewriteOperationWithSourceRange> operations= new ArrayList<>();
ControlStatementFinder finder= new ControlStatementFinder(convertSingleStatementToBlock, removeUnnecessaryBlock, removeUnnecessaryBlockContainingReturnOrThrow, operations);
compilationUnit.accept(finder);

if (operations.isEmpty())
return null;

CompilationUnitRewriteOperation[] ops= operations.toArray(new CompilationUnitRewriteOperation[operations.size()]);
CompilationUnitRewriteOperationWithSourceRange[] ops= operations.toArray(new CompilationUnitRewriteOperationWithSourceRange[operations.size()]);
return new ControlStatementsFix(FixMessages.ControlStatementsFix_change_name, compilationUnit, ops);
}

protected ControlStatementsFix(String name, CompilationUnit compilationUnit, CompilationUnitRewriteOperation[] fixRewriteOperations) {
protected ControlStatementsFix(String name, CompilationUnit compilationUnit, CompilationUnitRewriteOperationWithSourceRange[] fixRewriteOperations) {
super(name, compilationUnit, fixRewriteOperations);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public boolean visit(ParenthesizedExpression node) {
}
}

private static class AddParenthesisOperation extends CompilationUnitRewriteOperation {
private static class AddParenthesisOperation extends CompilationUnitRewriteOperationWithSourceRange {

private final Expression[] fExpressions;

Expand All @@ -119,7 +119,7 @@ public void rewriteASTInternal(CompilationUnitRewrite cuRewrite, LinkedProposalM
}
}

private static class RemoveParenthesisOperation extends CompilationUnitRewriteOperation {
private static class RemoveParenthesisOperation extends CompilationUnitRewriteOperationWithSourceRange {

private final HashSet<ParenthesizedExpression> fExpressions;

Expand Down Expand Up @@ -172,8 +172,8 @@ public static ExpressionsFix createAddParanoidalParenthesisFix(CompilationUnit c
return null;


CompilationUnitRewriteOperation op= new AddParenthesisOperation(changedNodes.toArray(new Expression[changedNodes.size()]));
return new ExpressionsFix(FixMessages.ExpressionsFix_addParanoiacParentheses_description, compilationUnit, new CompilationUnitRewriteOperation[] {op});
CompilationUnitRewriteOperationWithSourceRange op= new AddParenthesisOperation(changedNodes.toArray(new Expression[changedNodes.size()]));
return new ExpressionsFix(FixMessages.ExpressionsFix_addParanoiacParentheses_description, compilationUnit, new CompilationUnitRewriteOperationWithSourceRange[] {op});
}

public static ExpressionsFix createRemoveUnnecessaryParenthesisFix(CompilationUnit compilationUnit, ASTNode[] nodes) {
Expand All @@ -188,7 +188,7 @@ public static ExpressionsFix createRemoveUnnecessaryParenthesisFix(CompilationUn

HashSet<ParenthesizedExpression> expressions= new HashSet<>(changedNodes);
RemoveParenthesisOperation op= new RemoveParenthesisOperation(expressions);
return new ExpressionsFix(FixMessages.ExpressionsFix_removeUnnecessaryParentheses_description, compilationUnit, new CompilationUnitRewriteOperation[] {op});
return new ExpressionsFix(FixMessages.ExpressionsFix_removeUnnecessaryParentheses_description, compilationUnit, new CompilationUnitRewriteOperationWithSourceRange[] {op});
}

public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit,
Expand All @@ -202,8 +202,8 @@ public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit,
if (changedNodes.isEmpty())
return null;

CompilationUnitRewriteOperation op= new AddParenthesisOperation(changedNodes.toArray(new Expression[changedNodes.size()]));
return new ExpressionsFix(FixMessages.ExpressionsFix_add_parentheses_change_name, compilationUnit, new CompilationUnitRewriteOperation[] {op});
CompilationUnitRewriteOperationWithSourceRange op= new AddParenthesisOperation(changedNodes.toArray(new Expression[changedNodes.size()]));
return new ExpressionsFix(FixMessages.ExpressionsFix_add_parentheses_change_name, compilationUnit, new CompilationUnitRewriteOperationWithSourceRange[] {op});
} else if (removeUnnecessaryParenthesis) {
final ArrayList<ParenthesizedExpression> changedNodes = new ArrayList<>();
compilationUnit.accept(new UnnecessaryParenthesisVisitor(changedNodes));
Expand All @@ -212,13 +212,13 @@ public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit,
return null;

HashSet<ParenthesizedExpression> expressions= new HashSet<>(changedNodes);
CompilationUnitRewriteOperation op= new RemoveParenthesisOperation(expressions);
return new ExpressionsFix(FixMessages.ExpressionsFix_remove_parentheses_change_name, compilationUnit, new CompilationUnitRewriteOperation[] {op});
CompilationUnitRewriteOperationWithSourceRange op= new RemoveParenthesisOperation(expressions);
return new ExpressionsFix(FixMessages.ExpressionsFix_remove_parentheses_change_name, compilationUnit, new CompilationUnitRewriteOperationWithSourceRange[] {op});
}
return null;
}

protected ExpressionsFix(String name, CompilationUnit compilationUnit, CompilationUnitRewriteOperation[] fixRewriteOperations) {
protected ExpressionsFix(String name, CompilationUnit compilationUnit, CompilationUnitRewriteOperationWithSourceRange[] fixRewriteOperations) {
super(name, compilationUnit, fixRewriteOperations);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class NullAnnotationsFix extends CompilationUnitRewriteOperationsFix {

private CompilationUnit cu;

public NullAnnotationsFix(String name, CompilationUnit compilationUnit, CompilationUnitRewriteOperation[] operations) {
public NullAnnotationsFix(String name, CompilationUnit compilationUnit, CompilationUnitRewriteOperationWithSourceRange[] operations) {
super(name, compilationUnit, operations);
cu= compilationUnit;
}
Expand Down Expand Up @@ -170,7 +170,7 @@ public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, IProble
if (!JavaModelUtil.is50OrHigher(cu.getJavaProject()))
return null;

List<CompilationUnitRewriteOperation> operations= new ArrayList<>();
List<CompilationUnitRewriteOperationWithSourceRange> operations= new ArrayList<>();
if (locations == null) {
org.eclipse.jdt.core.compiler.IProblem[] problems= compilationUnit.getProblems();
locations= new IProblemLocation[problems.length];
Expand All @@ -190,11 +190,11 @@ public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, IProble
}
if (operations.isEmpty())
return null;
CompilationUnitRewriteOperation[] operationsArray= operations.toArray(new CompilationUnitRewriteOperation[operations.size()]);
CompilationUnitRewriteOperationWithSourceRange[] operationsArray= operations.toArray(new CompilationUnitRewriteOperationWithSourceRange[operations.size()]);
return new NullAnnotationsFix(message, compilationUnit, operationsArray);
}

private static boolean createMoveTypeAnnotationOperations(CompilationUnit compilationUnit, IProblemLocation[] locations, List<CompilationUnitRewriteOperation> operations) {
private static boolean createMoveTypeAnnotationOperations(CompilationUnit compilationUnit, IProblemLocation[] locations, List<CompilationUnitRewriteOperationWithSourceRange> operations) {
boolean isMove= false;
for (IProblemLocation location: locations) {
if (location == null)
Expand All @@ -206,7 +206,7 @@ private static boolean createMoveTypeAnnotationOperations(CompilationUnit compil
return isMove;
}

private static void createAddNullAnnotationOperations(CompilationUnit compilationUnit, IProblemLocation[] locations, List<CompilationUnitRewriteOperation> result) {
private static void createAddNullAnnotationOperations(CompilationUnit compilationUnit, IProblemLocation[] locations, List<CompilationUnitRewriteOperationWithSourceRange> result) {
String nullableAnnotationName= getNullableAnnotationName(compilationUnit.getJavaElement(), false);
String nonNullAnnotationName= getNonNullAnnotationName(compilationUnit.getJavaElement(), false);

Expand Down Expand Up @@ -262,7 +262,7 @@ private static void createAddNullAnnotationOperations(CompilationUnit compilatio
}
}

private static void createRemoveRedundantNullAnnotationsOperations(CompilationUnit compilationUnit, IProblemLocation[] locations, List<CompilationUnitRewriteOperation> result) {
private static void createRemoveRedundantNullAnnotationsOperations(CompilationUnit compilationUnit, IProblemLocation[] locations, List<CompilationUnitRewriteOperationWithSourceRange> result) {
for (IProblemLocation problem : locations) {
if (problem == null)
continue; // problem was filtered out by createCleanUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
import org.eclipse.jdt.internal.corext.codemanipulation.RedundantNullnessTypeAnnotationsFilter;
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.dom.Bindings;
import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFix.CompilationUnitRewriteOperation;
import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperationWithSourceRange;
import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.corext.util.Messages;
Expand All @@ -96,7 +96,7 @@ public enum ChangeKind {
TARGET // change the target method of a method call
}

static abstract class SignatureAnnotationRewriteOperation extends CompilationUnitRewriteOperation {
static abstract class SignatureAnnotationRewriteOperation extends CompilationUnitRewriteOperationWithSourceRange {
// initialized from the Builder:
protected CompilationUnit fUnit;
protected String fAnnotationToAdd;
Expand Down Expand Up @@ -329,7 +329,7 @@ public void rewriteASTInternal(CompilationUnitRewrite cuRewrite, LinkedProposalM
}
}

static class RemoveRedundantAnnotationRewriteOperation extends CompilationUnitRewriteOperation {
static class RemoveRedundantAnnotationRewriteOperation extends CompilationUnitRewriteOperationWithSourceRange {

private IProblemLocation fProblem;
private CompilationUnit fCompilationUnit;
Expand Down Expand Up @@ -385,7 +385,7 @@ public void rewriteASTInternal(CompilationUnitRewrite cuRewrite, LinkedProposalM
}
}

static class AddMissingDefaultNullnessRewriteOperation extends CompilationUnitRewriteOperation {
static class AddMissingDefaultNullnessRewriteOperation extends CompilationUnitRewriteOperationWithSourceRange {

private IProblemLocation fProblem;
private CompilationUnit fCompilationUnit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.eclipse.jdt.ui.text.java.IProblemLocation;

public class TypeAnnotationFix extends CompilationUnitRewriteOperationsFix {
public TypeAnnotationFix(String name, CompilationUnit compilationUnit, CompilationUnitRewriteOperation operation) {
public TypeAnnotationFix(String name, CompilationUnit compilationUnit, CompilationUnitRewriteOperationWithSourceRange operation) {
super(name, compilationUnit, operation);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.jdt.core.dom.rewrite.ListRewrite;

import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFix.CompilationUnitRewriteOperation;
import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperationWithSourceRange;
import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;

import org.eclipse.jdt.ui.text.java.IProblemLocation;

public class TypeAnnotationRewriteOperations {
static class MoveTypeAnnotationRewriteOperation extends CompilationUnitRewriteOperation {
static class MoveTypeAnnotationRewriteOperation extends CompilationUnitRewriteOperationWithSourceRange {

private IProblemLocation fProblem;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@
import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory;
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.dom.ForLoops;
import org.eclipse.jdt.internal.corext.dom.VarDefinitionsUsesVisitor;
import org.eclipse.jdt.internal.corext.dom.ForLoops.ForLoopContent;
import org.eclipse.jdt.internal.corext.dom.VarDefinitionsUsesVisitor;
import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFix;
import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFix.CompilationUnitRewriteOperation;
import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperationWithSourceRange;
import org.eclipse.jdt.internal.corext.fix.LinkedProposalModelCore;
import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
Expand Down Expand Up @@ -111,7 +111,7 @@ protected ICleanUpFix createFix(final CompilationUnit unit) throws CoreException
return null;
}

final List<CompilationUnitRewriteOperation> rewriteOperations= new ArrayList<>();
final List<CompilationUnitRewriteOperationWithSourceRange> rewriteOperations= new ArrayList<>();

unit.accept(new ASTVisitor() {
@Override
Expand Down Expand Up @@ -260,7 +260,7 @@ private boolean isSameVariable(final ForLoopContent loopContent, final MethodInv
}

return new CompilationUnitRewriteOperationsFix(MultiFixMessages.AddAllCleanup_description, unit,
rewriteOperations.toArray(new CompilationUnitRewriteOperation[0]));
rewriteOperations.toArray(new CompilationUnitRewriteOperationWithSourceRange[0]));
}

@Override
Expand All @@ -278,7 +278,7 @@ protected ICleanUpFix createFix(final CompilationUnit unit, final IProblemLocati
return null;
}

private static class AddOrRemoveAllForArrayOperation extends CompilationUnitRewriteOperation {
private static class AddOrRemoveAllForArrayOperation extends CompilationUnitRewriteOperationWithSourceRange {
private final Statement toReplace;
private final Expression affectedCollection;
private final Expression addedData;
Expand Down Expand Up @@ -328,7 +328,7 @@ public void rewriteASTInternal(final CompilationUnitRewrite cuRewrite, final Lin
}
}

private static class AddAllForCollectionOperation extends CompilationUnitRewriteOperation {
private static class AddAllForCollectionOperation extends CompilationUnitRewriteOperationWithSourceRange {
private final Statement toReplace;
private final Expression affectedCollection;
private final Expression addedData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import org.eclipse.jdt.internal.corext.dom.ForLoops.ForLoopContent;
import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFix;
import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFix.CompilationUnitRewriteOperation;
import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperationWithSourceRange;
import org.eclipse.jdt.internal.corext.fix.LinkedProposalModelCore;
import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;

Expand Down Expand Up @@ -106,7 +106,7 @@ protected ICleanUpFix createFix(CompilationUnit unit) throws CoreException {
return null;
}

final List<CompilationUnitRewriteOperation> rewriteOperations= new ArrayList<>();
final List<CompilationUnitRewriteOperationWithSourceRange> rewriteOperations= new ArrayList<>();

unit.accept(new ASTVisitor() {
@Override
Expand Down Expand Up @@ -197,7 +197,7 @@ private boolean isSameVariable(final ForLoopContent loopContent, final ArrayAcce
}

return new CompilationUnitRewriteOperationsFix(MultiFixMessages.ArraysFillCleanUp_description, unit,
rewriteOperations.toArray(new CompilationUnitRewriteOperation[0]));
rewriteOperations.toArray(new CompilationUnitRewriteOperationWithSourceRange[0]));
}

@Override
Expand All @@ -210,7 +210,7 @@ protected ICleanUpFix createFix(final CompilationUnit unit, final IProblemLocati
return null;
}

private static class ArraysFillOperation extends CompilationUnitRewriteOperation {
private static class ArraysFillOperation extends CompilationUnitRewriteOperationWithSourceRange {
private final ForStatement node;
private final Assignment assignment;
private final ArrayAccess arrayAccess;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFix;
import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFix.CompilationUnitRewriteOperation;
import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperationWithSourceRange;
import org.eclipse.jdt.internal.corext.fix.LinkedProposalModelCore;
import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
Expand Down Expand Up @@ -103,7 +103,7 @@ protected ICleanUpFix createFix(CompilationUnit unit) throws CoreException {
return null;
}

final List<CompilationUnitRewriteOperation> rewriteOperations= new ArrayList<>();
final List<CompilationUnitRewriteOperationWithSourceRange> rewriteOperations= new ArrayList<>();

unit.accept(new ASTVisitor() {
@Override
Expand Down Expand Up @@ -186,7 +186,7 @@ private boolean hasConflictingMethodOrConstructor(final MethodInvocation visited
}

return new CompilationUnitRewriteOperationsFix(MultiFixMessages.AutoboxingCleanup_description, unit,
rewriteOperations.toArray(new CompilationUnitRewriteOperation[rewriteOperations.size()]));
rewriteOperations.toArray(new CompilationUnitRewriteOperationWithSourceRange[rewriteOperations.size()]));
}

@Override
Expand All @@ -199,7 +199,7 @@ protected ICleanUpFix createFix(CompilationUnit unit, IProblemLocation[] problem
return null;
}

private static class AutoboxingOperation extends CompilationUnitRewriteOperation {
private static class AutoboxingOperation extends CompilationUnitRewriteOperationWithSourceRange {
private final ASTNode node;

private final ITypeBinding primitiveType;
Expand Down
Loading

0 comments on commit 378e170

Please sign in to comment.