[AA] Move classIdIfNonLocal to analysis-internal-utils
- The utility will be needed by a `KtFir*Symbol` class.
This commit is contained in:
committed by
Space Team
parent
9cc6809ec6
commit
e70a3a899f
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.utils
|
||||
|
||||
import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.PsiClassOwner
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
public val PsiClass.classIdIfNonLocal: ClassId?
|
||||
get() {
|
||||
val packageName = (containingFile as? PsiClassOwner)?.packageName ?: return null
|
||||
val qualifiedName = qualifiedName ?: return null
|
||||
val relatedClassName = qualifiedName.removePrefix("$packageName.")
|
||||
if (relatedClassName.isEmpty()) return null
|
||||
|
||||
return ClassId(FqName(packageName), FqName(relatedClassName), false)
|
||||
}
|
||||
Reference in New Issue
Block a user