Search in sources :

Example 1 with MultiLineRule

use of org.eclipse.jface.text.rules.MultiLineRule in project eclipse.platform.text by eclipse.

the class DefaultPartitionerZeroLengthTest method setUp.

@Before
public void setUp() {
    fDoc = new Document();
    IPartitionTokenScanner scanner = new RuleBasedPartitionScanner() {

        {
            IToken comment = new Token(COMMENT);
            IPredicateRule[] rules = new IPredicateRule[] { new MultiLineRule("/*", "*/", comment) };
            setPredicateRules(rules);
        }
    };
    fPartitioner = new FastPartitioner(scanner, new String[] { DEFAULT, COMMENT });
    fDoc.setDocumentPartitioner(fPartitioner);
    fPartitioner.connect(fDoc);
}
Also used : RuleBasedPartitionScanner(org.eclipse.jface.text.rules.RuleBasedPartitionScanner) IToken(org.eclipse.jface.text.rules.IToken) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) MultiLineRule(org.eclipse.jface.text.rules.MultiLineRule) IPartitionTokenScanner(org.eclipse.jface.text.rules.IPartitionTokenScanner) IToken(org.eclipse.jface.text.rules.IToken) Token(org.eclipse.jface.text.rules.Token) IPredicateRule(org.eclipse.jface.text.rules.IPredicateRule) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) Before(org.junit.Before)

Example 2 with MultiLineRule

use of org.eclipse.jface.text.rules.MultiLineRule in project eclipse.platform.text by eclipse.

the class FastPartitionerTest method testBug368219_1.

@Test
public void testBug368219_1() throws Exception {
    fPartitioner.disconnect();
    IPartitionTokenScanner scanner = new RuleBasedPartitionScanner() {

        {
            IToken comment = new Token(COMMENT);
            IPredicateRule[] rules = new IPredicateRule[] { new MultiLineRule("/*", "*/", comment) };
            setPredicateRules(rules);
        }
    };
    fPartitioner = createPartitioner(scanner);
    fDoc.setDocumentPartitioner(fPartitioner);
    fPartitioner.connect(fDoc);
    fDoc.set("/**");
    assertEqualPartition(0, 3, DEFAULT);
}
Also used : RuleBasedPartitionScanner(org.eclipse.jface.text.rules.RuleBasedPartitionScanner) IToken(org.eclipse.jface.text.rules.IToken) MultiLineRule(org.eclipse.jface.text.rules.MultiLineRule) IPartitionTokenScanner(org.eclipse.jface.text.rules.IPartitionTokenScanner) IToken(org.eclipse.jface.text.rules.IToken) Token(org.eclipse.jface.text.rules.Token) IPredicateRule(org.eclipse.jface.text.rules.IPredicateRule) Test(org.junit.Test)

Example 3 with MultiLineRule

use of org.eclipse.jface.text.rules.MultiLineRule in project eclipse.platform.text by eclipse.

the class FastPartitionerTest method testBug368219_2.

@Test
public void testBug368219_2() throws Exception {
    fPartitioner.disconnect();
    IPartitionTokenScanner scanner = new RuleBasedPartitionScanner() {

        {
            IToken comment = new Token(COMMENT);
            IPredicateRule[] rules = new IPredicateRule[] { new MultiLineRule("/*", "*/", comment, (char) 0, true) };
            setPredicateRules(rules);
        }
    };
    fPartitioner = createPartitioner(scanner);
    fDoc.setDocumentPartitioner(fPartitioner);
    fPartitioner.connect(fDoc);
    fDoc.set("/**");
    assertEqualPartition(0, 3, COMMENT);
}
Also used : RuleBasedPartitionScanner(org.eclipse.jface.text.rules.RuleBasedPartitionScanner) IToken(org.eclipse.jface.text.rules.IToken) MultiLineRule(org.eclipse.jface.text.rules.MultiLineRule) IPartitionTokenScanner(org.eclipse.jface.text.rules.IPartitionTokenScanner) IToken(org.eclipse.jface.text.rules.IToken) Token(org.eclipse.jface.text.rules.Token) IPredicateRule(org.eclipse.jface.text.rules.IPredicateRule) Test(org.junit.Test)

