Added comments.
This commit is contained in:
@@ -58,6 +58,9 @@ public object DescriptorToSourceUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE this is also used by KDoc
|
// NOTE this is also used by KDoc
|
||||||
|
// Returns PSI element for descriptor. If there are many relevant elements (e.g. it is fake override
|
||||||
|
// with multiple declarations), finds any of them. It can't find declarations in builtins or decompiled code.
|
||||||
|
// In IDE, use DescriptorToSourceUtilsIde instead.
|
||||||
platformStatic
|
platformStatic
|
||||||
public fun descriptorToDeclaration(descriptor: DeclarationDescriptor): PsiElement? {
|
public fun descriptorToDeclaration(descriptor: DeclarationDescriptor): PsiElement? {
|
||||||
for (declarationDescriptor in getEffectiveReferencedDescriptors(descriptor.getOriginal())) {
|
for (declarationDescriptor in getEffectiveReferencedDescriptors(descriptor.getOriginal())) {
|
||||||
|
|||||||
+3
@@ -30,10 +30,13 @@ import java.util.*
|
|||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
|
|
||||||
public object DescriptorToSourceUtilsIde {
|
public object DescriptorToSourceUtilsIde {
|
||||||
|
// Returns PSI element for descriptor. If there are many relevant elements (e.g. it is fake override
|
||||||
|
// with multiple declarations), finds any of them. It can find declarations in builtins or decompiled code.
|
||||||
public fun getAnyDeclaration(project: Project, descriptor: DeclarationDescriptor): PsiElement? {
|
public fun getAnyDeclaration(project: Project, descriptor: DeclarationDescriptor): PsiElement? {
|
||||||
return getDeclarationsStream(project, descriptor).firstOrNull()
|
return getDeclarationsStream(project, descriptor).firstOrNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns all PSI elements for descriptor. It can find declarations in builtins or decompiled code.
|
||||||
public fun getAllDeclarations(project: Project, targetDescriptor: DeclarationDescriptor): Collection<PsiElement> {
|
public fun getAllDeclarations(project: Project, targetDescriptor: DeclarationDescriptor): Collection<PsiElement> {
|
||||||
val result = getDeclarationsStream(project, targetDescriptor).toHashSet()
|
val result = getDeclarationsStream(project, targetDescriptor).toHashSet()
|
||||||
// filter out elements which are navigate to some other element of the result
|
// filter out elements which are navigate to some other element of the result
|
||||||
|
|||||||
Reference in New Issue
Block a user