Search in sources :

Example 11 with ICharacterPairMatcher

use of org.eclipse.jface.text.source.ICharacterPairMatcher in project webtools.sourceediting by eclipse.

the class AbstractPairMatcherTest method testBoundaries.

/**
 * Test a few boundary conditions.
 *
 * * @throws BadLocationException
 */
public void testBoundaries() throws BadLocationException {
    final ICharacterPairMatcher matcher = createMatcher("()[]{}");
    final StringDocument doc = new StringDocument("abcdefghijkl");
    assertNull(matcher.match(null, 0));
    assertNull(matcher.match(doc, -1));
    assertNull(matcher.match(doc, doc.getLength() + 1));
    matcher.dispose();
}
Also used : ICharacterPairMatcher(org.eclipse.jface.text.source.ICharacterPairMatcher)

Example 12 with ICharacterPairMatcher

use of org.eclipse.jface.text.source.ICharacterPairMatcher in project eclipse.platform.text by eclipse.

the class AbstractPairMatcherTest method testPartitioned.

/**
 * Test that it doesn't match across different partitions.
 *
 * @throws BadLocationException test failure
 */
@Test
public void testPartitioned() throws BadLocationException {
    final ICharacterPairMatcher matcher = createMatcher("()[]{}");
    performMatch(matcher, "(% |a a| )#");
    performMatch(matcher, "#( |a a| )%");
    performMatch(matcher, "|b #( )% b|");
    performMatch(matcher, "( |b )% b|");
    performMatch(matcher, "(% |b ) b|");
    performMatch(matcher, "|a ( a| )%");
    performMatch(matcher, "|a (% a| )");
    performMatch(matcher, "|c #( c| ) ( |c )% c|");
    performMatch(matcher, "|c (% c| ) ( |c )# c|");
    performMatch(matcher, "(% |a ) a| |b ) b| |c ) c| )#");
    performMatch(matcher, "#( % |a a| )#");
    performMatch(matcher, "|b #( % )# b|");
    performMatch(matcher, "|c #( % c| ) ( |c )# c|");
    performMatch(matcher, "|c #( c| ) ( |c % )# c|");
    performMatch(matcher, "#( % |a ) a| |b ) b| |c ) c| )#");
    performMatch(matcher, "#( |a % a| )#");
    performMatch(matcher, "( |a #( a| ( |a % a| ) |a )# a| )");
    performMatch(matcher, "#( % % |a a| )#");
    performMatch(matcher, "|b #( % % )# b|");
    performMatch(matcher, "|c #( % % c| ) ( |c )# c|");
    performMatch(matcher, "|c #( c| ) ( |c % % )# c|");
    performMatch(matcher, "#( % % |a ) a| |b ) b| |c ) c| )#");
    performMatch(matcher, " #( |c ( c| % % |c ) c| )#");
    matcher.dispose();
}
Also used : ICharacterPairMatcher(org.eclipse.jface.text.source.ICharacterPairMatcher) Test(org.junit.Test)

Example 13 with ICharacterPairMatcher

use of org.eclipse.jface.text.source.ICharacterPairMatcher in project eclipse.platform.text by eclipse.

the class AbstractPairMatcherTest method testBoundaries.

/**
 * Test a few boundary conditions.
 *
 * * @throws BadLocationException test failure
 */
@Test
public void testBoundaries() throws BadLocationException {
    final ICharacterPairMatcher matcher = createMatcher("()[]{}");
    final StringDocument doc = new StringDocument("abcdefghijkl");
    assertNull(matcher.match(null, 0));
    assertNull(matcher.match(doc, -1));
    assertNull(matcher.match(doc, doc.getLength() + 1));
    matcher.dispose();
}
Also used : ICharacterPairMatcher(org.eclipse.jface.text.source.ICharacterPairMatcher) Test(org.junit.Test)

Example 14 with ICharacterPairMatcher

use of org.eclipse.jface.text.source.ICharacterPairMatcher in project eclipse.platform.text by eclipse.

