UAST: cleanup plugin file to have only plugin definition
This commit is contained in:
committed by
Ilya Kirillov
parent
8b93727f64
commit
5effbce363
@@ -18,7 +18,6 @@ package org.jetbrains.uast.kotlin
|
|||||||
|
|
||||||
import com.intellij.lang.Language
|
import com.intellij.lang.Language
|
||||||
import com.intellij.openapi.components.ServiceManager
|
import com.intellij.openapi.components.ServiceManager
|
||||||
import com.intellij.openapi.util.Key
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.PsiFile
|
import com.intellij.psi.PsiFile
|
||||||
import org.jetbrains.kotlin.asJava.classes.KtLightClassForFacade
|
import org.jetbrains.kotlin.asJava.classes.KtLightClassForFacade
|
||||||
@@ -33,8 +32,6 @@ import org.jetbrains.uast.kotlin.KotlinConverter.convertDeclaration
|
|||||||
import org.jetbrains.uast.kotlin.KotlinConverter.convertDeclarationOrElement
|
import org.jetbrains.uast.kotlin.KotlinConverter.convertDeclarationOrElement
|
||||||
import org.jetbrains.uast.kotlin.psi.UastFakeLightPrimaryConstructor
|
import org.jetbrains.uast.kotlin.psi.UastFakeLightPrimaryConstructor
|
||||||
|
|
||||||
var PsiElement.destructuringDeclarationInitializer: Boolean? by UserDataProperty(Key.create("kotlin.uast.destructuringDeclarationInitializer"))
|
|
||||||
|
|
||||||
class KotlinUastLanguagePlugin : UastLanguagePlugin {
|
class KotlinUastLanguagePlugin : UastLanguagePlugin {
|
||||||
override val priority = 10
|
override val priority = 10
|
||||||
|
|
||||||
@@ -65,9 +62,9 @@ class KotlinUastLanguagePlugin : UastLanguagePlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getMethodCallExpression(
|
override fun getMethodCallExpression(
|
||||||
element: PsiElement,
|
element: PsiElement,
|
||||||
containingClassFqName: String?,
|
containingClassFqName: String?,
|
||||||
methodName: String
|
methodName: String
|
||||||
): UastLanguagePlugin.ResolvedMethod? {
|
): UastLanguagePlugin.ResolvedMethod? {
|
||||||
if (element !is KtCallExpression) return null
|
if (element !is KtCallExpression) return null
|
||||||
val resolvedCall = element.getResolvedCall(element.analyze()) ?: return null
|
val resolvedCall = element.getResolvedCall(element.analyze()) ?: return null
|
||||||
@@ -84,14 +81,15 @@ class KotlinUastLanguagePlugin : UastLanguagePlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getConstructorCallExpression(
|
override fun getConstructorCallExpression(
|
||||||
element: PsiElement,
|
element: PsiElement,
|
||||||
fqName: String
|
fqName: String
|
||||||
): UastLanguagePlugin.ResolvedConstructor? {
|
): UastLanguagePlugin.ResolvedConstructor? {
|
||||||
if (element !is KtCallExpression) return null
|
if (element !is KtCallExpression) return null
|
||||||
val resolvedCall = element.getResolvedCall(element.analyze()) ?: return null
|
val resolvedCall = element.getResolvedCall(element.analyze()) ?: return null
|
||||||
val resultingDescriptor = resolvedCall.resultingDescriptor
|
val resultingDescriptor = resolvedCall.resultingDescriptor
|
||||||
if (resultingDescriptor !is ConstructorDescriptor
|
if (resultingDescriptor !is ConstructorDescriptor
|
||||||
|| resultingDescriptor.returnType.constructor.declarationDescriptor?.name?.asString() != fqName) {
|
|| resultingDescriptor.returnType.constructor.declarationDescriptor?.name?.asString() != fqName
|
||||||
|
) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,8 +138,3 @@ class KotlinUastLanguagePlugin : UastLanguagePlugin {
|
|||||||
else -> sequenceOf(convertElementWithParent(element, requiredTypes.nonEmptyOr(DEFAULT_TYPES_LIST)) as? T).filterNotNull()
|
else -> sequenceOf(convertElementWithParent(element, requiredTypes.nonEmptyOr(DEFAULT_TYPES_LIST)) as? T).filterNotNull()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val kotlinUastPlugin: UastLanguagePlugin by lz {
|
|
||||||
UastLanguagePlugin.getInstances().find { it.language == KotlinLanguage.INSTANCE }
|
|
||||||
?: KotlinUastLanguagePlugin()
|
|
||||||
}
|
|
||||||
|
|||||||
+3
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.uast.kotlin
|
package org.jetbrains.uast.kotlin
|
||||||
|
|
||||||
|
import com.intellij.openapi.util.Key
|
||||||
import com.intellij.psi.*
|
import com.intellij.psi.*
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||||
@@ -34,6 +35,8 @@ import org.jetbrains.uast.kotlin.declarations.KotlinUIdentifier
|
|||||||
import org.jetbrains.uast.kotlin.internal.DelegatedMultiResolve
|
import org.jetbrains.uast.kotlin.internal.DelegatedMultiResolve
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
|
var PsiElement.destructuringDeclarationInitializer: Boolean? by UserDataProperty(Key.create("kotlin.uast.destructuringDeclarationInitializer"))
|
||||||
|
|
||||||
open class KotlinUSimpleReferenceExpression(
|
open class KotlinUSimpleReferenceExpression(
|
||||||
override val sourcePsi: KtSimpleNameExpression,
|
override val sourcePsi: KtSimpleNameExpression,
|
||||||
givenParent: UElement?
|
givenParent: UElement?
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.builtins.isBuiltinFunctionalTypeOrSubtype
|
|||||||
import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter
|
import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor
|
import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor
|
||||||
|
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaPackageFragment
|
import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaPackageFragment
|
||||||
import org.jetbrains.kotlin.load.java.sam.SamAdapterDescriptor
|
import org.jetbrains.kotlin.load.java.sam.SamAdapterDescriptor
|
||||||
@@ -81,6 +82,11 @@ import org.jetbrains.uast.kotlin.psi.UastFakeLightPrimaryConstructor
|
|||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
import java.text.StringCharacterIterator
|
import java.text.StringCharacterIterator
|
||||||
|
|
||||||
|
val kotlinUastPlugin: UastLanguagePlugin by lz {
|
||||||
|
UastLanguagePlugin.getInstances().find { it.language == KotlinLanguage.INSTANCE }
|
||||||
|
?: KotlinUastLanguagePlugin()
|
||||||
|
}
|
||||||
|
|
||||||
internal val KOTLIN_CACHED_UELEMENT_KEY = Key.create<WeakReference<UElement>>("cached-kotlin-uelement")
|
internal val KOTLIN_CACHED_UELEMENT_KEY = Key.create<WeakReference<UElement>>("cached-kotlin-uelement")
|
||||||
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
|||||||
Reference in New Issue
Block a user