mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
properly working navigation
This commit is contained in:
@@ -478,9 +478,10 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateDoc(PsiElement element, final PsiElement originalElement) {
|
||||
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
|
||||
originalElement = null;
|
||||
}
|
||||
if (element instanceof PsiMethodCallExpression) {
|
||||
return getMethodCandidateInfo((PsiMethodCallExpression)element);
|
||||
@@ -520,7 +521,7 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext
|
||||
PsiFormatUtilBase.SHOW_TYPE |
|
||||
PsiFormatUtilBase.SHOW_PARAMETERS,
|
||||
PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.SHOW_NAME);
|
||||
createElementLink(sb, targetClass, StringUtil.escapeXml(str));
|
||||
createElementLink(sb, constructor, StringUtil.escapeXml(str));
|
||||
}
|
||||
|
||||
return CodeInsightBundle.message("javadoc.constructor.candidates", targetClass.getName(), sb);
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight
|
||||
|
||||
import com.intellij.codeInsight.documentation.DocumentationManager
|
||||
import com.intellij.codeInsight.navigation.CtrlMouseHandler
|
||||
import com.intellij.lang.java.JavaDocumentationProvider
|
||||
@@ -40,7 +39,7 @@ class Foo2 {{
|
||||
originalElement
|
||||
)
|
||||
|
||||
assert doc == """<html>Candidates for new <b>Foo</b>() are:<br> <a href="psi_element://Foo">Foo()</a><br> <a href="psi_element://Foo">Foo(int param)</a><br></html>"""
|
||||
assert doc == """<html>Candidates for new <b>Foo</b>() are:<br> <a href="psi_element://Foo#Foo()">Foo()</a><br> <a href="psi_element://Foo#Foo(int)">Foo(int param)</a><br></html>"""
|
||||
}
|
||||
|
||||
public void testConstructorDoc2() {
|
||||
@@ -51,13 +50,15 @@ class Foo2 {{
|
||||
new Foo(<caret>)
|
||||
}}
|
||||
'''
|
||||
def exprList = PsiTreeUtil.getParentOfType(myFixture.file.findElementAt(myFixture.editor.caretModel.offset), PsiExpressionList.class)
|
||||
|
||||
def elementAt = myFixture.file.findElementAt(myFixture.editor.caretModel.offset)
|
||||
def exprList = PsiTreeUtil.getParentOfType(elementAt, PsiExpressionList.class)
|
||||
def doc = new JavaDocumentationProvider().generateDoc(
|
||||
exprList,
|
||||
null
|
||||
elementAt
|
||||
)
|
||||
|
||||
assert doc == """<html>Candidates for new <b>Foo</b>() are:<br> <a href="psi_element://Foo">Foo()</a><br> <a href="psi_element://Foo">Foo(int param)</a><br></html>"""
|
||||
assert doc == """<html>Candidates for new <b>Foo</b>() are:<br> <a href="psi_element://Foo#Foo()">Foo()</a><br> <a href="psi_element://Foo#Foo(int)">Foo(int param)</a><br></html>"""
|
||||
}
|
||||
|
||||
public void testMethodDocWhenInArgList() {
|
||||
|
||||
+2
-1
@@ -73,7 +73,8 @@ public class ClassNameCompletionTest extends LightFixtureCompletionTestCase {
|
||||
);
|
||||
|
||||
assertEquals(doc,
|
||||
"<html>Candidates for new <b>Time</b>() are:<br> <a href=\"psi_element://Time\">Time()</a><br> <a href=\"psi_element://Time\">Time(long time)</a><br></html>");
|
||||
"<html>Candidates for new <b>Time</b>() are:<br> <a href=\"psi_element://Time#Time()\">Time()</a><br> " +
|
||||
" <a href=\"psi_element://Time#Time(long)\">Time(long time)</a><br></html>");
|
||||
}
|
||||
|
||||
public void testTypeParametersTemplate() throws Exception {
|
||||
|
||||
+6
-22
@@ -91,7 +91,6 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
private static final String DOCUMENTATION_AUTO_UPDATE_ENABLED = "DocumentationAutoUpdateEnabled";
|
||||
|
||||
private Editor myEditor = null;
|
||||
private PsiElement myExpressionList;
|
||||
private final Alarm myUpdateDocAlarm;
|
||||
private WeakReference<JBPopup> myDocInfoHintRef;
|
||||
private Component myPreviouslyFocused = null;
|
||||
@@ -291,20 +290,21 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
|
||||
final PsiElement list =
|
||||
ParameterInfoController.findArgumentList(file, editor.getCaretModel().getOffset(), -1);
|
||||
PsiElement expressionList = null;
|
||||
if (list != null) {
|
||||
LookupEx lookup = LookupManager.getInstance(myProject).getActiveLookup();
|
||||
if (lookup != null) {
|
||||
myExpressionList = null; // take completion variants for documentation then
|
||||
expressionList = null; // take completion variants for documentation then
|
||||
} else {
|
||||
myExpressionList = list;
|
||||
expressionList = list;
|
||||
}
|
||||
}
|
||||
|
||||
final PsiElement originalElement = getContextElement(editor, file);
|
||||
PsiElement element = assertSameProject(findTargetElement(editor, file));
|
||||
|
||||
if (element == null && myExpressionList != null) {
|
||||
element = myExpressionList;
|
||||
if (element == null && expressionList != null) {
|
||||
element = expressionList;
|
||||
}
|
||||
|
||||
if (element == null && file == null) return; //file == null for text field editor
|
||||
@@ -487,7 +487,6 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
Disposer.dispose(component);
|
||||
myEditor = null;
|
||||
myPreviouslyFocused = null;
|
||||
myExpressionList = null;
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
})
|
||||
@@ -1059,17 +1058,7 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
}
|
||||
}
|
||||
);
|
||||
if (myExpressionList != null) {
|
||||
final String doc = ApplicationManager.getApplication().runReadAction(
|
||||
new NullableComputable<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
return generateDocumentation(provider);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (doc != null) return doc;
|
||||
}
|
||||
|
||||
if (provider instanceof ExternalDocumentationProvider) {
|
||||
final List<String> urls = ApplicationManager.getApplication().runReadAction(
|
||||
new NullableComputable<List<String>>() {
|
||||
@@ -1106,11 +1095,6 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String generateDocumentation(DocumentationProvider provider) {
|
||||
return provider.generateDoc(myExpressionList, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiElement getElement() {
|
||||
|
||||
Reference in New Issue
Block a user