Add KotlinBuiltIns#isBuiltIn, use it instead of other utilities
This commit is contained in:
@@ -17,23 +17,16 @@
|
||||
package org.jetbrains.kotlin.js.descriptorUtils
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||
|
||||
val KotlinType.nameIfStandardType: Name?
|
||||
get() {
|
||||
return constructor.declarationDescriptor
|
||||
?.check { descriptor ->
|
||||
descriptor.builtIns.isBuiltInPackageFragment(descriptor.containingDeclaration as? PackageFragmentDescriptor)
|
||||
}
|
||||
?.name
|
||||
}
|
||||
get() = constructor.declarationDescriptor?.check(KotlinBuiltIns::isBuiltIn)?.name
|
||||
|
||||
fun KotlinType.getJetTypeFqName(printTypeArguments: Boolean): String {
|
||||
val declaration = requireNotNull(constructor.declarationDescriptor)
|
||||
@@ -47,8 +40,9 @@ fun KotlinType.getJetTypeFqName(printTypeArguments: Boolean): String {
|
||||
if (printTypeArguments && !typeArguments.isEmpty()) {
|
||||
val joinedTypeArguments = StringUtil.join(typeArguments, { projection -> projection.type.getJetTypeFqName(false) }, ", ")
|
||||
|
||||
typeArgumentsAsString = "<" + joinedTypeArguments + ">"
|
||||
} else {
|
||||
typeArgumentsAsString = "<$joinedTypeArguments>"
|
||||
}
|
||||
else {
|
||||
typeArgumentsAsString = ""
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user