diff options
author | Deepak Azad | 2012-06-09 14:17:07 +0000 |
---|---|---|
committer | Deepak Azad | 2012-06-09 14:17:07 +0000 |
commit | e61b17dce5f8cd8dee9b4804193afb07250db29c (patch) | |
tree | 5418c211abb9a7c629e71bfb3359d936255da786 | |
parent | 03b415b2980f64697216f297f75295c1721d3ceb (diff) | |
download | eclipse.platform.text-e61b17dce5f8cd8dee9b4804193afb07250db29c.tar.gz eclipse.platform.text-e61b17dce5f8cd8dee9b4804193afb07250db29c.tar.xz eclipse.platform.text-e61b17dce5f8cd8dee9b4804193afb07250db29c.zip |
Bug 380794: [implementation] Make DefaultCharacterPairMatcher.findMatchingPeer(..) non-recursive
-rw-r--r-- | org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java | 25 |
1 files changed, 6 insertions, 19 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 56fbc906c66..f9dc9c9c558 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 @@ -322,14 +322,15 @@ public class DefaultCharacterPairMatcher implements ICharacterPairMatcher, IChar */ private int findMatchingPeer(DocumentPartitionAccessor doc, char start, char end, boolean searchForward, int boundary, int startPos) throws BadLocationException { int pos= startPos; + int nestingLevel= 0; while (pos != boundary) { final char c= doc.getChar(pos); - if (doc.isMatch(pos, end)) { - return pos; + if (c == end && doc.inPartition(pos)) { + if (nestingLevel == 0) + return pos; + nestingLevel--; } else if (c == start && doc.inPartition(pos)) { - pos= findMatchingPeer(doc, start, end, searchForward, boundary, - doc.getNextPosition(pos, searchForward)); - if (pos == -1) return -1; + nestingLevel++; } pos= doc.getNextPosition(pos, searchForward); } @@ -497,20 +498,6 @@ public class DefaultCharacterPairMatcher implements ICharacterPairMatcher, IChar } /** - * Returns true if the character at the specified position is a valid match for the - * specified end character. To be a valid match, it must be in the appropriate partition and - * equal to the end character. - * - * @param pos an offset within this document - * @param end the end character to match against - * @return true exactly if the position represents a valid match - * @throws BadLocationException if the offset is invalid in this document - */ - public boolean isMatch(int pos, char end) throws BadLocationException { - return getChar(pos) == end && inPartition(pos); - } - - /** * Returns true if the specified offset is within the partition * managed by this document. * |