mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] k2: disable introduce on java class qualifiers
KTIJ-29112 GitOrigin-RevId: 331670ed0531ebb3dd54b2850773ae574efdd10e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
29c5d0bfab
commit
74673a44df
+5
@@ -561,6 +561,11 @@ public abstract class ExtractionTestGenerated extends AbstractExtractionTest {
|
||||
runTest("testData/refactoring/introduceVariable/It.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaInnerClassQualifier.kt")
|
||||
public void testJavaInnerClassQualifier() throws Exception {
|
||||
runTest("testData/refactoring/introduceVariable/javaInnerClassQualifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt10808.kt")
|
||||
public void testKt10808() throws Exception {
|
||||
runTest("testData/refactoring/introduceVariable/kt10808.kt");
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
<selection>Thread.State</selection>.BLOCKED
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
Cannot perform refactoring without an expression
|
||||
+5
-3
@@ -3,6 +3,7 @@ package org.jetbrains.kotlin.idea.k2.refactoring.introduce.introduceVariable
|
||||
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiPackage
|
||||
import com.intellij.psi.util.elementType
|
||||
@@ -38,11 +39,12 @@ internal class KotlinIntroduceVariableServiceK2Impl(private val project: Project
|
||||
?: findStringTemplateOrStringTemplateEntryExpression(file, startOffset, endOffset, elementKind)
|
||||
?: findStringTemplateFragment(file, startOffset, endOffset, elementKind)
|
||||
|
||||
if (element is KtSimpleNameExpression) {
|
||||
if (element is KtExpression) {
|
||||
val qualifiedExpression = element.parent as? KtDotQualifiedExpression
|
||||
if (qualifiedExpression != null && qualifiedExpression.receiverExpression == element) {
|
||||
val resolved = element.mainReference.resolve()
|
||||
if (resolved is PsiPackage || resolved is KtTypeAlias || resolved is KtClassOrObject && resolved.getDeclarationKeyword()?.elementType != KtTokens.OBJECT_KEYWORD) {
|
||||
val resolved = ((element as? KtDotQualifiedExpression)?.selectorExpression ?: element).mainReference?.resolve()
|
||||
if (resolved is PsiPackage || resolved is PsiClass ||
|
||||
resolved is KtTypeAlias || resolved is KtClassOrObject && resolved.getDeclarationKeyword()?.elementType != KtTokens.OBJECT_KEYWORD) {
|
||||
element = null
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -559,6 +559,11 @@ public abstract class K2IntroduceVariableTestGenerated extends AbstractK2Introdu
|
||||
runTest("../../idea/tests/testData/refactoring/introduceVariable/It.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaInnerClassQualifier.kt")
|
||||
public void testJavaInnerClassQualifier() throws Exception {
|
||||
runTest("../../idea/tests/testData/refactoring/introduceVariable/javaInnerClassQualifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt10808.kt")
|
||||
public void testKt10808() throws Exception {
|
||||
runTest("../../idea/tests/testData/refactoring/introduceVariable/kt10808.kt");
|
||||
|
||||
Reference in New Issue
Block a user