Example 4 with MultiLineRule

use of org.eclipse.jface.text.rules.MultiLineRule in project eclipse.platform.text by eclipse.

the class FastPartitionerTest method setUp.

@Before
public void setUp() {
    fDoc = new Document();
    IPartitionTokenScanner scanner = new RuleBasedPartitionScanner() {

        {
            IToken comment = new Token(COMMENT);
            IPredicateRule[] rules = new IPredicateRule[] { new MultiLineRule("/*", "*/", comment) };
            setPredicateRules(rules);
        }
    };
    fPartitioner = createPartitioner(scanner);
    fDoc.setDocumentPartitioner(fPartitioner);
    fPartitioner.connect(fDoc);
}
Also used : RuleBasedPartitionScanner(org.eclipse.jface.text.rules.RuleBasedPartitionScanner) IToken(org.eclipse.jface.text.rules.IToken) MultiLineRule(org.eclipse.jface.text.rules.MultiLineRule) IPartitionTokenScanner(org.eclipse.jface.text.rules.IPartitionTokenScanner) IToken(org.eclipse.jface.text.rules.IToken) Token(org.eclipse.jface.text.rules.Token) IPredicateRule(org.eclipse.jface.text.rules.IPredicateRule) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) Before(org.junit.Before)

Example 5 with MultiLineRule

use of org.eclipse.jface.text.rules.MultiLineRule in project eclipse.platform.text by eclipse.

the class FastPartitionerTest method testBug409538_1.

@Test
public void testBug409538_1() throws Exception {
    fPartitioner.disconnect();
    IPartitionTokenScanner scanner = new RuleBasedPartitionScanner() {

        {
            IToken comment = new Token(COMMENT);
            IPredicateRule[] rules = new IPredicateRule[] { new MultiLineRule("<!--", "-->", comment, (char) 0, true) };
            setPredicateRules(rules);
        }
    };
    fPartitioner = createPartitioner(scanner);
    fDoc.setDocumentPartitioner(fPartitioner);
    fPartitioner.connect(fDoc);
    fDoc.set("<");
    assertEqualPartition(0, 1, DEFAULT);
}
Also used : RuleBasedPartitionScanner(org.eclipse.jface.text.rules.RuleBasedPartitionScanner) IToken(org.eclipse.jface.text.rules.IToken) MultiLineRule(org.eclipse.jface.text.rules.MultiLineRule) IPartitionTokenScanner(org.eclipse.jface.text.rules.IPartitionTokenScanner) IToken(org.eclipse.jface.text.rules.IToken) Token(org.eclipse.jface.text.rules.Token) IPredicateRule(org.eclipse.jface.text.rules.IPredicateRule) Test(org.junit.Test)

Aggregations

MultiLineRule (org.eclipse.jface.text.rules.MultiLineRule)15 IToken (org.eclipse.jface.text.rules.IToken)13 Token (org.eclipse.jface.text.rules.Token)11 IPartitionTokenScanner (org.eclipse.jface.text.rules.IPartitionTokenScanner)8 IPredicateRule (org.eclipse.jface.text.rules.IPredicateRule)8 RuleBasedPartitionScanner (org.eclipse.jface.text.rules.RuleBasedPartitionScanner)8 IRule (org.eclipse.jface.text.rules.IRule)7 ArrayList (java.util.ArrayList)6 SingleLineRule (org.eclipse.jface.text.rules.SingleLineRule)5 Document (org.eclipse.jface.text.Document)4 IDocument (org.eclipse.jface.text.IDocument)4 TextAttribute (org.eclipse.jface.text.TextAttribute)4 EndOfLineRule (org.eclipse.jface.text.rules.EndOfLineRule)4 Test (org.junit.Test)4 WordRule (org.eclipse.jface.text.rules.WordRule)3 Color (org.eclipse.swt.graphics.Color)3 List (java.util.List)2 FastPartitioner (org.eclipse.jface.text.rules.FastPartitioner)2 RGB (org.eclipse.swt.graphics.RGB)2 Before (org.junit.Before)2