Fixes after review: renamed to isMemberExtensionDeclaration
This commit is contained in:
+5
-5
@@ -52,7 +52,7 @@ class MigrateExternalExtensionFix(declaration: KtNamedDeclaration)
|
|||||||
val declaration = element ?: return
|
val declaration = element ?: return
|
||||||
|
|
||||||
when {
|
when {
|
||||||
isExternalMemberDeclaration(declaration) -> fixExtensionMemberDeclaration(declaration, editor)
|
isMemberExtensionDeclaration(declaration) -> fixExtensionMemberDeclaration(declaration, editor)
|
||||||
isMemberDeclaration(declaration) -> {
|
isMemberDeclaration(declaration) -> {
|
||||||
val containingClass = declaration.containingClassOrObject
|
val containingClass = declaration.containingClassOrObject
|
||||||
if (containingClass != null) {
|
if (containingClass != null) {
|
||||||
@@ -76,7 +76,7 @@ class MigrateExternalExtensionFix(declaration: KtNamedDeclaration)
|
|||||||
annotations.nativeAnnotation.delete()
|
annotations.nativeAnnotation.delete()
|
||||||
} else {
|
} else {
|
||||||
val externalDeclaration = ConvertMemberToExtensionIntention.convert(memberDeclaration)
|
val externalDeclaration = ConvertMemberToExtensionIntention.convert(memberDeclaration)
|
||||||
fixExtensionMemberDeclaration(externalDeclaration, null)
|
fixExtensionMemberDeclaration(externalDeclaration, null) // editor is null as we are not going to open any live templates
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ class MigrateExternalExtensionFix(declaration: KtNamedDeclaration)
|
|||||||
|
|
||||||
companion object : KotlinSingleIntentionActionFactory() {
|
companion object : KotlinSingleIntentionActionFactory() {
|
||||||
private fun KtAnnotationEntry.isJsAnnotation(vararg predefinedAnnotations: PredefinedAnnotation): Boolean {
|
private fun KtAnnotationEntry.isJsAnnotation(vararg predefinedAnnotations: PredefinedAnnotation): Boolean {
|
||||||
val bindingContext = analyze(BodyResolveMode.PARTIAL_WITH_DIAGNOSTICS)
|
val bindingContext = analyze(BodyResolveMode.PARTIAL)
|
||||||
val annotationDescriptor = bindingContext[BindingContext.ANNOTATION, this]
|
val annotationDescriptor = bindingContext[BindingContext.ANNOTATION, this]
|
||||||
return annotationDescriptor != null && predefinedAnnotations.any { checkAnnotationName(annotationDescriptor, it.fqName) }
|
return annotationDescriptor != null && predefinedAnnotations.any { checkAnnotationName(annotationDescriptor, it.fqName) }
|
||||||
}
|
}
|
||||||
@@ -236,7 +236,7 @@ class MigrateExternalExtensionFix(declaration: KtNamedDeclaration)
|
|||||||
return isJsAnnotation(PredefinedAnnotation.NATIVE, PredefinedAnnotation.NATIVE_GETTER, PredefinedAnnotation.NATIVE_SETTER, PredefinedAnnotation.NATIVE_INVOKE )
|
return isJsAnnotation(PredefinedAnnotation.NATIVE, PredefinedAnnotation.NATIVE_GETTER, PredefinedAnnotation.NATIVE_SETTER, PredefinedAnnotation.NATIVE_INVOKE )
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isExternalMemberDeclaration(psiElement: PsiElement): Boolean {
|
private fun isMemberExtensionDeclaration(psiElement: PsiElement): Boolean {
|
||||||
return (psiElement is KtNamedFunction && psiElement.receiverTypeReference != null) ||
|
return (psiElement is KtNamedFunction && psiElement.receiverTypeReference != null) ||
|
||||||
(psiElement is KtProperty && psiElement.receiverTypeReference != null)
|
(psiElement is KtProperty && psiElement.receiverTypeReference != null)
|
||||||
}
|
}
|
||||||
@@ -260,7 +260,7 @@ class MigrateExternalExtensionFix(declaration: KtNamedDeclaration)
|
|||||||
val e = diagnostic.psiElement
|
val e = diagnostic.psiElement
|
||||||
when (diagnostic.factory) {
|
when (diagnostic.factory) {
|
||||||
ErrorsJs.WRONG_EXTERNAL_DECLARATION -> {
|
ErrorsJs.WRONG_EXTERNAL_DECLARATION -> {
|
||||||
if (isExternalMemberDeclaration(e)) {
|
if (isMemberExtensionDeclaration(e)) {
|
||||||
return MigrateExternalExtensionFix(e as KtNamedDeclaration)
|
return MigrateExternalExtensionFix(e as KtNamedDeclaration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user