refactoring
This commit is contained in:
parent
481da56e8c
commit
ca196a5de3
|
@ -26,9 +26,9 @@ public class OutputsSectionConsumer implements ConfigurationConsumer {
|
|||
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
System.out.println("handleEndStruct");
|
||||
|
||||
if (state.stack.isEmpty()) {
|
||||
tsOutput.writeFields(structure, "", 0);
|
||||
tsOutput.run(readerState, structure, 0);
|
||||
|
||||
if (state.stack.isEmpty()) {
|
||||
if (tsOutputsSectionFileName != null) {
|
||||
FileWriter fos = new FileWriter(tsOutputsSectionFileName);
|
||||
fos.write(tsOutput.getContent());
|
||||
|
|
|
@ -146,8 +146,9 @@ public class TSProjectConsumer implements ConfigurationConsumer {
|
|||
@Override
|
||||
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
state.variableRegistry.register(structure.name + "_size", structure.getTotalSize());
|
||||
tsOutput.run(readerState, structure, 0);
|
||||
|
||||
if (state.stack.isEmpty()) {
|
||||
totalTsSize = tsOutput.writeFields(structure, "", 0);
|
||||
state.variableRegistry.register("TOTAL_CONFIG_SIZE", totalTsSize);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.rusefi.ReaderState;
|
|||
import com.rusefi.TypesHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.rusefi.ToolUtil.EOL;
|
||||
|
||||
|
@ -53,7 +54,7 @@ public class TsOutput {
|
|||
|
||||
if (cs != null) {
|
||||
String extraPrefix = cs.withPrefix ? configField.getName() + "_" : "";
|
||||
return writeFields(cs, prefix + extraPrefix, tsPosition);
|
||||
return writeFields(cs.tsFields, prefix + extraPrefix, tsPosition);
|
||||
}
|
||||
|
||||
if (configField.isBit()) {
|
||||
|
@ -115,9 +116,15 @@ public class TsOutput {
|
|||
return tsPosition;
|
||||
}
|
||||
|
||||
protected int writeFields(ConfigStructure configStructure, String prefix, int tsPosition) throws IOException {
|
||||
FieldIterator iterator = new FieldIterator(configStructure.tsFields);
|
||||
for (int i = 0; i < configStructure.tsFields.size(); i++) {
|
||||
public void run(ReaderState state, ConfigStructure structure, int sensorTsPosition) throws IOException {
|
||||
if (state.stack.isEmpty()) {
|
||||
writeFields(structure.tsFields, "", sensorTsPosition);
|
||||
}
|
||||
}
|
||||
|
||||
protected int writeFields(List<ConfigField> tsFields, String prefix, int tsPosition) throws IOException {
|
||||
FieldIterator iterator = new FieldIterator(tsFields);
|
||||
for (int i = 0; i < tsFields.size(); i++) {
|
||||
iterator.start(i);
|
||||
|
||||
tsPosition = writeOneField(iterator, prefix, tsPosition);
|
||||
|
|
Loading…
Reference in New Issue