refactoring: smaller interface helps with encapsulation
This commit is contained in:
parent
ea9455f98f
commit
38529cb4b7
|
@ -1,6 +1,6 @@
|
|||
package com.rusefi;
|
||||
|
||||
import com.rusefi.newparse.ParseState;
|
||||
import com.rusefi.newparse.DefinitionsState;
|
||||
import com.rusefi.newparse.parsing.Definition;
|
||||
import com.rusefi.util.LazyFile;
|
||||
import com.rusefi.util.SystemOut;
|
||||
|
@ -8,7 +8,7 @@ import com.rusefi.util.SystemOut;
|
|||
import java.io.IOException;
|
||||
|
||||
public class ExtraUtil {
|
||||
static void handleFiringOrder(String firingEnumFileName, VariableRegistry variableRegistry, ParseState parseState) throws IOException {
|
||||
static void handleFiringOrder(String firingEnumFileName, VariableRegistry variableRegistry, DefinitionsState parseState) throws IOException {
|
||||
if (firingEnumFileName != null) {
|
||||
SystemOut.println("Reading firing from " + firingEnumFileName);
|
||||
String result = FiringOrderTSLogic.invoke(firingEnumFileName);
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.rusefi;
|
|||
|
||||
import com.devexperts.logging.Logging;
|
||||
import com.rusefi.enum_reader.Value;
|
||||
import com.rusefi.newparse.ParseState;
|
||||
import com.rusefi.newparse.DefinitionsState;
|
||||
import com.rusefi.newparse.parsing.Definition;
|
||||
import com.rusefi.util.SystemOut;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -46,7 +46,7 @@ public class PinoutLogic {
|
|||
return null;
|
||||
}
|
||||
|
||||
private static void registerPins(String boardName, ArrayList<PinState> listPins, VariableRegistry registry, ReaderState state, ParseState parseState) {
|
||||
private static void registerPins(String boardName, ArrayList<PinState> listPins, VariableRegistry registry, ReaderState state, DefinitionsState parseState) {
|
||||
if (listPins == null || listPins.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ public class PinoutLogic {
|
|||
return new PinoutLogic(boardName, boardYamlFiles);
|
||||
}
|
||||
|
||||
public void registerBoardSpecificPinNames(VariableRegistry registry, ReaderState state, ParseState parseState) throws IOException {
|
||||
public void registerBoardSpecificPinNames(VariableRegistry registry, ReaderState state, DefinitionsState parseState) throws IOException {
|
||||
readFiles();
|
||||
registerPins(boardName, globalList, registry, state, parseState);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public class RusefiParseErrorStrategy extends DefaultErrorStrategy {
|
|||
SystemOut.println("Successfully parsed (Antlr) " + filePath + " in " + durationMs + "ms");
|
||||
}
|
||||
|
||||
public static void parseDefinitionString(ParseTreeListener listener, String content) throws IOException {
|
||||
public static void parseDefinitionString(ParseTreeListener listener, String content) {
|
||||
SystemOut.println("Parsing string (Antlr)");
|
||||
|
||||
CharStream in = new ANTLRInputStream(content);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package com.rusefi.newparse;
|
||||
|
||||
import com.rusefi.VariableRegistry;
|
||||
import com.rusefi.newparse.parsing.Definition;
|
||||
|
||||
public interface DefinitionsState {
|
||||
void addDefinition(VariableRegistry variableRegistry, String name, String value, Definition.OverwritePolicy overwritePolicy);
|
||||
|
||||
void setDefinitionPolicy(Definition.OverwritePolicy policy);
|
||||
}
|
|
@ -13,7 +13,7 @@ import java.util.regex.Pattern;
|
|||
|
||||
import static com.rusefi.VariableRegistry.AUTO_ENUM_SUFFIX;
|
||||
|
||||
public class ParseState {
|
||||
public class ParseState implements DefinitionsState {
|
||||
private final Map<String, Definition> definitions = new HashMap<>();
|
||||
private final Map<String, Struct> structs = new HashMap<>();
|
||||
private final List<Struct> structList = new ArrayList<>();
|
||||
|
@ -116,6 +116,7 @@ public class ParseState {
|
|||
/**
|
||||
* we are in a lengthy period of transition between two implementations
|
||||
*/
|
||||
@Override
|
||||
public void addDefinition(VariableRegistry variableRegistry, String name, String value, Definition.OverwritePolicy overwritePolicy) {
|
||||
// old implementation
|
||||
variableRegistry.register(name, value);
|
||||
|
@ -146,6 +147,7 @@ public class ParseState {
|
|||
addDefinition(name, value, definitionOverwritePolicy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefinitionPolicy(Definition.OverwritePolicy policy) {
|
||||
this.definitionOverwritePolicy = policy;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.output;
|
||||
|
||||
import com.rusefi.*;
|
||||
import com.rusefi.newparse.DefinitionsState;
|
||||
import com.rusefi.newparse.ParseState;
|
||||
import com.rusefi.newparse.parsing.Definition;
|
||||
import com.rusefi.util.SystemOut;
|
||||
|
@ -20,7 +21,7 @@ public class SignatureConsumer implements ConfigurationConsumer {
|
|||
this.registry = registry;
|
||||
}
|
||||
|
||||
public static void storeUniqueBuildId(ReaderState state, ParseState parseState, String tsPath, FirmwareVersion uniqueId) {
|
||||
public static void storeUniqueBuildId(ReaderState state, DefinitionsState parseState, String tsPath, FirmwareVersion uniqueId) {
|
||||
// store a hash as a built-in variable
|
||||
|
||||
// nasty trick - do not insert signature into live data files
|
||||
|
|
Loading…
Reference in New Issue