FIR Java model: support static members & enum entries
Related to KT-29218
This commit is contained in:
@@ -11,8 +11,6 @@ import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirCallableMember
|
||||
import org.jetbrains.kotlin.fir.declarations.FirConstructor
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableClass
|
||||
import org.jetbrains.kotlin.fir.expressions.FirCall
|
||||
import org.jetbrains.kotlin.fir.java.declarations.*
|
||||
import org.jetbrains.kotlin.fir.resolve.AbstractFirSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.constructType
|
||||
@@ -91,7 +89,6 @@ class JavaSymbolProvider(
|
||||
// TODO: may be we can process fields & methods later.
|
||||
// However, they should be built up to override resolve stage
|
||||
for (javaField in javaClass.fields) {
|
||||
if (javaField.isStatic) continue // TODO: statics
|
||||
val fieldName = javaField.name
|
||||
val fieldId = CallableId(classId.packageFqName, classId.relativeClassName, fieldName)
|
||||
val fieldSymbol = FirFieldSymbol(fieldId)
|
||||
@@ -100,14 +97,14 @@ class JavaSymbolProvider(
|
||||
session, fieldSymbol, fieldName,
|
||||
javaField.visibility, javaField.modality,
|
||||
returnTypeRef = returnType.toFirJavaTypeRef(session),
|
||||
isVar = !javaField.isFinal
|
||||
isVar = !javaField.isFinal,
|
||||
isStatic = javaField.isStatic
|
||||
).apply {
|
||||
addAnnotationsFrom(javaField)
|
||||
}
|
||||
declarations += firJavaField
|
||||
}
|
||||
for (javaMethod in javaClass.methods) {
|
||||
if (javaMethod.isStatic) continue // TODO: statics
|
||||
val methodName = javaMethod.name
|
||||
val methodId = CallableId(classId.packageFqName, classId.relativeClassName, methodName)
|
||||
val methodSymbol = FirFunctionSymbol(methodId)
|
||||
@@ -115,7 +112,8 @@ class JavaSymbolProvider(
|
||||
val firJavaMethod = FirJavaMethod(
|
||||
session, methodSymbol, methodName,
|
||||
javaMethod.visibility, javaMethod.modality,
|
||||
returnTypeRef = returnType.toFirJavaTypeRef(session)
|
||||
returnTypeRef = returnType.toFirJavaTypeRef(session),
|
||||
isStatic = javaMethod.isStatic
|
||||
).apply {
|
||||
for (typeParameter in javaMethod.typeParameters) {
|
||||
typeParameters += createTypeParameterSymbol(session, typeParameter.name).fir
|
||||
|
||||
@@ -22,7 +22,8 @@ class FirJavaField(
|
||||
visibility: Visibility,
|
||||
modality: Modality?,
|
||||
returnTypeRef: FirJavaTypeRef,
|
||||
override val isVar: Boolean
|
||||
override val isVar: Boolean,
|
||||
isStatic: Boolean
|
||||
) : FirAbstractCallableMember(
|
||||
session, psi = null, symbol = symbol, name = name,
|
||||
visibility = visibility, modality = modality,
|
||||
@@ -34,4 +35,8 @@ class FirJavaField(
|
||||
|
||||
override val initializer: FirExpression?
|
||||
get() = null
|
||||
|
||||
init {
|
||||
status.isStatic = isStatic
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,8 @@ class FirJavaMethod(
|
||||
name: Name,
|
||||
visibility: Visibility,
|
||||
modality: Modality?,
|
||||
returnTypeRef: FirJavaTypeRef
|
||||
returnTypeRef: FirJavaTypeRef,
|
||||
isStatic: Boolean
|
||||
) : FirMemberFunctionImpl(
|
||||
session, null, symbol, name,
|
||||
visibility, modality,
|
||||
@@ -29,4 +30,8 @@ class FirJavaMethod(
|
||||
isOperator = true, // All Java methods with name that allows to use it in operator form are considered operators
|
||||
isInfix = false, isInline = false, isTailRec = false, isExternal = false, isSuspend = false,
|
||||
receiverTypeRef = null, returnTypeRef = returnTypeRef
|
||||
)
|
||||
) {
|
||||
init {
|
||||
status.isStatic = isStatic
|
||||
}
|
||||
}
|
||||
+1
@@ -94,6 +94,7 @@ class JavaClassEnhancementScope(
|
||||
delegate = null
|
||||
).apply {
|
||||
annotations += firField.annotations
|
||||
status.isStatic = firField.isStatic
|
||||
}
|
||||
}
|
||||
return symbol
|
||||
|
||||
Reference in New Issue
Block a user