Search in sources :

Example 6 with ICharacterPairMatcher

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

the class AbstractPairMatcherTest method testSimpleMatchSameMatcher.

/**
 * Very simple checks.
 *
 * @throws BadLocationException test failure
 */
@Test
public void testSimpleMatchSameMatcher() throws BadLocationException {
    final ICharacterPairMatcher matcher = createMatcher("()[]{}");
    performMatch(matcher, "#(   )%");
    performMatch(matcher, "#[   ]%");
    performMatch(matcher, "#{   }%");
    performMatch(matcher, "(%   )#");
    performMatch(matcher, "[%   ]#");
    performMatch(matcher, "{%   }#");
    performMatch(matcher, "#(   %)%");
    performMatch(matcher, "#[   %]%");
    performMatch(matcher, "#{   %}%");
    performMatch(matcher, "%(%   )#");
    performMatch(matcher, "%[%   ]#");
    performMatch(matcher, "%{%   }#");
    performMatch(matcher, "#(  %  )#");
    performMatch(matcher, "#[  %  ]#");
    performMatch(matcher, "#{  %  }#");
    performMatch(matcher, "#(  % %  )#");
    performMatch(matcher, "#[  % %  ]#");
    performMatch(matcher, "#{  % %  }#");
    matcher.dispose();
}
Also used : ICharacterPairMatcher(org.eclipse.jface.text.source.ICharacterPairMatcher) Test(org.junit.Test)

Example 7 with ICharacterPairMatcher

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

the class ABSEditor method configureSourceViewerDecorationSupport.

@Override
protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
    IPreferenceStore store = getPreferenceStore();
    store.setValue(LOCATION_TYPE_NEAR_TEXTSTYLE_KEY, LOCATION_TYPE_NEAR_TEXTSTYLE_VALUE);
    store.setValue(LOCATION_TYPE_FAR_TEXTSTYLE_KEY, LOCATION_TYPE_FAR_TEXTSTYLE_VALUE);
    store.setValue(LOCATION_TYPE_SOMEWHERE_TEXTSTYLE_KEY, LOCATION_TYPE_SOMEWHERE_TEXTSTYLE_VALUE);
    super.configureSourceViewerDecorationSupport(support);
    // which brackets to match
    char[] matchChars = { '(', ')', '[', ']', '{', '}' };
    ICharacterPairMatcher matcher = new DefaultCharacterPairMatcher(matchChars, IDocumentExtension3.DEFAULT_PARTITIONING);
    support.setCharacterPairMatcher(matcher);
    support.setMatchingCharacterPainterPreferenceKeys(EDITOR_MATCHING_BRACKETS, EDITOR_MATCHING_BRACKETS_COLOR);
    // Enable bracket highlighting in the preference store
    store.setDefault(EDITOR_MATCHING_BRACKETS, true);
    store.setDefault(EDITOR_MATCHING_BRACKETS_COLOR, Constants.DEFAULT_MATCHING_BRACKETS_COLOR);
}
Also used : DefaultCharacterPairMatcher(org.eclipse.jface.text.source.DefaultCharacterPairMatcher) ICharacterPairMatcher(org.eclipse.jface.text.source.ICharacterPairMatcher) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 8 with ICharacterPairMatcher

use of org.eclipse.jface.text.source.ICharacterPairMatcher in project jbosstools-hibernate by jbosstools.

the class HQLEditor method configureSourceViewerDecorationSupport.

@Override
protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
    super.configureSourceViewerDecorationSupport(support);
    // which brackets to match
    char[] matchChars = { '(', ')', '[', ']', '{', '}' };
    ICharacterPairMatcher matcher = new DefaultCharacterPairMatcher(matchChars, IDocumentExtension3.DEFAULT_PARTITIONING);
    support.setCharacterPairMatcher(matcher);
    support.setMatchingCharacterPainterPreferenceKeys(HQL_EDITOR_MATCHING_BRACKETS, HQL_EDITOR_MATCHING_BRACKETS_COLOR);
    // Enable bracket highlighting in the preference store
    IPreferenceStore store = getPreferenceStore();
    store.setDefault(HQL_EDITOR_MATCHING_BRACKETS, true);
    // $NON-NLS-1$
    store.setDefault(HQL_EDITOR_MATCHING_BRACKETS_COLOR, "128,128,128");
}
Also used : DefaultCharacterPairMatcher(org.eclipse.jface.text.source.DefaultCharacterPairMatcher) ICharacterPairMatcher(org.eclipse.jface.text.source.ICharacterPairMatcher) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 9 with ICharacterPairMatcher

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

the class AbstractPairMatcherTest method testCloseMatches.

/**
 * Close matches.
 *
 * @throws BadLocationException
 */
public void testCloseMatches() throws BadLocationException {
    final ICharacterPairMatcher matcher = createMatcher("()[]{}");
    performMatch(matcher, "#()%");
    performMatch(matcher, "(%)#");
    performMatch(matcher, "#(())%");
    performMatch(matcher, "(%())#");
    performMatch(matcher, "((%)#)");
    performMatch(matcher, "(#()%)");
    matcher.dispose();
}
Also used : ICharacterPairMatcher(org.eclipse.jface.text.source.ICharacterPairMatcher)

Example 10 with ICharacterPairMatcher

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

the class AbstractPairMatcherTest method performMatch.

private void performMatch(final String delims, final String testCase) {
    final ICharacterPairMatcher matcher = createMatcher(delims);
    performMatch(matcher, testCase);
    matcher.dispose();
}
Also used : ICharacterPairMatcher(org.eclipse.jface.text.source.ICharacterPairMatcher)

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