-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
343 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
*/bin/ | ||
*/target/ | ||
.idea/ | ||
*.iml | ||
*.prefs | ||
.checkstyle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
bin.includes = META-INF/,\ | ||
.,\ | ||
license/,\ | ||
checkstyle-8.34-all.jar | ||
checkstyle-8.35-all.jar | ||
jars.compile.order = . | ||
source.. = metadata/ |
Binary file renamed
BIN
+11.2 MB
...ipsecs.checkstyle/checkstyle-8.34-all.jar → ...ipsecs.checkstyle/checkstyle-8.35-all.jar
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
84 changes: 84 additions & 0 deletions
84
net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/meta/CheckUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package net.sf.eclipsecs.core.config.meta; | ||
|
||
import java.util.Set; | ||
|
||
import com.puppycrawl.tools.checkstyle.PackageNamesLoader; | ||
import com.puppycrawl.tools.checkstyle.PackageObjectFactory; | ||
import com.puppycrawl.tools.checkstyle.api.AbstractCheck; | ||
import com.puppycrawl.tools.checkstyle.api.CheckstyleException; | ||
import com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck; | ||
import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; | ||
import com.puppycrawl.tools.checkstyle.utils.TokenUtil; | ||
|
||
import net.sf.eclipsecs.core.CheckstylePlugin; | ||
|
||
public final class CheckUtil { | ||
private CheckUtil() { | ||
} | ||
|
||
public static Object getCheck(String checkName) { | ||
final ClassLoader classLoader = CheckstylePlugin.getDefault() | ||
.getAddonExtensionClassLoader(); | ||
try { | ||
final Set<String> packageNames = PackageNamesLoader.getPackageNames(classLoader); | ||
return new PackageObjectFactory(packageNames, classLoader) | ||
.createModule(checkName); | ||
} | ||
catch (CheckstyleException ex) { | ||
throw new IllegalStateException("exception occured during load of " + checkName, ex); | ||
} | ||
} | ||
|
||
public static String getAcceptableTokens(String checkName) { | ||
final Object checkResult = getCheck(checkName); | ||
String result = null; | ||
if (AbstractJavadocCheck.class.isAssignableFrom(checkResult.getClass())) { | ||
final AbstractJavadocCheck javadocCheck = (AbstractJavadocCheck) checkResult; | ||
result = getTokenText(true, javadocCheck.getAcceptableJavadocTokens(), | ||
javadocCheck.getRequiredJavadocTokens()); | ||
} | ||
else if (AbstractCheck.class.isAssignableFrom(checkResult.getClass())) { | ||
final AbstractCheck check = (AbstractCheck) checkResult; | ||
result = getTokenText(false, check.getAcceptableTokens(), | ||
check.getRequiredTokens()); | ||
} | ||
return result; | ||
} | ||
|
||
public static String getTokenText(boolean isJavadocCheck, int[] tokens, int... requiredTokens) { | ||
final StringBuilder result = new StringBuilder(); | ||
boolean first = true; | ||
|
||
for (int token : tokens) { | ||
boolean found = false; | ||
|
||
for (int subtraction : requiredTokens) { | ||
if (subtraction == token) { | ||
found = true; | ||
break; | ||
} | ||
} | ||
|
||
if (found) { | ||
continue; | ||
} | ||
|
||
if (first) { | ||
first = false; | ||
} | ||
else { | ||
result.append(','); | ||
} | ||
|
||
if (isJavadocCheck) { | ||
result.append(JavadocUtil.getTokenName(token)); | ||
} | ||
else { | ||
result.append(TokenUtil.getTokenName(token)); | ||
} | ||
} | ||
|
||
return result.toString(); | ||
} | ||
} | ||
|
Oops, something went wrong.