Search in sources :

Example 1 with RSyntaxDocument

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));
}
Also used : RSyntaxDocument(org.fife.ui.rsyntaxtextarea.RSyntaxDocument) RSyntaxTextArea(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea) Test(org.junit.jupiter.api.Test)

Example 2 with RSyntaxDocument

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());
}
Also used : RSyntaxDocument(org.fife.ui.rsyntaxtextarea.RSyntaxDocument) Test(org.junit.jupiter.api.Test)

Example 3 with RSyntaxDocument

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());
}
Also used : RSyntaxDocument(org.fife.ui.rsyntaxtextarea.RSyntaxDocument) Test(org.junit.jupiter.api.Test)

Example 4 with RSyntaxDocument

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());
}
Also used : RSyntaxDocument(org.fife.ui.rsyntaxtextarea.RSyntaxDocument) Test(org.junit.jupiter.api.Test)

Example 5 with RSyntaxDocument

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);
}
Also used : RSyntaxDocument(org.fife.ui.rsyntaxtextarea.RSyntaxDocument) Test(org.junit.jupiter.api.Test)

Aggregations

RSyntaxDocument (org.fife.ui.rsyntaxtextarea.RSyntaxDocument)35 RSyntaxTextArea (org.fife.ui.rsyntaxtextarea.RSyntaxTextArea)9 Test (org.junit.jupiter.api.Test)8 BadLocationException (javax.swing.text.BadLocationException)7 JPanel (javax.swing.JPanel)5 Element (javax.swing.text.Element)5 VhdlSyntax (com.cburch.logisim.vhdl.syntax.VhdlSyntax)4 Caret (javax.swing.text.Caret)4 Token (org.fife.ui.rsyntaxtextarea.Token)4 RTextScrollPane (org.fife.ui.rtextarea.RTextScrollPane)4 Dimension (java.awt.Dimension)3 TokenMakerFactory (org.fife.ui.rsyntaxtextarea.TokenMakerFactory)3 AbstractParser (org.fife.ui.rsyntaxtextarea.parser.AbstractParser)3 DefaultParseResult (org.fife.ui.rsyntaxtextarea.parser.DefaultParseResult)3 ParseResult (org.fife.ui.rsyntaxtextarea.parser.ParseResult)3 FlowLayout (java.awt.FlowLayout)2 Point (java.awt.Point)2 BreakIterator (java.text.BreakIterator)2 Color (java.awt.Color)1 Container (java.awt.Container)1