[java] Implement getName for implicit classes

GitOrigin-RevId: 069362cff5ebee9eaf5e75d566097a2deaed8e8f
This commit is contained in:
Bart van Helvert
2024-06-24 13:56:25 +02:00
committed by intellij-monorepo-bot
parent 7a3729260a
commit 0232d76e56
11 changed files with 20 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide;
import com.intellij.openapi.project.Project;
@@ -7,7 +7,6 @@ import com.intellij.testFramework.LightPlatformTestCase;
public class JavaFilePasteProviderTest extends LightPlatformTestCase {
public void testDetectClassName() {
Project project = getProject();
assertNull(JavaFilePasteProvider.detectClassName(project, "random text pasted"));
assertEquals("X", JavaFilePasteProvider.detectClassName(project, "class X {}"));
assertEquals("Y", JavaFilePasteProvider.detectClassName(project, "class X {} public class Y{}"));
assertEquals("R", JavaFilePasteProvider.detectClassName(project, "record R() {}"));

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.java.psi
import com.intellij.openapi.command.WriteCommandAction
@@ -378,7 +378,6 @@ class B {}"""
int field;
""".trimIndent())
val implicitClass = file.classes.single() as PsiImplicitClass
TestCase.assertNull(implicitClass.name)
val method = implicitClass.methods.single()
TestCase.assertEquals("myMethod", method.name)
val aClass = implicitClass.innerClasses.single()