Collect local declarations under properties (KT-14215); improve presentation of object declarations
#KT-14215 Fixed
This commit is contained in:
+5
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
|||||||
import org.jetbrains.kotlin.idea.KotlinDescriptorIconProvider
|
import org.jetbrains.kotlin.idea.KotlinDescriptorIconProvider
|
||||||
import org.jetbrains.kotlin.psi.KtAnonymousInitializer
|
import org.jetbrains.kotlin.psi.KtAnonymousInitializer
|
||||||
import org.jetbrains.kotlin.psi.KtModifierListOwner
|
import org.jetbrains.kotlin.psi.KtModifierListOwner
|
||||||
|
import org.jetbrains.kotlin.psi.KtObjectDeclaration
|
||||||
import org.jetbrains.kotlin.psi.KtPsiUtil
|
import org.jetbrains.kotlin.psi.KtPsiUtil
|
||||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer.Companion.ONLY_NAMES_WITH_SHORT_TYPES
|
import org.jetbrains.kotlin.renderer.DescriptorRenderer.Companion.ONLY_NAMES_WITH_SHORT_TYPES
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.getAllOverriddenDeclarations
|
import org.jetbrains.kotlin.resolve.DescriptorUtils.getAllOverriddenDeclarations
|
||||||
@@ -82,6 +83,10 @@ internal class KotlinStructureElementPresentation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getElementText(navigatablePsiElement: NavigatablePsiElement, descriptor: DeclarationDescriptor?): String? {
|
private fun getElementText(navigatablePsiElement: NavigatablePsiElement, descriptor: DeclarationDescriptor?): String? {
|
||||||
|
if (navigatablePsiElement is KtObjectDeclaration && navigatablePsiElement.isObjectLiteral()) {
|
||||||
|
return "object" + (navigatablePsiElement.getSuperTypeList()?.text?.let { " : $it" } ?: "")
|
||||||
|
}
|
||||||
|
|
||||||
if (descriptor != null) {
|
if (descriptor != null) {
|
||||||
return ONLY_NAMES_WITH_SHORT_TYPES.render(descriptor)
|
return ONLY_NAMES_WITH_SHORT_TYPES.render(descriptor)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -90,7 +90,7 @@ class KotlinStructureViewElement(val element: NavigatablePsiElement,
|
|||||||
is KtFile -> element.declarations
|
is KtFile -> element.declarations
|
||||||
is KtClass -> element.getStructureDeclarations()
|
is KtClass -> element.getStructureDeclarations()
|
||||||
is KtClassOrObject -> element.declarations
|
is KtClassOrObject -> element.declarations
|
||||||
is KtFunction, is KtClassInitializer -> element.collectLocalDeclarations()
|
is KtFunction, is KtClassInitializer, is KtProperty -> element.collectLocalDeclarations()
|
||||||
else -> emptyList()
|
else -> emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
-AnonymousObjectMembers.kt
|
||||||
|
-C
|
||||||
|
-bar(): Unit
|
||||||
|
-object : Runnable
|
||||||
|
run(): Unit
|
||||||
|
xyzzy(): Unit
|
||||||
|
-f: Runnable
|
||||||
|
-object : Runnable
|
||||||
|
run(): Unit
|
||||||
|
xyzzy(): Unit
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
class C {
|
||||||
|
val f = object : Runnable {
|
||||||
|
fun run() { }
|
||||||
|
|
||||||
|
fun xyzzy() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar() {
|
||||||
|
val g = object : Runnable {
|
||||||
|
fun run() { }
|
||||||
|
|
||||||
|
fun xyzzy() { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-1
@@ -19,7 +19,8 @@
|
|||||||
a: Int
|
a: Int
|
||||||
a: Int
|
a: Int
|
||||||
a: String on Comparable<T>
|
a: String on Comparable<T>
|
||||||
b: Any
|
-b: Any
|
||||||
|
object
|
||||||
-Enum1
|
-Enum1
|
||||||
FIRST
|
FIRST
|
||||||
SECOND
|
SECOND
|
||||||
|
|||||||
+6
@@ -36,6 +36,12 @@ public class KotlinFileStructureTestGenerated extends AbstractKotlinFileStructur
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/structureView/fileStructure"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/structureView/fileStructure"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("AnonymousObjectMembers.kt")
|
||||||
|
public void testAnonymousObjectMembers() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/structureView/fileStructure/AnonymousObjectMembers.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("CheckLocationForKotlin.kt")
|
@TestMetadata("CheckLocationForKotlin.kt")
|
||||||
public void testCheckLocationForKotlin() throws Exception {
|
public void testCheckLocationForKotlin() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/structureView/fileStructure/CheckLocationForKotlin.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/structureView/fileStructure/CheckLocationForKotlin.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user