mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-167473 'Quick Documentation' doesn't work on a method call if there are several applicable overloads
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -506,8 +506,11 @@ public class JavaDocumentationProvider extends DocumentationProviderEx implement
|
||||
|
||||
@Override
|
||||
public String generateDoc(PsiElement element, PsiElement originalElement) {
|
||||
if (element instanceof PsiExpressionList) {
|
||||
element = element.getParent(); // for new Class(<caret>) or methodCall(<caret>) proceed from method call or new expression
|
||||
// for new Class(<caret>) or methodCall(<caret>) proceed from method call or new expression
|
||||
// same for new Cl<caret>ass() or method<caret>Call()
|
||||
if (element instanceof PsiExpressionList ||
|
||||
element instanceof PsiReferenceExpression && element.getParent() instanceof PsiMethodCallExpression) {
|
||||
element = element.getParent();
|
||||
originalElement = null;
|
||||
}
|
||||
if (element instanceof PsiMethodCallExpression) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -231,6 +231,26 @@ class Bar {
|
||||
assert doc == expected
|
||||
}
|
||||
|
||||
void "test at method name with overloads"() {
|
||||
def input = """\
|
||||
class Foo {
|
||||
void foo(String s) {
|
||||
s.region<caret>Matches()
|
||||
}
|
||||
}""".stripIndent()
|
||||
|
||||
def actual = JavaExternalDocumentationTest.getDocumentationText(myFixture.project, input)
|
||||
|
||||
def expected =
|
||||
"<html>Candidates for method call <b>s.regionMatches()</b> are:<br>" +
|
||||
"<br>" +
|
||||
" <a href=\"psi_element://java.lang.String#regionMatches(int, java.lang.String, int, int)\">boolean regionMatches(int, String, int, int)</a><br>" +
|
||||
" <a href=\"psi_element://java.lang.String#regionMatches(boolean, int, java.lang.String, int, int)\">boolean regionMatches(boolean, int, String, int, int)</a><br>" +
|
||||
"</html>"
|
||||
|
||||
assert actual == expected
|
||||
}
|
||||
|
||||
private void configure(String text) {
|
||||
myFixture.configureByText 'a.java', text
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -150,12 +150,16 @@ public class JavaExternalDocumentationTest extends PlatformTestCase {
|
||||
}
|
||||
|
||||
private String getDocumentationText(String sourceEditorText) throws Exception {
|
||||
return getDocumentationText(myProject, sourceEditorText);
|
||||
}
|
||||
|
||||
public static String getDocumentationText(Project project, String sourceEditorText) throws Exception {
|
||||
int caretPosition = sourceEditorText.indexOf(EditorTestUtil.CARET_TAG);
|
||||
if (caretPosition >= 0) {
|
||||
sourceEditorText = sourceEditorText.substring(0, caretPosition) +
|
||||
sourceEditorText.substring(caretPosition + EditorTestUtil.CARET_TAG.length());
|
||||
}
|
||||
PsiFile psiFile = PsiFileFactory.getInstance(myProject).createFileFromText(JavaLanguage.INSTANCE, sourceEditorText);
|
||||
PsiFile psiFile = PsiFileFactory.getInstance(project).createFileFromText(JavaLanguage.INSTANCE, sourceEditorText);
|
||||
return getDocumentationText(psiFile, caretPosition);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user