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