fix JavadocInspectionQuickFixTest

This commit is contained in:
Bas Leijdekkers
2013-10-07 11:04:49 +02:00
parent a0163c7c3d
commit 80c1fc4a87
7 changed files with 17 additions and 18 deletions
@@ -518,7 +518,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
}
if (absentParameters != null) {
for (PsiTypeParameter psiTypeParameter : absentParameters) {
problems.add(createMissingParamTagDescriptor(nameIdentifier, psiTypeParameter, manager, isOnTheFly));
problems.add(createMissingParamTagDescriptor(docComment.getFirstChild(), psiTypeParameter, manager, isOnTheFly));
}
}
}
@@ -578,11 +578,11 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
return problems;
}
private static ProblemDescriptor createMissingParamTagDescriptor(final PsiIdentifier nameIdentifier,
private static ProblemDescriptor createMissingParamTagDescriptor(final PsiElement elementToHighlight,
final PsiTypeParameter psiTypeParameter,
final InspectionManager manager, boolean isOnTheFly) {
String message = InspectionsBundle.message("inspection.javadoc.problem.missing.tag", "<code>@param</code>");
return createDescriptor(nameIdentifier, message, new AddMissingTagFix("param", "<" + psiTypeParameter.getName() + ">"), manager,
return createDescriptor(elementToHighlight, message, new AddMissingTagFix("param", "<" + psiTypeParameter.getName() + ">"), manager,
isOnTheFly);
}
@@ -885,8 +885,11 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
protected PsiElement getAnchor(ProblemDescriptor descriptor) {
PsiElement element = descriptor.getPsiElement();
PsiElement parent = element == null ? null : element.getParent();
if (!(parent instanceof PsiMethod)) return null;
PsiParameter[] parameters = ((PsiMethod)parent).getParameterList().getParameters();
if (!(parent instanceof PsiDocComment)) return null;
final PsiDocComment docComment = (PsiDocComment)parent;
final PsiDocCommentOwner owner = docComment.getOwner();
if (!(owner instanceof PsiMethod)) return null;
PsiParameter[] parameters = ((PsiMethod)owner).getParameterList().getParameters();
PsiParameter myParam = ContainerUtil.find(parameters, new Condition<PsiParameter>() {
@Override
public boolean value(PsiParameter psiParameter) {
@@ -895,10 +898,6 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
});
if (myParam == null) return null;
final PsiMethod psiMethod = PsiTreeUtil.getParentOfType(myParam, PsiMethod.class);
LOG.assertTrue(psiMethod != null);
final PsiDocComment docComment = psiMethod.getDocComment();
LOG.assertTrue(docComment != null);
PsiDocTag[] tags = docComment.findTagsByName("param");
if (tags.length == 0) { //insert as first tag or append to description
tags = docComment.getTags();
@@ -3,7 +3,7 @@ class a {
/**
* @throws Exception
*/
public void <caret>run() throws Exception {
public void run() throws Exception {
}
}
@@ -5,7 +5,7 @@ class a {
* @param a
* @param b
*/
public void <caret>foo(int a, int b, in c){
public void foo(int a, int b, in c){
}
}
@@ -2,5 +2,5 @@
/**
* @param <T>
*/
class <caret>a<T> {
class a<T> {
}
@@ -1,8 +1,8 @@
// "Add tag @throws java.lang.Exception" "true"
class a {
/**
/**<caret>
*/
public void <caret>run() throws Exception {
public void run() throws Exception {
}
}
@@ -1,10 +1,10 @@
// "Add tag @param for parameter 'a'" "true"
class a {
/**
/**<caret>
* @param b
*/
public void <caret>foo(int a, int b, in c){
public void foo(int a, int b, in c){
}
}
@@ -1,5 +1,5 @@
// "Add tag @param <T>" "true"
/**
/**<caret>
*/
class <caret>a<T> {
class a<T> {
}