Skip to content

Commit

Permalink
Overhaul of the Configuration (#3031)
Browse files Browse the repository at this point in the history
The KeY settings are in a *hysterical* and *historic* shape.

This PR tries to homogenize the settings to Java POJOs using the
JavaBeans standard and mechanism. The measurement include:

* Introduction of Getter/Setter
* Removal of `SettingsListener` in favour of `PropertyChangeListener`
  (You can listen on individual configuration changes.)

**Most of the changes** results from dependencies to the
`SettingsListener`, or the change of field-access to getter and setter.

A next PR step will change the settings language in KeY files to a
custom type-safe backward
compatible language.
  • Loading branch information
wadoon authored Apr 6, 2023
2 parents ae71749 + 6505700 commit dd62d03
Show file tree
Hide file tree
Showing 76 changed files with 916 additions and 1,112 deletions.
29 changes: 0 additions & 29 deletions .devcontainer/devcontainer.json

This file was deleted.

9 changes: 3 additions & 6 deletions key.core.example/src/main/java/org/key_project/Main.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package org.key_project;

import java.io.File;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.*;

import de.uka.ilkd.key.control.KeYEnvironment;
import de.uka.ilkd.key.java.abstraction.KeYJavaType;
Expand Down Expand Up @@ -69,8 +66,8 @@ private static KeYEnvironment<?> setupEnvironment(File location) throws ProblemL
}
// Set Taclet options
ChoiceSettings choiceSettings = ProofSettings.DEFAULT_SETTINGS.getChoiceSettings();
HashMap<String, String> oldSettings = choiceSettings.getDefaultChoices();
HashMap<String, String> newSettings = new HashMap<>(oldSettings);
Map<String, String> oldSettings = choiceSettings.getDefaultChoices();
Map<String, String> newSettings = new HashMap<>(oldSettings);
newSettings.putAll(MiscTools.getDefaultTacletOptions());
choiceSettings.setDefaultChoices(newSettings);
// Load source code
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package de.uka.ilkd.key.proof_references.testcase;

import java.io.File;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.function.Predicate;

import de.uka.ilkd.key.control.KeYEnvironment;
Expand Down Expand Up @@ -63,7 +63,8 @@ protected void doReferenceFunctionTest(File baseDir, String javaPathInBaseDir,
IProofReferencesAnalyst analyst, ExpectedProofReferences... expectedReferences)
throws Exception {
doReferenceFunctionTest(baseDir, javaPathInBaseDir, containerTypeName, targetName,
useContracts, analyst, null, expectedReferences);
useContracts, analyst,
null, expectedReferences);
}

