From c5852152b20e0cee9c22713b4caf28fe9c73504b Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Tue, 14 Oct 2014 15:11:29 +0400 Subject: [PATCH] Don't ruin highlighting if there's no descriptor in resolve session #EA-61683 Fixed --- .../highlighter/markers/SuperDeclarationMarker.kt | 6 ++++-- .../codeInsight/lineMarker/BadCodeNoExceptions.kt | 10 ++++++++++ .../plugin/codeInsight/LineMarkersTestGenerated.java | 6 ++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 idea/testData/codeInsight/lineMarker/BadCodeNoExceptions.kt diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/markers/SuperDeclarationMarker.kt b/idea/src/org/jetbrains/jet/plugin/highlighter/markers/SuperDeclarationMarker.kt index 9022aae2411..61dbd7ff666 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/markers/SuperDeclarationMarker.kt +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/markers/SuperDeclarationMarker.kt @@ -34,8 +34,9 @@ import org.jetbrains.annotations.TestOnly import com.intellij.codeInsight.daemon.GutterIconNavigationHandler import java.util.ArrayList import com.intellij.util.Function -import org.jetbrains.jet.plugin.caches.resolve.getLazyResolveSession import org.jetbrains.jet.lang.psi.JetDeclaration +import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache +import org.jetbrains.jet.lang.resolve.BindingContext object SuperDeclarationMarkerTooltip: Function { override fun `fun`(jetDeclaration: JetDeclaration?): String? { @@ -111,7 +112,8 @@ public data class ResolveWithParentsResult( val overriddenDescriptors: Collection) public fun resolveDeclarationWithParents(element: JetDeclaration): ResolveWithParentsResult { - val descriptor = element.getLazyResolveSession().resolveToDescriptor(element) + val bindingContext = AnalyzerFacadeWithCache.getContextForElement(element) + val descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element) if (descriptor !is CallableMemberDescriptor) return ResolveWithParentsResult(null, listOf()) diff --git a/idea/testData/codeInsight/lineMarker/BadCodeNoExceptions.kt b/idea/testData/codeInsight/lineMarker/BadCodeNoExceptions.kt new file mode 100644 index 00000000000..3fa668a0c63 --- /dev/null +++ b/idea/testData/codeInsight/lineMarker/BadCodeNoExceptions.kt @@ -0,0 +1,10 @@ +trait Hi { + fun foo(): Int +} + +// Closing brace is intentionally missed +val id = array("kotlin.FlexibleType" + +private class Some(): Hi { + override fun foo() = 1 +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/codeInsight/LineMarkersTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/codeInsight/LineMarkersTestGenerated.java index cb620023f97..37cf904fe38 100644 --- a/idea/tests/org/jetbrains/jet/plugin/codeInsight/LineMarkersTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/codeInsight/LineMarkersTestGenerated.java @@ -38,6 +38,12 @@ public class LineMarkersTestGenerated extends AbstractLineMarkersTest { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/codeInsight/lineMarker"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("BadCodeNoExceptions.kt") + public void testBadCodeNoExceptions() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/codeInsight/lineMarker/BadCodeNoExceptions.kt"); + doTest(fileName); + } + @TestMetadata("Class.kt") public void testClass() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/codeInsight/lineMarker/Class.kt");