Add the ability to get containing source file from SourceElement
This commit is contained in:
@@ -17,8 +17,17 @@
|
||||
package org.jetbrains.kotlin.resolve.source
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.descriptors.SourceFile
|
||||
|
||||
public interface PsiSourceElement : SourceElement {
|
||||
public val psi: PsiElement?
|
||||
|
||||
override fun getContainingFile(): SourceFile = psi?.containingFile?.let { PsiSourceFile(it) } ?: SourceFile.NO_SOURCE_FILE
|
||||
}
|
||||
|
||||
public class PsiSourceFile(private val psiFile: PsiFile): SourceFile {
|
||||
override fun equals(other: Any?): Boolean = other is PsiSourceFile && psiFile == other.psiFile
|
||||
override fun hashCode(): Int = psiFile.hashCode()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user