Reformat: structureView package
This commit is contained in:
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import java.util.*
|
||||
|
||||
class KotlinInheritedMembersNodeProvider: InheritedMembersNodeProvider<TreeElement>() {
|
||||
class KotlinInheritedMembersNodeProvider : InheritedMembersNodeProvider<TreeElement>() {
|
||||
override fun provideNodes(node: TreeElement): Collection<TreeElement> {
|
||||
if (node !is KotlinStructureViewElement) return listOf()
|
||||
|
||||
|
||||
+3
-3
@@ -37,9 +37,9 @@ import org.jetbrains.kotlin.resolve.OverridingUtil.filterOutOverridden
|
||||
import javax.swing.Icon
|
||||
|
||||
internal class KotlinStructureElementPresentation(
|
||||
private val isInherited: Boolean,
|
||||
navigatablePsiElement: NavigatablePsiElement,
|
||||
descriptor: DeclarationDescriptor?
|
||||
private val isInherited: Boolean,
|
||||
navigatablePsiElement: NavigatablePsiElement,
|
||||
descriptor: DeclarationDescriptor?
|
||||
) : ColoredItemPresentation, LocationPresentation {
|
||||
private val attributesKey = getElementAttributesKey(isInherited, navigatablePsiElement)
|
||||
private val elementText = getElementText(navigatablePsiElement, descriptor)
|
||||
|
||||
+15
-13
@@ -34,21 +34,23 @@ import javax.swing.Icon
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class KotlinStructureViewElement(val element: NavigatablePsiElement,
|
||||
private val isInherited: Boolean = false) : PsiTreeElementBase<NavigatablePsiElement>(element), Queryable {
|
||||
class KotlinStructureViewElement(
|
||||
val element: NavigatablePsiElement,
|
||||
private val isInherited: Boolean = false
|
||||
) : PsiTreeElementBase<NavigatablePsiElement>(element), Queryable {
|
||||
|
||||
private var kotlinPresentation
|
||||
by AssignableLazyProperty {
|
||||
KotlinStructureElementPresentation(isInherited, element, countDescriptor())
|
||||
}
|
||||
by AssignableLazyProperty {
|
||||
KotlinStructureElementPresentation(isInherited, element, countDescriptor())
|
||||
}
|
||||
|
||||
var isPublic
|
||||
by AssignableLazyProperty {
|
||||
isPublic(countDescriptor())
|
||||
}
|
||||
by AssignableLazyProperty {
|
||||
isPublic(countDescriptor())
|
||||
}
|
||||
private set
|
||||
|
||||
constructor(element: NavigatablePsiElement, descriptor: DeclarationDescriptor, isInherited: Boolean) : this(element, isInherited){
|
||||
constructor(element: NavigatablePsiElement, descriptor: DeclarationDescriptor, isInherited: Boolean) : this(element, isInherited) {
|
||||
if (element !is KtElement) {
|
||||
// Avoid storing descriptor in fields
|
||||
kotlinPresentation = KotlinStructureElementPresentation(isInherited, element, descriptor)
|
||||
@@ -100,7 +102,7 @@ class KotlinStructureViewElement(val element: NavigatablePsiElement,
|
||||
}
|
||||
|
||||
private fun isPublic(descriptor: DeclarationDescriptor?) =
|
||||
(descriptor as? DeclarationDescriptorWithVisibility)?.visibility == Visibilities.PUBLIC
|
||||
(descriptor as? DeclarationDescriptorWithVisibility)?.visibility == Visibilities.PUBLIC
|
||||
|
||||
private fun countDescriptor(): DeclarationDescriptor? = when {
|
||||
!element.isValid -> null
|
||||
@@ -127,7 +129,7 @@ private class AssignableLazyProperty<in R, T : Any>(val init: () -> T) : ReadWri
|
||||
}
|
||||
|
||||
fun KtClassOrObject.getStructureDeclarations() =
|
||||
(primaryConstructor?.let { listOf(it) } ?: emptyList()) +
|
||||
primaryConstructorParameters.filter { it.hasValOrVar() } +
|
||||
declarations
|
||||
(primaryConstructor?.let { listOf(it) } ?: emptyList()) +
|
||||
primaryConstructorParameters.filter { it.hasValOrVar() } +
|
||||
declarations
|
||||
|
||||
|
||||
+3
-2
@@ -28,8 +28,9 @@ import org.jetbrains.kotlin.psi.KtEnumEntry
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
|
||||
class KotlinStructureViewModel(ktFile: KtFile, editor: Editor?) :
|
||||
StructureViewModelBase(ktFile, editor, KotlinStructureViewElement(ktFile, false)),
|
||||
StructureViewModel.ElementInfoProvider {
|
||||
StructureViewModelBase(ktFile, editor, KotlinStructureViewElement(ktFile, false)),
|
||||
StructureViewModel.ElementInfoProvider {
|
||||
|
||||
init {
|
||||
withSuitableClasses(KtDeclaration::class.java)
|
||||
withSorters(Sorter.ALPHA_SORTER)
|
||||
|
||||
Reference in New Issue
Block a user