Skip to content

Commit eebe397

Browse files
committed
Merge branch 'main' into weigl/jsonrpc
* main: (68 commits) fix classcastexception in logic printer Spotless changes Slight change to tooltip text. heap indication (logging and status line) replace JSR305 annotations with JSpecify Added forgotten test for getFirst Remaned methods to better reflect their intention Fix bug in refectoring retrieval Add comments and test for LabelCollection Clean up spotless changes and some typo corrections clean up Some additional optimisations Optimized TermLabel processing using a linked hash set for common operations instead of a list Refactorings container can use mutable linked sets Optimize offline dependency tracker and add tests IdentityHashSet collection class Contract creation should use correct OriginLabel settings Minor polishing Simplify TermLabelManager API ... # Conflicts: # key.core/src/main/java/de/uka/ilkd/key/proof/Node.java # key.ui/src/main/java/de/uka/ilkd/key/gui/actions/RunAllProofsAction.java
2 parents 7894006 + b482f34 commit eebe397

348 files changed

Lines changed: 3182 additions & 2489 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ subprojects {
5757
group = rootProject.group
5858
version = rootProject.version
5959

60-
sourceCompatibility = 17
61-
targetCompatibility = 17
60+
java {
61+
sourceCompatibility = 17
62+
targetCompatibility = 17
63+
}
6264

6365
repositories {
6466
mavenCentral()
@@ -69,20 +71,17 @@ subprojects {
6971

7072
dependencies {
7173
implementation("org.slf4j:slf4j-api:2.0.9")
72-
testImplementation("ch.qos.logback:logback-classic:1.4.11")
73-
74-
//compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.12.0'
75-
//compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.12.0'
76-
implementation 'com.google.code.findbugs:jsr305:3.0.2'
7774

75+
testImplementation("ch.qos.logback:logback-classic:1.4.11")
7876
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
7977
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.0'
78+
testImplementation project(':key.util')
79+
8080
testCompileOnly 'junit:junit:4.13.2'
8181
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.10.0'
8282
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
8383

84-
85-
testImplementation project(':key.util')
84+
implementation("org.jspecify:jspecify:0.3.0")
8685
}
8786

8887
tasks.withType(JavaCompile) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

key.core.proof_references/src/main/java/de/uka/ilkd/key/proof_references/reference/DefaultProofReference.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import de.uka.ilkd.key.proof.Node;
1111
import de.uka.ilkd.key.proof.Proof;
1212

13+
import org.key_project.util.Strings;
14+
1315
/**
1416
* Default implementation of {@link IProofReference}.
1517
*
@@ -40,7 +42,7 @@ public class DefaultProofReference<T> implements IProofReference<T> {
4042
* Constructor
4143
*
4244
* @param kind The reference kind as human readable {@link String}.
43-
* @param source The source {@link Proof}.
45+
* @param node Node to access the source {@link Proof} (or null).
4446
* @param target The target source member.
4547
*/
4648
public DefaultProofReference(String kind, Node node, T target) {
@@ -128,15 +130,7 @@ public String toString() {
128130
sb.append("\"");
129131
if (!getNodes().isEmpty()) {
130132
sb.append(" at node(s) ");
131-
boolean afterFirst = false;
132-
for (Node node : getNodes()) {
133-
if (afterFirst) {
134-
sb.append(", ");
135-
} else {
136-
afterFirst = true;
137-
}
138-
sb.append(node.serialNr());
139-
}
133+
sb.append(Strings.formatAsList(getNodes(), "", ", ", "", Node::serialNr));
140134
}
141135
if (getSource() != null) {
142136
sb.append(" of proof \"");

key.core.rifl/src/main/java/de/uka/ilkd/key/util/rifl/RIFLTransformer.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
import recoder.java.JavaProgramFactory;
2727
import recoder.java.declaration.ClassDeclaration;
2828
import recoder.java.declaration.MethodDeclaration;
29-
import recoder.java.declaration.ParameterDeclaration;
29+
30+
import static org.key_project.util.Strings.*;
3031

3132
/**
3233
* Facet class for interpreting RIFL specifications. The Requirements for Information Flow Language
@@ -194,16 +195,8 @@ public void doTransform(final File riflFilename, final File source, final File s
194195

195196
ClassDeclaration clazz = (ClassDeclaration) cu.getPrimaryTypeDeclaration();
196197
for (MethodDeclaration mdecl : si.getSpecifiedMethodDeclarations()) {
197-
198-
199-
StringBuilder sb = new StringBuilder();
200-
for (ParameterDeclaration p : mdecl.getParameters()) {
201-
sb.append(p.getTypeReference().getName());
202-
sb.append(",");
203-
}
204-
if (sb.length() > 0) {
205-
sb.deleteCharAt(sb.length() - 1);
206-
}
198+
final StringBuilder sb = new StringBuilder();
199+
sb.append(formatAsList(mdecl.getParameters(), "", ",", ""));
207200

208201
String poname = clazz.getFullName() + "[" + clazz.getFullName() + "\\\\:\\\\:"
209202
+ mdecl.getName() + "(" + sb + ")" + "]" + ".Non-interference contract.0";

key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/BlockContractValidityTermLabelUpdate.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,18 @@
66
import java.util.Set;
77

88
import de.uka.ilkd.key.java.Services;
9-
import de.uka.ilkd.key.logic.JavaBlock;
109
import de.uka.ilkd.key.logic.Name;
1110
import de.uka.ilkd.key.logic.PosInOccurrence;
1211
import de.uka.ilkd.key.logic.Term;
1312
import de.uka.ilkd.key.logic.label.BlockContractValidityTermLabel;
1413
import de.uka.ilkd.key.logic.label.TermLabel;
1514
import de.uka.ilkd.key.logic.label.TermLabelState;
16-
import de.uka.ilkd.key.logic.op.Operator;
17-
import de.uka.ilkd.key.logic.op.QuantifiableVariable;
1815
import de.uka.ilkd.key.rule.BlockContractInternalRule;
1916
import de.uka.ilkd.key.rule.LoopContractInternalRule;
2017
import de.uka.ilkd.key.rule.Rule;
2118
import de.uka.ilkd.key.rule.RuleApp;
2219
import de.uka.ilkd.key.symbolic_execution.util.SymbolicExecutionUtil;
2320

24-
import org.key_project.util.collection.ImmutableArray;
2521
import org.key_project.util.collection.ImmutableList;
2622
import org.key_project.util.collection.ImmutableSLList;
2723
import org.key_project.util.java.CollectionUtil;
@@ -47,9 +43,8 @@ public ImmutableList<Name> getSupportedRuleNames() {
4743
@Override
4844
public void updateLabels(TermLabelState state, Services services,
4945
PosInOccurrence applicationPosInOccurrence, Term applicationTerm, Term modalityTerm,
50-
Rule rule, RuleApp ruleApp, Object hint, Term tacletTerm, Operator newTermOp,
51-
ImmutableArray<Term> newTermSubs, ImmutableArray<QuantifiableVariable> newTermBoundVars,
52-
JavaBlock newTermJavaBlock, Set<TermLabel> labels) {
46+
Rule rule, RuleApp ruleApp, Object hint, Term tacletTerm, Term newTerm,
47+
Set<TermLabel> labels) {
5348
if ((rule instanceof BlockContractInternalRule || rule instanceof LoopContractInternalRule)
5449
&& ((BlockContractInternalRule.BlockContractHint) hint)
5550
.getExceptionalVariable() != null

key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/FormulaTermLabelRefactoring.java

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import de.uka.ilkd.key.java.Services;
99
import de.uka.ilkd.key.logic.*;
1010
import de.uka.ilkd.key.logic.label.FormulaTermLabel;
11+
import de.uka.ilkd.key.logic.label.LabelCollection;
1112
import de.uka.ilkd.key.logic.label.TermLabel;
1213
import de.uka.ilkd.key.logic.label.TermLabelState;
1314
import de.uka.ilkd.key.proof.Goal;
@@ -28,7 +29,7 @@
2829
*/
2930
public class FormulaTermLabelRefactoring implements TermLabelRefactoring {
3031
/**
31-
* Key prefix used in {@link TermLabelState} to store that the inner most label was already
32+
* Key prefix used in {@link TermLabelState} to store that the innermost label was already
3233
* refactored on a given {@link Goal}.
3334
*/
3435
private static final String INNER_MOST_PARENT_REFACTORED_PREFIX =
@@ -37,7 +38,8 @@ public class FormulaTermLabelRefactoring implements TermLabelRefactoring {
3738
/**
3839
* Key used in {@link TermLabelState} by the {@link StayOnOperatorTermLabelPolicy} to indicate
3940
* that a refactoring below an update ({@link RefactoringScope#APPLICATION_BELOW_UPDATES}) is
40-
* required performed by {@link #refactorBewlowUpdates(PosInOccurrence, Term, List)}.
41+
* required, which will be performed by
42+
* {@link #refactorBelowUpdates(PosInOccurrence, Term, LabelCollection)}.
4143
* <p>
4244
* This is for instance required for the following rules:
4345
* <ul>
@@ -61,14 +63,14 @@ public class FormulaTermLabelRefactoring implements TermLabelRefactoring {
6163
* <li>{@code concrete_or_4}</li>
6264
* </ul>
6365
*/
64-
private static final String UPDATE_REFACTORING_REQUIRED = "updateRefactroingRequired";
66+
private static final String UPDATE_REFACTORING_REQUIRED = "updateRefactoringRequired";
6567

6668
/**
6769
* Key used in {@link TermLabelState} by the {@link FormulaTermLabelUpdate} to indicate that a
6870
* refactoring of parents
6971
* ({@link RefactoringScope#APPLICATION_CHILDREN_AND_GRANDCHILDREN_SUBTREE_AND_PARENTS}) is
70-
* required performed by
71-
* {@link #refactorInCaseOfNewIdRequired(TermLabelState, Goal, Term, Services, List)}.
72+
* required, which will be performed by
73+
* {@link #refactorInCaseOfNewIdRequired(TermLabelState, Goal, Term, Services, LabelCollection)}.
7274
* <p>
7375
* This is for instance required if a rule is applied on a sub term without a
7476
* {@link FormulaTermLabel} of a parent which has a {@link FormulaTermLabel}. Example rules are:
@@ -82,7 +84,8 @@ public class FormulaTermLabelRefactoring implements TermLabelRefactoring {
8284
/**
8385
* Key used in {@link TermLabelState} by the {@link FormulaTermLabelUpdate} to indicate that a
8486
* refactoring of specified {@link SequentFormula}s ({@link RefactoringScope#SEQUENT}) is
85-
* required performed by {@link #refactorSequentFormulas(TermLabelState, Services, Term, List)}.
87+
* required, which will be performed by
88+
* {@link #refactorSequentFormulas(TermLabelState, Services, Term, LabelCollection)}.
8689
* <p>
8790
* This is for instance required if the assumes clause of a rule has a {@link FormulaTermLabel}
8891
* but the application does not have it. Example rules are:
@@ -110,9 +113,9 @@ public RefactoringScope defineRefactoringScope(TermLabelState state, Services se
110113
Object hint, Term tacletTerm) {
111114
if (shouldRefactorSpecificationApplication(rule, goal, hint)) {
112115
return RefactoringScope.APPLICATION_CHILDREN_AND_GRANDCHILDREN_SUBTREE;
113-
} else if (isParentRefactroingRequired(state)) {
116+
} else if (isParentRefactoringRequired(state)) {
114117
return RefactoringScope.APPLICATION_CHILDREN_AND_GRANDCHILDREN_SUBTREE_AND_PARENTS;
115-
} else if (isUpdateRefactroingRequired(state)) {
118+
} else if (isUpdateRefactoringRequired(state)) {
116119
return RefactoringScope.APPLICATION_BELOW_UPDATES;
117120
} else if (containsSequentFormulasToRefactor(state)) {
118121
return RefactoringScope.SEQUENT;
@@ -131,7 +134,7 @@ public RefactoringScope defineRefactoringScope(TermLabelState state, Services se
131134
* @param hint The hint to check.
132135
* @return {@code true} perform refactoring, {@code false} do not perform refactoring.
133136
*/
134-
protected boolean shouldRefactorSpecificationApplication(Rule rule, Goal goal, Object hint) {
137+
private boolean shouldRefactorSpecificationApplication(Rule rule, Goal goal, Object hint) {
135138
return TermLabelRefactoring.shouldRefactorOnBuiltInRule(rule, goal, hint);
136139
}
137140

@@ -141,13 +144,13 @@ protected boolean shouldRefactorSpecificationApplication(Rule rule, Goal goal, O
141144
@Override
142145
public void refactorLabels(TermLabelState state, Services services,
143146
PosInOccurrence applicationPosInOccurrence, Term applicationTerm, Rule rule, Goal goal,
144-
Object hint, Term tacletTerm, Term term, List<TermLabel> labels) {
147+
Object hint, Term tacletTerm, Term term, LabelCollection labels) {
145148
if (shouldRefactorSpecificationApplication(rule, goal, hint)) {
146-
refactorSpecificationApplication(term, goal, services, labels, hint);
147-
} else if (isParentRefactroingRequired(state)) {
149+
refactorSpecificationApplication(term, services, labels, hint);
150+
} else if (isParentRefactoringRequired(state)) {
148151
refactorInCaseOfNewIdRequired(state, goal, term, services, labels);
149-
} else if (isUpdateRefactroingRequired(state)) {
150-
refactorBewlowUpdates(applicationPosInOccurrence, term, labels);
152+
} else if (isUpdateRefactoringRequired(state)) {
153+
refactorBelowUpdates(applicationPosInOccurrence, term, labels);
151154
} else if (containsSequentFormulasToRefactor(state)) {
152155
refactorSequentFormulas(state, services, term, labels);
153156
} else if (SyntacticalReplaceVisitor.SUBSTITUTION_WITH_LABELS_HINT.equals(hint)) {
@@ -159,13 +162,12 @@ public void refactorLabels(TermLabelState state, Services services,
159162
* Refactors a specification application.
160163
*
161164
* @param term The {@link Term} which is now refactored.
162-
* @param goal The optional {@link Goal} on which the {@link Term} to create will be used.
163165
* @param services The {@link Services} used by the {@link Proof} on which a {@link Rule} is
164166
* applied right now.
165167
* @param labels The new labels the {@link Term} will have after the refactoring.
166168
*/
167-
protected void refactorSpecificationApplication(Term term, Goal goal, Services services,
168-
List<TermLabel> labels, Object hint) {
169+
private void refactorSpecificationApplication(Term term, Services services,
170+
LabelCollection labels, Object hint) {
169171
if (TruthValueTracingUtil.isPredicate(term)
170172
|| (CloseAfterMerge.FINAL_WEAKENING_TERM_HINT.equals(hint)
171173
&& TruthValueTracingUtil.isLogicOperator(term))) {
@@ -180,7 +182,7 @@ protected void refactorSpecificationApplication(Term term, Goal goal, Services s
180182
}
181183

182184
/**
183-
* Refactors in case that the inner most label needs a new ID.
185+
* Refactors in case that the innermost label needs a new ID.
184186
*
185187
* @param state The {@link TermLabelState} of the current rule application.
186188
* @param goal The optional {@link Goal} on which the {@link Term} to create will be used.
@@ -189,8 +191,8 @@ protected void refactorSpecificationApplication(Term term, Goal goal, Services s
189191
* applied right now.
190192
* @param labels The new labels the {@link Term} will have after the refactoring.
191193
*/
192-
protected void refactorInCaseOfNewIdRequired(TermLabelState state, Goal goal, Term term,
193-
Services services, List<TermLabel> labels) {
194+
private void refactorInCaseOfNewIdRequired(TermLabelState state, Goal goal, Term term,
195+
Services services, LabelCollection labels) {
194196
if (goal != null && !isInnerMostParentRefactored(state, goal)) {
195197
TermLabel existingLabel = term.getLabel(FormulaTermLabel.NAME);
196198
if (existingLabel instanceof FormulaTermLabel pLabel) {
@@ -212,8 +214,8 @@ protected void refactorInCaseOfNewIdRequired(TermLabelState state, Goal goal, Te
212214
* @param term The {@link Term} which is now refactored.
213215
* @param labels The new labels the {@link Term} will have after the refactoring.
214216
*/
215-
protected void refactorBewlowUpdates(PosInOccurrence applicationPosInOccurrence, Term term,
216-
List<TermLabel> labels) {
217+
private void refactorBelowUpdates(PosInOccurrence applicationPosInOccurrence, Term term,
218+
LabelCollection labels) {
217219
Term applicationTerm =
218220
applicationPosInOccurrence != null ? applicationPosInOccurrence.subTerm() : null;
219221
FormulaTermLabel applicationLabel = applicationTerm != null
@@ -243,8 +245,8 @@ protected void refactorBewlowUpdates(PosInOccurrence applicationPosInOccurrence,
243245
* @param term The {@link Term} which is now refactored.
244246
* @param labels The new labels the {@link Term} will have after the refactoring.
245247
*/
246-
protected void refactorSequentFormulas(TermLabelState state, Services services, final Term term,
247-
List<TermLabel> labels) {
248+
private void refactorSequentFormulas(TermLabelState state, Services services, final Term term,
249+
LabelCollection labels) {
248250
Set<SequentFormula> sequentFormulas = getSequentFormulasToRefactor(state);
249251
if (CollectionUtil.search(sequentFormulas, element -> element.formula() == term) != null) {
250252
FormulaTermLabel termLabel = (FormulaTermLabel) term.getLabel(FormulaTermLabel.NAME);
@@ -259,14 +261,14 @@ protected void refactorSequentFormulas(TermLabelState state, Services services,
259261
}
260262

261263
/**
262-
* Refactors the given {@link Term} after a substitiution.
264+
* Refactors the given {@link Term} after a substitution.
263265
*
264266
* @param term The {@link Term} to refactor.
265267
* @param tacletTerm The taclet {@link Term} which provides additional labels to be merged with
266268
* the other {@link Term}.
267269
* @param labels The new labels the {@link Term} will have after the refactoring.
268270
*/
269-
protected void refactorSubstitution(Term term, Term tacletTerm, List<TermLabel> labels) {
271+
private void refactorSubstitution(Term term, Term tacletTerm, LabelCollection labels) {
270272
FormulaTermLabel tacletLabel =
271273
(FormulaTermLabel) tacletTerm.getLabel(FormulaTermLabel.NAME);
272274
if (tacletLabel != null) {
@@ -277,7 +279,7 @@ protected void refactorSubstitution(Term term, Term tacletTerm, List<TermLabel>
277279
} else {
278280
List<String> beforeIds =
279281
new ArrayList<>(Arrays.asList(existingLabel.getBeforeIds()));
280-
boolean changed = true;
282+
boolean changed = false;
281283
if (!beforeIds.contains(tacletLabel.getId())) {
282284
changed = true;
283285
beforeIds.add(tacletLabel.getId());
@@ -298,7 +300,7 @@ protected void refactorSubstitution(Term term, Term tacletTerm, List<TermLabel>
298300
}
299301

300302
/**
301-
* Checks if the inner most parent was already refactored on the given {@link Goal}.
303+
* Checks if the innermost parent was already refactored on the given {@link Goal}.
302304
*
303305
* @param state The {@link TermLabelState} to read from.
304306
* @param goal The {@link Goal} to check.
@@ -310,7 +312,7 @@ public static boolean isInnerMostParentRefactored(TermLabelState state, Goal goa
310312
}
311313

312314
/**
313-
* Defines if the inner most parent was already refactored on the given {@link Goal}.
315+
* Defines if the innermost parent was already refactored on the given {@link Goal}.
314316
*
315317
* @param state The {@link TermLabelState} to read from.
316318
* @param goal The {@link Goal} to check.
@@ -329,7 +331,7 @@ public static void setInnerMostParentRefactored(TermLabelState state, Goal goal,
329331
* @param state The {@link TermLabelState} to read from.
330332
* @return {@code true} refactoring required, {@code false} refactoring is not required.
331333
*/
332-
public static boolean isUpdateRefactroingRequired(TermLabelState state) {
334+
public static boolean isUpdateRefactoringRequired(TermLabelState state) {
333335
Map<Object, Object> labelState = state.getLabelState(FormulaTermLabel.NAME);
334336
Object value = labelState.get(UPDATE_REFACTORING_REQUIRED);
335337
return value instanceof Boolean && (Boolean) value;
@@ -341,7 +343,7 @@ public static boolean isUpdateRefactroingRequired(TermLabelState state) {
341343
* @param state The {@link TermLabelState} to modify.
342344
* @param required {@code true} refactoring required, {@code false} refactoring is not required.
343345
*/
344-
public static void setUpdateRefactroingRequired(TermLabelState state, boolean required) {
346+
public static void setUpdateRefactoringRequired(TermLabelState state, boolean required) {
345347
Map<Object, Object> labelState = state.getLabelState(FormulaTermLabel.NAME);
346348
labelState.put(UPDATE_REFACTORING_REQUIRED, required);
347349
}
@@ -352,7 +354,7 @@ public static void setUpdateRefactroingRequired(TermLabelState state, boolean re
352354
* @param state The {@link TermLabelState} to read from.
353355
* @return {@code true} refactoring required, {@code false} refactoring is not required.
354356
*/
355-
public static boolean isParentRefactroingRequired(TermLabelState state) {
357+
public static boolean isParentRefactoringRequired(TermLabelState state) {
356358
Map<Object, Object> labelState = state.getLabelState(FormulaTermLabel.NAME);
357359
Object value = labelState.get(PARENT_REFACTORING_REQUIRED);
358360
return value instanceof Boolean && (Boolean) value;
@@ -364,7 +366,7 @@ public static boolean isParentRefactroingRequired(TermLabelState state) {
364366
* @param state The {@link TermLabelState} to modify.
365367
* @param required {@code true} refactoring required, {@code false} refactoring is not required.
366368
*/
367-
public static void setParentRefactroingRequired(TermLabelState state, boolean required) {
369+
public static void setParentRefactoringRequired(TermLabelState state, boolean required) {
368370
Map<Object, Object> labelState = state.getLabelState(FormulaTermLabel.NAME);
369371
labelState.put(PARENT_REFACTORING_REQUIRED, required);
370372
}

0 commit comments

Comments
 (0)