[kotlin] Do not handle method parameter is a structure view node

#KTIJ-35298

GitOrigin-RevId: 615c72fe256faab835da0f53d37142f6a75d2862
This commit is contained in:
Vladimir Dolzhenko
2025-08-20 17:22:59 +02:00
committed by intellij-monorepo-bot
parent 79a7fc2065
commit 1ac8cb7215
5 changed files with 98 additions and 0 deletions

View File

@@ -11,6 +11,7 @@ fun isStructureViewNode(element: PsiElement?): Boolean =
element is KtDeclaration &&
element !is KtPropertyAccessor &&
element !is KtFunctionLiteral &&
element !is KtParameter &&
!((element is KtProperty || element is KtFunction) && !element.topLevelDeclaration && element.containingClassOrObject !is KtNamedDeclaration)
private val KtDeclaration.topLevelDeclaration: Boolean

View File

@@ -0,0 +1,83 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.idea.k2.navigationToolbar;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.idea.base.plugin.KotlinPluginMode;
import org.jetbrains.kotlin.idea.base.test.TestRoot;
import org.jetbrains.kotlin.idea.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.idea.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import org.jetbrains.kotlin.idea.navigationToolbar.AbstractKotlinNavBarTest;
/**
* This class is generated by {@link org.jetbrains.kotlin.testGenerator.generator.TestGenerator}.
* DO NOT MODIFY MANUALLY.
*/
@SuppressWarnings("all")
@TestRoot("code-insight/kotlin.code-insight.k2")
@TestDataPath("$CONTENT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@TestMetadata("../../idea/tests/testData/navigationToolbar")
public class KotlinNavBarTestGenerated extends AbstractKotlinNavBarTest {
@java.lang.Override
@org.jetbrains.annotations.NotNull
public final KotlinPluginMode getPluginMode() {
return KotlinPluginMode.K2;
}
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("build1.gradle.kts")
public void testBuild1_gradle() throws Exception {
runTest("../../idea/tests/testData/navigationToolbar/build1.gradle.kts");
}
@TestMetadata("build2.gradle.kts")
public void testBuild2_gradle() throws Exception {
runTest("../../idea/tests/testData/navigationToolbar/build2.gradle.kts");
}
@TestMetadata("ClassProperty.kt")
public void testClassProperty() throws Exception {
runTest("../../idea/tests/testData/navigationToolbar/ClassProperty.kt");
}
@TestMetadata("fileNameDoesntMatchClassName.kt")
public void testFileNameDoesntMatchClassName() throws Exception {
runTest("../../idea/tests/testData/navigationToolbar/fileNameDoesntMatchClassName.kt");
}
@TestMetadata("MethodInClass.kt")
public void testMethodInClass() throws Exception {
runTest("../../idea/tests/testData/navigationToolbar/MethodInClass.kt");
}
@TestMetadata("MethodInClassAndParameters.kt")
public void testMethodInClassAndParameters() throws Exception {
runTest("../../idea/tests/testData/navigationToolbar/MethodInClassAndParameters.kt");
}
@TestMetadata("MethodParameter.kt")
public void testMethodParameter() throws Exception {
runTest("../../idea/tests/testData/navigationToolbar/MethodParameter.kt");
}
@TestMetadata("SeveralClassesInFile.kt")
public void testSeveralClassesInFile() throws Exception {
runTest("../../idea/tests/testData/navigationToolbar/SeveralClassesInFile.kt");
}
@TestMetadata("topLevelFunction.kt")
public void testTopLevelFunction() throws Exception {
runTest("../../idea/tests/testData/navigationToolbar/topLevelFunction.kt");
}
@TestMetadata("topLevelProperty.kt")
public void testTopLevelProperty() throws Exception {
runTest("../../idea/tests/testData/navigationToolbar/topLevelProperty.kt");
}
}

View File

@@ -60,6 +60,11 @@ public class KotlinNavBarTestGenerated extends AbstractKotlinNavBarTest {
runTest("testData/navigationToolbar/MethodInClassAndParameters.kt");
}
@TestMetadata("MethodParameter.kt")
public void testMethodParameter() throws Exception {
runTest("testData/navigationToolbar/MethodParameter.kt");
}
@TestMetadata("SeveralClassesInFile.kt")
public void testSeveralClassesInFile() throws Exception {
runTest("testData/navigationToolbar/SeveralClassesInFile.kt");

View File

@@ -0,0 +1,5 @@
// NAV_BAR_ITEMS: src, MethodParameter, foo
class MethodParameter {
fun foo(na<caret>me: String) { }
}

View File

@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.idea.k2.unwrap.AbstractKotlinFirUnwrapRemoveTest
import org.jetbrains.kotlin.idea.navigation.AbstractKotlinGotoImplementationMultiModuleTest
import org.jetbrains.kotlin.idea.navigation.AbstractKotlinGotoImplementationMultifileTest
import org.jetbrains.kotlin.idea.navigation.AbstractKotlinGotoImplementationTest
import org.jetbrains.kotlin.idea.navigationToolbar.AbstractKotlinNavBarTest
import org.jetbrains.kotlin.idea.refactoring.AbstractNameSuggestionProviderTest
import org.jetbrains.kotlin.testGenerator.model.*
import org.jetbrains.kotlin.testGenerator.model.GroupCategory.CODE_INSIGHT
@@ -62,6 +63,9 @@ internal fun MutableTWorkspace.generateK2CodeInsightTests() {
testClass<AbstractKotlinGotoImplementationMultiModuleTest>(generatedClassName = "org.jetbrains.kotlin.idea.k2.navigation.KotlinGotoImplementationMultiModuleTestGenerated") {
model("../../../idea/tests/testData/navigation/implementations/multiModule", isRecursive = false, pattern = DIRECTORY)
}
testClass<AbstractKotlinNavBarTest>(generatedClassName = "org.jetbrains.kotlin.idea.k2.navigationToolbar.KotlinNavBarTestGenerated") {
model("../../../idea/tests/testData/navigationToolbar", isRecursive = false, pattern = KT_OR_KTS)
}
testClass<AbstractNameSuggestionProviderTest>(generatedClassName = "org.jetbrains.kotlin.idea.k2.KotlinNameSuggestionProviderTestGenerated") {
model("../../../idea/tests/testData/refactoring/nameSuggestionProvider")
}