Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup #3064

Merged
merged 36 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
cabdcfc
Simplify asserts
jwiesler Mar 12, 2023
3682ac1
Verbose and redundant statements
jwiesler Mar 12, 2023
9ea37a8
Code style issues
jwiesler Mar 12, 2023
fbfc80d
Declaration redundancy
jwiesler Mar 12, 2023
7ca09ad
Control flow and boolean simplifications
jwiesler Mar 13, 2023
6826fe8
Numeric issues, Collection.addAll, initCause, manual array copies, bo…
jwiesler Mar 12, 2023
506b609
Object.equals
jwiesler Mar 12, 2023
28bf2a7
Use UTF-8 instead of system default when converting strings from bytes
jwiesler Mar 12, 2023
1e03880
More final fields
jwiesler Mar 12, 2023
fab73b6
Unused imports
jwiesler Mar 12, 2023
f6f15b9
More default charsets
jwiesler Mar 12, 2023
8a34537
Use Java 5
jwiesler Mar 12, 2023
223d057
Use Java 8
jwiesler Mar 12, 2023
cc980ff
Static inner classes and toArray
jwiesler Mar 12, 2023
385b393
String concat in StringBuilder append
jwiesler Mar 12, 2023
a81c5a4
String concat in StringBuilder append, String append in loop
jwiesler Mar 12, 2023
7c7e06d
Minor changes
jwiesler Mar 12, 2023
279f715
Stream api, checks already covered by other checks, weak variable typ…
jwiesler Mar 12, 2023
400f219
Fix returned stream
jwiesler Mar 13, 2023
8e195c9
Fix macro args generics
jwiesler Mar 13, 2023
4a2157a
Fix test walk dir
jwiesler Mar 13, 2023
d2b7b6c
Enforce proof script argument fields not being final
jwiesler Mar 13, 2023
daa21ce
Use parseInt instead of valueOf
jwiesler Mar 13, 2023
3056bfe
Fix some critical warnings by removing dead code
jwiesler Mar 20, 2023
ab9f5ef
Remove java.util logging
jwiesler Mar 20, 2023
699f7ae
Remove more manual logging
jwiesler Mar 21, 2023
4ad88f8
Improve log output of RunAllProofsFunctional
jwiesler Mar 21, 2023
97de68f
Replace printStackTrace with logging
jwiesler Mar 22, 2023
7c23bcb
Minor changes
jwiesler Mar 22, 2023
4343ae4
Obsolete collection types
jwiesler Mar 25, 2023
a2c926d
Code style
jwiesler Mar 22, 2023
5af6617
Use slf4j.detectLoggerNameMismatch and fix issues
jwiesler Mar 25, 2023
476e31e
Fix exception cause being dropped in MiscTools::extractURI
jwiesler Mar 26, 2023
d1d9fbf
Wrong logger class parameter used
jwiesler Mar 26, 2023
b903cf2
Spotless
jwiesler Mar 31, 2023
0f92998
Merge branch 'main' into cleanup
jwiesler Apr 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private static class ReferenceAnalaystProofVisitor implements ProofVisitor {
* The result.
*/
private final LinkedHashSet<IProofReference<?>> result =
new LinkedHashSet<IProofReference<?>>();
new LinkedHashSet<>();

/**
* Constructor.
Expand Down Expand Up @@ -168,7 +168,7 @@ public static LinkedHashSet<IProofReference<?>> computeProofReferences(Node node
*/
public static LinkedHashSet<IProofReference<?>> computeProofReferences(Node node,
Services services, ImmutableList<IProofReferencesAnalyst> analysts) {
LinkedHashSet<IProofReference<?>> result = new LinkedHashSet<IProofReference<?>>();
LinkedHashSet<IProofReference<?>> result = new LinkedHashSet<>();
if (node != null && analysts != null) {
for (IProofReferencesAnalyst analyst : analysts) {
LinkedHashSet<IProofReference<?>> analystResult =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ public LinkedHashSet<IProofReference<?>> computeReferences(Node node, Services s
// Invariant was applied
PartialInvAxiom axiom = (PartialInvAxiom) found;
DefaultProofReference<ClassInvariant> reference =
new DefaultProofReference<ClassInvariant>(IProofReference.USE_INVARIANT,
new DefaultProofReference<>(IProofReference.USE_INVARIANT,
node, axiom.getInv());
LinkedHashSet<IProofReference<?>> result =
new LinkedHashSet<IProofReference<?>>();
new LinkedHashSet<>();
result.add(reference);
return result;
} else if (found != null) {
// ClassAxiom was applied
DefaultProofReference<ClassAxiom> reference =
new DefaultProofReference<ClassAxiom>(IProofReference.USE_AXIOM, node,
new DefaultProofReference<>(IProofReference.USE_AXIOM, node,
found);
LinkedHashSet<IProofReference<?>> result =
new LinkedHashSet<IProofReference<?>>();
new LinkedHashSet<>();
result.add(reference);
return result;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public LinkedHashSet<IProofReference<?>> computeReferences(Node node, Services s
if (node.getAppliedRuleApp() instanceof AbstractContractRuleApp) {
AbstractContractRuleApp contractRuleApp =
(AbstractContractRuleApp) node.getAppliedRuleApp();
DefaultProofReference<Contract> reference = new DefaultProofReference<Contract>(
DefaultProofReference<Contract> reference = new DefaultProofReference<>(
IProofReference.USE_CONTRACT, node, contractRuleApp.getInstantiation());
LinkedHashSet<IProofReference<?>> result = new LinkedHashSet<IProofReference<?>>();
LinkedHashSet<IProofReference<?>> result = new LinkedHashSet<>();
result.add(reference);
return result;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ public interface IProofReferencesAnalyst {
* @return The found {@link IProofReference} or {@code null}/empty set if the applied rule is
* not supported.
*/
public LinkedHashSet<IProofReference<?>> computeReferences(Node node, Services services);
LinkedHashSet<IProofReference<?>> computeReferences(Node node, Services services);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public LinkedHashSet<IProofReference<?>> computeReferences(Node node, Services s
MethodBodyStatement mbs = (MethodBodyStatement) info.getActiveStatement();
IProgramMethod pm = mbs.getProgramMethod(services);
DefaultProofReference<IProgramMethod> reference =
new DefaultProofReference<IProgramMethod>(IProofReference.INLINE_METHOD, node,
new DefaultProofReference<>(IProofReference.INLINE_METHOD, node,
pm);
LinkedHashSet<IProofReference<?>> result = new LinkedHashSet<IProofReference<?>>();
LinkedHashSet<IProofReference<?>> result = new LinkedHashSet<>();
result.add(reference);
return result;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import de.uka.ilkd.key.java.ProgramElement;
import de.uka.ilkd.key.java.Services;
import de.uka.ilkd.key.java.abstraction.KeYJavaType;
import de.uka.ilkd.key.java.abstraction.Type;
import de.uka.ilkd.key.java.expression.Assignment;
import de.uka.ilkd.key.java.reference.ExecutionContext;
import de.uka.ilkd.key.java.reference.MethodReference;
Expand Down Expand Up @@ -50,14 +49,14 @@ public LinkedHashSet<IProofReference<?>> computeReferences(Node node, Services s
IProofReference<IProgramMethod> reference = createReference(node, services,
context, (MethodReference) info.getActiveStatement());
LinkedHashSet<IProofReference<?>> result =
new LinkedHashSet<IProofReference<?>>();
new LinkedHashSet<>();
result.add(reference);
return result;
} else if (info.getActiveStatement() instanceof Assignment) {
Assignment assignment = (Assignment) info.getActiveStatement();
ExecutionContext context = extractContext(node, services);
LinkedHashSet<IProofReference<?>> result =
new LinkedHashSet<IProofReference<?>>();
new LinkedHashSet<>();
for (int i = 0; i < assignment.getChildCount(); i++) {
ProgramElement child = assignment.getChildAt(i);
if (child instanceof MethodReference) {
Expand Down Expand Up @@ -106,7 +105,7 @@ protected IProofReference<IProgramMethod> createReference(Node node, Services se
if (context != null) {
KeYJavaType refPrefixType = mr.determineStaticPrefixType(services, context);
IProgramMethod pm = mr.method(services, refPrefixType, context);
return new DefaultProofReference<IProgramMethod>(IProofReference.CALL_METHOD, node, pm);
return new DefaultProofReference<>(IProofReference.CALL_METHOD, node, pm);
} else {
if (!(node.getAppliedRuleApp() instanceof PosTacletApp)) {
throw new IllegalArgumentException("PosTacletApp expected.");
Expand All @@ -131,8 +130,8 @@ protected IProofReference<IProgramMethod> createReference(Node node, Services se
throw new IllegalArgumentException("Empty argument list expected.");
}
IProgramMethod pm = services.getJavaInfo().getProgramMethod(type.getKeYJavaType(),
method.toString(), ImmutableSLList.<Type>nil(), type.getKeYJavaType());
return new DefaultProofReference<IProgramMethod>(IProofReference.CALL_METHOD, node, pm);
method.toString(), ImmutableSLList.nil(), type.getKeYJavaType());
return new DefaultProofReference<>(IProofReference.CALL_METHOD, node, pm);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public LinkedHashSet<IProofReference<?>> computeReferences(Node node, Services s
if (node.getAppliedRuleApp() != null && node.getNodeInfo() != null) {
SourceElement statement = node.getNodeInfo().getActiveStatement();
if (statement instanceof CopyAssignment) {
LinkedHashSet<IProofReference<?>> result = new LinkedHashSet<IProofReference<?>>();
LinkedHashSet<IProofReference<?>> result = new LinkedHashSet<>();
listReferences(node, (CopyAssignment) statement,
services.getJavaInfo().getArrayLength(), result, true);
return result;
} else if (statement instanceof If) {
LinkedHashSet<IProofReference<?>> result = new LinkedHashSet<IProofReference<?>>();
LinkedHashSet<IProofReference<?>> result = new LinkedHashSet<>();
listReferences(node, ((If) statement).getExpression(),
services.getJavaInfo().getArrayLength(), result, false);
return result;
Expand All @@ -63,7 +63,7 @@ protected void listReferences(Node node, ProgramElement pe, ProgramVariable arra
ProgramVariable pv = (ProgramVariable) pe;
if (pv.isMember()) {
DefaultProofReference<ProgramVariable> reference =
new DefaultProofReference<ProgramVariable>(IProofReference.ACCESS, node,
new DefaultProofReference<>(IProofReference.ACCESS, node,
(ProgramVariable) pe);
ProofReferenceUtil.merge(toFill, reference);
}
Expand All @@ -76,7 +76,7 @@ protected void listReferences(Node node, ProgramElement pe, ProgramVariable arra
ProgramVariable pv = fr.getProgramVariable();
if (pv != arrayLength) {
DefaultProofReference<ProgramVariable> reference =
new DefaultProofReference<ProgramVariable>(IProofReference.ACCESS, node, pv);
new DefaultProofReference<>(IProofReference.ACCESS, node, pv);
ProofReferenceUtil.merge(toFill, reference);
}
} else if (includeExpressionContainer && pe instanceof ExpressionContainer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ public class DefaultProofReference<T> implements IProofReference<T> {
/**
* The reference kind as human readable {@link String}.
*/
private String kind;
private final String kind;

/**
* The source {@link Proof}.
*/
private Proof source;
private final Proof source;

/**
* The target source member.
*/
private T target;
private final T target;

/**
* The {@link Node} in which the reference was found.
*/
private LinkedHashSet<Node> nodes = new LinkedHashSet<Node>();
private final LinkedHashSet<Node> nodes = new LinkedHashSet<>();

/**
* Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public interface IProofReference<T> {
* ({@link #getTarget()}).
* </p>
*/
public static final String CALL_METHOD = "Call Method";
String CALL_METHOD = "Call Method";

/**
* <p>
Expand All @@ -43,7 +43,7 @@ public interface IProofReference<T> {
* ({@link #getTarget()}).
* </p>
*/
public static final String INLINE_METHOD = "Inline Method";
String INLINE_METHOD = "Inline Method";

/**
* <p>
Expand All @@ -54,7 +54,7 @@ public interface IProofReference<T> {
* References of this kind should provide a {@link Contract} as target ({@link #getTarget()}).
* </p>
*/
public static final String USE_CONTRACT = "Use Contract";
String USE_CONTRACT = "Use Contract";

/**
* <p>
Expand All @@ -65,7 +65,7 @@ public interface IProofReference<T> {
* ({@link #getTarget()}).
* </p>
*/
public static final String ACCESS = "Access";
String ACCESS = "Access";

/**
* <p>
Expand All @@ -76,7 +76,7 @@ public interface IProofReference<T> {
* ({@link #getTarget()}).
* </p>
*/
public static final String USE_INVARIANT = "Use Invariant";
String USE_INVARIANT = "Use Invariant";

/**
* <p>
Expand All @@ -87,40 +87,40 @@ public interface IProofReference<T> {
* ({@link #getTarget()}).
* </p>
*/
public static final String USE_AXIOM = "Use Axiom";
String USE_AXIOM = "Use Axiom";

/**
* Returns the reference kind which is a human readable {@link String}.
*
* @return The reference kind as human readable {@link String}.
*/
public String getKind();
String getKind();

/**
* Returns the {@link Node}s in which the reference was found.
*
* @return The {@link Node}s in which the reference was found.
*/
public LinkedHashSet<Node> getNodes();
LinkedHashSet<Node> getNodes();

/**
* Adds the given {@link Node}s to the own {@link Node}s.
*
* @param nodes The {@link Node}s to add.
*/
public void addNodes(Collection<Node> nodes);
void addNodes(Collection<Node> nodes);

/**
* Returns the target source member.
*
* @return The target source member.
*/
public T getTarget();
T getTarget();

/**
* Returns the source {@link Proof}.
*
* @return The source {@link Proof}.
*/
public Proof getSource();
Proof getSource();
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ protected IProofTester createReferenceMethodTester(final IProofReferencesAnalyst
// Filter references
if (currentReferenceFilter != null) {
LinkedHashSet<IProofReference<?>> filteredReferences =
new LinkedHashSet<IProofReference<?>>();
new LinkedHashSet<>();
for (IProofReference<?> reference : references) {
if (currentReferenceFilter.test(reference)) {
filteredReferences.add(reference);
Expand All @@ -179,7 +179,7 @@ protected IProofTester createReferenceMethodTester(final IProofReferencesAnalyst
*/
protected LinkedHashSet<IProofReference<?>> findReferences(
LinkedHashSet<IProofReference<?>> references, Node node) {
LinkedHashSet<IProofReference<?>> result = new LinkedHashSet<IProofReference<?>>();
LinkedHashSet<IProofReference<?>> result = new LinkedHashSet<>();
for (IProofReference<?> reference : references) {
if (reference.getNodes().contains(node)) {
result.add(reference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
import de.uka.ilkd.key.logic.Term;
import de.uka.ilkd.key.logic.op.LocationVariable;
import de.uka.ilkd.key.logic.op.Modality;
import de.uka.ilkd.key.logic.op.SVSubstitute;
import de.uka.ilkd.key.strategy.IBreakpointStopCondition;
import de.uka.ilkd.key.symbolic_execution.strategy.breakpoint.AbstractConditionalBreakpoint;
import de.uka.ilkd.key.symbolic_execution.strategy.breakpoint.IBreakpoint;

public class TermProgramVariableCollectorKeepUpdatesForBreakpointconditions
extends TermProgramVariableCollector {
private IBreakpointStopCondition breakpointStopCondition;
private final IBreakpointStopCondition breakpointStopCondition;

public TermProgramVariableCollectorKeepUpdatesForBreakpointconditions(Services services,
IBreakpointStopCondition breakpointStopCondition) {
Expand All @@ -36,9 +35,9 @@ private void addVarsToKeep() {
AbstractConditionalBreakpoint conditionalBreakpoint =
(AbstractConditionalBreakpoint) breakpoint;
if (conditionalBreakpoint.getToKeep() != null) {
for (SVSubstitute sub : conditionalBreakpoint.getToKeep()) {
for (LocationVariable sub : conditionalBreakpoint.getToKeep()) {
if (sub instanceof LocationVariable) {
super.result().add((LocationVariable) sub);
super.result().add(sub);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ public boolean mergeLabels(SequentFormula existingSF, Term existingTerm,
mergedLabels.remove(existingLabel);
// Add new label
mergedLabels.add(newLabel);
return true;
} else {
mergedLabels.add(rejectedLabel);
return true;
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ protected void refactorSequentFormulas(TermLabelState state, Services services,
FormulaTermLabel termLabel = (FormulaTermLabel) term.getLabel(FormulaTermLabel.NAME);
if (termLabel != null) {
labels.remove(termLabel);
Set<String> beforeIds = new LinkedHashSet<String>();
Set<String> beforeIds = new LinkedHashSet<>();
beforeIds.add(termLabel.getId());
int labelSubID = FormulaTermLabel.newLabelSubID(services, termLabel);
labels.add(new FormulaTermLabel(termLabel.getMajorId(), labelSubID, beforeIds));
Expand Down Expand Up @@ -318,7 +318,7 @@ public static void setInnerMostParentRefactored(TermLabelState state, Goal goal,
boolean refactored) {
Map<Object, Object> labelState = state.getLabelState(FormulaTermLabel.NAME);
labelState.put(INNER_MOST_PARENT_REFACTORED_PREFIX + goal.node().serialNr(),
Boolean.valueOf(refactored));
refactored);
}

/**
Expand All @@ -330,7 +330,7 @@ public static void setInnerMostParentRefactored(TermLabelState state, Goal goal,
public static boolean isUpdateRefactroingRequired(TermLabelState state) {
Map<Object, Object> labelState = state.getLabelState(FormulaTermLabel.NAME);
Object value = labelState.get(UPDATE_REFACTORING_REQUIRED);
return value instanceof Boolean && ((Boolean) value).booleanValue();
return value instanceof Boolean && (Boolean) value;
}

/**
Expand All @@ -341,7 +341,7 @@ public static boolean isUpdateRefactroingRequired(TermLabelState state) {
*/
public static void setUpdateRefactroingRequired(TermLabelState state, boolean required) {
Map<Object, Object> labelState = state.getLabelState(FormulaTermLabel.NAME);
labelState.put(UPDATE_REFACTORING_REQUIRED, Boolean.valueOf(required));
labelState.put(UPDATE_REFACTORING_REQUIRED, required);
}

/**
Expand All @@ -353,7 +353,7 @@ public static void setUpdateRefactroingRequired(TermLabelState state, boolean re
public static boolean isParentRefactroingRequired(TermLabelState state) {
Map<Object, Object> labelState = state.getLabelState(FormulaTermLabel.NAME);
Object value = labelState.get(PARENT_REFACTORING_REQUIRED);
return value instanceof Boolean && ((Boolean) value).booleanValue();
return value instanceof Boolean && (Boolean) value;
}

/**
Expand All @@ -364,7 +364,7 @@ public static boolean isParentRefactroingRequired(TermLabelState state) {
*/
public static void setParentRefactroingRequired(TermLabelState state, boolean required) {
Map<Object, Object> labelState = state.getLabelState(FormulaTermLabel.NAME);
labelState.put(PARENT_REFACTORING_REQUIRED, Boolean.valueOf(required));
labelState.put(PARENT_REFACTORING_REQUIRED, required);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void updateLabels(TermLabelState state, Services services,
TacletApp ta = (TacletApp) ruleApp;
if (ta.ifInstsComplete() && ta.ifFormulaInstantiations() != null) {
Map<SequentFormula, FormulaTermLabel> ifLabels =
new LinkedHashMap<SequentFormula, FormulaTermLabel>();
new LinkedHashMap<>();
for (IfFormulaInstantiation ifInst : ta.ifFormulaInstantiations()) {
FormulaTermLabel ifLabel = StayOnFormulaTermLabelPolicy.searchFormulaTermLabel(
ifInst.getConstrainedFormula().formula().getLabels());
Expand Down
Loading