aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-colorizer
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-07-17 21:40:44 +0200
committerDavid Gageot <david@gageot.net>2012-07-17 21:40:44 +0200
commitae729f4a4ebad1a8c0261da4e08892a85227e5cd (patch)
treee552ec0a34aaaaa4c4714ccf9ade697018550ba9 /sonar-colorizer
parent9a3d6d33cb3fb6d58e922ac53e72a72682d55333 (diff)
downloadsonarqube-ae729f4a4ebad1a8c0261da4e08892a85227e5cd.tar.gz
sonarqube-ae729f4a4ebad1a8c0261da4e08892a85227e5cd.zip
Replace unmodifiableSets with ImmutableSets
Diffstat (limited to 'sonar-colorizer')
-rw-r--r--sonar-colorizer/pom.xml4
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/GroovyKeywords.java21
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlDecorator.java9
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/JavaKeywords.java28
4 files changed, 25 insertions, 37 deletions
diff --git a/sonar-colorizer/pom.xml b/sonar-colorizer/pom.xml
index 13aebf419fc..29fd845dd46 100644
--- a/sonar-colorizer/pom.xml
+++ b/sonar-colorizer/pom.xml
@@ -16,8 +16,8 @@
<dependencies>
<dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.sonar</groupId>
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/GroovyKeywords.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/GroovyKeywords.java
index e12f8558dfd..f2c7c41e2fb 100644
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/GroovyKeywords.java
+++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/GroovyKeywords.java
@@ -19,27 +19,20 @@
*/
package org.sonar.colorizer;
-import java.util.Collections;
-import java.util.HashSet;
+import com.google.common.collect.ImmutableSet;
+
import java.util.Set;
public final class GroovyKeywords {
-
- private static final Set<String> KEYWORDS = new HashSet<String>();
-
- private static final String[] GROOVY_KEYWORDS = {
- "as", "assert", "break", "case", "catch", "class", "continue", "def",
- "default", "do", "else", "extends", "finally", "for", "if", "in", "implements", "import", "instanceof", "interface", "new", "package",
- "property", "return", "switch", "throw", "throws", "try", "while"};
-
- static {
- Collections.addAll(KEYWORDS, GROOVY_KEYWORDS);
- }
+ private static final Set<String> KEYWORDS = ImmutableSet.of(
+ "as", "assert", "break", "case", "catch", "class", "continue", "def",
+ "default", "do", "else", "extends", "finally", "for", "if", "in", "implements", "import", "instanceof", "interface", "new", "package",
+ "property", "return", "switch", "throw", "throws", "try", "while");
private GroovyKeywords() {
}
public static Set<String> get() {
- return Collections.unmodifiableSet(KEYWORDS);
+ return KEYWORDS;
}
}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlDecorator.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlDecorator.java
index 8c830560047..2dd6482a034 100644
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlDecorator.java
+++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlDecorator.java
@@ -19,7 +19,8 @@
*/
package org.sonar.colorizer;
-import org.apache.commons.io.IOUtils;
+import com.google.common.io.ByteStreams;
+import com.google.common.io.Closeables;
import org.sonar.channel.CodeReader;
import java.io.IOException;
@@ -44,7 +45,7 @@ public class HtmlDecorator extends Tokenizer {
StringBuilder sb = new StringBuilder();
if (options.isGenerateHtmlHeader()) {
sb.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" "
- + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html><head><style type=\"text/css\">");
+ + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html><head><style type=\"text/css\">");
sb.append(getCss());
sb.append("</style></head><body>");
}
@@ -91,13 +92,13 @@ public class HtmlDecorator extends Tokenizer {
InputStream input = null;
try {
input = HtmlRenderer.class.getResourceAsStream(CSS_PATH);
- return IOUtils.toString(input);
+ return new String(ByteStreams.toByteArray(input));
} catch (IOException e) {
throw new SynhtaxHighlightingException("Sonar Colorizer CSS file not found: " + CSS_PATH, e);
} finally {
- IOUtils.closeQuietly(input);
+ Closeables.closeQuietly(input);
}
}
}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaKeywords.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaKeywords.java
index 3057db57679..418cd1b0028 100644
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaKeywords.java
+++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaKeywords.java
@@ -19,31 +19,25 @@
*/
package org.sonar.colorizer;
-import java.util.Collections;
-import java.util.HashSet;
+import com.google.common.collect.ImmutableSet;
+
import java.util.Set;
public final class JavaKeywords {
- private static final Set<String> KEYWORDS = new HashSet<String>();
-
- private static final String[] JAVA_KEYWORDS = {
- "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char",
- "class", "const", "continue", "default",
- "do", "double", "else", "enum", "extends", "false", "final", "finally", "float", "for",
- "goto", "if", "implements", "import", "instanceof",
- "int", "interface", "long", "native", "new", "null", "package", "private",
- "protected", "public", "return", "short", "static", "strictfp",
- "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "void", "volatile", "while"};
-
- static {
- Collections.addAll(KEYWORDS, JAVA_KEYWORDS);
- }
+ private static final Set<String> KEYWORDS = ImmutableSet.of(
+ "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char",
+ "class", "const", "continue", "default",
+ "do", "double", "else", "enum", "extends", "false", "final", "finally", "float", "for",
+ "goto", "if", "implements", "import", "instanceof",
+ "int", "interface", "long", "native", "new", "null", "package", "private",
+ "protected", "public", "return", "short", "static", "strictfp",
+ "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "void", "volatile", "while");
private JavaKeywords() {
}
public static Set<String> get() {
- return Collections.unmodifiableSet(KEYWORDS);
+ return KEYWORDS;
}
}