88import de .uka .ilkd .key .java .Services ;
99import de .uka .ilkd .key .logic .*;
1010import de .uka .ilkd .key .logic .label .FormulaTermLabel ;
11+ import de .uka .ilkd .key .logic .label .LabelCollection ;
1112import de .uka .ilkd .key .logic .label .TermLabel ;
1213import de .uka .ilkd .key .logic .label .TermLabelState ;
1314import de .uka .ilkd .key .proof .Goal ;
2829 */
2930public 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