From 8c91a618e42266cb7d201480fc4bd8c3f6cdeedc Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Sat, 23 Jan 2010 14:03:50 +0300 Subject: [PATCH] IDEA-38432 CSS: non-curved braces without pair brace are resolved as matching to curved braces --- .../codeInsight/highlighting/BraceMatchingUtil.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java index 33709cc88c..c3bbed3225 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java @@ -66,6 +66,7 @@ public class BraceMatchingUtil { String brace1TagName; boolean isStrict; boolean isCaseSensitive; + boolean isStructural; private BraceMatcher myMatcher; MatchBraceContext(CharSequence _fileText, FileType _fileType, HighlighterIterator _iterator, boolean _forward) { @@ -80,6 +81,7 @@ public class BraceMatchingUtil { brace1TagName = myMatcher == null ? null : getTagName(myMatcher,fileText, iterator); isStrict = myMatcher != null && isStrictTagMatching(myMatcher,fileType, group); + isStructural = !isStrict && myMatcher != null && myMatcher.isStructuralBrace(iterator, fileText, fileType); isCaseSensitive = myMatcher != null && areTagsCaseSensitive(myMatcher,fileType, group); } @@ -115,6 +117,12 @@ public class BraceMatchingUtil { } String tagName = myMatcher == null ? null : getTagName(myMatcher,fileText, iterator); if (!isStrict && !Comparing.equal(brace1TagName, tagName, isCaseSensitive)) continue; + + if (isStructural && (forward ? isRBraceToken(iterator, fileText, fileType) && !isPairBraces(brace1Token, tokenType, fileType) + : isLBraceToken(iterator, fileText, fileType) && !isPairBraces(brace1Token, tokenType, fileType))) { + if (!ourBraceStack.isEmpty() && myMatcher != null && !ourBraceStack.contains(myMatcher.getOppositeBraceTokenType(tokenType))) continue; + } + if (forward ? isLBraceToken(iterator, fileText, fileType) : isRBraceToken(iterator, fileText, fileType)){ ourBraceStack.push(tokenType); if (isStrict){ @@ -128,6 +136,12 @@ public class BraceMatchingUtil { topTagName = ourTagNameStack.pop(); } + if (!isStrict && myMatcher != null && ourBraceStack.contains(myMatcher.getOppositeBraceTokenType(tokenType))) { + while(!isPairBraces(topTokenType, tokenType, fileType)) { + topTokenType = ourBraceStack.pop(); + } + } + if (!isPairBraces(topTokenType, tokenType, fileType) || isStrict && !Comparing.equal(topTagName, tagName, isCaseSensitive) ){ -- 2.11.4.GIT