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

Formatter #3034

Merged
merged 39 commits into from Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
581b171
Remove WriterBackend, remove lots of impossible IOExceptions
jwiesler Feb 10, 2023
50a41d5
Fix lots of warnings and remove dead code
jwiesler Feb 10, 2023
f6aeafd
Fix lots of warnings and remove dead code
jwiesler Feb 10, 2023
e56336f
Remove a quadrillion IOExceptions
jwiesler Feb 10, 2023
1de53aa
Remove ProgramPrinter from interface, it's always overwritten
jwiesler Feb 11, 2023
59af75e
Code cleanup
jwiesler Feb 11, 2023
f1652de
Code cleanup
jwiesler Feb 11, 2023
11eb9e8
Make layouter mark type generic
jwiesler Feb 11, 2023
c262499
Constant createPositionTable=true
jwiesler Feb 11, 2023
bda7364
Minor refactoring
jwiesler Feb 11, 2023
570ce32
Refactor line width from backend
jwiesler Feb 13, 2023
19d3f58
Make Printer api more explicit
jwiesler Feb 13, 2023
d7bc5aa
Remove line break from gui output
jwiesler Feb 13, 2023
08b5968
New pretty printer on top of visitor
jwiesler Feb 13, 2023
1ebc542
Relative blocks and remove linked list usages
jwiesler Feb 16, 2023
7d8a191
Better multi line splitting
jwiesler Feb 16, 2023
6802675
Bring internal taclet printer to same format as key file formatter, f…
jwiesler Feb 20, 2023
b4492b8
Add warning when loop invariant is missing decreases clause
jwiesler Feb 20, 2023
a546e25
Fix smt beautifier test on Windows
jwiesler Feb 21, 2023
dfb95da
Remove colon from method frame
jwiesler Feb 21, 2023
47523f4
Fix parsing issues with method-frame
jwiesler Feb 21, 2023
7be3279
Remove newlines
jwiesler Feb 21, 2023
a513cc2
Deprecate old pretty printer
jwiesler Feb 21, 2023
2aa9992
Remove some missed colons
jwiesler Feb 22, 2023
1f5e1ba
Fix proof management dialog double click like the examples dialog
jwiesler Feb 22, 2023
b91db65
Delete old pretty printer
jwiesler Feb 23, 2023
fba4380
Fix tests
jwiesler Feb 23, 2023
d7b561f
Fix more tests
jwiesler Feb 23, 2023
18a1fdf
Fix loop specs being lost without decreases
jwiesler Feb 23, 2023
b5fe5e2
Use Java apis instead of CollectionUtil
jwiesler Feb 23, 2023
51e8d5b
Taclet equality oracle and fix transformers pretty printing
jwiesler Feb 23, 2023
e77d304
Spotless
jwiesler Feb 23, 2023
30b6f65
Fix colleciton util tests
jwiesler Feb 23, 2023
2273934
Minor interface refactoring
jwiesler Mar 6, 2023
0994514
Minor interface refactoring
jwiesler Mar 7, 2023
3933309
Cache sequent printing
jwiesler Mar 8, 2023
bf29a96
Fix bookmarks parsing and save recent files immediately
jwiesler Mar 8, 2023
51a136c
Fix small issue
jwiesler Mar 9, 2023
913f357
Merge branch 'main' into formatter
jwiesler Mar 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,5 +1,7 @@
package de.uka.ilkd.key.rule.label;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

