mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] Use the Kotlin source instead of the decompiled source if available
closes https://github.com/JetBrains/intellij-community/pull/2602 #KTIJ-27688 Fixed GitOrigin-RevId: 8da49d7049a003434eba604c55114de74ad2ea47
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e5c2c59036
commit
d5edfd3100
@@ -337,6 +337,10 @@ class KotlinDocumentationProvider : AbstractDocumentationProvider(), ExternalDoc
|
||||
|
||||
@Nls
|
||||
private fun getTextImpl(element: PsiElement, originalElement: PsiElement?, quickNavigation: Boolean): String? {
|
||||
(element as? KtElement)?.navigationElement.takeIf { it != element }?.let {
|
||||
return getTextImpl(it, originalElement, quickNavigation)
|
||||
}
|
||||
|
||||
if (element is PsiWhiteSpace) {
|
||||
val itElement = findElementWithText(originalElement, StandardNames.IMPLICIT_LAMBDA_PARAMETER_NAME.identifier)
|
||||
val itReference = itElement?.getParentOfType<KtNameReferenceExpression>(false)
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.idea.editor.quickDoc
|
||||
|
||||
import com.intellij.openapi.vfs.JarFileSystem
|
||||
import com.intellij.testFramework.PsiTestUtil
|
||||
import org.jetbrains.kotlin.idea.KotlinDocumentationProvider
|
||||
import org.jetbrains.kotlin.idea.test.IDEA_TEST_DATA_DIR
|
||||
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
|
||||
import org.junit.Assert
|
||||
|
||||
class QuickDocJarTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
fun testWithSources_showsDefaults() {
|
||||
val classesRoot = JarFileSystem.getInstance().refreshAndFindFileByPath("$IDEA_TEST_DATA_DIR/lib/HasDefaults.jar!/")
|
||||
PsiTestUtil.addProjectLibrary(myFixture.module, "mylib", listOf(classesRoot), listOf(classesRoot))
|
||||
|
||||
val psiFile = myFixture.addFileToProject("my/great/app/MyFile.kt", """
|
||||
package my.great.app
|
||||
import com.example.HasDefaults
|
||||
|
||||
fun myFunction() {
|
||||
HasDefaults.met<caret>hod(
|
||||
}
|
||||
""".trimIndent())
|
||||
myFixture.configureFromExistingVirtualFile(psiFile.virtualFile)
|
||||
|
||||
val element = myFixture.elementAtCaret
|
||||
|
||||
val html = KotlinDocumentationProvider().generateDoc(element, null)
|
||||
checkNotNull(html)
|
||||
Assert.assertFalse(html.contains("..."))
|
||||
Assert.assertTrue(html.contains("A_DEFAULT"))
|
||||
Assert.assertTrue(html.contains("B_DEFAULT"))
|
||||
}
|
||||
}
|
||||
@@ -4,4 +4,4 @@ fun test() {
|
||||
|
||||
//INFO: <div class='definition'><pre><span style="color:#000080;font-weight:bold;">public</span> <span style="color:#000080;font-weight:bold;">inline</span> <span style="color:#000080;font-weight:bold;">fun</span> <span style=""><</span><span style="color:#20999d;">T</span><span style="">></span> <span style="color:#000000;"><a href="psi_element://kotlin.collections.Iterable">Iterable</a></span><span style=""><</span><span style="color:#20999d;"><a href="psi_element://kotlin.collections.filter.T">T</a></span><span style="">></span><span style="">.</span><span style="color:#000000;">filter</span>(
|
||||
//INFO: <span style="color:#000000;">predicate</span><span style="">: </span><span style="">(</span><span style="color:#20999d;"><a href="psi_element://kotlin.collections.filter.T">T</a></span><span style="">) </span><span style="">-></span> <span style="color:#000000;">Boolean</span>
|
||||
//INFO: )<span style="">: </span><span style="color:#000000;"><a href="psi_element://kotlin.collections.List">List</a></span><span style=""><</span><span style="color:#20999d;"><a href="psi_element://kotlin.collections.filter.T">T</a></span><span style="">></span></pre></div><div class='content'><p style='margin-top:0;padding-top:0;'>Returns a list containing only elements matching the given <a href="psi_element://predicate"><code style='font-size:96%;'><span style="color:#0000ff;">predicate</span></code></a>.</p></div><table class='sections'><tr><td valign='top' class='section'><p>Samples:</td><td valign='top'><p><a href="psi_element://samples.collections.Collections.Filtering.filter"><code style='font-size:96%;'><span style="color:#000000;">samples</span><span style="">.</span><span style="color:#000000;">collections</span><span style="">.</span><span style="color:#000000;">Collections</span><span style="">.</span><span style="color:#000000;">Filtering</span><span style="">.</span><span style="color:#4585be;">filter</span></code></a><pre><code><span style=""><span style="color:#808080;font-style:italic;">// Unresolved</span></span></code></pre></td></table><div class='bottom'><icon src="/org/jetbrains/kotlin/idea/icons/classKotlin.svg"/> <a href="psi_element://kotlin.collections"><code><span style="color:#000000;">kotlin.collections</span></code></a><br/><icon src="/org/jetbrains/kotlin/idea/icons/kotlin_file.svg"/> CollectionsKt.class<br/></div>
|
||||
//INFO: )<span style="">: </span><span style="color:#000000;"><a href="psi_element://kotlin.collections.List">List</a></span><span style=""><</span><span style="color:#20999d;"><a href="psi_element://kotlin.collections.filter.T">T</a></span><span style="">></span></pre></div><div class='content'><p style='margin-top:0;padding-top:0;'>Returns a list containing only elements matching the given <a href="psi_element://predicate"><code style='font-size:96%;'><span style="color:#0000ff;">predicate</span></code></a>.</p></div><table class='sections'><tr><td valign='top' class='section'><p>Samples:</td><td valign='top'><p><a href="psi_element://samples.collections.Collections.Filtering.filter"><code style='font-size:96%;'><span style="color:#000000;">samples</span><span style="">.</span><span style="color:#000000;">collections</span><span style="">.</span><span style="color:#000000;">Collections</span><span style="">.</span><span style="color:#000000;">Filtering</span><span style="">.</span><span style="color:#4585be;">filter</span></code></a><pre><code><span style=""><span style="color:#808080;font-style:italic;">// Unresolved</span></span></code></pre></td></table><div class='bottom'><icon src="/org/jetbrains/kotlin/idea/icons/classKotlin.svg"/> <a href="psi_element://kotlin.collections"><code><span style="color:#000000;">kotlin.collections</span></code></a><br/><icon src="/org/jetbrains/kotlin/idea/icons/kotlin_file.svg"/> _Collections.kt<br/></div>
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user