From 920f99eea98b5a81a299e0d37fa90b5ba0fbc577 Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Fri, 30 Dec 2011 14:29:36 +0400 Subject: [PATCH] IDEA-79375 IDEA doesn't highlight parent brackets Brace matching is non-strict by default, so, critical places that change document text on that brace match information explicitly use strict matching now --- .../intellij/codeInsight/editorActions/TypedHandler.java | 6 +++--- .../codeInsight/highlighting/BraceMatchingUtil.java | 4 ++-- .../testFramework/LightPlatformCodeInsightTestCase.java | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TypedHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TypedHandler.java index cd0287280c28..c37dbe62c870 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TypedHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TypedHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -317,7 +317,7 @@ public class TypedHandler extends TypedActionHandlerBase { if (lparenOffset < 0) lparenOffset = 0; iterator = ((EditorEx)editor).getHighlighter().createIterator(lparenOffset); - boolean matched = BraceMatchingUtil.matchBrace(fileText, fileType, iterator, true); + boolean matched = BraceMatchingUtil.matchBrace(fileText, fileType, iterator, true, true); if (!matched) { String text; @@ -388,7 +388,7 @@ public class TypedHandler extends TypedActionHandlerBase { } iterator = ((EditorEx) editor).getHighlighter().createIterator(lparenthOffset); - boolean matched = BraceMatchingUtil.matchBrace(text, fileType, iterator, true); + boolean matched = BraceMatchingUtil.matchBrace(text, fileType, iterator, true, true); if (!matched) return false; 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 09fa0da60ac6..6d5b04616b3a 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java @@ -156,8 +156,8 @@ public class BraceMatchingUtil { topTokenType = myBraceStack.pop(); } } - else if (!topTokenType.equals(baseType) && (brace1TagName == null || !brace1TagName.equals(tagName))) { - // Ignore non-matched opposite-direction brace. + else if ((brace1TagName == null || !brace1TagName.equals(tagName)) && !isPairBraces(topTokenType, tokenType, fileType)) { + // Ignore non-matched opposite-direction brace for non-strict processing. myBraceStack.push(topTokenType); continue; } diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java index c398f4a24cd7..7ad3141db102 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -431,8 +431,8 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest caretMarker.getStartOffset(), CodeStyleSettingsManager.getSettings(getProject()).getIndentOptions(StdFileTypes.JAVA).TAB_SIZE); - assertEquals(getMessage("caretLine", message), caretLine + 1, myEditor.getCaretModel().getLogicalPosition().line + 1); - assertEquals(getMessage("caretColumn", message), caretCol + 1, myEditor.getCaretModel().getLogicalPosition().column + 1); + assertEquals(getMessage("caretLine", message), caretLine, myEditor.getCaretModel().getLogicalPosition().line); + assertEquals(getMessage("caretColumn", message), caretCol, myEditor.getCaretModel().getLogicalPosition().column); } }