live docs: whitespace support

This commit is contained in:
rusEfi 2020-02-22 15:37:58 -05:00
parent 9531d1e21b
commit ac09211d71
3 changed files with 30 additions and 0 deletions

Binary file not shown.

View File

@ -24,6 +24,7 @@ public class LiveDocsMetaParser {
private static final String DISPLAY_IF = "DISPLAY_IF";
private static final String DISPLAY_ELSE = "DISPLAY_ELSE";
private static final String DISPLAY_ENDIF = "DISPLAY_ENDIF";
private static final char QUOTE_SYMBOL = '"';
private static StringBuilder prefix = new StringBuilder();
private static String readLineByLine(String filePath) throws IOException {
@ -87,6 +88,14 @@ public class LiveDocsMetaParser {
} else if (DISPLAY_TEXT.equalsIgnoreCase(token)) {
if (s.hasNext()) {
String config = s.next();
if (config.startsWith(String.valueOf(QUOTE_SYMBOL))) {
config = config.substring(1);
while (!config.endsWith(String.valueOf(QUOTE_SYMBOL))) {
String next = s.next();
config += ' ' + next;
}
config = config.substring(0, config.length() - 1);
}
SystemOut.println("Display test " + config);
result.add(new TextRequest(config));
}

View File

@ -37,6 +37,27 @@ public class LiveDocsMetaParserTest {
assertEquals(3, r.first().size());
}
@Test
public void parseTextWithSpecialCharacters() {
MetaInfo r = LiveDocsMetaParser.parse(
"DISPLAY_TEXT(\"Analog: !MCU_reads\");"
);
assertEquals(1, r.first().size());
TextRequest request = (TextRequest) r.first().get(0);
assertEquals("Analog: !MCU_reads", request.getValue());
}
@Test
public void parseTextWithSpecialCharactersAndSpaces() {
MetaInfo r = LiveDocsMetaParser.parse(
"DISPLAY_TEXT(\"Analog: !MCU_reads\");"
);
assertEquals(1, r.first().size());
TextRequest request = (TextRequest) r.first().get(0);
assertEquals("Analog: !MCU_reads", request.getValue());
}
@Test
public void parseDisplayConfig() {
MetaInfo r = LiveDocsMetaParser.parse("\t\t// DISPLAY_TEXT(interpolate(\")\n" +