Search in sources :

Example 11 with IPredicateRule

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

Example 12 with IPredicateRule

use of org.eclipse.jface.text.rules.IPredicateRule in project webtools.sourceediting by eclipse.

the class AbstractPairMatcherTest method createPartitioner.

private static IDocumentPartitioner createPartitioner() {
    final RuleBasedPartitionScanner scan = new RuleBasedPartitionScanner();
    final List /*<IPredicateRule>*/
    rules = new ArrayList();
    rules.add(new SingleLineRule("|a", "a|", new Token("a")));
    rules.add(new SingleLineRule("|b", "b|", new Token("b")));
    rules.add(new SingleLineRule("|c", "c|", new Token("c")));
    scan.setPredicateRules((IPredicateRule[]) rules.toArray(new IPredicateRule[rules.size()]));
    scan.setDefaultReturnToken(new Token(DEFAULT_PARTITION));
    return new FastPartitioner(scan, new String[] { DEFAULT_PARTITION, "a", "b", "c" });
}
Also used : RuleBasedPartitionScanner(org.eclipse.jface.text.rules.RuleBasedPartitionScanner) SingleLineRule(org.eclipse.jface.text.rules.SingleLineRule) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Token(org.eclipse.jface.text.rules.Token) IPredicateRule(org.eclipse.jface.text.rules.IPredicateRule)

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