Skip to content

Commit e679a17

Browse files
committed
compute a proper problem header including also the taclets
1 parent cacb625 commit e679a17

5 files changed

Lines changed: 46 additions & 17 deletions

File tree

key.core/src/main/java/de/uka/ilkd/key/proof/init/AbstractPO.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,7 @@ public final String name() {
378378
/**
379379
* Creates declarations necessary to save/load proof in textual form (helper for createProof()).
380380
*/
381-
private void createProofHeader(
382-
JavaModel model, Services services) {
383-
381+
private void createProofHeader(JavaModel model, Services services) {
384382
if (header != null) {
385383
return;
386384
}
@@ -418,8 +416,7 @@ protected Proof createProof(String proofName, JTerm poTerm, InitConfig proofConf
418416
if (proofConfig == null) {
419417
proofConfig = environmentConfig.deepCopy();
420418
}
421-
final JavaModel javaModel = proofConfig.getServices().getJavaModel();
422-
createProofHeader(javaModel, proofConfig.getServices());
419+
header = proofConfig.getProblemHeader();
423420

424421
final Proof proof = createProofObject(proofName, header, poTerm, proofConfig);
425422

key.core/src/main/java/de/uka/ilkd/key/proof/init/InitConfig.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.key_project.util.collection.ImmutableSet;
3535

3636
import org.jspecify.annotations.NonNull;
37+
import org.jspecify.annotations.Nullable;
3738

3839
/**
3940
* an instance of this class describes the initial configuration of the prover. This includes sorts,
@@ -79,10 +80,12 @@ public class InitConfig {
7980
/** the fileRepo which is responsible for consistency between source code and proof */
8081
private FileRepo fileRepo;
8182

83+
// weigl this field is never set
8284
private String originalKeYFileName;
8385

8486
private ProofSettings settings;
8587

88+
private @Nullable String header;
8689

8790

8891
// -------------------------------------------------------------------------
@@ -437,6 +440,7 @@ public InitConfig copyWithServices(Services services) {
437440
(HashMap<Taclet, TacletBuilder<? extends Taclet>>) taclet2Builder.clone());
438441
ic.taclets = taclets;
439442
ic.originalKeYFileName = originalKeYFileName;
443+
ic.header = header;
440444
ic.justifInfo = justifInfo.copy();
441445
ic.fileRepo = fileRepo; // TODO: copy instead? delete via dispose method?
442446
return ic;
@@ -466,4 +470,12 @@ public void activateChoice(Choice choice) {
466470
.collect(ImmutableSet.collector())
467471
.add(choice));
468472
}
473+
474+
public @Nullable String getProblemHeader() {
475+
return header;
476+
}
477+
478+
public void setHeader(@Nullable String header) {
479+
this.header = header;
480+
}
469481
}

key.core/src/main/java/de/uka/ilkd/key/proof/init/KeYUserProblemFile.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ private Profile readProfileFromFile() {
254254
}
255255
}
256256

257+
258+
///
259+
public @Nullable String getProblemHeader() {
260+
return getParseContext().getProblemHeader();
261+
}
262+
257263
/**
258264
* Returns the default {@link Profile} which was defined by a constructor.
259265
*

key.core/src/main/java/de/uka/ilkd/key/proof/init/ProblemInitializer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@ public InitConfig prepare(EnvInput envInput) throws ProofInputException {
459459
if (Debug.ENABLE_DEBUG) {
460460
print(ic);
461461
}
462+
463+
if (envInput instanceof KeYUserProblemFile uf) {
464+
ic.setHeader(uf.getProblemHeader());
465+
}
466+
462467
return ic;
463468
}
464469
}

key.core/src/main/java/de/uka/ilkd/key/proof/io/OutputStreamProofSaver.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import de.uka.ilkd.key.proof.Node;
2222
import de.uka.ilkd.key.proof.Proof;
2323
import de.uka.ilkd.key.proof.init.IPersistablePO;
24+
import de.uka.ilkd.key.proof.init.KeYUserProblemFile;
2425
import de.uka.ilkd.key.proof.init.Profile;
2526
import de.uka.ilkd.key.proof.init.ProofOblInput;
2627
import de.uka.ilkd.key.proof.io.IProofFileParser.ProofElementID;
@@ -230,18 +231,26 @@ public void save(OutputStream out) throws IOException {
230231
}
231232
}
232233

233-
/**
234-
* Searches in the header for absolute paths to Java files and tries to replace them by paths
235-
* relative to the proof file to be saved.
236-
*
237-
* TODO weigl: if someone finds time, this function is a string manipulation mess.
238-
* You should rather parse the header using the {@link de.uka.ilkd.key.nparser.ParsingFacade}
239-
* and
240-
* use the {@link de.uka.ilkd.key.nparser.builder.ProblemFinder} to extract the field.
241-
*
242-
* Better would be to get rid of the header, and using an AST.
243-
*/
244-
private String makePathsRelative(String header) {
234+
/// Searches in the header for absolute paths to Java files and tries to replace them by paths
235+
/// relative to the proof file to be saved.
236+
/// If the given `header` is null, an empty string is returned. This is the case for proofs,
237+
/// that are non-KeY-file not crated by KeY-files.
238+
///
239+
/// @param header a string created a proper KeY-file content.
240+
///
241+
///
242+
/// TODO weigl: If someone finds time, this function is a string manipulation mess.
243+
/// You should rather parse the header using the [de.uka.ilkd.key.nparser.ParsingFacade]
244+
/// and use the [de.uka.ilkd.key.nparser.builder.ProblemFinder] to extract the field.
245+
/// Better would be to get rid of the header, and using an AST.
246+
///
247+
///
248+
/// @see KeYUserProblemFile#getProblemHeader()
249+
/// @see de.uka.ilkd.key.proof.init.InitConfig#getProblemHeader()
250+
private String makePathsRelative(@Nullable String header) {
251+
if (header == null) {
252+
return "";
253+
}
245254
final String[] search =
246255
{ "\\javaSource", "\\bootclasspath", "\\classpath", "\\include" };
247256
final String basePath;

0 commit comments

Comments
 (0)