Fix retrieving documentation for overridden methods.
(The test doesn't actually reproduce the problem because it can't be done in a single-file setup, but it verifies that the basic functionality continues to work.)
This commit is contained in:
@@ -46,7 +46,7 @@ object KDocFinder {
|
||||
|
||||
if (declaration is CallableDescriptor) {
|
||||
for (baseDescriptor in declaration.getOverriddenDescriptors()) {
|
||||
val baseKDoc = findKDoc(baseDescriptor)
|
||||
val baseKDoc = findKDoc(baseDescriptor.getOriginal())
|
||||
if (baseKDoc != null) {
|
||||
return baseKDoc
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
open class Foo() {
|
||||
/**
|
||||
* Doc for method xyzzy
|
||||
*/
|
||||
open fun xyzzy(): Int = 0
|
||||
}
|
||||
|
||||
open class Bar(): Foo() {
|
||||
override fun xyzzy(): Int = 1
|
||||
}
|
||||
@@ -16,12 +16,13 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.kdoc
|
||||
|
||||
import org.jetbrains.kotlin.idea.PluginTestCaseBase
|
||||
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
|
||||
import org.junit.Assert
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.idea.PluginTestCaseBase
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.junit.Assert
|
||||
|
||||
public class KDocFinderTest() : LightPlatformCodeInsightFixtureTestCase() {
|
||||
override fun getTestDataPath(): String {
|
||||
@@ -36,4 +37,13 @@ public class KDocFinderTest() : LightPlatformCodeInsightFixtureTestCase() {
|
||||
val doc = KDocFinder.findKDoc(constructorDescriptor)
|
||||
Assert.assertEquals("Doc for constructor of class C.", doc!!.getContent())
|
||||
}
|
||||
|
||||
public fun testOverridden() {
|
||||
myFixture.configureByFile(getTestName(false) + ".kt")
|
||||
val declaration = (myFixture.getFile() as JetFile).getDeclarations().single { it.getName() == "Bar" }
|
||||
val descriptor = declaration.resolveToDescriptor() as ClassDescriptor
|
||||
val overriddenFunctionDescriptor = descriptor.getDefaultType().getMemberScope().getFunctions(Name.identifier("xyzzy")).single()
|
||||
val doc = KDocFinder.findKDoc(overriddenFunctionDescriptor)
|
||||
Assert.assertEquals("Doc for method xyzzy", doc!!.getContent())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user