mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] generate documentation for implicit closure parameters and local variables (IDEA-130679)
This commit is contained in:
+2
-2
@@ -311,10 +311,10 @@ public class GroovyDocumentationProvider implements CodeDocumentationProvider, E
|
||||
|
||||
if (element == null) return null;
|
||||
|
||||
String standard = element.getNavigationElement() instanceof PsiDocCommentOwner ? generateExternalJavaDoc(element) : null;
|
||||
String standard = generateExternalJavaDoc(element);
|
||||
|
||||
if (element instanceof GrVariable &&
|
||||
((GrVariable)element).getTypeElementGroovy() == null &&
|
||||
((GrVariable)element).getDeclaredType() == null &&
|
||||
standard != null) {
|
||||
final String truncated = StringUtil.trimEnd(standard, BODY_HTML);
|
||||
|
||||
|
||||
@@ -63,11 +63,27 @@ new Gr().fo<caret>o()
|
||||
Use <a href="psi_element://Gr#bar()"><code>bar()</code></a> from class <a href="psi_element://Gr"><code>Gr</code></a> instead</body></html>'''
|
||||
}
|
||||
|
||||
void 'test untyped local variable'() {
|
||||
doTest '''\
|
||||
def aa = 1
|
||||
a<caret>a
|
||||
''', '''\
|
||||
<html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } p { margin: 5px 0; } </style></head><body><PRE><a href="psi_element://java.lang.Object"><code>Object</code></a> <b>aa</b></PRE><p>[inferred type] <a href="psi_element://java.lang.Integer"><code>Integer</code></a></body></html>'''
|
||||
}
|
||||
|
||||
void 'test implicit closure parameter'() {
|
||||
doTest '''\
|
||||
List<String> ss = []
|
||||
ss.collect { i<caret>t }
|
||||
''', '''\
|
||||
<html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } p { margin: 5px 0; } </style></head><body><PRE><a href="psi_element://java.lang.Object"><code>Object</code></a> <b>it</b></PRE><p>[inferred type] <a href="psi_element://java.lang.String"><code>String</code></a></body></html>'''
|
||||
}
|
||||
|
||||
private void doTest(String text, String doc) {
|
||||
myFixture.configureByText '_.groovy', text
|
||||
def ref = myFixture.file.findReferenceAt(myFixture.editor.caretModel.offset)
|
||||
def provider = new GroovyDocumentationProvider()
|
||||
def info = provider.generateDoc(ref.resolve(), ref.element)
|
||||
assert info == doc
|
||||
assertEquals(doc, info)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user