[FIR IDE] LC add jvmstatic method into companion object
This commit is contained in:
+1
-1
@@ -47,7 +47,7 @@ internal class FirLightAnnotationClassSymbol(
|
||||
.filterNot { it is KtFunctionSymbol && it.visibility == KtSymbolVisibility.PRIVATE }
|
||||
.filterNot { it is KtConstructorSymbol }
|
||||
|
||||
createMethods(visibleDeclarations, isTopLevel = false, result)
|
||||
createMethods(visibleDeclarations, result)
|
||||
}
|
||||
|
||||
result
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ internal class FirLightAnonymousClassForSymbol(
|
||||
|
||||
analyzeWithSymbolAsContext(anonymousObjectSymbol) {
|
||||
val callableSymbols = anonymousObjectSymbol.getDeclaredMemberScope().getCallableSymbols()
|
||||
createMethods(callableSymbols, isTopLevel = false, result)
|
||||
createMethods(callableSymbols, result)
|
||||
}
|
||||
|
||||
result
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ internal class FirLightClassForEnumEntry(
|
||||
|
||||
analyzeWithSymbolAsContext(enumEntrySymbol) {
|
||||
val callableSymbols = enumEntrySymbol.getDeclaredMemberScope().getCallableSymbols()
|
||||
createMethods(callableSymbols, isTopLevel = false, result)
|
||||
createMethods(callableSymbols, result)
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ class FirLightClassForFacade(
|
||||
}
|
||||
}
|
||||
|
||||
createMethods(symbols.asSequence(), isTopLevel = true, result)
|
||||
createMethods(symbols.asSequence(), result, isTopLevel = true)
|
||||
}
|
||||
|
||||
private val _ownMethods: List<KtLightMethod> by lazyPub {
|
||||
|
||||
+17
-1
@@ -6,6 +6,8 @@
|
||||
package org.jetbrains.kotlin.idea.asJava
|
||||
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.kotlin.asJava.builder.memberIndex
|
||||
import org.jetbrains.kotlin.asJava.classes.METHOD_INDEX_BASE
|
||||
import org.jetbrains.kotlin.asJava.classes.METHOD_INDEX_FOR_DEFAULT_CTOR
|
||||
import org.jetbrains.kotlin.asJava.classes.lazyPub
|
||||
import org.jetbrains.kotlin.asJava.elements.KtLightField
|
||||
@@ -100,7 +102,8 @@ internal open class FirLightClassForSymbol(
|
||||
}
|
||||
}
|
||||
|
||||
createMethods(visibleDeclarations, isTopLevel = false, result)
|
||||
val suppressStatic = classOrObjectSymbol.classKind == KtClassKind.COMPANION_OBJECT
|
||||
createMethods(visibleDeclarations, result, suppressStaticForMethods = suppressStatic)
|
||||
}
|
||||
|
||||
if (result.none { it.isConstructor }) {
|
||||
@@ -116,6 +119,8 @@ internal open class FirLightClassForSymbol(
|
||||
}
|
||||
}
|
||||
|
||||
addMethodsFromCompanionIfNeeded(result)
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
@@ -140,6 +145,17 @@ internal open class FirLightClassForSymbol(
|
||||
}
|
||||
}
|
||||
|
||||
private fun addMethodsFromCompanionIfNeeded(result: MutableList<KtLightMethod>) {
|
||||
classOrObjectSymbol.companionObject?.run {
|
||||
analyzeWithSymbolAsContext(this) {
|
||||
val methods = getDeclaredMemberScope().getCallableSymbols()
|
||||
.filterIsInstance<KtFunctionSymbol>()
|
||||
.filter { it.hasJvmStaticAnnotation() }
|
||||
createMethods(methods, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun addInstanceFieldIfNeeded(result: MutableList<KtLightField>) {
|
||||
val isNamedObject = classOrObjectSymbol.classKind == KtClassKind.OBJECT
|
||||
if (isNamedObject && classOrObjectSymbol.symbolKind != KtSymbolKind.LOCAL) {
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ internal class FirLightInterfaceClassSymbol(
|
||||
val visibleDeclarations = classOrObjectSymbol.getDeclaredMemberScope().getCallableSymbols()
|
||||
.filterNot { it is KtFunctionSymbol && it.visibility == KtSymbolVisibility.PRIVATE }
|
||||
|
||||
createMethods(visibleDeclarations, isTopLevel = false, result)
|
||||
createMethods(visibleDeclarations, result)
|
||||
}
|
||||
|
||||
result
|
||||
|
||||
+7
-5
@@ -98,10 +98,10 @@ private fun lightClassForEnumEntry(ktEnumEntry: KtEnumEntry): KtLightClass? {
|
||||
|
||||
internal fun FirLightClassBase.createMethods(
|
||||
declarations: Sequence<KtCallableSymbol>,
|
||||
isTopLevel: Boolean,
|
||||
result: MutableList<KtLightMethod>
|
||||
result: MutableList<KtLightMethod>,
|
||||
isTopLevel: Boolean = false,
|
||||
suppressStaticForMethods: Boolean = false
|
||||
) {
|
||||
var methodIndex = METHOD_INDEX_BASE
|
||||
for (declaration in declarations) {
|
||||
|
||||
if (declaration is KtFunctionSymbol && declaration.isInline) continue
|
||||
@@ -112,13 +112,15 @@ internal fun FirLightClassBase.createMethods(
|
||||
|
||||
when (declaration) {
|
||||
is KtFunctionSymbol -> {
|
||||
var methodIndex = METHOD_INDEX_BASE
|
||||
result.add(
|
||||
FirLightSimpleMethodForSymbol(
|
||||
functionSymbol = declaration,
|
||||
lightMemberOrigin = null,
|
||||
containingClass = this@createMethods,
|
||||
isTopLevel = isTopLevel,
|
||||
methodIndex = methodIndex++
|
||||
methodIndex = methodIndex,
|
||||
suppressStatic = suppressStaticForMethods
|
||||
)
|
||||
)
|
||||
|
||||
@@ -150,7 +152,7 @@ internal fun FirLightClassBase.createMethods(
|
||||
constructorSymbol = declaration,
|
||||
lightMemberOrigin = null,
|
||||
containingClass = this@createMethods,
|
||||
methodIndex++
|
||||
methodIndex = METHOD_INDEX_BASE
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
+1
@@ -139,6 +139,7 @@ internal class FirLightAccessorMethodForSymbol(
|
||||
override fun equals(other: Any?): Boolean =
|
||||
this === other ||
|
||||
(other is FirLightAccessorMethodForSymbol &&
|
||||
isGetter == other.isGetter &&
|
||||
kotlinOrigin == other.kotlinOrigin &&
|
||||
propertyAccessorSymbol == other.propertyAccessorSymbol)
|
||||
|
||||
|
||||
+4
-3
@@ -22,13 +22,14 @@ internal class FirLightSimpleMethodForSymbol(
|
||||
containingClass: FirLightClassBase,
|
||||
methodIndex: Int,
|
||||
isTopLevel: Boolean,
|
||||
argumentsSkipMask: BitSet? = null
|
||||
argumentsSkipMask: BitSet? = null,
|
||||
suppressStatic: Boolean = false
|
||||
) : FirLightMethodForSymbol(
|
||||
functionSymbol = functionSymbol,
|
||||
lightMemberOrigin = lightMemberOrigin,
|
||||
containingClass = containingClass,
|
||||
methodIndex = methodIndex,
|
||||
argumentsSkipMask = argumentsSkipMask
|
||||
argumentsSkipMask = argumentsSkipMask,
|
||||
) {
|
||||
|
||||
private val _name: String by lazyPub {
|
||||
@@ -96,7 +97,7 @@ internal class FirLightSimpleMethodForSymbol(
|
||||
|
||||
modifiers.add(_visibility)
|
||||
|
||||
if (functionSymbol.hasJvmStaticAnnotation()) {
|
||||
if (!suppressStatic && functionSymbol.hasJvmStaticAnnotation()) {
|
||||
modifiers.add(PsiModifier.STATIC)
|
||||
}
|
||||
if (functionSymbol.hasAnnotation("kotlin/jvm/Strictfp", null)) {
|
||||
|
||||
Reference in New Issue
Block a user