PsiDocMethodOrFieldRef: fixed javadoc resolve for references without param types (IDEA-205390)

This commit is contained in:
Artemiy Sartakov
2019-01-16 12:45:09 +07:00
parent 5527e88971
commit 25643b9c89
3 changed files with 15 additions and 9 deletions

View File

@@ -96,7 +96,7 @@ public class PsiDocMethodOrFieldRef extends CompositePsiElement implements PsiDo
}
}
final PsiType[] parameterTypes;
final MethodSignature methodSignature;
if (signature != null) {
final List<PsiType> types = ContainerUtil.newArrayListWithCapacity(signature.length);
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(element.getProject());
@@ -108,16 +108,14 @@ public class PsiDocMethodOrFieldRef extends CompositePsiElement implements PsiDo
types.add(PsiType.NULL);
}
}
parameterTypes = types.toArray(PsiType.createArray(types.size()));
methodSignature = MethodSignatureUtil.createMethodSignature(name, types.toArray(PsiType.createArray(types.size())),
PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY,
name.equals(scope.getName()));
}
else {
parameterTypes = PsiType.EMPTY_ARRAY;
methodSignature = null;
}
final MethodSignature methodSignature = MethodSignatureUtil.createMethodSignature(name, parameterTypes,
PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY,
name.equals(scope.getName()));
PsiMethod method = findMethod(methodSignature, name, getAllMethods(scope, this));
if (method != null) {
@@ -205,10 +203,10 @@ public class PsiDocMethodOrFieldRef extends CompositePsiElement implements PsiDo
}
@Nullable
public static PsiMethod findMethod(@NotNull MethodSignature methodSignature, @Nullable String name, @NotNull PsiMethod[] allMethods) {
public static PsiMethod findMethod(@Nullable MethodSignature methodSignature, @Nullable String name, @NotNull PsiMethod[] allMethods) {
for (PsiMethod method : allMethods) {
if (method.getName().equals(name) &&
MethodSignatureUtil.areSignaturesErasureEqual(methodSignature, method.getSignature(PsiSubstitutor.EMPTY))) {
(methodSignature == null || MethodSignatureUtil.areSignaturesErasureEqual(methodSignature, method.getSignature(PsiSubstitutor.EMPTY)))) {
return method;
}
}

View File

@@ -0,0 +1,7 @@
/**
* {@link #foo}
*/
class Foo {
void foo(Foo p1, Foo p2) {
}
}

View File

@@ -66,6 +66,7 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testSee5() { doTest(); }
public void testSee6() { doTest(); }
public void testLinkToItself() { doTest(); }
public void testLinkToMethodNoParams() { doTest(); }
public void testSeeConstants() { doTest(); }
public void testSeeNonRefs() { doTest(); }
public void testReturn0() { doTest(); }