Expand Down Expand Up @@ -27,10 +29,9 @@ public boolean mergeLabels(SequentFormula existingSF, Term existingTerm,
FormulaTermLabel fExisting = (FormulaTermLabel) existingLabel;
FormulaTermLabel fRejected = (FormulaTermLabel) rejectedLabel;
// Compute new label
List<String> newBeforeIds = new LinkedList<String>();
CollectionUtil.addAll(newBeforeIds, fExisting.getBeforeIds());
CollectionUtil.addAll(newBeforeIds, fRejected.getId());
CollectionUtil.addAll(newBeforeIds, fRejected.getBeforeIds());
List<String> newBeforeIds = new ArrayList<>(Arrays.asList(fExisting.getBeforeIds()));
newBeforeIds.add(fRejected.getId());
newBeforeIds.addAll(Arrays.asList(fRejected.getBeforeIds()));
FormulaTermLabel newLabel =
new FormulaTermLabel(fExisting.getMajorId(), fExisting.getMinorId(), newBeforeIds);
// Remove existing label
Expand Down
@@ -1,11 +1,6 @@
package de.uka.ilkd.key.rule.label;

import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;

import org.key_project.util.collection.ImmutableList;
import org.key_project.util.java.CollectionUtil;
Expand Down Expand Up @@ -233,8 +228,8 @@ protected void refactorBewlowUpdates(PosInOccurrence applicationPosInOccurrence,
labels.add(applicationLabel);
} else {
labels.remove(termLabel);
Set<String> beforeIds = new LinkedHashSet<String>();
CollectionUtil.addAll(beforeIds, termLabel.getBeforeIds());
Set<String> beforeIds =
new LinkedHashSet<>(Arrays.asList(termLabel.getBeforeIds()));
beforeIds.add(applicationLabel.getId());
labels.add(new FormulaTermLabel(termLabel.getMajorId(), termLabel.getMinorId(),
beforeIds));
Expand Down Expand Up @@ -288,8 +283,8 @@ protected void refactorSubstitution(Term term, Term tacletTerm, List<TermLabel>
if (existingLabel == null) {
labels.add(tacletLabel);
} else {
List<String> beforeIds = new LinkedList<String>();
CollectionUtil.addAll(beforeIds, existingLabel.getBeforeIds());
List<String> beforeIds =
new ArrayList<>(Arrays.asList(existingLabel.getBeforeIds()));
boolean changed = true;
if (!beforeIds.contains(tacletLabel.getId())) {
changed = true;
Expand Down
@@ -1,9 +1,6 @@
package de.uka.ilkd.key.symbolic_execution.model.impl;

import java.io.IOException;
import java.io.StringWriter;

import de.uka.ilkd.key.java.PrettyPrinter;
import de.uka.ilkd.key.pp.PrettyPrinter;
import de.uka.ilkd.key.java.statement.BranchStatement;
import de.uka.ilkd.key.java.statement.If;
import de.uka.ilkd.key.java.statement.Switch;
Expand Down Expand Up @@ -38,21 +35,15 @@ public ExecutionBranchStatement(ITreeSettings settings, Node proofNode) {
@Override
protected String lazyComputeName() {
BranchStatement bs = getActiveStatement();
try {
if (bs instanceof If) {
StringWriter sw = new StringWriter();
PrettyPrinter sb = new PrettyPrinter(sw, true);
sb.printIf((If) bs, false);
return sw.toString();
} else if (bs instanceof Switch) {
StringWriter sw = new StringWriter();
PrettyPrinter sb = new PrettyPrinter(sw, true);
sb.printSwitch((Switch) bs, false);
return sw.toString();
} else {
return bs.toString();
}
} catch (IOException e) {
if (bs instanceof If) {
PrettyPrinter p = PrettyPrinter.purePrinter();
p.performActionOnIf((If) bs, false);
return p.result();
} else if (bs instanceof Switch) {
PrettyPrinter p = PrettyPrinter.purePrinter();
p.performActionOnSwitch((Switch) bs, false);
return p.result();
} else {
return bs.toString();
}
}
Expand Down
@@ -1,14 +1,7 @@
package de.uka.ilkd.key.symbolic_execution.model.impl;

import java.io.IOException;
import java.io.StringWriter;

import de.uka.ilkd.key.java.PrettyPrinter;
import de.uka.ilkd.key.java.statement.Do;
import de.uka.ilkd.key.java.statement.EnhancedFor;
import de.uka.ilkd.key.java.statement.For;
import de.uka.ilkd.key.java.statement.LoopStatement;
import de.uka.ilkd.key.java.statement.While;
import de.uka.ilkd.key.pp.PrettyPrinter;
import de.uka.ilkd.key.java.statement.*;
import de.uka.ilkd.key.proof.Node;
import de.uka.ilkd.key.symbolic_execution.model.IExecutionConstraint;
import de.uka.ilkd.key.symbolic_execution.model.IExecutionLoopStatement;
Expand Down Expand Up @@ -40,35 +33,27 @@ public ExecutionLoopStatement(ITreeSettings settings, Node proofNode) {
@Override
protected String lazyComputeName() {
LoopStatement ls = getActiveStatement();
try {
if (ls.getGuardExpression() != null) {
if (ls instanceof While) {
StringWriter sw = new StringWriter();
PrettyPrinter sb = new PrettyPrinter(sw, true);
sb.printWhile((While) ls, false);
return sw.toString();
} else if (ls instanceof For) {
StringWriter sw = new StringWriter();
PrettyPrinter sb = new PrettyPrinter(sw, true);
sb.printFor((For) ls, false);
return sw.toString();
} else if (ls instanceof EnhancedFor) {
StringWriter sw = new StringWriter();
PrettyPrinter sb = new PrettyPrinter(sw, true);
sb.printEnhancedFor((EnhancedFor) ls, false);
return sw.toString();
} else if (ls instanceof Do) {
StringWriter sw = new StringWriter();
PrettyPrinter sb = new PrettyPrinter(sw, true);
sb.printDo((Do) ls, false);
return sw.toString();
} else {
return ls.toString();
}
if (ls.getGuardExpression() != null) {
if (ls instanceof While) {
PrettyPrinter p = PrettyPrinter.purePrinter();
p.performActionOnWhile((While) ls, false);
return p.result();
} else if (ls instanceof For) {
PrettyPrinter p = PrettyPrinter.purePrinter();
p.performActionOnFor((For) ls, false);
return p.result();
} else if (ls instanceof EnhancedFor) {
PrettyPrinter p = PrettyPrinter.purePrinter();
p.performActionOnEnhancedFor((EnhancedFor) ls, false);
return p.result();
} else if (ls instanceof Do) {
PrettyPrinter p = PrettyPrinter.purePrinter();
p.performActionOnDo((Do) ls, false);
return p.result();
} else {
return ls.toString();
}
} catch (IOException e) {
} else {
return ls.toString();
}
}
Expand Down
@@ -1,23 +1,6 @@
package de.uka.ilkd.key.symbolic_execution.po;

import java.io.IOException;
import java.io.StringWriter;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import de.uka.ilkd.key.speclang.jml.translation.Context;
import de.uka.ilkd.key.speclang.njml.JmlIO;
import org.key_project.util.collection.ImmutableArray;
import org.key_project.util.collection.ImmutableList;
import org.key_project.util.collection.ImmutableSLList;
import org.key_project.util.java.ObjectUtil;

import de.uka.ilkd.key.java.Expression;
import de.uka.ilkd.key.java.JavaInfo;
import de.uka.ilkd.key.java.PrettyPrinter;
import de.uka.ilkd.key.java.Services;
import de.uka.ilkd.key.java.StatementBlock;
import de.uka.ilkd.key.java.*;
import de.uka.ilkd.key.java.abstraction.KeYJavaType;
import de.uka.ilkd.key.java.statement.MethodBodyStatement;
import de.uka.ilkd.key.logic.Sequent;
Expand All @@ -27,9 +10,22 @@
import de.uka.ilkd.key.logic.op.LocationVariable;
import de.uka.ilkd.key.logic.op.Modality;
import de.uka.ilkd.key.logic.op.ProgramVariable;
import de.uka.ilkd.key.pp.PosTableLayouter;
import de.uka.ilkd.key.pp.PrettyPrinter;
import de.uka.ilkd.key.proof.init.AbstractOperationPO;
import de.uka.ilkd.key.proof.init.InitConfig;
import de.uka.ilkd.key.speclang.PositionedString;
import de.uka.ilkd.key.speclang.jml.translation.Context;
import de.uka.ilkd.key.speclang.njml.JmlIO;
import org.key_project.util.collection.ImmutableArray;
import org.key_project.util.collection.ImmutableList;
import org.key_project.util.collection.ImmutableSLList;
import org.key_project.util.java.ObjectUtil;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Properties;

/**
* <p>
Expand Down Expand Up @@ -258,7 +254,7 @@ public String getPrecondition() {
* {@inheritDoc}
*/
@Override
public void fillSaveProperties(Properties properties) throws IOException {
public void fillSaveProperties(Properties properties) {
super.fillSaveProperties(properties);
properties.setProperty("method", getProgramMethodSignature(getProgramMethod(), true));
if (getPrecondition() != null && !getPrecondition().isEmpty()) {
Expand All @@ -267,28 +263,24 @@ public void fillSaveProperties(Properties properties) throws IOException {
}

/**
* Returns a human readable full qualified method signature.
* Returns a human-readable full qualified method signature.
*
* @param pm The {@link IProgramMethod} which provides the signature.
* @param includeType Include the container type?
* @return The human readable method signature.
* @throws IOException Occurred Exception.
* @return The human-readable method signature.
*/
public static String getProgramMethodSignature(IProgramMethod pm, boolean includeType)
throws IOException {
StringWriter sw = new StringWriter();
try {
PrettyPrinter x = new PrettyPrinter(sw);
if (includeType) {
KeYJavaType type = pm.getContainerType();
sw.append(type.getFullName());
sw.append("#");
}
x.printFullMethodSignature(pm);
return sw.toString();
} finally {
sw.close();
public static String getProgramMethodSignature(IProgramMethod pm, boolean includeType) {
PosTableLayouter l = PosTableLayouter.pure();
l.beginC(0);
if (includeType) {
KeYJavaType type = pm.getContainerType();
l.print(type.getFullName());
l.print("#");
}
PrettyPrinter x = new PrettyPrinter(l);
x.writeFullMethodSignature(pm);
l.end();
return x.result();
}

/**
Expand Down
@@ -1,22 +1,6 @@
package de.uka.ilkd.key.symbolic_execution.po;

import java.io.IOException;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import org.key_project.util.collection.ImmutableList;
import org.key_project.util.collection.ImmutableSLList;
import org.key_project.util.java.ObjectUtil;

import de.uka.ilkd.key.java.Position;
import de.uka.ilkd.key.java.Services;
import de.uka.ilkd.key.java.Statement;
import de.uka.ilkd.key.java.StatementBlock;
import de.uka.ilkd.key.java.StatementContainer;
import de.uka.ilkd.key.java.*;
import de.uka.ilkd.key.java.abstraction.KeYJavaType;
import de.uka.ilkd.key.java.reference.ExecutionContext;
import de.uka.ilkd.key.java.reference.TypeRef;
Expand All @@ -32,6 +16,12 @@
import de.uka.ilkd.key.logic.op.LocationVariable;
import de.uka.ilkd.key.logic.op.ProgramVariable;
import de.uka.ilkd.key.proof.init.InitConfig;
import org.key_project.util.collection.ImmutableList;
import org.key_project.util.collection.ImmutableSLList;
import org.key_project.util.java.ObjectUtil;

import java.io.IOException;
import java.util.*;

/**
* <p>
Expand Down Expand Up @@ -305,7 +295,7 @@ public Position getEndPosition() {
* {@inheritDoc}
*/
@Override
public void fillSaveProperties(Properties properties) throws IOException {
public void fillSaveProperties(Properties properties) {
super.fillSaveProperties(properties);
if (getStartPosition() != null) {
properties.setProperty("startLine", getStartPosition().getLine() + "");
Expand Down