mirror of
https://github.com/DanilaFe/abacus
synced 2024-11-16 23:53:09 -08:00
Load definition files.
This commit is contained in:
parent
8f682e96af
commit
50cc51d089
|
@ -63,13 +63,13 @@ class Abacus(val configuration: Configuration) {
|
|||
* Reloads the Abacus core.
|
||||
*/
|
||||
fun reload(){
|
||||
pluginManager.reload()
|
||||
with(mutableContext) {
|
||||
numberImplementation = pluginManager.numberImplementationFor(configuration.numberImplementation)
|
||||
?: StandardPlugin.IMPLEMENTATION_NAIVE
|
||||
with(mutableContext){
|
||||
clearVariables()
|
||||
clearDefinitions()
|
||||
}
|
||||
pluginManager.reload()
|
||||
mutableContext.numberImplementation = pluginManager.numberImplementationFor(configuration.numberImplementation)
|
||||
?: StandardPlugin.IMPLEMENTATION_NAIVE
|
||||
}
|
||||
/**
|
||||
* Merges the current context with the provided one, updating
|
||||
|
|
|
@ -325,7 +325,8 @@ public class AbacusController implements PluginListener {
|
|||
FileReader fileReader = new FileReader(definitionFile);
|
||||
Scanner scanner = new Scanner(fileReader);
|
||||
while(scanner.hasNext()){
|
||||
abacus.evaluateTree(abacus.parseString(scanner.nextLine()));
|
||||
EvaluationResult result = abacus.evaluateTree(abacus.parseString(scanner.nextLine()));
|
||||
abacus.applyToContext(result.getResultingContext());
|
||||
}
|
||||
} catch (AbacusException abacusError) {
|
||||
outputText.setText(ERR_DEFINITION + "(" + abacusError.getMessage() + ")");
|
||||
|
@ -334,14 +335,6 @@ public class AbacusController implements PluginListener {
|
|||
} catch (FileNotFoundException ignored) {}
|
||||
}
|
||||
|
||||
private void reloadAbacus(){
|
||||
abacus.reload();
|
||||
ExtendedConfiguration abacusConfig = (ExtendedConfiguration) abacus.getConfiguration();
|
||||
for(String fileName: abacusConfig.getDefinitionFiles()) {
|
||||
loadDefinitionFile(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void performScan() {
|
||||
PluginManager abacusPluginManager = abacus.getPluginManager();
|
||||
|
@ -352,13 +345,13 @@ public class AbacusController implements PluginListener {
|
|||
} catch (IOException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
reloadAbacus();
|
||||
abacus.reload();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void performReload() {
|
||||
alertIfApplyNeeded(true);
|
||||
reloadAbacus();
|
||||
abacus.reload();
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -425,6 +418,9 @@ public class AbacusController implements PluginListener {
|
|||
}).collect(Collectors.toCollection(ArrayList::new)));
|
||||
functionList.sort(Comparator.comparing(Documentation::getCodeName));
|
||||
definitionFiles.addAll(configuration.getDefinitionFiles());
|
||||
for(String file : definitionFiles){
|
||||
loadDefinitionFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue
Block a user