KT-6676 Show enum ordinal in quickdoc (#1165)
KT-6676: Show enum ordinal in quickdoc #KT-6676 fixed
This commit is contained in:
@@ -194,6 +194,18 @@ class KotlinQuickDocumentationProvider : AbstractDocumentationProvider() {
|
|||||||
// element is not an KtReferenceExpression, but KtClass of enum
|
// element is not an KtReferenceExpression, but KtClass of enum
|
||||||
return renderEnum(element, originalElement, quickNavigation)
|
return renderEnum(element, originalElement, quickNavigation)
|
||||||
}
|
}
|
||||||
|
else if (element is KtEnumEntry && !quickNavigation) {
|
||||||
|
val ordinal = element.containingClassOrObject?.getBody()?.run { getChildrenOfType<KtEnumEntry>().indexOf(element) }
|
||||||
|
|
||||||
|
return buildString {
|
||||||
|
append(renderKotlinDeclaration(element, quickNavigation))
|
||||||
|
ordinal?.let {
|
||||||
|
wrapTag("b") {
|
||||||
|
append("Enum constant ordinal: $ordinal")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (element is KtDeclaration) {
|
else if (element is KtDeclaration) {
|
||||||
return renderKotlinDeclaration(element, quickNavigation)
|
return renderKotlinDeclaration(element, quickNavigation)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
enum class TestEnum{
|
||||||
|
A, B, <caret>C
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//INFO: <pre><b>enum entry</b> C <i>defined in</i> TestEnum</pre><b>Enum constant ordinal: 2</b>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
enum class TestEnum{
|
||||||
|
A, B, C
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
TestEnum.<caret>C
|
||||||
|
}
|
||||||
|
|
||||||
|
//INFO: <pre><b>enum entry</b> C <i>defined in</i> TestEnum</pre><b>Enum constant ordinal: 2</b>
|
||||||
+12
@@ -180,6 +180,18 @@ public class QuickDocProviderTestGenerated extends AbstractQuickDocProviderTest
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("OnEnumEntry.kt")
|
||||||
|
public void testOnEnumEntry() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/editor/quickDoc/OnEnumEntry.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("OnEnumEntryUsage.kt")
|
||||||
|
public void testOnEnumEntryUsage() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/editor/quickDoc/OnEnumEntryUsage.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("OnEnumUsage.kt")
|
@TestMetadata("OnEnumUsage.kt")
|
||||||
public void testOnEnumUsage() throws Exception {
|
public void testOnEnumUsage() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/editor/quickDoc/OnEnumUsage.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/editor/quickDoc/OnEnumUsage.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user