refactoring
This commit is contained in:
parent
d99106560d
commit
fef6e965d3
|
@ -3,6 +3,7 @@ package com.rusefi;
|
|||
import com.devexperts.logging.Logging;
|
||||
import com.opensr5.ini.field.EnumIniField;
|
||||
import com.rusefi.core.Pair;
|
||||
import com.rusefi.output.ConfigStructure;
|
||||
import com.rusefi.output.ConfigStructureImpl;
|
||||
import com.rusefi.output.DataLogConsumer;
|
||||
import com.rusefi.output.JavaFieldsConsumer;
|
||||
|
@ -115,7 +116,7 @@ public class ConfigField {
|
|||
return Integer.parseInt(s);
|
||||
}
|
||||
|
||||
public ConfigStructureImpl getStructureType() {
|
||||
public ConfigStructure getStructureType() {
|
||||
return getState().getStructures().get(getType());
|
||||
}
|
||||
|
||||
|
|
|
@ -390,7 +390,7 @@ public class ReaderState implements IReaderState {
|
|||
return tsCustomSize;
|
||||
}
|
||||
|
||||
public Map<String, ConfigStructureImpl> getStructures() {
|
||||
public Map<String, ? extends ConfigStructure> getStructures() {
|
||||
return structures;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class FragmentDialogConsumer implements ConfigurationConsumer {
|
|||
if (configField.getName().startsWith(ConfigStructureImpl.ALIGNMENT_FILL_AT))
|
||||
return 0;
|
||||
|
||||
ConfigStructureImpl cs = configField.getStructureType();
|
||||
ConfigStructure cs = configField.getStructureType();
|
||||
if (cs != null) {
|
||||
String extraPrefix = cs.isWithPrefix() ? configField.getName() + "_" : "";
|
||||
return writeFields(cs.getTsFields(), prefix + extraPrefix, tsPosition);
|
||||
|
|
|
@ -50,6 +50,7 @@ public abstract class JavaFieldsConsumer implements ConfigurationConsumer {
|
|||
return custom != null && custom.toLowerCase().startsWith(IniFileModel.FIELD_TYPE_STRING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
FieldsStrategy fieldsStrategy = new FieldsStrategy() {
|
||||
protected int writeOneField(FieldIterator iterator, String prefix, int tsPosition) {
|
||||
|
@ -64,7 +65,7 @@ public abstract class JavaFieldsConsumer implements ConfigurationConsumer {
|
|||
if (configField.getName().equals(prev.getName())) {
|
||||
return tsPosition;
|
||||
}
|
||||
ConfigStructureImpl cs = configField.getStructureType();
|
||||
ConfigStructure cs = configField.getStructureType();
|
||||
if (cs != null) {
|
||||
String extraPrefix = cs.isWithPrefix() ? configField.getName() + "_" : "";
|
||||
return writeFields(cs.getTsFields(), prefix + extraPrefix, tsPosition);
|
||||
|
|
|
@ -30,7 +30,7 @@ class PerFieldWithStructuresIterator extends FieldIterator {
|
|||
|
||||
@Override
|
||||
public void end() {
|
||||
ConfigStructureImpl cs = cf.getState().getStructures().get(cf.getType());
|
||||
ConfigStructure cs = cf.getState().getStructures().get(cf.getType());
|
||||
String content;
|
||||
if (cs != null) {
|
||||
if (cf.isFromIterate()) {
|
||||
|
|
|
@ -65,7 +65,7 @@ public class TsOutput {
|
|||
return tsPosition;
|
||||
}
|
||||
|
||||
ConfigStructureImpl cs = configField.getStructureType();
|
||||
ConfigStructure cs = configField.getStructureType();
|
||||
if (configField.getComment() != null && configField.getComment().trim().length() > 0 && cs == null) {
|
||||
String commentContent = configField.getCommentTemplated();
|
||||
commentContent = ConfigField.unquote(commentContent);
|
||||
|
|
|
@ -4,10 +4,7 @@ import com.rusefi.ConfigField;
|
|||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.TypesHelper;
|
||||
import com.rusefi.VariableRegistry;
|
||||
import com.rusefi.output.BaseCHeaderConsumer;
|
||||
import com.rusefi.output.ConfigStructureImpl;
|
||||
import com.rusefi.output.JavaFieldsConsumer;
|
||||
import com.rusefi.output.TSProjectConsumer;
|
||||
import com.rusefi.output.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
@ -163,7 +160,7 @@ public class ConfigFieldParserTest {
|
|||
|
||||
assertEquals(16, TypesHelper.getElementSize(state, "pid_s"));
|
||||
|
||||
ConfigStructureImpl structure = state.getStructures().get("pid_s");
|
||||
ConfigStructure structure = state.getStructures().get("pid_s");
|
||||
ConfigField firstField = structure.getcFields().get(0);
|
||||
assertEquals("ms", firstField.getUnits());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue