From e6eb7b137aa9ddbe8f3259689d762e702a27db1c Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Thu, 14 Dec 2017 19:29:17 +0300 Subject: [PATCH] IDEA-183578 Next method action navigates on a type parameter of a method --- .../JavaMethodNavigationOffsetProvider.java | 16 ++-------------- .../JavaMemberNavigationTest.groovy | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/navigation/JavaMethodNavigationOffsetProvider.java b/java/java-impl/src/com/intellij/codeInsight/navigation/JavaMethodNavigationOffsetProvider.java index d7c6d00e194e..643c88f78769 100644 --- a/java/java-impl/src/com/intellij/codeInsight/navigation/JavaMethodNavigationOffsetProvider.java +++ b/java/java-impl/src/com/intellij/codeInsight/navigation/JavaMethodNavigationOffsetProvider.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2009 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. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.codeInsight.navigation; @@ -33,7 +21,7 @@ public class JavaMethodNavigationOffsetProvider implements MethodNavigationOffse } private static boolean shouldStopAt(PsiElement e) { - if (e instanceof PsiMethod || e instanceof PsiClass) return true; + if (e instanceof PsiMethod || e instanceof PsiClass && !(e instanceof PsiTypeParameter)) return true; if (e instanceof PsiField) return Registry.is("ide.structural.navigation.visit.fields"); return e instanceof PsiJavaToken && e.getParent() instanceof PsiClass && e.textMatches("}"); } diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/navigation/JavaMemberNavigationTest.groovy b/java/java-tests/testSrc/com/intellij/java/codeInsight/navigation/JavaMemberNavigationTest.groovy index 95237f474546..0120b45c2f35 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/navigation/JavaMemberNavigationTest.groovy +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/navigation/JavaMemberNavigationTest.groovy @@ -1,4 +1,6 @@ -// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +/* + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. + */ package com.intellij.java.codeInsight.navigation import com.intellij.codeInsight.navigation.MethodUpDownUtil @@ -27,4 +29,19 @@ class Foo { assert file.text.indexOf('Local') in offsets assert file.text.indexOf('localMethod') in offsets } + + void "test type parameters are not included"() { + def file = myFixture.configureByText('a.java', ''' +class Foo { + void m1(T t) {} +} +''') + def offsets = MethodUpDownUtil.getNavigationOffsets(file, 0) + String typeParameterText = "" + def start = file.text.indexOf(typeParameterText) + def end = start + typeParameterText.length() + for (int offset : offsets) { + assert offset < start || offset > end + } + } }