*/
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;
}
}
*/
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;
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>");
}
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);
}
}
}
*/
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;
}
}