Correctly show quick doc for lookup elements that only have descriptors
#KT-19716 Fixed
This commit is contained in:
@@ -111,7 +111,10 @@ class KotlinQuickDocumentationProvider : AbstractDocumentationProvider() {
|
||||
|
||||
override fun getDocumentationElementForLookupItem(psiManager: PsiManager, `object`: Any?, element: PsiElement?): PsiElement? {
|
||||
if (`object` is DeclarationLookupObject) {
|
||||
return `object`.psiElement
|
||||
`object`.psiElement?.let { return it }
|
||||
`object`.descriptor?.let { descriptor ->
|
||||
return DescriptorToSourceUtilsIde.getAnyDeclaration(psiManager.project, descriptor)
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
val s = "foo".le<caret>
|
||||
@@ -16,23 +16,37 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.editor.quickDoc
|
||||
|
||||
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.idea.KotlinQuickDocumentationProvider
|
||||
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.junit.Assert
|
||||
|
||||
class QuickDocInCompletionTest(): LightPlatformCodeInsightFixtureTestCase() {
|
||||
class QuickDocInCompletionTest: KotlinLightCodeInsightFixtureTestCase() {
|
||||
override fun getTestDataPath(): String {
|
||||
return PluginTestCaseBase.getTestDataPathBase() + "/kdoc/inCompletion/"
|
||||
}
|
||||
|
||||
override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||
|
||||
fun testSimple() {
|
||||
val element = getElementFromLookup()
|
||||
Assert.assertTrue(element is KtClass)
|
||||
}
|
||||
|
||||
fun testProp() {
|
||||
val element = getElementFromLookup()
|
||||
Assert.assertTrue(element is KtProperty)
|
||||
}
|
||||
|
||||
private fun getElementFromLookup(): PsiElement? {
|
||||
myFixture.configureByFile(getTestName(true) + ".kt")
|
||||
val lookupElements = myFixture.completeBasic()
|
||||
val lookupObject = lookupElements.first().`object`
|
||||
val element = KotlinQuickDocumentationProvider().getDocumentationElementForLookupItem(
|
||||
return KotlinQuickDocumentationProvider().getDocumentationElementForLookupItem(
|
||||
myFixture.psiManager, lookupObject, null)
|
||||
Assert.assertTrue(element is KtClass)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user