the class AbstractPairMatcherTest method testNesting.

/**
 * Test that nesting works properly
 */
@Test
public void testNesting() {
    final ICharacterPairMatcher matcher = createMatcher("()[]{}");
    performMatch(matcher, " ( #( ( ( ) ) ( ) )% ) ");
    performMatch(matcher, " ( (% ( ( ) ) ( ) )# ) ");
    performMatch(matcher, " ( #( { ( ) } [ ] )% ) ");
    performMatch(matcher, " ( (% { ( ) } [ ] )# ) ");
    performMatch(matcher, " ( ( #{ ( ) }% [ ] ) ) ");
    performMatch(matcher, " ( ( {% ( ) }# [ ] ) ) ");
    performMatch(matcher, "a(b#(c(d(e)f)g(h)i)%j)k");
    performMatch(matcher, "a(b(%c(d(e)f)g(h)i)#j)k");
    performMatch(matcher, "a(b#(c{d(e)f}g[h]i)%j)k");
    performMatch(matcher, "a(b(%c{d(e)f}g[h]i)#j)k");
    performMatch(matcher, "a(b(c#{d(e)f}%g[h]i)j)k");
    performMatch(matcher, "a(b(c{%d(e)f}#g[h]i)j)k");
    performMatch(matcher, " ( #( ( ( ) ) ( ) % )# ) ");
    performMatch(matcher, " ( #( % ( ( ) ) ( ) )# ) ");
    performMatch(matcher, " ( #( { ( ) } [ ] % )# ) ");
    performMatch(matcher, " ( #( % { ( ) } [ ] )# ) ");
    performMatch(matcher, " ( ( #{ ( ) % }# [ ] ) ) ");
    performMatch(matcher, " ( ( #{ % ( ) }# [ ] ) ) ");
    performMatch(matcher, "a(b#(c(d(e)f)g(h)i%)#j)k");
    performMatch(matcher, "a(b#(%c(d(e)f)g(h)i)#j)k");
    performMatch(matcher, "a(b#(c{d(e)f}g[h]i%)#j)k");
    performMatch(matcher, "a(b#(%c{d(e)f}g[h]i)#j)k");
    performMatch(matcher, "a(b(c#{d(e)f%}#g[h]i)j)k");
    performMatch(matcher, "a(b(c#{%d(e)f}#g[h]i)j)k");
    matcher.dispose();
}
Also used : ICharacterPairMatcher(org.eclipse.jface.text.source.ICharacterPairMatcher) Test(org.junit.Test)

Example 15 with ICharacterPairMatcher

use of org.eclipse.jface.text.source.ICharacterPairMatcher in project eclipse.platform.text by eclipse.

the class AbstractPairMatcherTest method testBug156426.

@Test
public void testBug156426() {
    final ICharacterPairMatcher matcher = createMatcher("()[]{}<>");
    performMatch(matcher, " #( a < b )% ");
    performMatch(matcher, " (% a < b )# ");
    performMatch(matcher, " #( a > b )% ");
    performMatch(matcher, " (% a > b )# ");
    matcher.dispose();
}
Also used : ICharacterPairMatcher(org.eclipse.jface.text.source.ICharacterPairMatcher) Test(org.junit.Test)

Aggregations

ICharacterPairMatcher (org.eclipse.jface.text.source.ICharacterPairMatcher)26 Test (org.junit.Test)12 DefaultCharacterPairMatcher (org.eclipse.jface.text.source.DefaultCharacterPairMatcher)3 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 Point (org.eclipse.swt.graphics.Point)2 IDocument (org.eclipse.jface.text.IDocument)1 IRegion (org.eclipse.jface.text.IRegion)1 ITextViewerExtension5 (org.eclipse.jface.text.ITextViewerExtension5)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 ExtendedConfigurationBuilder (org.eclipse.wst.sse.ui.internal.ExtendedConfigurationBuilder)1