live docs: whitespace support
This commit is contained in:
parent
dd07e37ab3
commit
d576b8e627
Binary file not shown.
|
@ -24,6 +24,7 @@ public class LiveDocsMetaParser {
|
||||||
private static final String DISPLAY_IF = "DISPLAY_IF";
|
private static final String DISPLAY_IF = "DISPLAY_IF";
|
||||||
private static final String DISPLAY_ELSE = "DISPLAY_ELSE";
|
private static final String DISPLAY_ELSE = "DISPLAY_ELSE";
|
||||||
private static final String DISPLAY_ENDIF = "DISPLAY_ENDIF";
|
private static final String DISPLAY_ENDIF = "DISPLAY_ENDIF";
|
||||||
|
private static final char QUOTE_SYMBOL = '"';
|
||||||
private static StringBuilder prefix = new StringBuilder();
|
private static StringBuilder prefix = new StringBuilder();
|
||||||
|
|
||||||
private static String readLineByLine(String filePath) throws IOException {
|
private static String readLineByLine(String filePath) throws IOException {
|
||||||
|
@ -87,6 +88,14 @@ public class LiveDocsMetaParser {
|
||||||
} else if (DISPLAY_TEXT.equalsIgnoreCase(token)) {
|
} else if (DISPLAY_TEXT.equalsIgnoreCase(token)) {
|
||||||
if (s.hasNext()) {
|
if (s.hasNext()) {
|
||||||
String config = s.next();
|
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);
|
SystemOut.println("Display test " + config);
|
||||||
result.add(new TextRequest(config));
|
result.add(new TextRequest(config));
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,27 @@ public class LiveDocsMetaParserTest {
|
||||||
assertEquals(3, r.first().size());
|
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
|
@Test
|
||||||
public void parseDisplayConfig() {
|
public void parseDisplayConfig() {
|
||||||
MetaInfo r = LiveDocsMetaParser.parse("\t\t// DISPLAY_TEXT(interpolate(\")\n" +
|
MetaInfo r = LiveDocsMetaParser.parse("\t\t// DISPLAY_TEXT(interpolate(\")\n" +
|
||||||
|
|
Loading…
Reference in New Issue