@Override
public List<Integer> getWantedTokens() {
- return wantedTokens;
+ return WANTED_TOKENS;
}
@Override
res.setMeasure(Metric.COMPLEXITY, res.getInt(Metric.COMPLEXITY) + res.getInt(Metric.BRANCHES) + 1);
}
- private static final List<Integer> wantedTokens = Arrays.asList(TokenTypes.CTOR_DEF, TokenTypes.METHOD_DEF, TokenTypes.INSTANCE_INIT,
+ private static final List<Integer> WANTED_TOKENS = Arrays.asList(TokenTypes.CTOR_DEF, TokenTypes.METHOD_DEF, TokenTypes.INSTANCE_INIT,
TokenTypes.STATIC_INIT);
}
this.tagAfter = tagAfter;
}
- private static final EndMatcher endTokenMatcher = new EndMatcher() {
-
+ private static final EndMatcher END_TOKEN_MATCHER = new EndMatcher() {
public boolean match(int endFlag) {
return !Character.isJavaIdentifierPart(endFlag);
}
public boolean consume(CodeReader code, HtmlCodeBuilder codeBuilder) {
if (code.peek() == '@') {
codeBuilder.appendWithoutTransforming(tagBefore);
- code.popTo(endTokenMatcher, codeBuilder);
+ code.popTo(END_TOKEN_MATCHER, codeBuilder);
codeBuilder.appendWithoutTransforming(tagAfter);
return true;
} else {
private boolean caseInsensitive = false;
private Matcher matcher;
private final StringBuilder tmpBuilder = new StringBuilder();
- private final static String defaultRegex = "[a-zA-Z_][a-zA-Z0-9_]*+";
+ private final static String DEFAULT_REGEX = "[a-zA-Z_][a-zA-Z0-9_]*+";
private Set<String> keywords = new HashSet<String>();
public KeywordsTokenizer(String tagBefore, String tagAfter, Set<String> keywords) {
- this(tagBefore, tagAfter, keywords, defaultRegex);
+ this(tagBefore, tagAfter, keywords, DEFAULT_REGEX);
}
public KeywordsTokenizer(String tagBefore, String tagAfter, Set<String> keywords, String regex) {
this.tagBefore = tagBefore;
this.tagAfter = tagAfter;
Collections.addAll(this.keywords, keywords);
- this.matcher = Pattern.compile(defaultRegex).matcher("");
+ this.matcher = Pattern.compile(DEFAULT_REGEX).matcher("");
}
public boolean consume(CodeReader code, HtmlCodeBuilder codeBuilder) {
* </p>
* <p>
* Another implementation, which is also based on Java Regular Expressions, can be found in
- * <a href="https://github.com/JetBrains/intellij-community/blob/59fa7d3aa565b01ecf0fb067a4336af2c174bf5b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java#L865">FileUtil</a>
+ * <a href="https://github.com/JetBrains/intellij-community/blob/idea/107.743/platform/util/src/com/intellij/openapi/util/io/FileUtil.java#L847">FileUtil</a>
* from IntelliJ OpenAPI.
* </p>
*
throw new CommandException(command, e);
} finally {
- if (outputGobbler != null) {
- waitUntilFinish(outputGobbler);
- }
-
- if (errorGobbler != null) {
- waitUntilFinish(errorGobbler);
- }
-
- if (process != null) {
- closeStreams(process);
- }
+ waitUntilFinish(outputGobbler);
+ waitUntilFinish(errorGobbler);
+ closeStreams(process);
if (executorService != null) {
executorService.shutdown();
}
private void closeStreams(Process process) {
- IOUtils.closeQuietly(process.getInputStream());
- IOUtils.closeQuietly(process.getOutputStream());
- IOUtils.closeQuietly(process.getErrorStream());
+ if (process != null) {
+ IOUtils.closeQuietly(process.getInputStream());
+ IOUtils.closeQuietly(process.getOutputStream());
+ IOUtils.closeQuietly(process.getErrorStream());
+ }
}
private void waitUntilFinish(StreamGobbler thread) {
- try {
- thread.join();
- } catch (InterruptedException e) {
- // ignore
+ if (thread != null) {
+ try {
+ thread.join();
+ } catch (InterruptedException e) {
+ // ignore
+ }
}
}