summaryrefslogtreecommitdiffstats
path: root/sonar-colorizer/src
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-02-08 10:00:53 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-02-08 10:01:06 +0100
commitce9f2b67a8641de222a2fe2e7f1e2dd38553ee84 (patch)
tree635ea56fb58509cd76342825669463850014e61a /sonar-colorizer/src
parent86174fff46965a13ef8cfeccde852235c6a293d9 (diff)
downloadsonarqube-ce9f2b67a8641de222a2fe2e7f1e2dd38553ee84.tar.gz
sonarqube-ce9f2b67a8641de222a2fe2e7f1e2dd38553ee84.zip
Fix quality flaw
Diffstat (limited to 'sonar-colorizer/src')
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/JavaConstantTokenizer.java15
1 files changed, 7 insertions, 8 deletions
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaConstantTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaConstantTokenizer.java
index 03222f0c67c..7e0182b8fc3 100644
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaConstantTokenizer.java
+++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaConstantTokenizer.java
@@ -31,12 +31,15 @@ public class JavaConstantTokenizer extends Tokenizer {
private final String tagBefore;
private final String tagAfter;
private static final int DOT = '.';
- private EndMatcher endTokenMatcher = new EndMatcher() {
-
+ private static final EndMatcher END_TOKEN_MATCHER = new EndMatcher() {
@Override
public boolean match(int endFlag) {
return !isJavaConstantPart(endFlag);
}
+
+ private boolean isJavaConstantPart(int character) {
+ return Character.isUpperCase(character) || character == '_' || character == '-' || Character.isDigit(character);
+ }
};
public JavaConstantTokenizer(String tagBefore, String tagAfter) {
@@ -48,7 +51,7 @@ public class JavaConstantTokenizer extends Tokenizer {
int lastChar = code.lastChar();
if (isJavaConstantStart(code.peek()) && !Character.isJavaIdentifierPart(lastChar) && !Character.isJavaIdentifierStart(lastChar)
&& lastChar != DOT) {
- String constant = code.peekTo(endTokenMatcher);
+ String constant = code.peekTo(END_TOKEN_MATCHER);
int nextCharAfterConstant = code.peek(constant.length() + 1)[constant.length()];
if (nextCharAfterConstant != 0 && Character.isJavaIdentifierPart(nextCharAfterConstant)) {
return false;
@@ -62,7 +65,7 @@ public class JavaConstantTokenizer extends Tokenizer {
public boolean consume(CodeReader code, HtmlCodeBuilder codeBuilder) {
if (hasNextToken(code)) {
codeBuilder.appendWithoutTransforming(tagBefore);
- code.popTo(endTokenMatcher, codeBuilder);
+ code.popTo(END_TOKEN_MATCHER, codeBuilder);
codeBuilder.appendWithoutTransforming(tagAfter);
return true;
} else {
@@ -74,8 +77,4 @@ public class JavaConstantTokenizer extends Tokenizer {
return Character.isUpperCase(character);
}
- private static boolean isJavaConstantPart(int character) {
- return Character.isUpperCase(character) || character == '_' || character == '-' || Character.isDigit(character);
- }
-
}