From fef6e965d3b2cdd2045bb724a2b1e0f382654b81 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Fri, 6 Jan 2023 11:08:23 -0500 Subject: [PATCH] refactoring --- .../src/main/java/com/rusefi/ConfigField.java | 3 ++- .../src/main/java/com/rusefi/ReaderState.java | 2 +- .../java/com/rusefi/output/FragmentDialogConsumer.java | 2 +- .../main/java/com/rusefi/output/JavaFieldsConsumer.java | 3 ++- .../com/rusefi/output/PerFieldWithStructuresIterator.java | 2 +- .../src/main/java/com/rusefi/output/TsOutput.java | 2 +- .../test/java/com/rusefi/test/ConfigFieldParserTest.java | 7 ++----- 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/java_tools/configuration_definition/src/main/java/com/rusefi/ConfigField.java b/java_tools/configuration_definition/src/main/java/com/rusefi/ConfigField.java index 5eb7466b99..f917b7c2c0 100644 --- a/java_tools/configuration_definition/src/main/java/com/rusefi/ConfigField.java +++ b/java_tools/configuration_definition/src/main/java/com/rusefi/ConfigField.java @@ -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()); } diff --git a/java_tools/configuration_definition/src/main/java/com/rusefi/ReaderState.java b/java_tools/configuration_definition/src/main/java/com/rusefi/ReaderState.java index bb7548d80a..69e821748b 100644 --- a/java_tools/configuration_definition/src/main/java/com/rusefi/ReaderState.java +++ b/java_tools/configuration_definition/src/main/java/com/rusefi/ReaderState.java @@ -390,7 +390,7 @@ public class ReaderState implements IReaderState { return tsCustomSize; } - public Map getStructures() { + public Map getStructures() { return structures; } diff --git a/java_tools/configuration_definition/src/main/java/com/rusefi/output/FragmentDialogConsumer.java b/java_tools/configuration_definition/src/main/java/com/rusefi/output/FragmentDialogConsumer.java index e4197b06af..56bc8cd935 100644 --- a/java_tools/configuration_definition/src/main/java/com/rusefi/output/FragmentDialogConsumer.java +++ b/java_tools/configuration_definition/src/main/java/com/rusefi/output/FragmentDialogConsumer.java @@ -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); diff --git a/java_tools/configuration_definition/src/main/java/com/rusefi/output/JavaFieldsConsumer.java b/java_tools/configuration_definition/src/main/java/com/rusefi/output/JavaFieldsConsumer.java index d3ce31932b..507f304ef5 100644 --- a/java_tools/configuration_definition/src/main/java/com/rusefi/output/JavaFieldsConsumer.java +++ b/java_tools/configuration_definition/src/main/java/com/rusefi/output/JavaFieldsConsumer.java @@ -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); diff --git a/java_tools/configuration_definition/src/main/java/com/rusefi/output/PerFieldWithStructuresIterator.java b/java_tools/configuration_definition/src/main/java/com/rusefi/output/PerFieldWithStructuresIterator.java index 0860d4b884..327a2665cd 100644 --- a/java_tools/configuration_definition/src/main/java/com/rusefi/output/PerFieldWithStructuresIterator.java +++ b/java_tools/configuration_definition/src/main/java/com/rusefi/output/PerFieldWithStructuresIterator.java @@ -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()) { diff --git a/java_tools/configuration_definition/src/main/java/com/rusefi/output/TsOutput.java b/java_tools/configuration_definition/src/main/java/com/rusefi/output/TsOutput.java index b53c0bbe07..e6ba91183c 100644 --- a/java_tools/configuration_definition/src/main/java/com/rusefi/output/TsOutput.java +++ b/java_tools/configuration_definition/src/main/java/com/rusefi/output/TsOutput.java @@ -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); diff --git a/java_tools/configuration_definition/src/test/java/com/rusefi/test/ConfigFieldParserTest.java b/java_tools/configuration_definition/src/test/java/com/rusefi/test/ConfigFieldParserTest.java index 7728191641..dac7ad9807 100644 --- a/java_tools/configuration_definition/src/test/java/com/rusefi/test/ConfigFieldParserTest.java +++ b/java_tools/configuration_definition/src/test/java/com/rusefi/test/ConfigFieldParserTest.java @@ -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()); }