33 * SPDX-License-Identifier: GPL-2.0-only */
44package de .uka .ilkd .key .settings ;
55
6+ import de .uka .ilkd .key .util .KeYResourceManager ;
7+ import org .antlr .v4 .runtime .CharStreams ;
8+ import org .slf4j .Logger ;
9+ import org .slf4j .LoggerFactory ;
10+
611import java .beans .PropertyChangeListener ;
712import java .io .*;
813import java .net .URL ;
1116import java .util .List ;
1217import java .util .Properties ;
1318
14- import de .uka .ilkd .key .util .KeYResourceManager ;
15-
16- import org .antlr .v4 .runtime .CharStreams ;
17- import org .slf4j .Logger ;
18- import org .slf4j .LoggerFactory ;
19-
2019/// This class is used to load and save settings for proofs such as which data type models are used
2120/// to represent the java types.
2221/// Which heuristics have to be loaded and so on?
3029/// MaximumNumberOfHeuristcsApplications=400
3130/// number = "IntegerLDT.class"
3231/// boolean = "BooleanLDT.class"
33- /// ```
32+ ///```
3433///
3534/// @see Properties
3635/// @see Settings
3736public class ProofSettings {
3837 private static final Logger LOGGER = LoggerFactory .getLogger (ProofSettings .class );
3938
4039 public static final File PROVER_CONFIG_FILE =
41- new File (PathConfig .getKeyConfigDir (), "proof-settings.props" );
42-
43- public static final File PROVER_CONFIG_FILE_NEW =
44- new File (PathConfig .getKeyConfigDir (), "proof-settings.json" );
40+ new File (PathConfig .getKeyConfigDir (), "proof-settings.json" );
4541
4642 public static final URL PROVER_CONFIG_FILE_TEMPLATE = KeYResourceManager .getManager ()
4743 .getResourceFile (ProofSettings .class , "default-proof-settings.json" );
@@ -68,7 +64,7 @@ private static ProofSettings loadedSettings() {
6864 private final StrategySettings strategySettings = new StrategySettings ();
6965 private final ChoiceSettings choiceSettings = new ChoiceSettings ();
7066 private final ProofDependentSMTSettings smtSettings =
71- ProofDependentSMTSettings .getDefaultSettingsData ();
67+ ProofDependentSMTSettings .getDefaultSettingsData ();
7268 private final NewSMTTranslationSettings newSMTSettings = new NewSMTTranslationSettings ();
7369 private final TermLabelSettings termLabelSettings = new TermLabelSettings ();
7470
@@ -142,9 +138,11 @@ public void settingsToStream(Writer out) {
142138 */
143139 public void saveSettings () {
144140 try {
145- try (Writer out = new BufferedWriter (
146- new FileWriter (PROVER_CONFIG_FILE_NEW , StandardCharsets .UTF_8 ))) {
147- settingsToStream (out );
141+ if (PROVER_CONFIG_FILE .getParentFile ().mkdirs ()) {
142+ try (Writer out = new BufferedWriter (
143+ new FileWriter (PROVER_CONFIG_FILE , StandardCharsets .UTF_8 ))) {
144+ settingsToStream (out );
145+ }
148146 }
149147 } catch (IOException e ) {
150148 LOGGER .warn ("Could not save proof-settings." , e );
@@ -165,7 +163,7 @@ public void loadSettingsFromJSONStream(Reader in) throws IOException {
165163 public void loadDefaultJSONSettings () {
166164 if (PROVER_CONFIG_FILE_TEMPLATE == null ) {
167165 LOGGER .warn (
168- "default proof-settings file 'default-proof-settings.json' could not be found." );
166+ "default proof-settings file 'default-proof-settings.json' could not be found." );
169167 } else {
170168 try (var in = new InputStreamReader (PROVER_CONFIG_FILE_TEMPLATE .openStream ())) {
171169 loadSettingsFromJSONStream (in );
@@ -182,7 +180,7 @@ public void loadSettings() {
182180 if (Boolean .getBoolean (PathConfig .DISREGARD_SETTINGS_PROPERTY )) {
183181 LOGGER .warn ("The settings in {} are *not* read." , PROVER_CONFIG_FILE );
184182 } else {
185- var fileToUse = PROVER_CONFIG_FILE_NEW ;
183+ var fileToUse = PROVER_CONFIG_FILE ;
186184 try (var in = new BufferedReader (new FileReader (fileToUse , StandardCharsets .UTF_8 ))) {
187185 LOGGER .info ("Load proof dependent settings from file {}" , fileToUse );
188186 loadDefaultJSONSettings ();
0 commit comments