Search in sources :

Example 6 with IPartitionTokenScanner

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

the class FastPartitionerTest method testBug409538_2.

@Test
public void testBug409538_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("<!-- blah");
    assertEqualPartition(0, 9, 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 7 with IPartitionTokenScanner

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

the class FastPartitionerTest method testPR130900.

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

        {
            IToken comment = new Token(COMMENT);
            IPredicateRule[] rules = new IPredicateRule[] { new SingleLineRule("#", null, comment, (char) 0, true, false) };
            setPredicateRules(rules);
        }
    };
    fPartitioner = createPartitioner(scanner);
    fDoc.setDocumentPartitioner(fPartitioner);
    fPartitioner.connect(fDoc);
    fDoc.set("#");
    int[] offsets = new int[] { 0, 1 };
    assertComputePartitioning_InterleavingPartitions(offsets);
}
Also used : RuleBasedPartitionScanner(org.eclipse.jface.text.rules.RuleBasedPartitionScanner) IToken(org.eclipse.jface.text.rules.IToken) SingleLineRule(org.eclipse.jface.text.rules.SingleLineRule) 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

IPartitionTokenScanner (org.eclipse.jface.text.rules.IPartitionTokenScanner)7 IPredicateRule (org.eclipse.jface.text.rules.IPredicateRule)7 IToken (org.eclipse.jface.text.rules.IToken)7 RuleBasedPartitionScanner (org.eclipse.jface.text.rules.RuleBasedPartitionScanner)7 Token (org.eclipse.jface.text.rules.Token)7 MultiLineRule (org.eclipse.jface.text.rules.MultiLineRule)6 Test (org.junit.Test)5 Document (org.eclipse.jface.text.Document)2 IDocument (org.eclipse.jface.text.IDocument)2 Before (org.junit.Before)2 FastPartitioner (org.eclipse.jface.text.rules.FastPartitioner)1 SingleLineRule (org.eclipse.jface.text.rules.SingleLineRule)1