use of org.fife.ui.rsyntaxtextarea.RSyntaxDocument in project RSyntaxTextArea by bobbylight.
the class GutterTest method testPropertyChange_newDocumentUpdatesGutter.
@Test
void testPropertyChange_newDocumentUpdatesGutter() {
RSyntaxTextArea textArea = new RSyntaxTextArea();
Gutter gutter = new Gutter(textArea);
textArea.setDocument(new RSyntaxDocument(SyntaxConstants.SYNTAX_STYLE_C));
}
use of org.fife.ui.rsyntaxtextarea.RSyntaxDocument in project RSyntaxTextArea by bobbylight.
the class TaskTagParserTest method testParse_noLanguage.
@Test
void testParse_noLanguage() throws Exception {
TaskTagParser parser = new TaskTagParser();
parser.setTaskPattern(null);
RSyntaxDocument doc = new RSyntaxDocument(SyntaxConstants.SYNTAX_STYLE_NONE);
doc.insertString(0, "/* TODO: Fix this */ for", null);
ParseResult res = parser.parse(doc, doc.getSyntaxStyle());
Assertions.assertEquals(parser, res.getParser());
Assertions.assertEquals(0, res.getFirstLineParsed());
Assertions.assertEquals(0, res.getLastLineParsed());
List<ParserNotice> notices = res.getNotices();
Assertions.assertEquals(0, notices.size());
// Not really valid, but whatever
doc.setSyntaxStyle((String) null);
res = parser.parse(doc, doc.getSyntaxStyle());
Assertions.assertEquals(parser, res.getParser());
Assertions.assertEquals(0, res.getFirstLineParsed());
Assertions.assertEquals(0, res.getLastLineParsed());
notices = res.getNotices();
Assertions.assertEquals(0, notices.size());
}
use of org.fife.ui.rsyntaxtextarea.RSyntaxDocument in project RSyntaxTextArea by bobbylight.
the class TaskTagParserTest method testParse_happyPath.
@Test
void testParse_happyPath() throws Exception {
TaskTagParser parser = new TaskTagParser();
RSyntaxDocument doc = new RSyntaxDocument(SyntaxConstants.SYNTAX_STYLE_C);
doc.insertString(0, "/* TODO: Fix this */", null);
ParseResult res = parser.parse(doc, doc.getSyntaxStyle());
Assertions.assertEquals(parser, res.getParser());
Assertions.assertEquals(0, res.getFirstLineParsed());
Assertions.assertEquals(0, res.getLastLineParsed());
List<ParserNotice> notices = res.getNotices();
Assertions.assertEquals(1, notices.size());
// Note that the parser does not understand EOL vs. MLC comments, so
// it just returns everything from the start of the task to the end of
// the line.
Assertions.assertEquals("TODO: Fix this */", notices.get(0).getToolTipText());
}
use of org.fife.ui.rsyntaxtextarea.RSyntaxDocument in project RSyntaxTextArea by bobbylight.
the class XmlParserTest method testParse_error_unclosedTag_nodtd.
@Test
void testParse_error_unclosedTag_nodtd() throws Exception {
XmlParser parser = new XmlParser();
// Include a DTD just for more code coverage
RSyntaxDocument doc = new RSyntaxDocument(SyntaxConstants.SYNTAX_STYLE_XML);
doc.insertString(0, "<?xml version='1.0'?>\n" + "<books>", null);
ParseResult res = parser.parse(doc, doc.getSyntaxStyle());
Assertions.assertEquals(parser, res.getParser());
Assertions.assertEquals(0, res.getFirstLineParsed());
Assertions.assertEquals(1, res.getLastLineParsed());
List<ParserNotice> notices = res.getNotices();
Assertions.assertEquals(1, notices.size());
ParserNotice notice = notices.get(0);
Assertions.assertEquals(ParserNotice.Level.ERROR, notice.getLevel());
}
use of org.fife.ui.rsyntaxtextarea.RSyntaxDocument in project RSyntaxTextArea by bobbylight.
the class XmlParserTest method testParse_emptyDocument.
@Test
void testParse_emptyDocument() {
XmlParser parser = new XmlParser();
RSyntaxDocument doc = new RSyntaxDocument(SyntaxConstants.SYNTAX_STYLE_XML);
ParseResult res = parser.parse(doc, doc.getSyntaxStyle());
assertCleanParseResult_oneLineDocument(parser, res);
}
Aggregations