/**
Expand Down Expand Up @@ -306,7 +307,7 @@ protected void doProofFunctionTest(File baseDir, String javaPathInBaseDir,
assertNotNull(tester);
KeYEnvironment<?> environment = null;
Proof proof = null;
HashMap<String, String> originalTacletOptions = null;
Map<String, String> originalTacletOptions = null;
boolean usePrettyPrinting = ProofIndependentSettings.isUsePrettyPrinting();
try {
// Disable pretty printing to make tests more robust against different term
Expand Down Expand Up @@ -379,7 +380,7 @@ protected void doProofMethodTest(File baseDir, String javaPathInBaseDir,
assertNotNull(tester);
KeYEnvironment<?> environment = null;
Proof proof = null;
HashMap<String, String> originalTacletOptions = null;
Map<String, String> originalTacletOptions = null;
boolean usePrettyPrinting = ProofIndependentSettings.isUsePrettyPrinting();
try {
// Disable pretty printing to make tests more robust against different term
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import de.uka.ilkd.key.control.DefaultUserInterfaceControl;
import de.uka.ilkd.key.control.KeYEnvironment;
Expand Down Expand Up @@ -61,8 +62,8 @@ public static void main(String[] args) {
}
// Set Taclet options
ChoiceSettings choiceSettings = ProofSettings.DEFAULT_SETTINGS.getChoiceSettings();
HashMap<String, String> oldSettings = choiceSettings.getDefaultChoices();
HashMap<String, String> newSettings = new HashMap<>(oldSettings);
Map<String, String> oldSettings = choiceSettings.getDefaultChoices();
Map<String, String> newSettings = new HashMap<>(oldSettings);
newSettings.putAll(MiscTools.getDefaultTacletOptions());
newSettings.put("methodExpansion", "methodExpansion:noRestriction");
choiceSettings.setDefaultChoices(newSettings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2782,9 +2782,9 @@ public static String getChoiceSetting(String key) {
* @param value The new choice value to set.
*/
public static void setChoiceSetting(String key, String value) {
HashMap<String, String> settings =
var settings =
ProofSettings.DEFAULT_SETTINGS.getChoiceSettings().getDefaultChoices();
HashMap<String, String> clone = new LinkedHashMap<>(settings);
var clone = new LinkedHashMap<>(settings);
clone.put(key, value);
ProofSettings.DEFAULT_SETTINGS.getChoiceSettings().setDefaultChoices(clone);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2012,7 +2012,7 @@ protected SymbolicExecutionEnvironment<DefaultUserInterfaceControl> doSETTest(Fi
boolean variablesAreOnlyComputedFromUpdates, boolean simplifyConditions)
throws ProofInputException, IOException, ParserConfigurationException, SAXException,
ProblemLoaderException {
HashMap<String, String> originalTacletOptions = null;
Map<String, String> originalTacletOptions = null;
boolean originalOneStepSimplification = isOneStepSimplificationEnabled(null);
try {
// Make sure that parameter are valid.
Expand Down Expand Up @@ -2105,7 +2105,7 @@ protected SymbolicExecutionEnvironment<DefaultUserInterfaceControl> doSETTest(Fi
boolean variablesAreOnlyComputedFromUpdates, boolean truthValueEvaluationEnabled,
boolean simplifyConditions) throws ProofInputException, IOException,
ParserConfigurationException, SAXException, ProblemLoaderException {
HashMap<String, String> originalTacletOptions = null;
Map<String, String> originalTacletOptions = null;
try {
// Make sure that parameter are valid.
assertNotNull(javaPathInBaseDir);
Expand Down Expand Up @@ -2195,13 +2195,16 @@ private void internalDoSETTest(File oracleFile,
* @throws ProblemLoaderException Occurred Exception.
* @throws ProofInputException Occurred Exception.
*/
public static HashMap<String, String> setDefaultTacletOptions(File baseDir,
public static Map<String, String> setDefaultTacletOptions(File baseDir,
String javaPathInBaseDir, String baseContractName)
throws ProblemLoaderException, ProofInputException {
if (!SymbolicExecutionUtil.isChoiceSettingInitialised()) {
SymbolicExecutionEnvironment<DefaultUserInterfaceControl> env =
createSymbolicExecutionEnvironment(testCaseDirectory, javaPathInBaseDir,
baseContractName, false, false, false, false, false, false, false, false, false,
baseContractName,
false, false, false,
false, false, false,
false, false, false,
false, false);
env.dispose();
}
Expand All @@ -2219,14 +2222,18 @@ public static HashMap<String, String> setDefaultTacletOptions(File baseDir,
* @throws ProblemLoaderException Occurred Exception.
* @throws ProofInputException Occurred Exception.
*/
public static HashMap<String, String> setDefaultTacletOptions(File baseDir,
String javaPathInBaseDir, String containerTypeName, String methodFullName)
public static Map<String, String> setDefaultTacletOptions(File baseDir,
String javaPathInBaseDir,
String containerTypeName,
String methodFullName)
throws ProblemLoaderException, ProofInputException {
if (!SymbolicExecutionUtil.isChoiceSettingInitialised()) {
SymbolicExecutionEnvironment<DefaultUserInterfaceControl> env =
createSymbolicExecutionEnvironment(baseDir, javaPathInBaseDir, containerTypeName,
methodFullName, null, false, false, false, false, false, false, false, false,
false, false);
methodFullName,
null, false, false, false,
false, false, false, false,
false, false, false);
env.dispose();
}
return setDefaultTacletOptions();
Expand All @@ -2242,7 +2249,7 @@ public static HashMap<String, String> setDefaultTacletOptions(File baseDir,
* @throws ProblemLoaderException Occurred Exception.
* @throws ProofInputException Occurred Exception.
*/
public static HashMap<String, String> setDefaultTacletOptionsForTarget(File javaFile,
public static Map<String, String> setDefaultTacletOptionsForTarget(File javaFile,
String containerTypeName, final String targetName)
throws ProblemLoaderException, ProofInputException {
return HelperClassForTests.setDefaultTacletOptionsForTarget(javaFile, containerTypeName,
Expand All @@ -2254,8 +2261,8 @@ public static HashMap<String, String> setDefaultTacletOptionsForTarget(File java
*
* @return The original settings which are overwritten.
*/
public static HashMap<String, String> setDefaultTacletOptions() {
HashMap<String, String> original = HelperClassForTests.setDefaultTacletOptions();
public static Map<String, String> setDefaultTacletOptions() {
Map<String, String> original = HelperClassForTests.setDefaultTacletOptions();
ChoiceSettings choiceSettings = ProofSettings.DEFAULT_SETTINGS.getChoiceSettings();
ImmutableSet<Choice> cs = DefaultImmutableSet.nil();
cs = cs.add(new Choice("noRestriction", "methodExpansion"));
Expand All @@ -2268,7 +2275,7 @@ public static HashMap<String, String> setDefaultTacletOptions() {
*
* @param options The taclet options to restore.
*/
public static void restoreTacletOptions(HashMap<String, String> options) {
public static void restoreTacletOptions(Map<String, String> options) {
HelperClassForTests.restoreTacletOptions(options);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.uka.ilkd.key.symbolic_execution.testcase;

import java.io.File;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import de.uka.ilkd.key.control.DefaultUserInterfaceControl;
import de.uka.ilkd.key.control.KeYEnvironment;
Expand All @@ -20,6 +20,7 @@

import static org.junit.jupiter.api.Assertions.*;


/**
* Tests for {@link SymbolicExecutionTreeBuilder},
* {@link ExecutedSymbolicExecutionTreeNodesStopCondition} and {@link SymbolicExecutionGoalChooser}.
Expand Down Expand Up @@ -536,7 +537,7 @@ public void testComplexPruning() throws Exception {
@Test
public void testSymbolicExecutionCompletionsTest() throws Exception {
SymbolicExecutionEnvironment<DefaultUserInterfaceControl> env = null;
HashMap<String, String> originalTacletOptions = null;
Map<String, String> originalTacletOptions = null;
boolean originalOneStepSimplification = isOneStepSimplificationEnabled(null);
try {
String javaPathInBaseDir =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import de.uka.ilkd.key.control.DefaultUserInterfaceControl;
import de.uka.ilkd.key.symbolic_execution.SymbolicLayoutExtractor;
Expand All @@ -24,6 +24,7 @@

import static org.junit.jupiter.api.Assertions.*;


/**
* Tests {@link SymbolicLayoutExtractor}.
*
Expand Down Expand Up @@ -529,7 +530,7 @@ protected void doTest(String javaPathInkeyRepDirectory, String containerTypeName
String precondition, int numberOfReturnNodeInMostLeftBranch,
int expectedNumberOfLayouts, boolean useOperationContracts,
boolean onReturnStatementNode) throws Exception {
HashMap<String, String> originalTacletOptions = null;
Map<String, String> originalTacletOptions = null;
SymbolicExecutionEnvironment<DefaultUserInterfaceControl> env = null;
boolean originalOneStepSimplification = isOneStepSimplificationEnabled(null);
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.uka.ilkd.key.symbolic_execution.testcase.po;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;

import de.uka.ilkd.key.control.DefaultUserInterfaceControl;
Expand Down Expand Up @@ -40,7 +40,7 @@ public void testDoubleValue() throws Exception {
protected void doTest(String javaPathInkeyRepDirectory, String baseContractName,
String oraclePathInBaseDirFile, String expectedTryContent) throws ProofInputException,
IOException, ParserConfigurationException, SAXException, ProblemLoaderException {
HashMap<String, String> originalTacletOptions = null;
Map<String, String> originalTacletOptions = null;
SymbolicExecutionEnvironment<DefaultUserInterfaceControl> env = null;
try {
// Make sure that the correct taclet options are defined.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.uka.ilkd.key.symbolic_execution.testcase.po;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;

import de.uka.ilkd.key.control.DefaultUserInterfaceControl;
Expand Down Expand Up @@ -108,7 +108,7 @@ protected void doTest(String javaPathInkeyRepDirectory, String containerTypeName
String methodFullName, String oraclePathInBaseDirFile, String precondition,
String expectedTryContent) throws ProofInputException, IOException,
ParserConfigurationException, SAXException, ProblemLoaderException {
HashMap<String, String> originalTacletOptions = null;
Map<String, String> originalTacletOptions = null;
SymbolicExecutionEnvironment<DefaultUserInterfaceControl> env = null;
boolean originalOneStepSimplification = isOneStepSimplificationEnabled(null);
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.uka.ilkd.key.symbolic_execution.testcase.strategy;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;

import de.uka.ilkd.key.control.DefaultUserInterfaceControl;
Expand Down Expand Up @@ -29,7 +29,7 @@ public class TestExceptionBreakpointStopConditionCaughtOrUncaught
public void testBreakpointStopCondition() throws ProofInputException, IOException,
ParserConfigurationException, SAXException, ProblemLoaderException {
SymbolicExecutionEnvironment<DefaultUserInterfaceControl> env = null;
HashMap<String, String> originalTacletOptions = null;
Map<String, String> originalTacletOptions = null;
boolean originalOneStepSimplification = isOneStepSimplificationEnabled(null);
try {
// Define test settings
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.uka.ilkd.key.symbolic_execution.testcase.strategy;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;

import de.uka.ilkd.key.control.DefaultUserInterfaceControl;
Expand All @@ -23,7 +23,7 @@ public class TestExceptionBreakpointStopConditionWithHitCount
@Test
public void testBreakpointStopCondition() throws ProofInputException, IOException,
ParserConfigurationException, SAXException, ProblemLoaderException {
HashMap<String, String> originalTacletOptions = null;
Map<String, String> originalTacletOptions = null;
boolean originalOneStepSimplification = isOneStepSimplificationEnabled(null);
SymbolicExecutionEnvironment<DefaultUserInterfaceControl> env = null;
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.uka.ilkd.key.symbolic_execution.testcase.strategy;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;

import de.uka.ilkd.key.control.DefaultUserInterfaceControl;
Expand All @@ -23,7 +23,7 @@ public class TestExceptionBreakpointStopConditionWithSubclasses
@Test // weigl not prev. activated
public void testBreakpointStopCondition() throws ProofInputException, IOException,
ParserConfigurationException, SAXException, ProblemLoaderException {
HashMap<String, String> originalTacletOptions = null;
Map<String, String> originalTacletOptions = null;
boolean originalOneStepSimplification = isOneStepSimplificationEnabled(null);
SymbolicExecutionEnvironment<DefaultUserInterfaceControl> env = null;
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.uka.ilkd.key.symbolic_execution.testcase.strategy;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;

import de.uka.ilkd.key.control.DefaultUserInterfaceControl;
Expand All @@ -22,7 +22,7 @@ public class TestJavaWatchpointStopConditionWithHitCount extends AbstractSymboli
public void testBreakpointStopCondition() throws ProofInputException, IOException,
ParserConfigurationException, SAXException, ProblemLoaderException {
SymbolicExecutionEnvironment<DefaultUserInterfaceControl> env = null;
HashMap<String, String> originalTacletOptions = null;
Map<String, String> originalTacletOptions = null;
boolean originalOneStepSimplification = isOneStepSimplificationEnabled(null);
try {
// Define test settings
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.uka.ilkd.key.symbolic_execution.testcase.strategy;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;

import de.uka.ilkd.key.control.DefaultUserInterfaceControl;
Expand All @@ -24,7 +24,7 @@ public class TestKeYWatchpointGlobalVariablesOnSatisfiable
public void testBreakpointStopCondition() throws ProofInputException, IOException,
ParserConfigurationException, SAXException, ProblemLoaderException {
SymbolicExecutionEnvironment<DefaultUserInterfaceControl> env = null;
HashMap<String, String> originalTacletOptions = null;
Map<String, String> originalTacletOptions = null;
boolean originalOneStepSimplification = isOneStepSimplificationEnabled(null);
try {
// Define test settings
Expand Down
Loading

0 comments on commit dd62d03

Please sign in to comment.