mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-7316 Wrong text ranges for type references that have qualified canonical names
This commit is contained in:
@@ -43,14 +43,14 @@ public class DocStringReferenceProvider extends PsiReferenceProvider {
|
||||
StructuredDocString docString = StructuredDocString.parse(text);
|
||||
if (docString != null) {
|
||||
result.addAll(referencesFromNames(element, offset, docString,
|
||||
docString.getTagArguments(StructuredDocString.PARAM_TAGS), "parameter"));
|
||||
docString.getTagArguments(StructuredDocString.PARAM_TAGS), StructuredDocString.PARAMETER));
|
||||
result.addAll(referencesFromNames(element, offset, docString,
|
||||
docString.getTagArguments(StructuredDocString.PARAM_TYPE_TAGS), "parameter_type"));
|
||||
docString.getTagArguments(StructuredDocString.PARAM_TYPE_TAGS), StructuredDocString.PARAMETER_TYPE));
|
||||
result.addAll(referencesFromNames(element, offset, docString,
|
||||
docString.getKeywordArgumentSubstrings(), "keyword"));
|
||||
docString.getKeywordArgumentSubstrings(), StructuredDocString.KEYWORD));
|
||||
|
||||
result.addAll(referencesFromNames(element, offset, docString,
|
||||
docString.getTagArguments(StructuredDocString.VARIABLE_TAGS), "variable"));
|
||||
docString.getTagArguments(StructuredDocString.VARIABLE_TAGS), StructuredDocString.VARIABLE));
|
||||
}
|
||||
return result.toArray(new PsiReference[result.size()]);
|
||||
}
|
||||
@@ -69,9 +69,11 @@ public class DocStringReferenceProvider extends PsiReferenceProvider {
|
||||
if (PyNames.isIdentifier(s)) {
|
||||
result.add(new DocStringParameterReference(element, name.getTextRange().shiftRight(offset), refType));
|
||||
}
|
||||
final Substring type = docString.getParamTypeSubstring(s);
|
||||
if (type != null) {
|
||||
result.addAll(parseTypeReferences(element, type, offset));
|
||||
if (!refType.equals(StructuredDocString.PARAMETER_TYPE)) {
|
||||
final Substring type = docString.getParamTypeSubstring(s);
|
||||
if (type != null) {
|
||||
result.addAll(parseTypeReferences(element, type, offset));
|
||||
}
|
||||
}
|
||||
}
|
||||
final Substring rtype = docString.getReturnTypeSubstring();
|
||||
|
||||
@@ -33,6 +33,11 @@ public abstract class StructuredDocString {
|
||||
public static String[] RAISES_TAGS = new String[] { "raises", "raise", "except", "exception" };
|
||||
public static String[] RETURN_TAGS = new String[] { "return", "returns" };
|
||||
|
||||
public static String PARAMETER = "parameter";
|
||||
public static String PARAMETER_TYPE = "parameter_type";
|
||||
public static String KEYWORD = "keyword";
|
||||
public static String VARIABLE = "variable";
|
||||
|
||||
@Nullable
|
||||
public static StructuredDocString parse(String text) {
|
||||
if (text == null) {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
from datetime import datetime
|
||||
|
||||
def foo(p):
|
||||
"""Foo
|
||||
:param datetime p: a datetime
|
||||
<ref>
|
||||
"""
|
||||
@@ -476,4 +476,8 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
public void testKWArg() {
|
||||
assertResolvesTo(PyClass.class, "timedelta");
|
||||
}
|
||||
|
||||
public void testReferenceInDocstring() {
|
||||
assertResolvesTo(PyClass.class, "datetime");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user