Fix for KT-10665, now only signature + deprecation info shown in quick navigation tooltip

Fix tests, to use full documentation mode instead of quick navigate
This commit is contained in:
Simon Ogorodnik
2016-11-16 19:27:49 +03:00
parent 1c75c02dfe
commit e4a383f3e2
35 changed files with 62 additions and 51 deletions
@@ -160,31 +160,34 @@ class KotlinQuickDocumentationProvider : AbstractDocumentationProvider() {
}
var renderedDecl = DESCRIPTOR_RENDERER.render(declarationDescriptor)
if (!quickNavigation) {
renderedDecl = "<pre>$renderedDecl</pre>"
}
renderedDecl += renderDeprecationInfo(declarationDescriptor)
val comment = declarationDescriptor.findKDoc()
if (comment != null) {
val renderedComment = KDocRenderer.renderKDoc(comment)
if (renderedComment.startsWith("<p>")) {
renderedDecl += renderedComment
if (!quickNavigation) {
val comment = declarationDescriptor.findKDoc()
if (comment != null) {
val renderedComment = KDocRenderer.renderKDoc(comment)
if (renderedComment.startsWith("<p>")) {
renderedDecl += renderedComment
}
else {
renderedDecl = "$renderedDecl<br/>$renderedComment"
}
}
else {
renderedDecl = "$renderedDecl<br/>$renderedComment"
}
}
else {
if (declarationDescriptor is CallableDescriptor) { // If we couldn't find KDoc, try to find javadoc in one of super's
val psi = declarationDescriptor.findPsi() as? KtFunction
if (psi != null) {
val lightElement = LightClassUtil.getLightClassMethod(psi) // Light method for super's scan in javadoc info gen
val javaDocInfoGenerator = JavaDocInfoGeneratorFactory.create(psi.project, lightElement)
val builder = StringBuilder()
if (javaDocInfoGenerator.generateDocInfoCore(builder, false))
renderedDecl += builder.toString().substringAfter("</PRE>") // Cut off light method signature
if (declarationDescriptor is CallableDescriptor) { // If we couldn't find KDoc, try to find javadoc in one of super's
val psi = declarationDescriptor.findPsi() as? KtFunction
if (psi != null) {
val lightElement = LightClassUtil.getLightClassMethod(psi) // Light method for super's scan in javadoc info gen
val javaDocInfoGenerator = JavaDocInfoGeneratorFactory.create(psi.project, lightElement)
val builder = StringBuilder()
if (javaDocInfoGenerator.generateDocInfoCore(builder, false))
renderedDecl += builder.toString().substringAfter("</PRE>") // Cut off light method signature
}
}
}
}
+1 -1
View File
@@ -9,4 +9,4 @@ class C {
}
}
//INFO: <b>public</b> <b>final</b> <b>fun</b> foo(): Unit <i>defined in</i> C<p>Use <a href="psi_element://SOME_REFERENCED_VAL">SOME_REFERENCED_VAL</a> to do something</p>
//INFO: <pre><b>public</b> <b>final</b> <b>fun</b> foo(): Unit <i>defined in</i> C</pre><p>Use <a href="psi_element://SOME_REFERENCED_VAL">SOME_REFERENCED_VAL</a> to do something</p>
+1 -1
View File
@@ -1,3 +1,3 @@
fun some(<caret>f: (Int) -> String) : String? = null
//INFO: <b>value-parameter</b> f: (Int) &rarr; String <i>defined in</i> some
//INFO: <pre><b>value-parameter</b> f: (Int) &rarr; String <i>defined in</i> some</pre>
+1 -1
View File
@@ -4,4 +4,4 @@ fun foo() {
}
}
//INFO: <b>value-parameter</b> it: Int <i>defined in</i> foo.&lt;anonymous&gt;
//INFO: <pre><b>value-parameter</b> it: Int <i>defined in</i> foo.&lt;anonymous&gt;</pre>
+1 -1
View File
@@ -2,4 +2,4 @@ interface Base
class Some<<caret>T: Base>
//INFO: &lt;T : <a href="psi_element://Base">Base</a>&gt; <i>defined in</i> Some
//INFO: <pre>&lt;T : <a href="psi_element://Base">Base</a>&gt; <i>defined in</i> Some</pre>
+1 -1
View File
@@ -5,4 +5,4 @@ fun test() {
}
//INFO: <b>val</b> test: String? <i>defined in</i> test
//INFO: <pre><b>val</b> test: String? <i>defined in</i> test</pre>
+1 -1
View File
@@ -4,4 +4,4 @@ class C(var v: Int) {
}
}
//INFO: <b>public</b> <b>final</b> <b>var</b> v: Int <i>defined in</i> C
//INFO: <pre><b>public</b> <b>final</b> <b>var</b> v: Int <i>defined in</i> C</pre>
@@ -3,4 +3,4 @@ fun <caret>lol() {
println("lol")
}
//INFO: @<a href="psi_element://kotlin.Deprecated">Deprecated</a> <b>public</b> <b>fun</b> lol(): Unit <i>defined in</i> root package<DL><DT><b>Deprecated:</b></DT><DD>lol no more mainstream</DD><DT><b>Replace with:</b></DT><DD><code>kek()</code></DD></DL>
//INFO: <pre>@<a href="psi_element://kotlin.Deprecated">Deprecated</a> <b>public</b> <b>fun</b> lol(): Unit <i>defined in</i> root package</pre><DL><DT><b>Deprecated:</b></DT><DD>lol no more mainstream</DD><DT><b>Replace with:</b></DT><DD><code>kek()</code></DD></DL>
@@ -8,7 +8,7 @@
*/
class <caret>A<T>
//INFO: <b>public</b> <b>final</b> <b>class</b> A&lt;T&gt; <i>defined in</i> root package<p>Code block:</p>
//INFO: <pre><b>public</b> <b>final</b> <b>class</b> A&lt;T&gt; <i>defined in</i> root package</pre><p>Code block:</p>
//INFO: <pre><code>
//INFO: A&lt;T&gt;
//INFO: </code></pre><p>Code span: <code>&lt;T&gt;</code> is type parameter</p>
+1 -1
View File
@@ -13,7 +13,7 @@
*/
class <caret>A
//INFO: <b>public</b> <b>final</b> <b>class</b> A <i>defined in</i> root package<br/><pre><code>val a = A()
//INFO: <pre><b>public</b> <b>final</b> <b>class</b> A <i>defined in</i> root package</pre><br/><pre><code>val a = A()
//INFO: println(a) // comment</code></pre><pre><code>
//INFO: &lt;fenced&gt;Code_block&lt;/fenced&gt;
//INFO: </code></pre><pre><code>val b = B()
+4 -1
View File
@@ -2,4 +2,7 @@ fun testing() {
<caret>SomeClass<List<String>>()
}
//INFO: <b>public</b> <b>constructor</b> SomeClass&lt;T : (<(raw) Any?>&lt;Any?&gt;..<(raw) Any?>&lt;*&gt;?)&gt;()<br/>Java declaration:<br/>[light_idea_test_case] public class SomeClass&lt;T extends java.util.List&gt; extends Object
//INFO: <html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } p { margin: 5px 0; } </style></head><body><PRE>public class <b>SomeClass</b>&lt;T extends <a href="psi_element://java.util.List"><code>List</code></a>&gt;
//INFO: extends <a href="psi_element://java.lang.Object"><code>Object</code></a></PRE>
//INFO: Some Java Class
//INFO: <DD><DL><DT><b>Type parameters:</b><DD><code>&lt;T&gt;</code> - </DD></DL></DD></body></html>
+1 -1
View File
@@ -4,6 +4,6 @@ class A : OverrideMe() {
}
//INFO: <b>protected</b> <b>open</b> <b>fun</b> overrideMe(): Unit <i>defined in</i> A<DD><DL><DT><b>Description copied from class:</b>&nbsp;<a href="psi_element://OverrideMe"><code>OverrideMe</code></a><br>
//INFO: <pre><b>protected</b> <b>open</b> <b>fun</b> overrideMe(): Unit <i>defined in</i> A</pre><DD><DL><DT><b>Description copied from class:</b>&nbsp;<a href="psi_element://OverrideMe"><code>OverrideMe</code></a><br>
//INFO: Some comment
//INFO: </DD></DL></DD><DD><DL><DT><b>Overrides:</b><DD><a href="psi_element://OverrideMe#overrideMe()"><code>overrideMe</code></a> in class <a href="psi_element://OverrideMe"><code>OverrideMe</code></a></DD></DL></DD>
@@ -4,6 +4,6 @@ class A : OverrideMe {
}
//INFO: <b>public</b> <b>open</b> <b>fun</b> overrideMe(): Unit <i>defined in</i> A<DD><DL><DT><b>Description copied from interface:</b>&nbsp;<a href="psi_element://OverrideMe"><code>OverrideMe</code></a><br>
//INFO: <pre><b>public</b> <b>open</b> <b>fun</b> overrideMe(): Unit <i>defined in</i> A</pre><DD><DL><DT><b>Description copied from interface:</b>&nbsp;<a href="psi_element://OverrideMe"><code>OverrideMe</code></a><br>
//INFO: Some comment
//INFO: </DD></DL></DD><DD><DL><DT><b>Specified by:</b><DD><a href="psi_element://OverrideMe#overrideMe()"><code>overrideMe</code></a> in interface <a href="psi_element://OverrideMe"><code>OverrideMe</code></a></DD></DL></DD>
+3 -1
View File
@@ -2,4 +2,6 @@ fun ktTest() {
Test.<caret>foo("SomeTest")
}
//INFO: <b>public</b> <b>open</b> <b>fun</b> foo(param: String!): Array&lt;(out) Any!&gt;!<br/>Java declaration:<br/>Test...
//INFO: <html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } p { margin: 5px 0; } </style></head><body><small><b><a href="psi_element://Test"><code>Test</code></a></b></small><PRE><i>@Contract(value = &quot;_ -&gt; !null&quot;, pure = true)</i>&nbsp;
//INFO: public static&nbsp;<a href="psi_element://java.lang.Object"><code>Object</code></a>[]&nbsp;<b>foo</b>(<a href="psi_element://java.lang.String"><code>String</code></a>&nbsp;param)</PRE>
//INFO: Java Method</body></html>
+1 -1
View File
@@ -6,4 +6,4 @@ class KotlinClassUsedFromJava {
}
}
//INFO: <b>public</b> <b>final</b> <b>class</b> Test <i>defined in</i> testing<p>Some comment</p>
//INFO: <pre><b>public</b> <b>final</b> <b>class</b> Test <i>defined in</i> testing</pre><p>Some comment</p>
@@ -6,4 +6,5 @@ class KotlinPackageClassUsedFromJava {
}
}
//INFO: [light_idea_test_case] testing...
//INFO: <html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } p { margin: 5px 0; } </style></head><body><small><b>testing</b></small><PRE>public final class <b>testing.KotlinPackageClassUsedFromJava_DataKt</b>
//INFO: extends <a href="psi_element://java.lang.Object"><code>Object</code></a></PRE></body></html>
+1 -1
View File
@@ -2,4 +2,4 @@ fun test() {
listOf(1, 2, 4).<caret>filter { it > 0 }
}
//INFO: <b>public</b> inline <b>fun</b> &lt;T&gt; <a href="psi_element://kotlin.collections.Iterable">Iterable</a>&lt;<a href="psi_element://kotlin.collections.filter.T">T</a>&gt;.filter(predicate: (<a href="psi_element://kotlin.collections.filter.T">T</a>) &rarr; Boolean): <a href="psi_element://kotlin.collections.List">List</a>&lt;<a href="psi_element://kotlin.collections.filter.T">T</a>&gt; <i>defined in</i> kotlin.collections<p>Returns a list containing only elements matching the given <a href="psi_element://predicate">predicate</a>.</p>
//INFO: <pre><b>public</b> inline <b>fun</b> &lt;T&gt; <a href="psi_element://kotlin.collections.Iterable">Iterable</a>&lt;<a href="psi_element://kotlin.collections.filter.T">T</a>&gt;.filter(predicate: (<a href="psi_element://kotlin.collections.filter.T">T</a>) &rarr; Boolean): <a href="psi_element://kotlin.collections.List">List</a>&lt;<a href="psi_element://kotlin.collections.filter.T">T</a>&gt; <i>defined in</i> kotlin.collections</pre><p>Returns a list containing only elements matching the given <a href="psi_element://predicate">predicate</a>.</p>
@@ -3,4 +3,4 @@
*/
class <caret>Some
//INFO: <b>public</b> <b>final</b> <b>class</b> Some <i>defined in</i> root package<p>Usefull comment</p>
//INFO: <pre><b>public</b> <b>final</b> <b>class</b> Some <i>defined in</i> root package</pre><p>Usefull comment</p>
@@ -12,5 +12,5 @@ package test
*/
fun <caret>testFun(first: String, second: Int) = 12
//INFO: <b>public</b> <b>fun</b> testFun(first: String, second: Int): Int <i>defined in</i> test<p>Test function</p>
//INFO: <pre><b>public</b> <b>fun</b> testFun(first: String, second: Int): Int <i>defined in</i> test</pre><p>Test function</p>
//INFO: <dl><dt><b>Parameters:</b></dt><dd><code>first</code> - Some</dd><dd><code>second</code> - Other</dd></dl>
+1 -1
View File
@@ -14,4 +14,4 @@ fun test() {
D().f<caret>oo()
}
//INFO: <b>public</b> <b>open</b> <b>fun</b> foo(): Int <i>defined in</i> D<p>This method returns zero.</p>
//INFO: <pre><b>public</b> <b>open</b> <b>fun</b> foo(): Int <i>defined in</i> D</pre><p>This method returns zero.</p>
+1 -1
View File
@@ -14,4 +14,4 @@ fun test() {
D().f<caret>oo
}
//INFO: <b>public</b> <b>open</b> <b>val</b> foo: Int <i>defined in</i> D<p>This property returns zero.</p>
//INFO: <pre><b>public</b> <b>open</b> <b>val</b> foo: Int <i>defined in</i> D</pre><p>This property returns zero.</p>
+1 -1
View File
@@ -12,5 +12,5 @@ fun test() {
<caret>testMethod(1, "value")
}
//INFO: <b>public</b> <b>fun</b> testMethod(a: Int, b: String): Unit <i>defined in</i> root package<p>Some documentation</p>
//INFO: <pre><b>public</b> <b>fun</b> testMethod(a: Int, b: String): Unit <i>defined in</i> root package</pre><p>Some documentation</p>
//INFO: <dl><dt><b>Parameters:</b></dt><dd><code>a</code> - Some int</dd><dd><code>b</code> - String</dd></dl>
+1 -1
View File
@@ -10,4 +10,4 @@ fun test() {
<caret>testMethod()
}
//INFO: <b>public</b> <b>fun</b> testMethod(): Unit <i>defined in</i> root package<p>Some documentation on two lines.</p>
//INFO: <pre><b>public</b> <b>fun</b> testMethod(): Unit <i>defined in</i> root package</pre><p>Some documentation on two lines.</p>
@@ -12,5 +12,5 @@ fun test() {
<caret>testMethod(1, "value")
}
//INFO: <b>public</b> <b>fun</b> testMethod(a: Int, b: String): Unit <i>defined in</i> root package<p>Some documentation</p>
//INFO: <pre><b>public</b> <b>fun</b> testMethod(a: Int, b: String): Unit <i>defined in</i> root package</pre><p>Some documentation</p>
//INFO: <dl><dt><b>Parameters:</b></dt><dd><code>a</code> - Some int</dd><dd><code>b</code> - String</dd></dl>
@@ -24,7 +24,7 @@ fun test() {
<caret>testMethod(1, "value")
}
//INFO: <b>public</b> <b>fun</b> testMethod(): Unit <i>defined in</i> root package<p>Some documentation.</p>
//INFO: <pre><b>public</b> <b>fun</b> testMethod(): Unit <i>defined in</i> root package</pre><p>Some documentation.</p>
//INFO: <pre><code>
//INFO: Code block
//INFO: Second line
+1 -1
View File
@@ -27,7 +27,7 @@ fun test() {
<caret>testMethod(1, "value")
}
//INFO: <b>public</b> <b>fun</b> testMethod(): Unit <i>defined in</i> root package<p>Some documentation. <strong>Bold</strong> <em>underline</em> <code>code</code> foo: bar (baz) <a href="psi_element://quux">quux</a> 'apos'</p>
//INFO: <pre><b>public</b> <b>fun</b> testMethod(): Unit <i>defined in</i> root package</pre><p>Some documentation. <strong>Bold</strong> <em>underline</em> <code>code</code> foo: bar (baz) <a href="psi_element://quux">quux</a> 'apos'</p>
//INFO: <p><a href="http://www.kotlinlang.org">Kotlin</a> <a href="http://www.ibm.com">a<strong>b</strong><strong>d</strong> kas</a></p>
//INFO: <p><a href="psi_element://C">C</a></p>
//INFO: <p><a href="psi_element://C">See <strong>this</strong> class</a></p>
+1 -1
View File
@@ -13,7 +13,7 @@ fun test() {
1.<caret>testMethod("value")
}
//INFO: <b>public</b> <b>fun</b> Int.testMethod(b: String): Unit <i>defined in</i> root package<p>Some documentation</p>
//INFO: <pre><b>public</b> <b>fun</b> Int.testMethod(b: String): Unit <i>defined in</i> root package</pre><p>Some documentation</p>
//INFO: <dl><dt><b>Receiver:</b></dt><dd>Some int</dd></dl>
//INFO: <dl><dt><b>Parameters:</b></dt><dd><code>b</code> - String</dd></dl>
//INFO: <dl><dt><b>Returns:</b></dt><dd>Return <a href="psi_element://a">a</a> and nothing else</dd></dl>
@@ -13,6 +13,6 @@ fun test() {
<caret>testMethod(1, "value")
}
//INFO: <b>public</b> <b>fun</b> testMethod(a: Int, b: String): Unit <i>defined in</i> root package<p>Some documentation</p>
//INFO: <pre><b>public</b> <b>fun</b> testMethod(a: Int, b: String): Unit <i>defined in</i> root package</pre><p>Some documentation</p>
//INFO: <dl><dt><b>Parameters:</b></dt><dd><code>a</code> - Some int</dd><dd><code>b</code> - String</dd></dl>
//INFO: <dl><dt><b>Returns:</b></dt><dd>Return <a href="psi_element://a">a</a> and nothing else</dd></dl>
@@ -14,7 +14,7 @@ fun test() {
<caret>testMethod(1, "value")
}
//INFO: <b>public</b> <b>fun</b> testMethod(a: Int, b: String): Unit <i>defined in</i> root package<p>Some documentation</p>
//INFO: <pre><b>public</b> <b>fun</b> testMethod(a: Int, b: String): Unit <i>defined in</i> root package</pre><p>Some documentation</p>
//INFO: <dl><dt><b>Parameters:</b></dt><dd><code>a</code> - Some int</dd><dd><code>b</code> - String</dd></dl>
//INFO: <dl><dt><b>Returns:</b></dt><dd>Return value</dd></dl>
//INFO: <dl><dt><b>Throws:</b></dt><dd><code>IllegalArgumentException</code> - if the weather is bad</dd></dl>
+1 -1
View File
@@ -17,5 +17,5 @@ fun test() {
<caret>testMethod(1, "value")
}
//INFO: <b>public</b> <b>fun</b> testMethod(): Unit <i>defined in</i> root package<br/>
//INFO: <pre><b>public</b> <b>fun</b> testMethod(): Unit <i>defined in</i> root package</pre><br/>
//INFO: <DD><DL><DT><b>See Also:</b><DD><a href="psi_element://C"><code>C</code></a>, <a href="psi_element://D"><code>D</code></a>, <a href="http://kotl.in">kotlin</a></DD></DL></DD>
@@ -13,5 +13,5 @@ fun test() {
<caret>testMethod(1, "value")
}
//INFO: <b>public</b> <b>fun</b> &lt;T&gt; testMethod(a: Int, b: String): Unit <i>defined in</i> root package<p>Some documentation</p>
//INFO: <pre><b>public</b> <b>fun</b> &lt;T&gt; testMethod(a: Int, b: String): Unit <i>defined in</i> root package</pre><p>Some documentation</p>
//INFO: <dl><dt><b>Parameters:</b></dt><dd><code>T</code> - the type parameter</dd><dd><code>a</code> - Some int</dd><dd><code>b</code> - String</dd></dl>
+1 -1
View File
@@ -19,7 +19,7 @@ fun <caret>castTextSpell(spell: String) {
throw SecurityException("Magic prohibited outside Hogwarts")
}
//INFO: <b>public</b> <b>fun</b> castTextSpell(spell: String): Unit <i>defined in</i> magic<br/>
//INFO: <pre><b>public</b> <b>fun</b> castTextSpell(spell: String): Unit <i>defined in</i> magic</pre><br/>
//INFO: <dl><dt><b>Samples:</b></dt><dd><a href="psi_element://Samples.sampleMagic"><code>Samples.sampleMagic</code></a><pre><code>
//INFO: castTextSpell("[asd] [dse] [asz]")
//INFO: </code></pre></dd><dd><a href="psi_element://sampleScroll"><code>sampleScroll</code></a><pre><code>
+1 -1
View File
@@ -8,4 +8,4 @@ class Testing {
}
}
//INFO: <b>public</b> <b>fun</b> foo(bar: Int): Unit <i>defined in</i> some<p>KDoc foo</p>
//INFO: <pre><b>public</b> <b>fun</b> foo(bar: Int): Unit <i>defined in</i> some</pre><p>KDoc foo</p>
@@ -8,4 +8,4 @@ fun main(args: Array<String>) {
<caret>foo()
}
//INFO: <b>public</b> <b>fun</b> foo(x: <a href="psi_element://A">A</a>): Unit <i>defined in</i> root package
//INFO: <pre><b>public</b> <b>fun</b> foo(x: <a href="psi_element://A">A</a>): Unit <i>defined in</i> root package</pre>
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.idea.editor.quickDoc;
import com.intellij.codeInsight.documentation.DocumentationComponent;
import com.intellij.codeInsight.documentation.DocumentationManager;
import com.intellij.codeInsight.navigation.CtrlMouseHandler;
import com.intellij.openapi.util.io.FileUtil;
@@ -41,8 +42,9 @@ public abstract class AbstractQuickDocProviderTest extends KotlinLightCodeInsigh
DocumentationManager documentationManager = DocumentationManager.getInstance(myFixture.getProject());
PsiElement targetElement = documentationManager.findTargetElement(myFixture.getEditor(), myFixture.getFile());
PsiElement originalElement = DocumentationManager.getOriginalElement(targetElement);
String info = CtrlMouseHandler.getInfo(targetElement, element);
String info = DocumentationManager.getProviderFromElement(targetElement).generateDoc(targetElement, originalElement);
if (info != null) {
info = StringUtil.convertLineSeparators(info);
}