Skip to content

Commit d1a22ba

Browse files
committed
fix error that key-settings folder are not created
1 parent 88ffb5f commit d1a22ba

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

key.core/src/main/java/de/uka/ilkd/key/settings/ProofSettings.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
* SPDX-License-Identifier: GPL-2.0-only */
44
package 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+
611
import java.beans.PropertyChangeListener;
712
import java.io.*;
813
import java.net.URL;
@@ -11,12 +16,6 @@
1116
import java.util.List;
1217
import 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?
@@ -30,18 +29,15 @@
3029
/// MaximumNumberOfHeuristcsApplications=400
3130
/// number = "IntegerLDT.class"
3231
/// boolean = "BooleanLDT.class"
33-
/// ```
32+
///```
3433
///
3534
/// @see Properties
3635
/// @see Settings
3736
public 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

Comments
 (0)