refactoring
This commit is contained in:
parent
fef6e965d3
commit
8d2842d475
|
@ -121,10 +121,10 @@ public class LiveDataProcessor {
|
|||
|
||||
if (constexpr != null) {
|
||||
sdCardFieldsConsumer.home = constexpr;
|
||||
state.addDestination(sdCardFieldsConsumer::handleEndStruct);
|
||||
state.addDestination((state1, structure) -> sdCardFieldsConsumer.handleEndStruct(state1, structure));
|
||||
|
||||
outputValueConsumer.currentSectionPrefix = constexpr;
|
||||
state.addDestination(outputValueConsumer::handleEndStruct);
|
||||
state.addDestination((state1, structure) -> outputValueConsumer.handleEndStruct(state1, structure));
|
||||
}
|
||||
|
||||
state.doJob();
|
||||
|
|
|
@ -62,7 +62,7 @@ public class BaseCHeaderConsumer implements ConfigurationConsumer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) {
|
||||
public void handleEndStruct(IReaderState readerState, ConfigStructure structure) {
|
||||
if (structure.getComment() != null) {
|
||||
content.append("/**" + EOL + packComment(structure.getComment(), "") + EOL + "*/" + EOL);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.rusefi.output;
|
||||
|
||||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.IReaderState;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -13,5 +13,5 @@ public interface ConfigurationConsumer {
|
|||
|
||||
}
|
||||
|
||||
void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException;
|
||||
void handleEndStruct(IReaderState readerState, ConfigStructure structure) throws IOException;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.rusefi.output;
|
||||
|
||||
import com.rusefi.ConfigField;
|
||||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.IReaderState;
|
||||
import com.rusefi.TypesHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -32,7 +32,7 @@ public class DataLogConsumer implements ConfigurationConsumer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
public void handleEndStruct(IReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
if (readerState.isStackEmpty()) {
|
||||
PerFieldWithStructuresIterator iterator = new PerFieldWithStructuresIterator(readerState, structure.getTsFields(), "",
|
||||
(configField, prefix, prefix2) -> handle(prefix, prefix2));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.rusefi.output;
|
||||
|
||||
import com.rusefi.ConfigField;
|
||||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.IReaderState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -32,7 +32,7 @@ public class FragmentDialogConsumer implements ConfigurationConsumer {
|
|||
|
||||
|
||||
@Override
|
||||
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
public void handleEndStruct(IReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
FieldsStrategy fieldsStrategy = new FieldsStrategy() {
|
||||
@Override
|
||||
int writeOneField(FieldIterator iterator, String prefix, int tsPosition) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.rusefi.output;
|
||||
|
||||
import com.rusefi.ConfigField;
|
||||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.IReaderState;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
@ -18,7 +18,7 @@ public class GaugeConsumer implements ConfigurationConsumer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
public void handleEndStruct(IReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
if (readerState.isStackEmpty()) {
|
||||
PerFieldWithStructuresIterator iterator = new PerFieldWithStructuresIterator(readerState, structure.getTsFields(), "",
|
||||
(state, configField, prefix) -> handle(configField, prefix));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.rusefi.output;
|
||||
|
||||
import com.rusefi.ConfigField;
|
||||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.IReaderState;
|
||||
import com.rusefi.TypesHelper;
|
||||
import com.rusefi.core.Tuple;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -60,10 +60,10 @@ public class GetConfigValueConsumer implements ConfigurationConsumer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleEndStruct(ReaderState state, ConfigStructure structure) throws IOException {
|
||||
public void handleEndStruct(IReaderState state, ConfigStructure structure) throws IOException {
|
||||
if (state.isStackEmpty()) {
|
||||
PerFieldWithStructuresIterator iterator = new PerFieldWithStructuresIterator(state, structure.getTsFields(), "",
|
||||
this::processConfig, ".");
|
||||
(readerState, cf, prefix) -> processConfig(cf, prefix), ".");
|
||||
iterator.loop();
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public class GetConfigValueConsumer implements ConfigurationConsumer {
|
|||
writeStringToFile(mdOutputFileName, getMdContent());
|
||||
}
|
||||
|
||||
private String processConfig(ReaderState readerState, ConfigField cf, String prefix) {
|
||||
private String processConfig(ConfigField cf, String prefix) {
|
||||
if (cf.getName().contains(UNUSED) || cf.getName().contains(ALIGNMENT_FILL_AT))
|
||||
return "";
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.rusefi.output;
|
||||
|
||||
import com.rusefi.ConfigField;
|
||||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.IReaderState;
|
||||
import com.rusefi.TypesHelper;
|
||||
import com.rusefi.core.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -33,15 +33,15 @@ public class GetOutputValueConsumer implements ConfigurationConsumer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleEndStruct(ReaderState state, ConfigStructure structure) throws IOException {
|
||||
public void handleEndStruct(IReaderState state, ConfigStructure structure) throws IOException {
|
||||
if (state.isStackEmpty()) {
|
||||
PerFieldWithStructuresIterator iterator = new PerFieldWithStructuresIterator(state, structure.getTsFields(), "",
|
||||
this::processOutput, ".");
|
||||
(readerState, cf, prefix) -> processOutput(cf, prefix), ".");
|
||||
iterator.loop();
|
||||
}
|
||||
}
|
||||
|
||||
private String processOutput(ReaderState readerState, ConfigField cf, String prefix) {
|
||||
private String processOutput(ConfigField cf, String prefix) {
|
||||
if (cf.getName().contains(UNUSED) || cf.getName().contains(ALIGNMENT_FILL_AT))
|
||||
return "";
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public abstract class JavaFieldsConsumer implements ConfigurationConsumer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
public void handleEndStruct(IReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
FieldsStrategy fieldsStrategy = new FieldsStrategy() {
|
||||
protected int writeOneField(FieldIterator iterator, String prefix, int tsPosition) {
|
||||
ConfigField prev = iterator.getPrev();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.rusefi.output;
|
||||
|
||||
import com.rusefi.ConfigField;
|
||||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.IReaderState;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class JavaSensorsConsumer implements ConfigurationConsumer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
public void handleEndStruct(IReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
FieldsStrategy fieldsStrategy = new FieldsStrategy() {
|
||||
public int writeOneField(FieldIterator iterator, String prefix, int tsPosition) {
|
||||
ConfigField configField = iterator.cf;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.rusefi.output;
|
||||
|
||||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.IReaderState;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class OutputsSectionConsumer implements ConfigurationConsumer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
public void handleEndStruct(IReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
System.out.println("handleEndStruct");
|
||||
|
||||
sensorTsPosition = tsOutput.run(readerState, structure, sensorTsPosition);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.rusefi.output;
|
||||
|
||||
import com.rusefi.ConfigField;
|
||||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.IReaderState;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -10,13 +10,13 @@ import java.util.List;
|
|||
* @see FieldIterator is there a duplication?
|
||||
*/
|
||||
class PerFieldWithStructuresIterator extends FieldIterator {
|
||||
private final ReaderState state;
|
||||
private final IReaderState state;
|
||||
private final String prefix;
|
||||
private final Strategy strategy;
|
||||
private final String prefixSeparator;
|
||||
private final StringBuilder sb = new StringBuilder();
|
||||
|
||||
public PerFieldWithStructuresIterator(ReaderState state, List<ConfigField> fields, String prefix, Strategy strategy, String prefixSeparator) {
|
||||
public PerFieldWithStructuresIterator(IReaderState state, List<ConfigField> fields, String prefix, Strategy strategy, String prefixSeparator) {
|
||||
super(fields);
|
||||
this.state = state;
|
||||
this.prefix = prefix;
|
||||
|
@ -24,7 +24,7 @@ class PerFieldWithStructuresIterator extends FieldIterator {
|
|||
this.prefixSeparator = prefixSeparator;
|
||||
}
|
||||
|
||||
public PerFieldWithStructuresIterator(ReaderState state, List<ConfigField> fields, String prefix, Strategy strategy) {
|
||||
public PerFieldWithStructuresIterator(IReaderState state, List<ConfigField> fields, String prefix, Strategy strategy) {
|
||||
this(state, fields, prefix, strategy, "_");
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,6 @@ class PerFieldWithStructuresIterator extends FieldIterator {
|
|||
}
|
||||
|
||||
interface Strategy {
|
||||
String process(ReaderState state, ConfigField configField, String prefix);
|
||||
String process(IReaderState state, ConfigField configField, String prefix);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.rusefi.output;
|
||||
|
||||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.IReaderState;
|
||||
import com.rusefi.util.LazyFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -31,7 +31,7 @@ public class SdCardFieldsConsumer implements ConfigurationConsumer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleEndStruct(ReaderState state, ConfigStructure structure) throws IOException {
|
||||
public void handleEndStruct(IReaderState state, ConfigStructure structure) throws IOException {
|
||||
content.handleEndStruct(state, structure);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.rusefi.output;
|
||||
|
||||
import com.rusefi.ConfigField;
|
||||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.IReaderState;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class SdCardFieldsContent {
|
|||
|
||||
public String home = "engine->outputChannels";
|
||||
|
||||
public void handleEndStruct(ReaderState state, ConfigStructure structure) throws IOException {
|
||||
public void handleEndStruct(IReaderState state, ConfigStructure structure) throws IOException {
|
||||
if (state.isStackEmpty()) {
|
||||
PerFieldWithStructuresIterator iterator = new PerFieldWithStructuresIterator(state, structure.getTsFields(), "",
|
||||
(configField, prefix, prefix2) -> processOutput(prefix, prefix2), ".");
|
||||
|
|
|
@ -31,7 +31,7 @@ public class SignatureConsumer implements ConfigurationConsumer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
public void handleEndStruct(IReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
ExtraUtil.writeDefinesToFile(registry, destHeader, "by SignatureConsumer");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ public class TSProjectConsumer implements ConfigurationConsumer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
public void handleEndStruct(IReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
state.getVariableRegistry().register(structure.getName() + "_size", structure.getTotalSize());
|
||||
totalTsSize = tsOutput.run(readerState, structure, 0);
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.rusefi.output;
|
|||
|
||||
import com.opensr5.ini.field.IniField;
|
||||
import com.rusefi.ConfigField;
|
||||
import com.rusefi.IReaderState;
|
||||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.TypesHelper;
|
||||
import com.rusefi.newparse.parsing.Type;
|
||||
|
@ -34,7 +35,7 @@ public class TsOutput {
|
|||
return settingContextHelp.toString();
|
||||
}
|
||||
|
||||
public int run(ReaderState state, ConfigStructure structure, int sensorTsPosition) {
|
||||
public int run(IReaderState state, ConfigStructure structure, int sensorTsPosition) {
|
||||
FieldsStrategy strategy = new FieldsStrategy() {
|
||||
@Override
|
||||
public int writeOneField(FieldIterator it, String prefix, int tsPosition) {
|
||||
|
|
Loading…
Reference in New Issue