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_egt false
#define ts_drop_template_comments true
#define ts_show_etb_pins false
#define ts_show_analog_divider false
#define ts_show_spi false

View File

@ -78,7 +78,8 @@ enable2ndByteCanID = false
retrieveConfigError = "e"
;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
writeBlocks = on
interWriteDelay = 10

View File

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

View File

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