From 08f38405adc5d56f73fac65d14552d22250907c5 Mon Sep 17 00:00:00 2001 From: "Anna.Kozlova" Date: Wed, 14 Dec 2016 15:25:55 +0100 Subject: [PATCH] support navigation in stacktraces where class fqns are prefixed with module name (IDEA-165456) --- .../navigation/ExceptionFilterTest.java | 38 +++++++++++++++++++ .../execution/filters/ExceptionWorker.java | 4 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testSrc/com/intellij/navigation/ExceptionFilterTest.java diff --git a/java/java-tests/testSrc/com/intellij/navigation/ExceptionFilterTest.java b/java/java-tests/testSrc/com/intellij/navigation/ExceptionFilterTest.java new file mode 100644 index 000000000000..4072ef36b250 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/navigation/ExceptionFilterTest.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.intellij.navigation; + +import com.intellij.execution.filters.ExceptionInfoCache; +import com.intellij.execution.filters.ExceptionWorker; +import com.intellij.psi.PsiClass; +import com.intellij.psi.search.GlobalSearchScope; +import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase; + +public class ExceptionFilterTest extends JavaCodeInsightFixtureTestCase { + + public void testJava9ModulePrefixed() throws Throwable { + PsiClass psiClass = myFixture.addClass("package p; public class A {\n" + + " public void foo() {}\n" + + "}"); + ExceptionWorker worker = new ExceptionWorker(new ExceptionInfoCache(GlobalSearchScope.projectScope(getProject()))); + String line = "at mod.name/p.A.foo(A.java:2)"; + worker.execute(line, line.length()); + PsiClass aClass = worker.getPsiClass(); + assertNotNull(aClass); + assertEquals(psiClass, aClass); + } +} \ No newline at end of file diff --git a/java/openapi/src/com/intellij/execution/filters/ExceptionWorker.java b/java/openapi/src/com/intellij/execution/filters/ExceptionWorker.java index 78183569b714..c2c97a9e310d 100644 --- a/java/openapi/src/com/intellij/execution/filters/ExceptionWorker.java +++ b/java/openapi/src/com/intellij/execution/filters/ExceptionWorker.java @@ -196,9 +196,11 @@ public class ExceptionWorker { final int dotIdx = line.lastIndexOf('.', lParenIdx); if (dotIdx < 0 || dotIdx < startIdx) return null; + int moduleIdx = line.indexOf('/'); + int classNameIdx = moduleIdx > -1 && moduleIdx < lParenIdx ? moduleIdx + 1 : startIdx + 1 + (startIdx >= 0 ? AT.length() : 0); // class, method, link - return Trinity.create(new TextRange(startIdx + 1 + (startIdx >= 0 ? AT.length() : 0), handleSpaces(line, dotIdx, -1, true)), + return Trinity.create(new TextRange(classNameIdx, handleSpaces(line, dotIdx, -1, true)), new TextRange(handleSpaces(line, dotIdx + 1, 1, true), handleSpaces(line, lParenIdx + 1, -1, true)), new TextRange(lParenIdx, rParenIdx)); }