only:ts_drop_template_comments

This commit is contained in:
Andrey 2024-03-18 10:26:19 -04:00
parent 96bcc94e45
commit 1177ca80d7
4 changed files with 20 additions and 11 deletions

View File

@ -7,6 +7,8 @@
#define ts_show_clt_iat_pullup false #define ts_show_clt_iat_pullup false
#define ts_show_egt false #define ts_show_egt false
#define ts_drop_template_comments true
#define ts_show_etb_pins false #define ts_show_etb_pins false
#define ts_show_analog_divider false #define ts_show_analog_divider false
#define ts_show_spi false #define ts_show_spi false

View File

@ -78,7 +78,8 @@ enable2ndByteCanID = false
retrieveConfigError = "e" retrieveConfigError = "e"
;communication settings ;communication settings
pageActivationDelay = 500 ; Milliseconds delay after burn command. See https://sourceforge.net/p/rusefi/tickets/77/ ; Milliseconds delay after burn command. See https://sourceforge.net/p/rusefi/tickets/77/
pageActivationDelay = 500
;e.g. put writeblocks off and add an interwrite delay ;e.g. put writeblocks off and add an interwrite delay
writeBlocks = on writeBlocks = on
interWriteDelay = 10 interWriteDelay = 10

View File

@ -20,10 +20,11 @@ public class TSProjectConsumer implements ConfigurationConsumer {
private static final String TS_CONDITION = "@@if_"; private static final String TS_CONDITION = "@@if_";
public static final String SETTING_CONTEXT_HELP_END = "SettingContextHelpEnd"; public static final String SETTING_CONTEXT_HELP_END = "SettingContextHelpEnd";
public static final String SETTING_CONTEXT_HELP = "SettingContextHelp"; public static final String SETTING_CONTEXT_HELP = "SettingContextHelp";
public static final String TS_DROP_TEMPLATE_COMMENTS = "ts_drop_template_comments";
private final String tsPath; private final String tsPath;
private final ReaderStateImpl state; private final ReaderStateImpl state;
public boolean dropComments; private boolean dropComments;
private int totalTsSize; private int totalTsSize;
private final TsOutput tsOutput; private final TsOutput tsOutput;
@ -52,7 +53,9 @@ public class TSProjectConsumer implements ConfigurationConsumer {
tsHeader.write(tsContent.getPrefix()); tsHeader.write(tsContent.getPrefix());
tsHeader.write("; " + CONFIG_DEFINITION_START + ToolUtil.EOL); tsHeader.write("; " + CONFIG_DEFINITION_START + ToolUtil.EOL);
tsHeader.write("; this section " + state.getHeader() + ToolUtil.EOL + ToolUtil.EOL); if (!dropComments) {
tsHeader.write("; this section " + state.getHeader() + ToolUtil.EOL + ToolUtil.EOL);
}
tsHeader.write("pageSize = " + totalTsSize + ToolUtil.EOL); tsHeader.write("pageSize = " + totalTsSize + ToolUtil.EOL);
tsHeader.write("page = 1" + ToolUtil.EOL); tsHeader.write("page = 1" + ToolUtil.EOL);
tsHeader.write(fieldsSection); tsHeader.write(fieldsSection);
@ -83,6 +86,8 @@ public class TSProjectConsumer implements ConfigurationConsumer {
StringBuilder prefix = new StringBuilder(); StringBuilder prefix = new StringBuilder();
StringBuilder postfix = new StringBuilder(); StringBuilder postfix = new StringBuilder();
dropComments = Boolean.valueOf(state.getVariableRegistry().get(TS_DROP_TEMPLATE_COMMENTS));
boolean isBeforeStartTag = true; boolean isBeforeStartTag = true;
boolean isAfterEndTag = false; boolean isAfterEndTag = false;
String line; String line;
@ -95,7 +100,7 @@ public class TSProjectConsumer implements ConfigurationConsumer {
isAfterEndTag = true; isAfterEndTag = true;
continue; continue;
} }
if (line.trim().startsWith("!") && dropComments) if (line.trim().startsWith(";") && dropComments)
continue; continue;
if (line.contains(TS_CONDITION)) { if (line.contains(TS_CONDITION)) {

View File

@ -13,9 +13,9 @@ import java.io.StringBufferInputStream;
import static com.rusefi.AssertCompatibility.assertEquals; import static com.rusefi.AssertCompatibility.assertEquals;
public class TSProjectConsumerTest { public class TSProjectConsumerTest {
private static final String smallContent = "hello = \"!\"\n" + private static final String smallContent = "hello = \";\"\n" +
"world!comment\n" + "world;comment\n" +
"!comment2\n" + ";comment2\n" +
"end\n"; "end\n";
@Test @Test
@ -141,11 +141,12 @@ public class TSProjectConsumerTest {
@Test @Test
public void testReaderDropComments() throws IOException { public void testReaderDropComments() throws IOException {
TSProjectConsumer consumer = new TestTSProjectConsumer(null, new ReaderStateImpl()); ReaderStateImpl state = new ReaderStateImpl();
consumer.dropComments = true; TSProjectConsumer consumer = new TestTSProjectConsumer(null, state);
state.getVariableRegistry().put(TSProjectConsumer.TS_DROP_TEMPLATE_COMMENTS, "true");
TsFileContent content = consumer.getTsFileContent(new StringBufferInputStream(smallContent)); TsFileContent content = consumer.getTsFileContent(new StringBufferInputStream(smallContent));
assertEquals("hello = \"!\"\n" + assertEquals("hello = \";\"\n" +
"world!comment\n" + "world;comment\n" +
"end\n", content.getPrefix()); "end\n", content.getPrefix());
assertEquals("", content.getPostfix()); assertEquals("", content.getPostfix());
}} }}