Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
v1.09 Not adding JavaDoc warnings on @test methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-wallis committed Nov 5, 2015
1 parent 649326e commit 68e09e9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
15 changes: 7 additions & 8 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<idea-plugin version="2">
<id>com.smilingrob.plugin.robohexar</id>
<name>Robo Hexar</name>
<version>1.08</version>
<version>1.09</version>
<vendor email="smilingrob@gmail.com" url="http://smilingrob.com">Robert Wallis</vendor>

<description><![CDATA[
I am the grammar robot. I have been activated. Missing punctuation and grammar will be punished.
]]></description>

<change-notes><![CDATA[
<li>Warnings not errors.</li>
<li>No longer adding "Java-Doc" warnings to getters and setters.</li>
<li>No longer adding "Java-Doc" warnings methods with @Override.</li>
<li>Compiling for Java 6 because my Java 7 thing didn't work.</li>
<li>Added "Java-Doc" matcher.</li>
<li>Fixed "Capitalize" error on @ params</li>
<li>Compiled using JDK 7, so that it works on Hexar's machine.</li>
<li>1.09 - No longer adding "Java-Doc" warnings to @Test methods.</li>
<li>1.08 - Warnings not errors.</li>
<li>1.07 - No longer adding "Java-Doc" warnings to getters and setters.</li>
<li>1.06 - No longer adding "Java-Doc" warnings methods with @Override.</li>
<li>1.05 - Added "Java-Doc" matcher.</li>
<li>1.04 - Fixed "Capitalize" error on @ params</li>
]]></change-notes>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
Expand Down
20 changes: 19 additions & 1 deletion src/com/smilingrob/plugin/robohexar/JavaDocParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public List<JavaDocError> parse(PsiElement psiElement) {
if (psiElement instanceof PsiMethodImpl) {
PsiMethodImpl psiMethod = (PsiMethodImpl) psiElement;
if (psiMethod.getDocComment() == null) {
if (!hasOverrideAnnotation(psiMethod) && !isGetterOrSetter(psiMethod)) {
if (!hasOverrideAnnotation(psiMethod) && !hasTestAnnotation(psiMethod) && !isGetterOrSetter(psiMethod)) {
PsiElement name = psiMethod.getNameIdentifier();
if (name != null) {
errors.add(new JavaDocError(name, JavaDocError.ErrorType.MISSING_JAVA_DOC));
Expand Down Expand Up @@ -54,6 +54,24 @@ private boolean hasOverrideAnnotation(@NotNull PsiMethodImpl psiMethod) {
return false;
}

/**
*
*/
private boolean hasTestAnnotation(@NotNull PsiMethodImpl psiMethod) {
for (PsiElement childElement : psiMethod.getChildren()) {
String name = childElement.getText();
if (name != null) {
if (name.contains("@Test")) {
return true;
} else if (name.contains("@") && name.contains("Test")) {
// matches @SmallTest @MediumTest etc...
return true;
}
}
}
return false;
}

/**
* @param psiMethodImpl method node.
* @return true if it is a getter or a setter.
Expand Down

0 comments on commit 68e09e9

Please sign in to comment.