mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
K2: implement "create function from usage" for members (part of KTIJ-28926 K2: Create Function From Usage Fix)
- support "fir" version for dependency files in test data for AbstractQuickFixMultiFileTest - support generation of @Nullable/@NotNull in java method signatures - support nullability in generated java types (ExpectedTypeWithNullability) - support implicit receivers in generation (see computeImplicitReceiverType) - suggest creating new function in case of too many/too few arguments (K2CreateFromUsageQuickFixesRegistrar) GitOrigin-RevId: d1adac9e7a4f5caeb2300e80c953e95a0c339dcf
This commit is contained in:
committed by
intellij-monorepo-bot
parent
33442630e6
commit
f294fccb79
@@ -0,0 +1,40 @@
|
||||
// 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.lang.jvm.actions
|
||||
|
||||
import com.intellij.codeInsight.Nullability
|
||||
import com.intellij.lang.jvm.types.JvmType
|
||||
import com.intellij.psi.PsiType
|
||||
import com.intellij.psi.PsiTypeVisitor
|
||||
import com.intellij.psi.PsiTypes
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
|
||||
class ExpectedTypeWithNullability(val type: JvmType, val nullability: Nullability) : ExpectedType {
|
||||
override fun getTheType(): JvmType = type
|
||||
|
||||
override fun getTheKind(): ExpectedType.Kind = ExpectedType.Kind.EXACT
|
||||
|
||||
companion object {
|
||||
fun createExpectedKotlinType(type: JvmType, nullability: Nullability): ExpectedTypeWithNullability = ExpectedTypeWithNullability(type, nullability)
|
||||
|
||||
/**
|
||||
* A placeholder to denote "This type is invalid". Only thing this type does is returning `false` for `isValid()` function.
|
||||
*/
|
||||
val INVALID_TYPE: ExpectedTypeWithNullability = createExpectedKotlinType(object : PsiType(emptyArray()) {
|
||||
override fun <A : Any?> accept(visitor: PsiTypeVisitor<A>): A {
|
||||
return visitor.visitType(PsiTypes.nullType())
|
||||
}
|
||||
|
||||
override fun getPresentableText(): String = ""
|
||||
|
||||
override fun getCanonicalText(): String = ""
|
||||
|
||||
override fun isValid(): Boolean = false
|
||||
|
||||
override fun equalsToText(text: String): Boolean = false
|
||||
|
||||
override fun getResolveScope(): GlobalSearchScope? = null
|
||||
|
||||
override fun getSuperTypes(): Array<PsiType> = emptyArray()
|
||||
}, Nullability.UNKNOWN)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user