Search in sources :

Example 1 with IPredicateRule

use of org.eclipse.jface.text.rules.IPredicateRule 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 IPredicateRule

use of org.eclipse.jface.text.rules.IPredicateRule 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 IPredicateRule

use of org.eclipse.jface.text.rules.IPredicateRule 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 IPredicateRule

use of org.eclipse.jface.text.rules.IPredicateRule 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 IPredicateRule

use of org.eclipse.jface.text.rules.IPredicateRule 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

IPredicateRule (org.eclipse.jface.text.rules.IPredicateRule)12 RuleBasedPartitionScanner (org.eclipse.jface.text.rules.RuleBasedPartitionScanner)12 Token (org.eclipse.jface.text.rules.Token)12 IPartitionTokenScanner (org.eclipse.jface.text.rules.IPartitionTokenScanner)10 IToken (org.eclipse.jface.text.rules.IToken)10 MultiLineRule (org.eclipse.jface.text.rules.MultiLineRule)8 Test (org.junit.Test)5 Document (org.eclipse.jface.text.Document)4 IDocument (org.eclipse.jface.text.IDocument)4 FastPartitioner (org.eclipse.jface.text.rules.FastPartitioner)4 SingleLineRule (org.eclipse.jface.text.rules.SingleLineRule)4 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 List (java.util.List)1