mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
better inspection messages
This commit is contained in:
@@ -1752,8 +1752,10 @@ multiple.exceptions.declared.on.test.method.display.name=Multiple exceptions dec
|
||||
multiple.exceptions.declared.on.test.method.problem.descriptor=<code>#ref</code> could be replaced with 'throws Exception' #loc
|
||||
multiple.exceptions.declared.on.test.method.quickfix=Replace with 'throws Exception'
|
||||
unnecessary.javadoc.link.display.name=Unnecessary JavaDoc link
|
||||
unnecessary.javadoc.link.problem.descriptor=<code>#ref</code> is unnecessary #loc
|
||||
unnecessary.javadoc.link.quickfix=Remove unnecessary {0}
|
||||
unnecessary.javadoc.link.super.method.problem.descriptor=<code>#ref</code> pointing to super method is unnecessary #loc
|
||||
unnecessary.javadoc.link.this.method.problem.descriptor=<code>#ref</code> pointing to this method is unnecessary #loc
|
||||
unnecessary.javadoc.link.this.class.problem.descriptor=<code>#ref</code> pointing to containing class is unnecessary #loc
|
||||
unnecessary.javadoc.link.quickfix=Remove unnecessary '{0}'
|
||||
thread.local.not.static.final.display.name=ThreadLocal field not declared static final
|
||||
thread.local.not.static.final.problem.descriptor=ThreadLocal <code>#ref</code> is not declared 'static final' #loc
|
||||
remove.try.finally.block.quickfix=Remove try-finally block
|
||||
|
||||
+35
-16
@@ -39,6 +39,10 @@ import javax.swing.*;
|
||||
|
||||
public class UnnecessaryJavaDocLinkInspection extends BaseInspection {
|
||||
|
||||
private static final int THIS_METHOD = 1;
|
||||
private static final int THIS_CLASS = 2;
|
||||
private static final int SUPER_METHOD = 3;
|
||||
|
||||
@SuppressWarnings({"PublicField"})
|
||||
public boolean ignoreInlineLinkToSuper = false;
|
||||
|
||||
@@ -53,14 +57,24 @@ public class UnnecessaryJavaDocLinkInspection extends BaseInspection {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String buildErrorString(Object... infos) {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"unnecessary.javadoc.link.problem.descriptor");
|
||||
final int n = ((Integer) infos[1]).intValue();
|
||||
if (n == THIS_METHOD) {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"unnecessary.javadoc.link.this.method.problem.descriptor");
|
||||
} else if (n == THIS_CLASS) {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"unnecessary.javadoc.link.this.class.problem.descriptor");
|
||||
} else {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"unnecessary.javadoc.link.super.method.problem.descriptor");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent createOptionsPanel() {
|
||||
return new SingleCheckboxOptionsPanel(
|
||||
InspectionGadgetsBundle.message("unnecessary.javadoc.link.option"),
|
||||
InspectionGadgetsBundle.message(
|
||||
"unnecessary.javadoc.link.option"),
|
||||
this, "ignoreInlineLinkToSuper");
|
||||
}
|
||||
|
||||
@@ -88,10 +102,11 @@ public class UnnecessaryJavaDocLinkInspection extends BaseInspection {
|
||||
protected void doFix(Project project, ProblemDescriptor descriptor)
|
||||
throws IncorrectOperationException {
|
||||
final PsiElement element = descriptor.getPsiElement();
|
||||
if (!(element instanceof PsiDocTag)) {
|
||||
final PsiElement parent = element.getParent();
|
||||
if (!(parent instanceof PsiDocTag)) {
|
||||
return;
|
||||
}
|
||||
final PsiDocTag docTag = (PsiDocTag) element;
|
||||
final PsiDocTag docTag = (PsiDocTag) parent;
|
||||
final PsiDocComment docComment = docTag.getContainingComment();
|
||||
if (docComment != null) {
|
||||
if (shouldDeleteEntireComment(docComment)) {
|
||||
@@ -157,13 +172,15 @@ public class UnnecessaryJavaDocLinkInspection extends BaseInspection {
|
||||
return;
|
||||
}
|
||||
if (target.equals(containingMethod)) {
|
||||
registerError(tag, '@' + name);
|
||||
registerError(tag.getNameElement(), '@' + name,
|
||||
Integer.valueOf(THIS_METHOD));
|
||||
return;
|
||||
}
|
||||
final PsiClass containingClass =
|
||||
PsiTreeUtil.getParentOfType(tag, PsiClass.class);
|
||||
if (target.equals(containingClass)) {
|
||||
registerError(tag, '@' + name);
|
||||
registerError(tag.getNameElement(), '@' + name,
|
||||
Integer.valueOf(THIS_CLASS));
|
||||
return;
|
||||
}
|
||||
if (!(target instanceof PsiMethod)) {
|
||||
@@ -176,7 +193,8 @@ public class UnnecessaryJavaDocLinkInspection extends BaseInspection {
|
||||
if (ignoreInlineLinkToSuper && tag instanceof PsiInlineDocTag) {
|
||||
return;
|
||||
}
|
||||
registerError(tag, '@' + name);
|
||||
registerError(tag.getNameElement(), '@' + name,
|
||||
Integer.valueOf(SUPER_METHOD));
|
||||
}
|
||||
|
||||
private PsiReference extractReference(PsiDocTag tag) {
|
||||
@@ -190,16 +208,17 @@ public class UnnecessaryJavaDocLinkInspection extends BaseInspection {
|
||||
if (dataElements.length == 0) {
|
||||
return null;
|
||||
}
|
||||
final PsiElement lastElement =
|
||||
dataElements[dataElements.length - 1];
|
||||
if (lastElement == null) {
|
||||
PsiElement salientElement = null;
|
||||
for (PsiElement dataElement : dataElements) {
|
||||
if (!(dataElement instanceof PsiWhiteSpace)) {
|
||||
salientElement = dataElement;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (salientElement == null) {
|
||||
return null;
|
||||
}
|
||||
final PsiElement[] children = lastElement.getChildren();
|
||||
if (children.length == 0) {
|
||||
return null;
|
||||
}
|
||||
final PsiElement child = children[0];
|
||||
final PsiElement child = salientElement.getFirstChild();
|
||||
if (!(child instanceof PsiReference)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+6
@@ -19,4 +19,10 @@ public class UnnecessaryJavaDocLink {
|
||||
void foo() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.siyeh.igtest.style.unnecessary_javadoc_link.UnnecessaryJavaDocLink
|
||||
* something
|
||||
*/
|
||||
void bar() {}
|
||||
}
|
||||
|
||||
+5
-5
@@ -5,7 +5,7 @@
|
||||
<file>UnnecessaryJavaDocLink.java</file>
|
||||
<line>6</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary JavaDoc link</problem_class>
|
||||
<description><code>{@link UnnecessaryJavaDocLink}</code> is unnecessary #loc</description>
|
||||
<description><code>@link</code> pointing to containing class is unnecessary #loc</description>
|
||||
</problem>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<file>UnnecessaryJavaDocLink.java</file>
|
||||
<line>7</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary JavaDoc link</problem_class>
|
||||
<description><code>{@linkplain UnnecessaryJavaDocLink#equals(Object)}</code> is unnecessary #loc</description>
|
||||
<description><code>@linkplain</code> pointing to this method is unnecessary #loc</description>
|
||||
</problem>
|
||||
|
||||
|
||||
@@ -21,21 +21,21 @@
|
||||
<file>UnnecessaryJavaDocLink.java</file>
|
||||
<line>8</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary JavaDoc link</problem_class>
|
||||
<description><code>@see Object#equals(Object)</code> is unnecessary #loc</description>
|
||||
<description><code>@see</code> pointing to super method is unnecessary #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>UnnecessaryJavaDocLink.java</file>
|
||||
<line>16</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary JavaDoc link</problem_class>
|
||||
<description><code>{@link #foo()}</code> is unnecessary #loc</description>
|
||||
<description><code>@link</code> pointing to this method is unnecessary #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>UnnecessaryJavaDocLink.java</file>
|
||||
<line>17</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary JavaDoc link</problem_class>
|
||||
<description><code>@see #foo()</code> is unnecessary #loc</description>
|
||||
<description><code>@see</code> pointing to this method is unnecessary #loc</description>
|
||||
</problem>
|
||||
|
||||
</problems>
|
||||
Reference in New Issue
Block a user