diff options
author | Deepak Azad | 2012-02-10 10:27:51 +0000 |
---|---|---|
committer | Dani Megert | 2012-02-10 10:27:51 +0000 |
commit | b8d0417ed59519a46d28cac812ad3b7393dd83e9 (patch) | |
tree | 163e5f5c761fa497dc6f600ecbfc0d5d9cbb3a39 /org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java | |
parent | f7e9c6e267deffe8ad723ad4b8c99d360e585a7b (diff) | |
download | eclipse.platform.text-b8d0417ed59519a46d28cac812ad3b7393dd83e9.tar.gz eclipse.platform.text-b8d0417ed59519a46d28cac812ad3b7393dd83e9.tar.xz eclipse.platform.text-b8d0417ed59519a46d28cac812ad3b7393dd83e9.zip |
Fixed bug 366400: [preferences][syntax highlighting] New preference tov20120210-1027
always show enclosing brackets
Diffstat (limited to 'org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java')
-rw-r--r-- | org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java index 7b4b9e64bba..c329c61f04f 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java @@ -29,7 +29,7 @@ import org.eclipse.jface.text.TextUtilities; * * @since 3.3 */ -public class DefaultCharacterPairMatcher implements ICharacterPairMatcher { +public class DefaultCharacterPairMatcher implements ICharacterPairMatcher, ICharacterPairMatcherExtension { private int fAnchor= -1; private final CharPairs fPairs; @@ -107,6 +107,34 @@ public class DefaultCharacterPairMatcher implements ICharacterPairMatcher { } } + /** + * @see org.eclipse.jface.text.source.ICharacterPairMatcherExtension#findEnclosingPeerCharacters(org.eclipse.jface.text.IDocument, + * int) + * @since 3.8 + */ + public IRegion findEnclosingPeerCharacters(IDocument doc, int offset) { + if (doc == null || offset < 0 || offset > doc.getLength()) + return null; + try { + for (int offset1= offset; offset1 >= 0; offset1--) { + char prevChar= doc.getChar(Math.max(offset1 - 1, 0)); + if (fPairs.contains(prevChar) && fPairs.isStartCharacter(prevChar)) { + IRegion match= performMatch(doc, offset1); + if (match != null) { + int matchOffset= match.getOffset(); + int matchLength= match.getLength(); + if ((matchOffset <= offset) && (matchOffset + matchLength > offset)) { + return match; + } + } + } + } + } catch (BadLocationException ble) { + return null; + } + return null; + } + /* * Performs the actual work of matching for #match(IDocument, int). */ |