aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2017-03-01 15:17:30 +0100
committerdbmeneses <duarte.meneses@sonarsource.com>2017-03-16 16:44:48 +0100
commit6a03df65cc0c91a26150ea172a2c480e07326ea1 (patch)
tree7e50c42c842c62a9afb82c0880e64f8cb71ed472
parent77cf76d3531ea6cdd5f7b60808ac00867e902c58 (diff)
downloadsonarqube-6a03df65cc0c91a26150ea172a2c480e07326ea1.tar.gz
sonarqube-6a03df65cc0c91a26150ea172a2c480e07326ea1.zip
SONAR-7860 Remove CodeColorizerFormat API
-rw-r--r--it/it-tests/src/test/java/it/plugins/PluginsTest.java14
-rw-r--r--pom.xml1
-rw-r--r--sonar-colorizer/pom.xml52
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/CDocTokenizer.java32
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/CaseInsensitiveKeywordsTokenizer.java46
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/CodeColorizer.java69
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/CppDocTokenizer.java35
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/GroovyKeywords.java46
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/GroovyTokenizers.java43
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlCodeBuilder.java118
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlDecorator.java87
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlOptions.java128
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlRenderer.java69
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/InlineDocTokenizer.java62
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/JavaAnnotationTokenizer.java57
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/JavaConstantTokenizer.java80
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/JavaKeywords.java48
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/JavaTokenizers.java48
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/JavadocTokenizer.java35
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/KeywordsTokenizer.java98
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/LiteralTokenizer.java86
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/MultilinesDocTokenizer.java120
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/NotThreadSafeTokenizer.java32
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/RegexpTokenizer.java68
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/Renderer.java35
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/StringTokenizer.java44
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/SynhtaxHighlightingException.java40
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/Tokenizer.java33
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/TokenizerDispatcher.java65
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/package-info.java23
-rw-r--r--sonar-colorizer/src/main/resources/sonar-colorizer.css81
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/CDocTokenizerTest.java46
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/CaseInsensitiveKeywordsTokenizerTest.java44
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java156
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/CppTokenizerTest.java59
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlCodeBuilderTest.java78
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlDecoratorTest.java108
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlRendererTest.java69
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/JavaAnnotationTokenizerTest.java41
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/JavaConstantTokenizerTest.java72
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/JavaKeywordsTest.java33
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/JavaTokenizersTest.java53
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/JavadocTokenizerTest.java41
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/KeywordsTokenizerTest.java56
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/LiteralTokenizerTest.java59
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/MultilinesDocTokenizerTest.java104
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/RegexpTokenizerTest.java46
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/SyntaxHighlighterTestingHarness.java30
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/TokenizerDispatcherTest.java80
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/UserGuideTest.java76
-rw-r--r--sonar-colorizer/src/test/resources/org/sonar/colorizer/HtmlRendererTest/Sample.java17
-rw-r--r--sonar-colorizer/src/test/resources/org/sonar/colorizer/samples/Sample.groovy13
-rw-r--r--sonar-colorizer/src/test/resources/org/sonar/colorizer/samples/Sample.java52
-rw-r--r--sonar-colorizer/src/test/resources/org/sonar/colorizer/samples/SampleWithComments.java14
-rw-r--r--sonar-colorizer/src/test/resources/org/sonar/colorizer/samples/SingleLine.java1
-rw-r--r--sonar-plugin-api/pom.xml11
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/CodeColorizerFormat.java82
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/web/CodeColorizerFormatTest.java55
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/source/CodeColorizerSensor.java63
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/source/CodeColorizers.java90
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/source/HighlightingCodeBuilder.java90
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/source/HighlightingRenderer.java43
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/source/CodeColorizersTest.java232
-rw-r--r--sonar-scanner-engine/src/test/resources/org/sonar/scanner/source/CodeColorizersTest/Person.java12
-rw-r--r--sonar-scanner-engine/src/test/resources/org/sonar/scanner/source/CodeColorizersTest/Person.js8
-rw-r--r--sonar-scanner-engine/src/test/resources/org/sonar/scanner/source/CodeColorizersTest/package.html1
68 files changed, 7 insertions, 3827 deletions
diff --git a/it/it-tests/src/test/java/it/plugins/PluginsTest.java b/it/it-tests/src/test/java/it/plugins/PluginsTest.java
index a61c6001f1f..8ae792336d3 100644
--- a/it/it-tests/src/test/java/it/plugins/PluginsTest.java
+++ b/it/it-tests/src/test/java/it/plugins/PluginsTest.java
@@ -88,7 +88,7 @@ public class PluginsTest {
OrchestratorBuilder builder = Orchestrator.builderEnv()
.setZipFile(byWildcardMavenFilename(new File("../../sonar-application/target"), "sonar*.zip").getFile());
- // FIXME JSON plugin is temporary disabled as for the moment the github repo doesn't exist anymore installPlugin(builder, "JSON");;
+ // FIXME JSON plugin is temporarily disabled as for the moment the github repo doesn't exist anymore installPlugin(builder, "JSON");;
installPlugin(builder, "Sonargraph");
installPlugin(builder, "abap");
installPlugin(builder, "aemrules");
@@ -101,15 +101,15 @@ public class PluginsTest {
installPlugin(builder, "codecrackercsharp");
installPlugin(builder, "cpp");
installPlugin(builder, "csharp");
- // FIXME css plugin is temporary disabled as for the moment incompatible with the web plugin installPlugin(builder, "css");
- installPlugin(builder, "erlang");
- installPlugin(builder, "findbugs");
+ // FIXME css plugin is temporarily disabled as for the moment incompatible with the web plugin installPlugin(builder, "css");
+ // FIXME erlang plugin is temporarily disabled because it is not compatible with SQ 6.4 until usage of Colorizer API is removed
+ // FIXME findbugs plugin is temporarily disabled because it is not compatible with SQ 6.4 until usage of Colorizer API is removed
installPlugin(builder, "flex");
installPlugin(builder, "github");
installPlugin(builder, "googleanalytics");
installPlugin(builder, "groovy");
installPlugin(builder, "java");
- // FIXME javaProperties plugin is temporary disabled as for the moment the github repo doesn't exist anymore installPlugin(builder, "javaProperties");
+ // FIXME javaProperties plugin is temporarily disabled as for the moment the github repo doesn't exist anymore installPlugin(builder, "javaProperties");
installPlugin(builder, "javascript");
installPlugin(builder, "jdepend");
installPlugin(builder, "l10nde");
@@ -129,7 +129,7 @@ public class PluginsTest {
installPlugin(builder, "pli");
installPlugin(builder, "plsql");
installPlugin(builder, "pmd");
- installPlugin(builder, "puppet");
+ // FIXME puppet plugin is temporarily disabled because it is not compatible with SQ 6.4 until usage of Colorizer API is removed
installPlugin(builder, "python");
installPlugin(builder, "rci");
installPlugin(builder, "rpg");
@@ -193,7 +193,7 @@ public class PluginsTest {
private static void activateLicenses(OrchestratorBuilder builder) {
LICENSED_PLUGINS.forEach(builder::activateLicense);
}
-
+
private static void installPlugin(OrchestratorBuilder builder, String pluginKey) {
builder.setOrchestratorProperty(pluginKey + "Version", "LATEST_RELEASE");
builder.addPlugin(pluginKey);
diff --git a/pom.xml b/pom.xml
index bab465ea6b7..3a583205126 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,6 @@
<module>sonar-scanner-protocol</module>
<module>sonar-scanner-engine-shaded</module>
<module>sonar-check-api</module>
- <module>sonar-colorizer</module>
<module>sonar-core</module>
<module>sonar-duplications</module>
<module>sonar-home</module>
diff --git a/sonar-colorizer/pom.xml b/sonar-colorizer/pom.xml
deleted file mode 100644
index 293f760da08..00000000000
--- a/sonar-colorizer/pom.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.sonarsource.sonarqube</groupId>
- <artifactId>sonarqube</artifactId>
- <version>6.4-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>sonar-colorizer</artifactId>
-
- <name>SonarQube :: Code Colorizer</name>
- <description>Code syntax highlighter</description>
-
- <dependencies>
- <dependency>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-channel</artifactId>
- <exclusions>
- <exclusion>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
-</project>
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/CDocTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/CDocTokenizer.java
deleted file mode 100644
index e983f9a0665..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/CDocTokenizer.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public class CDocTokenizer extends InlineDocTokenizer {
-
- public CDocTokenizer(String tagBefore, String tagAfter) {
- super("//", tagBefore, tagAfter);
- }
-
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/CaseInsensitiveKeywordsTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/CaseInsensitiveKeywordsTokenizer.java
deleted file mode 100644
index c9bc514f3c9..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/CaseInsensitiveKeywordsTokenizer.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import java.util.Set;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public class CaseInsensitiveKeywordsTokenizer extends KeywordsTokenizer {
-
- public CaseInsensitiveKeywordsTokenizer(String tagBefore, String tagAfter, Set<String> keywords) {
- super(tagBefore, tagAfter, keywords);
- setCaseInsensitive(true);
- }
-
- public CaseInsensitiveKeywordsTokenizer(String tagBefore, String tagAfter, String... keywords) {
- super(tagBefore, tagAfter, keywords);
- setCaseInsensitive(true);
- }
-
- @Override
- public KeywordsTokenizer clone() {
- KeywordsTokenizer clone = super.clone();
- clone.setCaseInsensitive(true);
- return clone;
- }
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/CodeColorizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/CodeColorizer.java
deleted file mode 100644
index 4a089aff62c..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/CodeColorizer.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import javax.annotation.Nullable;
-
-import java.io.Reader;
-import java.util.List;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public class CodeColorizer {
-
- private List<Tokenizer> tokenizers = null;
-
- public CodeColorizer(List<Tokenizer> tokenizers) {
- this.tokenizers = tokenizers;
- }
-
- public CodeColorizer(Format format) {
- this.tokenizers = format.getTokenizers();
- }
-
- public String toHtml(Reader code, @Nullable HtmlOptions options) {
- HtmlOptions opts = options == null ? HtmlOptions.DEFAULT : options;
- return new HtmlRenderer(opts).render(code, tokenizers);
- }
-
- public static String javaToHtml(Reader code, HtmlOptions options) {
- return new CodeColorizer(Format.JAVA).toHtml(code, options);
- }
-
- public static String groovyToHtml(Reader code, HtmlOptions options) {
- return new CodeColorizer(Format.GROOVY).toHtml(code, options);
- }
-
- public enum Format {
- JAVA(JavaTokenizers.forHtml()), GROOVY(GroovyTokenizers.forHtml());
-
- private List<Tokenizer> tokenizers;
-
- Format(List<Tokenizer> tokenizers) {
- this.tokenizers = tokenizers;
- }
-
- public List<Tokenizer> getTokenizers() {
- return tokenizers;
- }
- }
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/CppDocTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/CppDocTokenizer.java
deleted file mode 100644
index 3a9ace1a75f..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/CppDocTokenizer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public class CppDocTokenizer extends MultilinesDocTokenizer {
-
- public CppDocTokenizer(String tagBefore, String tagAfter) {
- super("/*", "*/", tagBefore, tagAfter);
- }
-
- public CppDocTokenizer() {
- this("", "");
- }
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/GroovyKeywords.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/GroovyKeywords.java
deleted file mode 100644
index 70e397f5e4e..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/GroovyKeywords.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public final class GroovyKeywords {
-
- private static final Set<String> KEYWORDS = new HashSet<>();
-
- static {
- KEYWORDS.addAll(Arrays.asList("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 KEYWORDS;
- }
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/GroovyTokenizers.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/GroovyTokenizers.java
deleted file mode 100644
index 2b646df1715..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/GroovyTokenizers.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public final class GroovyTokenizers {
-
- private static final String SPAN_END = "</span>";
-
- private GroovyTokenizers() {
- }
-
- public static List<Tokenizer> forHtml() {
- return Collections.unmodifiableList(Arrays.asList(new JavaAnnotationTokenizer("<span class=\"a\">", SPAN_END), new LiteralTokenizer(
- "<span class=\"s\">", SPAN_END), new CDocTokenizer("<span class=\"cd\">", SPAN_END), new CppDocTokenizer("<span class=\"cppd\">",
- SPAN_END), new JavadocTokenizer("<span class=\"j\">", SPAN_END), new JavaConstantTokenizer("<span class=\"c\">", SPAN_END),
- new KeywordsTokenizer("<span class=\"k\">", SPAN_END, GroovyKeywords.get())));
- }
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlCodeBuilder.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlCodeBuilder.java
deleted file mode 100644
index 125675a868a..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlCodeBuilder.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public class HtmlCodeBuilder implements Appendable {
-
- private StringBuilder colorizedCode = new StringBuilder();
- private Map variables = new HashMap();
-
- @Override
- public Appendable append(CharSequence csq) {
- for (int i = 0; i < csq.length(); i++) {
- append(csq.charAt(i));
- }
- return this;
- }
-
- @Override
- public Appendable append(char c) {
- if (c == '<') {
- colorizedCode.append("&lt;");
- } else if (c == '>') {
- colorizedCode.append("&gt;");
- } else if (c == '&') {
- colorizedCode.append("&amp;");
- } else {
- colorizedCode.append(c);
- }
- return this;
- }
-
- @Override
- public Appendable append(CharSequence csq, int start, int end) {
- for (int i = start; i < end; i++) {
- append(csq.charAt(i));
- }
- return this;
- }
-
- public void appendWithoutTransforming(String htmlTag) {
- colorizedCode.append(htmlTag);
- }
-
- @Override
- public String toString() {
- return colorizedCode.toString();
- }
-
- public StringBuilder getColorizedCode() {
- return colorizedCode;
- }
-
- /**
- * Save a stateful variable.
- *
- * @param key
- * can NOT be null
- * @param value
- * can be null
- */
- public void setVariable(Object key, @Nullable Object value) {
- variables.put(key, value);
- }
-
- /**
- * Get a stateful variable. Return null if not found.
- */
- @CheckForNull
- public Object getVariable(Object key) {
- return variables.get(key);
- }
-
- /**
- * Get a stateful variable. Return the default value if not found.
- */
- public Object getVariable(Object key, Object defaultValue) {
- Object result = variables.get(key);
- if (result == null) {
- result = defaultValue;
- }
- return result;
- }
-
- /**
- * All stateful variables
- */
- public Map getVariables() {
- return variables;
- }
-
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlDecorator.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlDecorator.java
deleted file mode 100644
index f468e9271fc..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlDecorator.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.sonar.channel.CodeReader;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public class HtmlDecorator extends Tokenizer {
-
- private HtmlOptions options;
- private int lineId;
-
- private static final int LF = '\n';
- private static final int CR = '\r';
-
- public HtmlDecorator(HtmlOptions options) {
- this.options = options;
- this.lineId = options.getFirstLineId();
- }
-
- public String getTagBeginOfFile() {
- 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><body>");
- }
- sb.append("<table class=\"code\" id=\"");
- if (options.getTableId() != null) {
- sb.append(options.getTableId());
- }
- sb.append("\"><tbody><tr id=\"").append(lineId++).append("\"><td><pre>");
- return sb.toString();
- }
-
- public String getTagEndOfFile() {
- StringBuilder sb = new StringBuilder();
- sb.append("</pre></td></tr></tbody></table>");
- if (options.isGenerateHtmlHeader()) {
- sb.append("</body></html>");
- }
- return sb.toString();
- }
-
- public String getTagBefore() {
- String tag = "<tr id=\"" + lineId + "\"><td><pre>";
- lineId++;
- return tag;
- }
-
- public String getTagAfter() {
- return "</pre></td></tr>";
- }
-
- @Override
- public boolean consume(CodeReader code, HtmlCodeBuilder codeBuilder) {
- int lineNumber = code.getLinePosition();
- if (code.peek() == LF || code.peek() == CR) {
- code.pop();
- if (lineNumber != code.getLinePosition()) {
- codeBuilder.appendWithoutTransforming(getTagAfter());
- codeBuilder.appendWithoutTransforming(getTagBefore());
- }
- return true;
- }
- return false;
- }
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlOptions.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlOptions.java
deleted file mode 100644
index e4f7a989907..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlOptions.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public class HtmlOptions {
- public static final HtmlOptions DEFAULT = new HtmlOptions(true, null, true);
- public static final OnlySyntaxHtmlOptions ONLY_SYNTAX = new OnlySyntaxHtmlOptions();
-
- private boolean generateTable = true;
- private boolean generateHtmlHeader = true;
- private String tableId = null;
- private int firstLineId = 1;
-
- public HtmlOptions() {
- }
-
- public HtmlOptions(boolean generateTable, @Nullable String tableId, boolean generateHtmlHeader) {
- this.generateTable = generateTable;
- this.generateHtmlHeader = generateHtmlHeader;
- this.tableId = tableId;
- }
-
- public boolean isGenerateTable() {
- return generateTable;
- }
-
- public HtmlOptions setGenerateTable(boolean b) {
- this.generateTable = b;
- return this;
- }
-
- /**
- * Used only if isGenerateTable() is true
- */
- public boolean isGenerateHtmlHeader() {
- return generateHtmlHeader;
- }
-
- /**
- * Defines if the HTML header, including CSS, must be generated.
- */
- public HtmlOptions setGenerateHtmlHeader(boolean b) {
- this.generateHtmlHeader = b;
- return this;
- }
-
- @CheckForNull
- public String getTableId() {
- return tableId;
- }
-
- /**
- * Used only if isGenerateTable() is true. This field is optional.
- */
- public HtmlOptions setTableId(String id) {
- this.tableId = id;
- return this;
- }
-
- /**
- * Used only if isGenerateTable() is true. Default value is 1.
- */
- public int getFirstLineId() {
- return firstLineId;
- }
-
- public HtmlOptions setFirstLineId(int i) {
- this.firstLineId = i;
- return this;
- }
-}
-
-class OnlySyntaxHtmlOptions extends HtmlOptions {
-
- @Override
- public boolean isGenerateTable() {
- return false;
- }
-
- @Override
- public boolean isGenerateHtmlHeader() {
- return false;
- }
-
- @Override
- public String getTableId() {
- return null;
- }
-
- @Override
- public HtmlOptions setGenerateHtmlHeader(boolean b) {
- throw new IllegalStateException();
- }
-
- @Override
- public HtmlOptions setGenerateTable(boolean b) {
- throw new IllegalStateException();
- }
-
- @Override
- public HtmlOptions setTableId(String id) {
- throw new IllegalStateException();
- }
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlRenderer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlRenderer.java
deleted file mode 100644
index c7e29052904..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlRenderer.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.sonar.channel.Channel;
-import org.sonar.channel.CodeReader;
-
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public class HtmlRenderer extends Renderer {
-
- private HtmlOptions options = null;
-
- public HtmlRenderer(HtmlOptions options) {
- this.options = options;
- }
-
- public HtmlRenderer() {
- this(HtmlOptions.DEFAULT);
- }
-
- @Override
- public String render(Reader code, List<? extends Channel<HtmlCodeBuilder>> tokenizers) {
- try {
- List<Channel<HtmlCodeBuilder>> allTokenizers = new ArrayList<>();
- HtmlCodeBuilder codeBuilder = new HtmlCodeBuilder();
- HtmlDecorator htmlDecorator = new HtmlDecorator(options);
-
- // optimization
- if (options != null && options.isGenerateTable()) {
- codeBuilder.appendWithoutTransforming(htmlDecorator.getTagBeginOfFile());
- allTokenizers.add(htmlDecorator);
- }
- allTokenizers.addAll(tokenizers);
-
- new TokenizerDispatcher(allTokenizers).colorize(new CodeReader(code), codeBuilder);
- // optimization
- if (options != null && options.isGenerateTable()) {
- codeBuilder.appendWithoutTransforming(htmlDecorator.getTagEndOfFile());
- }
- return codeBuilder.toString();
- } catch (Exception e) {
- throw new SynhtaxHighlightingException("Can not render code", e);
- }
- }
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/InlineDocTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/InlineDocTokenizer.java
deleted file mode 100644
index 0d9bddd23e8..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/InlineDocTokenizer.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.sonar.channel.CodeReader;
-import org.sonar.channel.EndMatcher;
-
-import java.util.Arrays;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public abstract class InlineDocTokenizer extends Tokenizer {
-
- private final String tagBefore;
- private final String tagAfter;
-
- private final char[] startToken;
- private static final EndMatcher LINE_END_MATCHER = new EndMatcher() {
- @Override
- public boolean match(int endFlag) {
- return endFlag == '\r' || endFlag == '\n';
- }
- };
-
- public InlineDocTokenizer(String startToken, String tagBefore, String tagAfter) {
- this.tagBefore = tagBefore;
- this.tagAfter = tagAfter;
- this.startToken = startToken.toCharArray();
- }
-
- @Override
- public boolean consume(CodeReader code, HtmlCodeBuilder codeBuilder) {
- if (code.peek() == startToken[0] && Arrays.equals(code.peek(startToken.length), startToken)) {
- codeBuilder.appendWithoutTransforming(tagBefore);
- code.popTo(LINE_END_MATCHER, codeBuilder);
- codeBuilder.appendWithoutTransforming(tagAfter);
- return true;
- } else {
- return false;
- }
- }
-
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaAnnotationTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaAnnotationTokenizer.java
deleted file mode 100644
index 266620801f9..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaAnnotationTokenizer.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.sonar.channel.CodeReader;
-import org.sonar.channel.EndMatcher;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public class JavaAnnotationTokenizer extends Tokenizer {
-
- private final String tagBefore;
- private final String tagAfter;
- private static final EndMatcher END_TOKEN_MATCHER = new EndMatcher() {
- @Override
- public boolean match(int endFlag) {
- return !Character.isJavaIdentifierPart(endFlag);
- }
- };
-
- public JavaAnnotationTokenizer(String tagBefore, String tagAfter) {
- this.tagBefore = tagBefore;
- this.tagAfter = tagAfter;
- }
-
- @Override
- public boolean consume(CodeReader code, HtmlCodeBuilder codeBuilder) {
- if (code.peek() == '@') {
- codeBuilder.appendWithoutTransforming(tagBefore);
- code.popTo(END_TOKEN_MATCHER, codeBuilder);
- codeBuilder.appendWithoutTransforming(tagAfter);
- return true;
- } else {
- return false;
- }
- }
-
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaConstantTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaConstantTokenizer.java
deleted file mode 100644
index 3725e10c9fd..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaConstantTokenizer.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.sonar.channel.CodeReader;
-import org.sonar.channel.EndMatcher;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public class JavaConstantTokenizer extends Tokenizer {
-
- private final String tagBefore;
- private final String tagAfter;
- private static final int DOT = '.';
- 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) {
- this.tagBefore = tagBefore;
- this.tagAfter = tagAfter;
- }
-
- private static boolean hasNextToken(CodeReader code) {
- int lastChar = code.lastChar();
- if (isJavaConstantStart(code.peek()) && !Character.isJavaIdentifierPart(lastChar) && !Character.isJavaIdentifierStart(lastChar)
- && lastChar != DOT) {
- String constant = code.peekTo(END_TOKEN_MATCHER);
- int nextCharAfterConstant = code.peek(constant.length() + 1)[constant.length()];
- if (nextCharAfterConstant != 0 && Character.isJavaIdentifierPart(nextCharAfterConstant)) {
- return false;
- }
- return true;
- }
- return false;
- }
-
- @Override
- public boolean consume(CodeReader code, HtmlCodeBuilder codeBuilder) {
- if (hasNextToken(code)) {
- codeBuilder.appendWithoutTransforming(tagBefore);
- code.popTo(END_TOKEN_MATCHER, codeBuilder);
- codeBuilder.appendWithoutTransforming(tagAfter);
- return true;
- } else {
- return false;
- }
- }
-
- private static boolean isJavaConstantStart(int character) {
- return Character.isUpperCase(character);
- }
-
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaKeywords.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaKeywords.java
deleted file mode 100644
index 11a82f15eb2..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaKeywords.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public final class JavaKeywords {
-
- private static final Set<String> KEYWORDS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
- "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 KEYWORDS;
- }
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaTokenizers.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaTokenizers.java
deleted file mode 100644
index 9b2f192d880..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaTokenizers.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public final class JavaTokenizers {
-
- private static final List<Tokenizer> TOKENIZERS = Collections.unmodifiableList(Arrays.asList(
- new JavaAnnotationTokenizer("<span class=\"a\">", "</span>"),
- new LiteralTokenizer("<span class=\"s\">", "</span>"),
- new CDocTokenizer("<span class=\"cd\">", "</span>"),
- new JavadocTokenizer("<span class=\"j\">", "</span>"),
- new CppDocTokenizer("<span class=\"cppd\">", "</span>"),
- new JavaConstantTokenizer("<span class=\"c\">", "</span>"),
- new KeywordsTokenizer("<span class=\"k\">", "</span>", JavaKeywords.get())));
-
- private JavaTokenizers() {
- // only static stuff
- }
-
- public static List<Tokenizer> forHtml() {
- return TOKENIZERS;
- }
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavadocTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/JavadocTokenizer.java
deleted file mode 100644
index 8f2743c73c9..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavadocTokenizer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public class JavadocTokenizer extends MultilinesDocTokenizer {
-
- public JavadocTokenizer(String tagBefore, String tagAfter) {
- super("/**", "*/", tagBefore, tagAfter);
- }
-
- public JavadocTokenizer() {
- this("", "");
- }
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/KeywordsTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/KeywordsTokenizer.java
deleted file mode 100644
index 28929b0e341..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/KeywordsTokenizer.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.sonar.channel.CodeReader;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public class KeywordsTokenizer extends NotThreadSafeTokenizer {
-
- private final String tagBefore;
- private final String tagAfter;
- private boolean caseInsensitive = false;
- private Matcher matcher;
- private final StringBuilder tmpBuilder = new StringBuilder();
- private static final String DEFAULT_REGEX = "[a-zA-Z_][a-zA-Z0-9_]*+";
-
- private Set<String> keywords = new HashSet<>();
-
- public KeywordsTokenizer(String tagBefore, String tagAfter, Set<String> keywords) {
- this(tagBefore, tagAfter, keywords, DEFAULT_REGEX);
- }
-
- public KeywordsTokenizer(String tagBefore, String tagAfter, Set<String> keywords, String regex) {
- this.tagBefore = tagBefore;
- this.tagAfter = tagAfter;
- this.keywords = keywords;
- this.matcher = Pattern.compile(regex).matcher("");
- }
-
- public KeywordsTokenizer(String tagBefore, String tagAfter, String... keywords) {
- this.tagBefore = tagBefore;
- this.tagAfter = tagAfter;
- Collections.addAll(this.keywords, keywords);
- this.matcher = Pattern.compile(DEFAULT_REGEX).matcher("");
- }
-
- @Override
- public boolean consume(CodeReader code, HtmlCodeBuilder codeBuilder) {
- if (code.popTo(matcher, tmpBuilder) > 0) {
- if (isKeyword(tmpBuilder.toString())) {
- codeBuilder.appendWithoutTransforming(tagBefore);
- codeBuilder.append(tmpBuilder);
- codeBuilder.appendWithoutTransforming(tagAfter);
- } else {
- codeBuilder.append(tmpBuilder);
- }
- tmpBuilder.delete(0, tmpBuilder.length());
- return true;
- }
- return false;
- }
-
- private boolean isKeyword(String word) {
- if (!caseInsensitive && keywords.contains(word)) {
- return true;
- } else if (caseInsensitive && keywords.contains(word.toUpperCase(Locale.ENGLISH))) {
- return true;
- }
- return false;
- }
-
- public void setCaseInsensitive(boolean caseInsensitive) {
- this.caseInsensitive = caseInsensitive;
- }
-
- @Override
- public KeywordsTokenizer clone() {
- KeywordsTokenizer clone = new KeywordsTokenizer(tagBefore, tagAfter, keywords, matcher.pattern().pattern());
- clone.caseInsensitive = caseInsensitive;
- return clone;
- }
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/LiteralTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/LiteralTokenizer.java
deleted file mode 100644
index ea2a73b5f7c..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/LiteralTokenizer.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.sonar.channel.CodeReader;
-import org.sonar.channel.EndMatcher;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public class LiteralTokenizer extends Tokenizer {
-
- private final String tagBefore;
- private final String tagAfter;
-
- public LiteralTokenizer(String tagBefore, String tagAfter) {
- this.tagBefore = tagBefore;
- this.tagAfter = tagAfter;
- }
-
- public LiteralTokenizer() {
- this("", "");
- }
-
- @Override
- public boolean consume(CodeReader code, HtmlCodeBuilder codeBuilder) {
- if (code.peek() == '\'' || code.peek() == '\"') {
- codeBuilder.appendWithoutTransforming(tagBefore);
- int firstChar = code.peek();
- code.popTo(new EndCommentMatcher(firstChar, code), codeBuilder);
- codeBuilder.appendWithoutTransforming(tagAfter);
- return true;
- } else {
- return false;
- }
- }
-
- private static class EndCommentMatcher implements EndMatcher {
-
- private final int firstChar;
- private final CodeReader code;
- private StringBuilder literalValue;
-
- public EndCommentMatcher(int firstChar, CodeReader code) {
- this.firstChar = firstChar;
- this.code = code;
- literalValue = new StringBuilder();
- }
-
- @Override
- public boolean match(int endFlag) {
- literalValue.append((char) endFlag);
- return code.lastChar() == firstChar && evenNumberOfBackSlashBeforeDelimiter() && literalValue.length() > 1;
- }
-
- private boolean evenNumberOfBackSlashBeforeDelimiter() {
- int numberOfBackSlashChar = 0;
- for (int index = literalValue.length() - 3; index >= 0; index--) {
- if (literalValue.charAt(index) == '\\') {
- numberOfBackSlashChar++;
- } else {
- break;
- }
- }
- return numberOfBackSlashChar % 2 == 0;
- }
- }
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/MultilinesDocTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/MultilinesDocTokenizer.java
deleted file mode 100644
index 92a294cb523..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/MultilinesDocTokenizer.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.sonar.channel.CodeReader;
-import org.sonar.channel.EndMatcher;
-
-import java.util.Arrays;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public class MultilinesDocTokenizer extends Tokenizer {
-
- private static final String COMMENT_STARTED_ON_PREVIOUS_LINE = "COMMENT_STARTED_ON_PREVIOUS_LINE";
- private static final String COMMENT_TOKENIZER = "MULTILINE_COMMENT_TOKENIZER";
- private final char[] startToken;
- private final char[] endToken;
- private final String tagBefore;
- private final String tagAfter;
-
- /**
- * @deprecated endToken is hardcoded to star-slash, whatever the startToken !
- */
- @Deprecated
- public MultilinesDocTokenizer(String startToken, String tagBefore, String tagAfter) {
- this(startToken, "*/", tagBefore, tagAfter);
- }
-
- public MultilinesDocTokenizer(String startToken, String endToken, String tagBefore, String tagAfter) {
- this.tagBefore = tagBefore;
- this.tagAfter = tagAfter;
- this.startToken = startToken.toCharArray();
- this.endToken = endToken.toCharArray();
- }
-
- public boolean hasNextToken(CodeReader code, HtmlCodeBuilder codeBuilder) {
- return code.peek() != '\n'
- && code.peek() != '\r'
- && (isCommentStartedOnPreviousLine(codeBuilder) || (code.peek() == startToken[0] && Arrays.equals(code.peek(startToken.length),
- startToken)));
- }
-
- @Override
- public boolean consume(CodeReader code, HtmlCodeBuilder codeBuilder) {
- if (hasNextToken(code, codeBuilder)) {
- codeBuilder.appendWithoutTransforming(tagBefore);
- code.popTo(new MultilineEndTokenMatcher(code, codeBuilder), codeBuilder);
- codeBuilder.appendWithoutTransforming(tagAfter);
- return true;
- } else {
- return false;
- }
- }
-
- private class MultilineEndTokenMatcher implements EndMatcher {
-
- private final CodeReader code;
- private final HtmlCodeBuilder codeBuilder;
- private int commentSize = 0;
-
- public MultilineEndTokenMatcher(CodeReader code, HtmlCodeBuilder codeBuilder) {
- this.code = code;
- this.codeBuilder = codeBuilder;
- }
-
- @Override
- public boolean match(int endFlag) {
- commentSize++;
- if (commentSize >= endToken.length + startToken.length || (commentSize >= endToken.length && isCommentStartedOnPreviousLine(codeBuilder))) {
- boolean matches = true;
- for (int i = 1; i <= endToken.length; i++) {
- if (code.charAt(-i) != endToken[endToken.length - i]) {
- matches = false;
- break;
- }
- }
- if (matches) {
- setCommentStartedOnPreviousLine(codeBuilder, Boolean.FALSE);
- return true;
- }
- }
-
- if (endFlag == '\r' || endFlag == '\n') {
- setCommentStartedOnPreviousLine(codeBuilder, Boolean.TRUE);
- return true;
- }
- return false;
- }
- }
-
- private boolean isCommentStartedOnPreviousLine(HtmlCodeBuilder codeBuilder) {
- Boolean b = (Boolean) codeBuilder.getVariable(COMMENT_STARTED_ON_PREVIOUS_LINE, Boolean.FALSE);
- return (b == Boolean.TRUE) && (this.equals(codeBuilder.getVariable(COMMENT_TOKENIZER)));
- }
-
- private void setCommentStartedOnPreviousLine(HtmlCodeBuilder codeBuilder, Boolean b) {
- codeBuilder.setVariable(COMMENT_STARTED_ON_PREVIOUS_LINE, b);
- codeBuilder.setVariable(COMMENT_TOKENIZER, b ? this : null);
- }
-
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/NotThreadSafeTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/NotThreadSafeTokenizer.java
deleted file mode 100644
index 65f813c753c..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/NotThreadSafeTokenizer.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-/**
- * A thread safe Tokenizer. Before each use by the CodeColorizer, the method clone() is automatically
- * called to clone the current instance.
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public abstract class NotThreadSafeTokenizer extends Tokenizer implements Cloneable {
-
- @Override
- public abstract NotThreadSafeTokenizer clone();
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/RegexpTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/RegexpTokenizer.java
deleted file mode 100644
index 96a30c703e2..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/RegexpTokenizer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.sonar.channel.CodeReader;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public class RegexpTokenizer extends NotThreadSafeTokenizer {
-
- private final String tagBefore;
- private final String tagAfter;
- private final Matcher matcher;
- private final StringBuilder tmpBuilder = new StringBuilder();
-
- /**
- * @param tagBefore
- * Html tag to add before the token
- * @param tagAfter
- * Html tag to add after the token
- * @param regexp
- * Regular expression which must be used to match token
- */
- public RegexpTokenizer(String tagBefore, String tagAfter, String regexp) {
- this.tagBefore = tagBefore;
- this.tagAfter = tagAfter;
- this.matcher = Pattern.compile(regexp).matcher("");
- }
-
- @Override
- public boolean consume(CodeReader code, HtmlCodeBuilder codeBuilder) {
- if (code.popTo(matcher, tmpBuilder) > 0) {
- codeBuilder.appendWithoutTransforming(tagBefore);
- codeBuilder.append(tmpBuilder);
- codeBuilder.appendWithoutTransforming(tagAfter);
- tmpBuilder.delete(0, tmpBuilder.length());
- return true;
- }
- return false;
- }
-
- @Override
- public RegexpTokenizer clone() {
- return new RegexpTokenizer(tagBefore, tagAfter, matcher.pattern().pattern());
- }
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/Renderer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/Renderer.java
deleted file mode 100644
index 98ac15f87f4..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/Renderer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.sonar.channel.Channel;
-
-import java.io.Reader;
-import java.util.List;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public abstract class Renderer {
-
- public abstract String render(Reader code, List<? extends Channel<HtmlCodeBuilder>> tokenizers);
-
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/StringTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/StringTokenizer.java
deleted file mode 100644
index 32f213f2dc2..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/StringTokenizer.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.sonar.channel.CodeReader;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public class StringTokenizer extends Tokenizer {
-
- private final LiteralTokenizer tokenizer;
-
- public StringTokenizer(String tagBefore, String tagAfter) {
- tokenizer = new LiteralTokenizer(tagBefore, tagAfter);
- }
-
- public StringTokenizer() {
- tokenizer = new LiteralTokenizer("", "");
- }
-
- @Override
- public boolean consume(CodeReader code, HtmlCodeBuilder output) {
- return tokenizer.consume(code, output);
- }
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/SynhtaxHighlightingException.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/SynhtaxHighlightingException.java
deleted file mode 100644
index 3e30862fe60..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/SynhtaxHighlightingException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-/**
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public class SynhtaxHighlightingException extends RuntimeException {
-
- public SynhtaxHighlightingException(String arg0, Throwable arg1) {
- super(arg0, arg1);
- }
-
- public SynhtaxHighlightingException(String arg0) {
- super(arg0);
- }
-
- public SynhtaxHighlightingException(Throwable arg0) {
- super(arg0);
- }
-
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/Tokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/Tokenizer.java
deleted file mode 100644
index f1e8a8e5ad8..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/Tokenizer.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.sonar.channel.Channel;
-
-/**
- * A token highlighter is in charge to optionally consume the next characters (token) of a CodeReader
- * and to add the highlighted token to an HtmlCodeBuilder.
- *
- * IMPORTANT: a Tokenizer must be THREAD-SAFE otherwise use {@link NotThreadSafeTokenizer}
- * @deprecated since 4.5.2 replace by highlighting mechanism
- */
-@Deprecated
-public abstract class Tokenizer extends Channel<HtmlCodeBuilder> {
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/TokenizerDispatcher.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/TokenizerDispatcher.java
deleted file mode 100644
index d18320d0f26..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/TokenizerDispatcher.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.sonar.channel.Channel;
-import org.sonar.channel.CodeReader;
-
-import java.util.List;
-
-public class TokenizerDispatcher {
-
- private Channel<HtmlCodeBuilder>[] tokenizers;
-
- public TokenizerDispatcher(Channel<HtmlCodeBuilder>... tokenizers) {
- this.tokenizers = tokenizers;
- }
-
- public TokenizerDispatcher(List<Channel<HtmlCodeBuilder>> tokenizersArray) {
- this.tokenizers = tokenizersArray.toArray(new Channel[tokenizersArray.size()]);
- }
-
- public final String colorize(String code) {
- HtmlCodeBuilder colorizedCode = new HtmlCodeBuilder();
- colorize(new CodeReader(code), colorizedCode);
- return colorizedCode.toString();
- }
-
- public final void colorize(CodeReader code, HtmlCodeBuilder colorizedCode) {
- cloneNotThreadSafeTokenizers();
- nextChar:
- while (code.peek() != -1) {
- for (Channel<HtmlCodeBuilder> codeTokenizer : tokenizers) {
- if (codeTokenizer.consume(code, colorizedCode)) {
- continue nextChar;
- }
- }
- colorizedCode.append((char) code.pop());
- }
- }
-
- private void cloneNotThreadSafeTokenizers() {
- for (int i = 0; i < tokenizers.length; i++) {
- if (tokenizers[i] instanceof NotThreadSafeTokenizer) {
- tokenizers[i] = ((NotThreadSafeTokenizer) tokenizers[i]).clone();
- }
- }
- }
-}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/package-info.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/package-info.java
deleted file mode 100644
index c830dbac059..00000000000
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.colorizer;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-colorizer/src/main/resources/sonar-colorizer.css b/sonar-colorizer/src/main/resources/sonar-colorizer.css
deleted file mode 100644
index 06328e22632..00000000000
--- a/sonar-colorizer/src/main/resources/sonar-colorizer.css
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- WARNING - THIS FILE IS USED ONLY A TEMPLATE USED BY HtmlDecorator
- The CSS file used by webapp is defined at in the sonar-web module (see sonar-colorizer.less)
-
- Any modification of this file must be applied to the sonar-web less file.
-*/
-
-.code {
- font-size: 12px;
-}
-
-.code pre {
- font-family: Monospace;
- margin: 0;
- padding: 0 5px;
- color: #111;
- margin: 0;
-}
-
-/* for example java annotations */
-.code .a {
- color: #808000;
-}
-
-/* constants */
-.code .c {
- color: #660E80;
- font-style: italic;
- font-weight: bold;
-}
-
-/* javadoc */
-.code .j {
- color: #666666;
- font-style: normal;
-}
-
-/* classic comment */
-.code .cd {
- color: #666666;
- font-style: italic;
-}
-
-/* C++ doc */
-.code .cppd {
- color: #666666;
- font-style: italic;
-}
-
-/* keyword */
-.code .k {
- color: #000080;
- font-weight: bold;
-}
-
-/* string */
-.code .s {
- color: #008000;
- font-weight: bold;
-}
-
-/* keyword light*/
-.code .h {
- color: #000080;
- font-weight: normal;
-}
-
-/* preprocessing directive */
-.code .p {
- color: #347235;
- font-weight: normal;
-}
-
-.sym {
- cursor: hand; cursor: pointer;
-}
-
-.highlighted {
- background-color: #B3D4FF;
-}
-
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/CDocTokenizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/CDocTokenizerTest.java
deleted file mode 100644
index 8acb38e0a27..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/CDocTokenizerTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.channel.CodeReader;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class CDocTokenizerTest {
-
- private HtmlCodeBuilder codeBuilder;
-
- @Before
- public void init() {
- codeBuilder = new HtmlCodeBuilder();
- }
-
- @Test
- public void testRead() {
- CDocTokenizer tokenizer = new CDocTokenizer("<c>", "</c>");
- assertThat(tokenizer.consume(new CodeReader("//this is a comment"), codeBuilder)).isTrue();
- assertThat(codeBuilder.toString()).isEqualTo("<c>//this is a comment</c>");
-
- assertThat(tokenizer.consume(new CodeReader("this is not a comment"), codeBuilder)).isFalse();
- assertThat(codeBuilder.toString()).isEqualTo("<c>//this is a comment</c>");
- }
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/CaseInsensitiveKeywordsTokenizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/CaseInsensitiveKeywordsTokenizerTest.java
deleted file mode 100644
index 4c9749fc9b6..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/CaseInsensitiveKeywordsTokenizerTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.colorizer.SyntaxHighlighterTestingHarness.highlight;
-
-public class CaseInsensitiveKeywordsTokenizerTest {
-
- @Test
- public void hasNextToken() {
- CaseInsensitiveKeywordsTokenizer tokenizer = new CaseInsensitiveKeywordsTokenizer("<k>", "</k>", "PROCEDURE");
- assertThat(highlight("procedure name", tokenizer)).isEqualTo("<k>procedure</k> name");
- assertThat(highlight("Procedure name", tokenizer)).isEqualTo("<k>Procedure</k> name");
- assertThat(highlight("PROCEDURE name", tokenizer)).isEqualTo("<k>PROCEDURE</k> name");
- }
-
- @Test
- public void testClone() {
- CaseInsensitiveKeywordsTokenizer tokenizer = new CaseInsensitiveKeywordsTokenizer("<k>", "</k>", "PROCEDURE");
- Tokenizer cloneTokenizer = tokenizer.clone();
- assertThat(tokenizer).isNotEqualTo(cloneTokenizer);
- assertThat(highlight("procedure name", cloneTokenizer)).isEqualTo("<k>procedure</k> name");
- }
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java
deleted file mode 100644
index 69ccde16c50..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.apache.commons.io.IOUtils;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class CodeColorizerTest {
-
- @Test
- public void javaToHtml() throws IOException {
- Reader java = readFile("/org/sonar/colorizer/samples/Sample.java");
-
- String html = CodeColorizer.javaToHtml(java, HtmlOptions.DEFAULT);
-
- assertHtml(html);
- assertContains(html, "<pre><span class=\"k\">public</span> <span class=\"k\">class</span> Sample {</pre>");
- }
-
- @Test
- public void shouldSupportWindowsEndOfLines() throws IOException {
- Reader windowsFile = readFile("/org/sonar/colorizer/samples/Sample.java", IOUtils.LINE_SEPARATOR_WINDOWS);
-
- String html = CodeColorizer.javaToHtml(windowsFile, HtmlOptions.DEFAULT);
-
- assertHtml(html);
- assertContains(html, "<pre><span class=\"k\">public</span> <span class=\"k\">class</span> Sample {</pre>");
- }
-
- @Test
- public void useHtmlOptions() throws IOException {
- Reader java = readFile("/org/sonar/colorizer/samples/Sample.java");
-
- HtmlOptions options = new HtmlOptions(true, "my-table-id", false);
- String html = CodeColorizer.javaToHtml(java, options);
-
- assertThat(html).contains("<table class=\"code\" id=\"my-table-id\"");
- assertThat(html).doesNotContain("<style");
- }
-
- @Test
- public void groovyToHtml() throws IOException {
- Reader groovy = readFile("/org/sonar/colorizer/samples/Sample.groovy");
-
- String html = CodeColorizer.groovyToHtml(groovy, HtmlOptions.DEFAULT);
-
- assertHtml(html);
- assertContains(html, "<pre><span class=\"k\">class</span> Greet {</pre>");
- }
-
- @Test
- public void mustBeThreadsafe() throws InterruptedException, ExecutionException, IOException {
- final int taskCount = 50;
- final int threadCount = 5;
-
- class ColorizerTask implements Callable<String> {
-
- Reader java;
-
- ColorizerTask() throws IOException {
- this.java = readFile("/org/sonar/colorizer/samples/Sample.java");
- }
-
- public String call() throws Exception {
- return CodeColorizer.javaToHtml(java, HtmlOptions.ONLY_SYNTAX);
- }
- }
-
- Collection<Callable<String>> tasks = new ArrayList<>();
- for (int i = 0; i < taskCount; i++) {
- tasks.add(new ColorizerTask());
- }
- List<Future<String>> futures = Executors.newFixedThreadPool(threadCount).invokeAll(tasks);
-
- assertThat(futures).hasSize(taskCount);
-
- // all html must be the same
- String html = futures.get(0).get();
- for (Future<String> future : futures) {
- assertThat(html).isEqualTo(future.get());
- }
- }
-
- @Test
- public void shouldEscapeSpecialCharacters() throws Exception {
-
- Reader java = readFile("/org/sonar/colorizer/samples/SampleWithComments.java");
-
- String html = CodeColorizer.javaToHtml(java, HtmlOptions.DEFAULT);
-
- assertHtml(html);
- assertContains(html, "<pre> <span class=\"cppd\">/*</span></pre>",
- "<pre><span class=\"cppd\"> * This method does &lt;b&gt;something&lt;/b&gt;</span></pre>",
- "<pre><span class=\"cppd\"> *</span></pre>",
- "<pre><span class=\"cppd\"> * &amp;lt;p&amp;gt;description&amp;lt;/p&amp;gt;</span></pre>",
- "<pre><span class=\"cppd\"> */</span></pre>");
- }
-
- /**
- * @return Reader for specified file with EOL normalized to specified one.
- */
- private Reader readFile(String path, String eol) throws IOException {
- StringBuilder sb = new StringBuilder();
- for (String line : IOUtils.readLines(getClass().getResourceAsStream(path))) {
- sb.append(line).append(eol);
- }
- return new StringReader(sb.toString());
- }
-
- /**
- * @return Reader for specified file with EOL normalized to LF.
- */
- private Reader readFile(String path) throws IOException {
- return readFile(path, IOUtils.LINE_SEPARATOR_UNIX);
- }
-
- private void assertHtml(String html) {
- assertContains(html, "<table class=\"code\"", "</html>");
- }
-
- private void assertContains(String html, String... strings) {
- for (String string : strings) {
- assertThat(html).contains(string);
- }
- }
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/CppTokenizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/CppTokenizerTest.java
deleted file mode 100644
index 582f700b0f3..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/CppTokenizerTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.channel.CodeReader;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class CppTokenizerTest {
-
- private HtmlCodeBuilder codeBuilder;
-
- @Before
- public void init() {
- codeBuilder = new HtmlCodeBuilder();
- }
-
- @Test
- public void testRead() {
- CppDocTokenizer javadocTokenizer = new CppDocTokenizer("<c>", "</c>");
- assertTrue(javadocTokenizer.consume(new CodeReader("/*this is a cpp comment*/ private"), codeBuilder));
- assertEquals("<c>/*this is a cpp comment*/</c>", codeBuilder.toString());
-
- assertFalse(javadocTokenizer.consume(new CodeReader("//this is not a cpp comment"), codeBuilder));
- }
-
-
- @Test
- public void testReadOnMultilines() {
- CppDocTokenizer javadocTokenizer = new CppDocTokenizer("<c>", "</c>");
- CodeReader reader = new CodeReader("/*this is \n a cpp comment*/ private");
- assertTrue(javadocTokenizer.consume(reader, codeBuilder));
- assertEquals("<c>/*this is </c>", codeBuilder.toString());
- codeBuilder.append((char)reader.pop());
- assertTrue(javadocTokenizer.consume(reader, codeBuilder));
- assertEquals("<c>/*this is </c>\n<c> a cpp comment*/</c>", codeBuilder.toString());
- }
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlCodeBuilderTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlCodeBuilderTest.java
deleted file mode 100644
index e74b4ce0b09..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlCodeBuilderTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class HtmlCodeBuilderTest {
-
- private HtmlCodeBuilder builder;
-
- @Before
- public void init() {
- builder = new HtmlCodeBuilder();
- }
-
- @Test
- public void testAppendCharSequence() {
- builder.append("freddy < olivier");
- assertThat("freddy &lt; olivier").isEqualTo(builder.toString());
- }
-
- @Test
- public void testAppendChar() {
- builder.append('p');
- builder.append('a');
- builder.append('>');
- assertThat("pa&gt;").isEqualTo(builder.toString());
- }
-
- @Test
- public void testAppendCharSequenceIntInt() {
- builder.append("freddy < olivier", 0, 2);
- assertThat("fr").isEqualTo(builder.toString());
- }
-
- @Test
- public void testAppendWithoutTransforming() {
- builder.appendWithoutTransforming("<inside>outside");
- assertThat("<inside>outside").isEqualTo(builder.toString());
- }
-
- @Test
- public void testStatefulVariables() {
- assertThat(builder.getVariable("foo")).isNull();
-
- builder.setVariable("foo", "xxx");
- assertThat((String) builder.getVariable("foo")).isEqualTo(("xxx"));
-
- builder.setVariable("foo", "yyy");
- assertThat((String) builder.getVariable("foo")).isEqualTo(("yyy"));
-
- builder.setVariable("foo", null);
- assertThat(builder.getVariable("foo")).isNull();
-
- assertThat((String) builder.getVariable("foo", "default")).isEqualTo(("default"));
- }
-
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlDecoratorTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlDecoratorTest.java
deleted file mode 100644
index 525d1243834..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlDecoratorTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.junit.Test;
-import org.sonar.channel.CodeReader;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class HtmlDecoratorTest {
-
- @Test
- public void beginOfFileTag() {
- HtmlDecorator decorator = new HtmlDecorator(HtmlOptions.DEFAULT);
- String tag = decorator.getTagBeginOfFile();
- assertContains(tag, "<html", "<table");
- }
-
- @Test
- public void beginOfFileTagWithTableId() {
- HtmlOptions options = new HtmlOptions().setGenerateTable(true).setTableId("foo");
- HtmlDecorator decorator = new HtmlDecorator(options);
-
- String tag = decorator.getTagBeginOfFile();
-
- assertContains(tag, "<table class=\"code\" id=\"foo\">");
- }
-
- @Test
- public void beginOfFileTagWithoutHeader() {
- HtmlOptions options = new HtmlOptions().setGenerateTable(true).setGenerateHtmlHeader(false);
- HtmlDecorator decorator = new HtmlDecorator(options);
-
- String tag = decorator.getTagBeginOfFile();
-
- assertNotContains(tag, "<html", "<body");
- assertContains(tag, "<table");
- }
-
- @Test
- public void endOfFileTag() {
- HtmlDecorator decorator = new HtmlDecorator(HtmlOptions.DEFAULT);
- String tag = decorator.getTagEndOfFile();
- assertContains(tag, "</table>", "</body>", "</html>");
- }
-
- @Test
- public void endOfFileTagWithoutHeader() {
- HtmlOptions options = new HtmlOptions().setGenerateTable(true).setGenerateHtmlHeader(false);
- HtmlDecorator decorator = new HtmlDecorator(options);
-
- String tag = decorator.getTagEndOfFile();
-
- assertContains(tag, "</table>");
- assertNotContains(tag, "</body>", "</html>");
- }
-
- @Test
- public void shouldAddTagsBetweenEachLine() {
- HtmlOptions options = new HtmlOptions().setGenerateTable(true).setGenerateHtmlHeader(false);
- HtmlDecorator decorator = new HtmlDecorator(options);
- CodeReader code = new CodeReader("\r\n\r");
- HtmlCodeBuilder output = new HtmlCodeBuilder();
-
- output.appendWithoutTransforming(decorator.getTagBeginOfFile());
- assertThat(decorator.consume(code, output)).isTrue();
- assertThat(decorator.consume(code, output)).isTrue();
- assertThat(decorator.consume(code, output)).isTrue();
- output.appendWithoutTransforming(decorator.getTagEndOfFile());
-
- assertThat(output.toString()).isEqualTo(
- "<table class=\"code\" id=\"\"><tbody>"
- + "<tr id=\"1\"><td><pre></pre></td></tr>"
- + "<tr id=\"2\"><td><pre></pre></td></tr>"
- + "<tr id=\"3\"><td><pre></pre></td></tr>"
- + "</tbody></table>"
- );
- }
-
- public void assertContains(String html, String... strings) {
- for (String string : strings) {
- assertThat(html).contains(string);
- }
- }
-
- public void assertNotContains(String html, String... strings) {
- for (String string : strings) {
- assertThat(html).doesNotContain(string);
- }
- }
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlRendererTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlRendererTest.java
deleted file mode 100644
index d24f4d60840..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlRendererTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.apache.commons.io.FileUtils;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.Arrays;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class HtmlRendererTest {
-
- private KeywordsTokenizer javaKeywordTokenizer = new KeywordsTokenizer("<span class='k'>", "</span>", JavaKeywords.get());
-
- @Test
- public void renderJavaSyntax() {
- HtmlRenderer htmlRenderer = new HtmlRenderer(HtmlOptions.ONLY_SYNTAX);
-
- String html = htmlRenderer.render(new StringReader("public class Hello {"), Arrays.asList(javaKeywordTokenizer));
-
- assertThat(html).isEqualTo("<span class='k'>public</span> <span class='k'>class</span> Hello {");
- }
-
- @Test
- public void supportHtmlSpecialCharacters() {
- HtmlRenderer htmlRenderer = new HtmlRenderer(HtmlOptions.ONLY_SYNTAX);
-
- String html = htmlRenderer.render(new StringReader("foo(\"<html>\");"), Arrays.asList(new LiteralTokenizer("<s>", "</s>")));
-
- assertThat(html).isEqualTo("foo(<s>\"&lt;html&gt;\"</s>);");
- }
-
- @Test
- public void renderJavaFile() throws IOException {
- File java = FileUtils.toFile(getClass().getResource("/org/sonar/colorizer/HtmlRendererTest/Sample.java"));
-
- String html = new HtmlRenderer().render(new FileReader(java), Arrays.asList(javaKeywordTokenizer));
-
- assertThat(html).contains("<html>");
- assertThat(html).contains("<table class=\"code\"");
- assertThat(html).contains("public");
- assertThat(html).contains("class");
- assertThat(html).contains("Sample");
- assertThat(html).contains("</html>");
- }
-
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaAnnotationTokenizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaAnnotationTokenizerTest.java
deleted file mode 100644
index 177709cf08b..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaAnnotationTokenizerTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.colorizer.SyntaxHighlighterTestingHarness.highlight;
-
-public class JavaAnnotationTokenizerTest {
-
- JavaAnnotationTokenizer tokenizer = new JavaAnnotationTokenizer("<a>", "</a>");
-
- @Test
- public void testHighlighting() {
- assertThat(highlight("@deprecated public", tokenizer)).isEqualTo("<a>@deprecated</a> public");
- assertThat(highlight("import", tokenizer)).isEqualTo("import");
- }
-
- @Test
- public void testHighlightingWithProperties() {
- assertThat(highlight("@Target(ElementType.METHOD)", tokenizer)).isEqualTo("<a>@Target</a>(ElementType.METHOD)");
- }
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaConstantTokenizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaConstantTokenizerTest.java
deleted file mode 100644
index 3119921834c..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaConstantTokenizerTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.channel.CodeReader;
-
-public class JavaConstantTokenizerTest {
-
- private JavaConstantTokenizer tokenizer;
- private HtmlCodeBuilder codeBuilder;
-
- @Before
- public void init() {
- tokenizer = new JavaConstantTokenizer("<c>", "</c>");
- codeBuilder = new HtmlCodeBuilder();
- }
-
- @Test
- public void testRead() {
- assertTrue(tokenizer.consume(new CodeReader("CONSTANT"), codeBuilder));
- assertTrue(tokenizer.consume(new CodeReader("IS_CONSTANT "), codeBuilder));
- assertTrue(tokenizer.consume(new CodeReader("IS-CONSTANT "), codeBuilder));
- assertFalse(tokenizer.consume(new CodeReader("Class"), codeBuilder));
- assertFalse(tokenizer.consume(new CodeReader("_NOTACONSTANT"), codeBuilder));
- assertFalse(tokenizer.consume(new CodeReader("IS_not_a_constant"), codeBuilder));
- assertFalse(tokenizer.consume(new CodeReader("property"), codeBuilder));
- assertFalse(tokenizer.consume(new CodeReader(" "), codeBuilder));
- }
-
- @Test
- public void upperCaseWordsStartingWithADotShoutNotBeHighlighted() {
- CodeReader reader = new CodeReader(".URL");
- reader.pop();
- assertFalse(tokenizer.consume(reader, codeBuilder));
- }
-
- @Test
- public void hasNextTokenWhenFirstCharacterIsNotAConstant() {
- CodeReader code = new CodeReader("sCONSTANT");
- code.pop();
- assertFalse(tokenizer.consume(code, codeBuilder));
- }
-
- @Test
- public void nextToken() {
- assertTrue(tokenizer.consume(new CodeReader("IS_TRUE = 4;"), codeBuilder));
- assertEquals("<c>IS_TRUE</c>", codeBuilder.toString());
- }
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaKeywordsTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaKeywordsTest.java
deleted file mode 100644
index 3408ecef6b9..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaKeywordsTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class JavaKeywordsTest {
-
- @Test
- public void get() {
- assertThat(JavaKeywords.get()).hasSize(53);
- assertThat(JavaKeywords.get()).contains("true", "public", "switch");
- }
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaTokenizersTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaTokenizersTest.java
deleted file mode 100644
index 7ec24b37bbe..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaTokenizersTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import java.util.List;
-
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.fail;
-
-public class JavaTokenizersTest {
-
- @Test
- public void forHtml() {
- assertThat(JavaTokenizers.forHtml().size()).isGreaterThan(3);
- }
-
- @Test
- public void javadocIsDefinedBeforeCppComment() {
- // just because /** must be detected before /*
- assertThat(indexOf(JavaTokenizers.forHtml(), JavadocTokenizer.class)).isLessThan(
- indexOf(JavaTokenizers.forHtml(), CppDocTokenizer.class));
- }
-
- private Integer indexOf(List<Tokenizer> tokenizers, Class tokenizerClass) {
- for (int i = 0; i < tokenizers.size(); i++) {
- if (tokenizers.get(i).getClass().equals(tokenizerClass)) {
- return i;
- }
- }
-
- fail("Tokenizer not found: " + tokenizerClass);
- return null;
- }
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavadocTokenizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/JavadocTokenizerTest.java
deleted file mode 100644
index 6068e107f17..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavadocTokenizerTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.colorizer.SyntaxHighlighterTestingHarness.highlight;
-
-public class JavadocTokenizerTest {
-
- JavadocTokenizer tokenizer = new JavadocTokenizer("<j>", "</j>");
-
- @Test
- public void testHighlighting() {
- assertThat(highlight("/**this is a javadoc*/ public ...", tokenizer)).isEqualTo("<j>/**this is a javadoc*/</j> public ...");
- assertThat(highlight("//this is not a javadoc", tokenizer)).isEqualTo("//this is not a javadoc");
- }
-
- @Test
- public void testHighlightingOnMultipleLines() {
- assertThat(highlight("/**this is \n a javadoc*/ private", tokenizer)).isEqualTo("<j>/**this is </j>\n<j> a javadoc*/</j> private");
- }
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/KeywordsTokenizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/KeywordsTokenizerTest.java
deleted file mode 100644
index a8deca49e50..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/KeywordsTokenizerTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.colorizer.SyntaxHighlighterTestingHarness.highlight;
-
-import org.junit.Test;
-
-public class KeywordsTokenizerTest {
-
- @Test
- public void testColorizeKeywords() {
- KeywordsTokenizer tokenizer = new KeywordsTokenizer("<s>", "</s>", "public", "new");
- assertThat(highlight("new()", tokenizer)).isEqualTo("<s>new</s>()");
- assertThat(highlight("public new get()", tokenizer)).isEqualTo("<s>public</s> <s>new</s> get()");
- assertThat(highlight("publication", tokenizer)).isEqualTo("publication");
- }
-
- @Test
- public void testUnderscoreAndDigit() {
- KeywordsTokenizer tokenizer = new KeywordsTokenizer("<s>", "</s>", "_01public");
- assertThat(highlight("_01public", tokenizer)).isEqualTo("<s>_01public</s>");
- }
-
- @Test
- public void testCaseSensitive() {
- KeywordsTokenizer tokenizer = new KeywordsTokenizer("<s>", "</s>", "public");
- assertThat(highlight("PUBLIC Public public", tokenizer)).isEqualTo("PUBLIC Public <s>public</s>");
- }
-
- @Test
- public void testClone() {
- KeywordsTokenizer tokenizer = new KeywordsTokenizer("<s>", "</s>", "public", "[a-z]+");
- KeywordsTokenizer cloneTokenizer = tokenizer.clone();
- assertThat(tokenizer).isNotEqualTo(cloneTokenizer);
- assertThat(highlight("public 1234", cloneTokenizer)).isEqualTo("<s>public</s> 1234");
- }
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/LiteralTokenizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/LiteralTokenizerTest.java
deleted file mode 100644
index 62f945b5989..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/LiteralTokenizerTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.channel.CodeReader;
-
-public class LiteralTokenizerTest {
-
- private HtmlCodeBuilder codeBuilder;
-
- @Before
- public void init() {
- codeBuilder = new HtmlCodeBuilder();
- }
-
- @Test
- public void nextToken() {
- LiteralTokenizer tokenizer = new LiteralTokenizer("<s>", "</s>");
- assertTrue(tokenizer.consume(new CodeReader("\"toto\";"), codeBuilder));
- assertEquals("<s>\"toto\"</s>", codeBuilder.toString());
- init();
- assertTrue(tokenizer.consume(new CodeReader("\"\";"), codeBuilder));
- assertEquals("<s>\"\"</s>", codeBuilder.toString());
- init();
- assertTrue(tokenizer.consume(new CodeReader("\'\';"), codeBuilder));
- assertEquals("<s>\'\'</s>", codeBuilder.toString());
- init();
- assertTrue(tokenizer.consume(new CodeReader("\"(\\\"\").replace"), codeBuilder));
- assertEquals("<s>\"(\\\"\"</s>", codeBuilder.toString());
- init();
- assertTrue(tokenizer.consume(new CodeReader("\'\\\\\';"), codeBuilder));
- assertEquals("<s>\'\\\\\'</s>", codeBuilder.toString());
- init();
- assertTrue(tokenizer.consume(new CodeReader("\"to\\'to\""), codeBuilder));
- assertEquals("<s>\"to\\'to\"</s>", codeBuilder.toString());
- }
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/MultilinesDocTokenizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/MultilinesDocTokenizerTest.java
deleted file mode 100644
index 173b1295905..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/MultilinesDocTokenizerTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.channel.CodeReader;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class MultilinesDocTokenizerTest {
-
- private HtmlCodeBuilder codeBuilder;
-
- @Before
- public void init() {
- codeBuilder = new HtmlCodeBuilder();
- }
-
- @Test
- public void testStandardComment() {
- MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("{[||", "");
- assertThat(tokenizer.hasNextToken(new CodeReader("{[|| And here is strange multi-line comment"), new HtmlCodeBuilder())).isTrue();
- assertThat(tokenizer.hasNextToken(new CodeReader("// this is not a strange multi-line comment"), new HtmlCodeBuilder())).isFalse();
- }
-
- @Test
- public void testLongStartToken() {
- CodeReader reader = new CodeReader("/*** multi-line comment**/ private part");
- MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("/***", "**/");
- assertThat(tokenizer.consume(reader, codeBuilder)).isTrue();
- assertThat(codeBuilder.toString()).isEqualTo("/*** multi-line comment**/");
- }
-
- @Test
- public void testStartTokenEndTokenOverlapping() {
- CodeReader reader = new CodeReader("/*// multi-line comment*/ private part");
- MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("/*", "*/");
- assertThat(tokenizer.consume(reader, codeBuilder)).isTrue();
- assertThat(codeBuilder.toString()).isEqualTo("/*// multi-line comment*/");
- }
-
- @Test
- public void testMultilinesComment() {
- CodeReader reader = new CodeReader("/* multi-line comment\n*/ private part");
- MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("/*", "*/");
- assertThat(tokenizer.consume(reader, codeBuilder)).isTrue();
- assertThat(codeBuilder.toString()).isEqualTo("/* multi-line comment");
- reader.pop();
- assertThat(tokenizer.consume(reader, codeBuilder)).isTrue();
- assertThat(codeBuilder.toString()).isEqualTo("/* multi-line comment*/");
- }
-
- /**
- * SONAR-3531
- */
- @Test
- public void should_work_for_html_comments() {
- CodeReader reader = new CodeReader("<!-- multi-line comment\n--> private part");
- MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("<!--", "-->");
- assertThat(tokenizer.consume(reader, codeBuilder)).isTrue();
- assertThat(codeBuilder.toString()).isEqualTo("&lt;!-- multi-line comment");
- reader.pop();
- assertThat(tokenizer.consume(reader, codeBuilder)).isTrue();
- assertThat(codeBuilder.toString()).isEqualTo("&lt;!-- multi-line comment--&gt;");
- }
-
- /**
- * SONAR-3531
- */
- @Test
- public void should_be_possible_to_use_two_instances() {
- CodeReader reader = new CodeReader("<!-- multi-line comment\n--> private part");
- MultilinesDocTokenizer tokenizer1 = new MultiLineDocTokenizerImpl("<!--", "-->");
- MultilinesDocTokenizer tokenizer2 = new MultiLineDocTokenizerImpl("<!--", "-->");
- assertThat(tokenizer1.consume(reader, codeBuilder)).isTrue();
- reader.pop();
- assertThat(tokenizer2.consume(reader, codeBuilder)).isFalse();
- }
-
- public class MultiLineDocTokenizerImpl extends MultilinesDocTokenizer {
- public MultiLineDocTokenizerImpl(String startToken, String endToken) {
- super(startToken, endToken, "", "");
- }
- }
-
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/RegexpTokenizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/RegexpTokenizerTest.java
deleted file mode 100644
index 3f9893e9209..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/RegexpTokenizerTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.colorizer.SyntaxHighlighterTestingHarness.highlight;
-
-public class RegexpTokenizerTest {
-
- RegexpTokenizer tokenHighlighter;
- ;
-
- @Test
- public void testHighlight() {
- tokenHighlighter = new RegexpTokenizer("<r>", "</r>", "[0-9]+");
- assertThat(highlight("123, word = 435;", tokenHighlighter)).isEqualTo("<r>123</r>, word = <r>435</r>;");
- }
-
- @Test
- public void testClone() {
- RegexpTokenizer tokenizer = new RegexpTokenizer("<r>", "</r>", "[a-z]+");
- RegexpTokenizer cloneTokenizer = tokenizer.clone();
- assertThat(tokenizer).isNotEqualTo(cloneTokenizer);
- assertThat(highlight("public 1234", cloneTokenizer)).isEqualTo("<r>public</r> 1234");
- }
-
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/SyntaxHighlighterTestingHarness.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/SyntaxHighlighterTestingHarness.java
deleted file mode 100644
index 36ed546ef96..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/SyntaxHighlighterTestingHarness.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.sonar.channel.Channel;
-
-public class SyntaxHighlighterTestingHarness {
-
- public static String highlight(String input, Channel<HtmlCodeBuilder> tokenHighlighter) {
- TokenizerDispatcher syntaxHighlighter = new TokenizerDispatcher(tokenHighlighter);
- return syntaxHighlighter.colorize(input);
- }
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/TokenizerDispatcherTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/TokenizerDispatcherTest.java
deleted file mode 100644
index 4da76a7bf83..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/TokenizerDispatcherTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import org.junit.Test;
-import org.sonar.channel.Channel;
-import org.sonar.channel.CodeReader;
-
-import java.util.Arrays;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class TokenizerDispatcherTest {
-
- @Test
- public void testPipeCodeTokenizer() {
- TokenizerDispatcher colorization = newColorizer();
- assertThat(colorization.colorize("public void get(){")).isEqualTo("public void get(){");
- }
-
- @Test
- public void testKeywordsCodeTokenizer() {
- TokenizerDispatcher colorization = newColorizer(new KeywordsTokenizer("<k>", "</k>", JavaKeywords.get()));
- assertThat(colorization.colorize("public void get(){")).isEqualTo("<k>public</k> <k>void</k> get(){");
- }
-
- @Test
- public void testPriorityToComment() {
- TokenizerDispatcher colorization = newColorizer(new CDocTokenizer("<c>", "</c>"), new KeywordsTokenizer("<k>", "</k>", JavaKeywords
- .get()));
- assertThat(colorization.colorize("assert //public void get(){")).isEqualTo("<k>assert</k> <c>//public void get(){</c>");
- }
-
- @Test
- public void testCommentThenStringThenJavaKeywords() {
- TokenizerDispatcher colorization = newColorizer(new CDocTokenizer("<c>", "</c>"), new LiteralTokenizer("<s>", "</s>"),
- new KeywordsTokenizer("<k>", "</k>", JavaKeywords.get()));
- assertThat(colorization.colorize("assert(\"message\"); //comment")).isEqualTo("<k>assert</k>(<s>\"message\"</s>); <c>//comment</c>");
- }
-
- @Test(expected = IllegalStateException.class)
- public void testCloneNotThreadSafeTokenizers() {
- NotThreadSafeTokenizer tokenizer = new NotThreadSafeTokenizer() {
-
- @Override
- public boolean consume(CodeReader code, HtmlCodeBuilder output) {
- output.append((char) code.pop());
- return true;
- }
-
- @Override
- public NotThreadSafeTokenizer clone() {
- throw new IllegalStateException("The clone method has been called as expected.");
- }
- };
- TokenizerDispatcher colorization = newColorizer(tokenizer);
- colorization.colorize("source code");
- }
-
- private TokenizerDispatcher newColorizer(Channel<HtmlCodeBuilder>... tokenizers) {
- return new TokenizerDispatcher(Arrays.asList(tokenizers));
- }
-}
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/UserGuideTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/UserGuideTest.java
deleted file mode 100644
index ae380273855..00000000000
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/UserGuideTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.colorizer;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.Reader;
-
-import org.apache.commons.io.FileUtils;
-import org.junit.Test;
-
-public class UserGuideTest {
-
- @Test
- public void javaToHtml() throws IOException {
- Reader java = readFile("/org/sonar/colorizer/samples/Sample.java");
-
- String html = CodeColorizer.javaToHtml(java, HtmlOptions.DEFAULT);
-
- save(html, "Sample.java.html");
- }
-
- @Test
- public void groovyToHtml() throws IOException {
- Reader groovy = readFile("/org/sonar/colorizer/samples/Sample.groovy");
-
- String html = CodeColorizer.groovyToHtml(groovy, HtmlOptions.DEFAULT);
-
- save(html, "Sample.groovy.html");
- }
-
- @Test
- public void customizeOutput() throws IOException {
- Reader java = readFile("/org/sonar/colorizer/samples/Sample.java");
-
- // generate only the <table> element, without including the CSS and the HTML header
- HtmlOptions options = new HtmlOptions(true, "my-table-id", false);
- String html = CodeColorizer.javaToHtml(java, options);
-
- save(html, "CustomizeOutput.java.html");
- }
-
- @Test
- public void defineNewLanguage() {
-
- }
-
- private FileReader readFile(String path) throws FileNotFoundException {
- return new FileReader(FileUtils.toFile(getClass().getResource(path)));
- }
-
- private void save(String html, String filename) throws IOException {
- File output = new File("target/userguide/" + filename);
- FileUtils.writeStringToFile(output, html);
- System.out.println("HTML sample saved to: " + output.getAbsolutePath());
- }
-}
diff --git a/sonar-colorizer/src/test/resources/org/sonar/colorizer/HtmlRendererTest/Sample.java b/sonar-colorizer/src/test/resources/org/sonar/colorizer/HtmlRendererTest/Sample.java
deleted file mode 100644
index f2377b733f5..00000000000
--- a/sonar-colorizer/src/test/resources/org/sonar/colorizer/HtmlRendererTest/Sample.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.sonar.colorizer.colorizer.HtmlRendererTest;
-
-public class Sample {
-
- /**
- * some javadoc
- *
- * @return foo
- */
- @Deprecated
- public String foo(String bar) {
- if (true) {
- return "foo";
- }
- return "bar";
- }
-}
diff --git a/sonar-colorizer/src/test/resources/org/sonar/colorizer/samples/Sample.groovy b/sonar-colorizer/src/test/resources/org/sonar/colorizer/samples/Sample.groovy
deleted file mode 100644
index 70de12a2e30..00000000000
--- a/sonar-colorizer/src/test/resources/org/sonar/colorizer/samples/Sample.groovy
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- comment
- */
-@Deprecated
-class Greet {
- def name
- Greet(who) { name = who[0].toUpperCase() +
- who[1..-1] }
- def salute() { println "Hello $name!" }
-}
-
-g = new Greet('world') // create object
-g.salute() // Output "Hello World!"
diff --git a/sonar-colorizer/src/test/resources/org/sonar/colorizer/samples/Sample.java b/sonar-colorizer/src/test/resources/org/sonar/colorizer/samples/Sample.java
deleted file mode 100644
index 2480c7afce4..00000000000
--- a/sonar-colorizer/src/test/resources/org/sonar/colorizer/samples/Sample.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.sonar.colorizer.samples;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Target;
-import java.net.URL;
-
-/*
- * NOT javadoc, for example license header
-*/
-public class Sample {
-
- private static final double NUMBER = 3.1415;
- private static final double INTEGER = 77;
-
- /**
- * some javadoc
- *
- * @return foo
- */
- @Deprecated
- public String foo(String bar) {
- // single-line comment
- if (true) {
- return "foo";
- }
-
- String backslashes = "";
- backslashes.replaceAll("\\(", "(\"").replaceAll("\\)", "\")");
-
- /*
- Multi-lines comment
- */
- return "bar";
- }
-
- /**
- * Special HTML characters in code : <code>foo</code>
- */
- public void specialHtmlCharacters() {
- String special = "<html> <<";
- }
-
-
- public native void nativeMethod() /*-{
- Window.alert('this is javascript');
- }-*/;
-}
-
-@Target(ElementType.METHOD)
- @interface Foo {
-
-}
diff --git a/sonar-colorizer/src/test/resources/org/sonar/colorizer/samples/SampleWithComments.java b/sonar-colorizer/src/test/resources/org/sonar/colorizer/samples/SampleWithComments.java
deleted file mode 100644
index d132e7597c6..00000000000
--- a/sonar-colorizer/src/test/resources/org/sonar/colorizer/samples/SampleWithComments.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.sonar.colorizer.samples;
-
-public class SampleWithComments {
-
- /*
- * This method does <b>something</b>
- *
- * &lt;p&gt;description&lt;/p&gt;
- */
-
- public void doSomething() {
- }
-
-}
diff --git a/sonar-colorizer/src/test/resources/org/sonar/colorizer/samples/SingleLine.java b/sonar-colorizer/src/test/resources/org/sonar/colorizer/samples/SingleLine.java
deleted file mode 100644
index bb24835cc0d..00000000000
--- a/sonar-colorizer/src/test/resources/org/sonar/colorizer/samples/SingleLine.java
+++ /dev/null
@@ -1 +0,0 @@
-package org.sonar.colorizer.samples;
diff --git a/sonar-plugin-api/pom.xml b/sonar-plugin-api/pom.xml
index a982696bda0..6ce34e9f521 100644
--- a/sonar-plugin-api/pom.xml
+++ b/sonar-plugin-api/pom.xml
@@ -69,17 +69,6 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>sonar-colorizer</artifactId>
- <version>${project.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
<artifactId>sonar-duplications</artifactId>
<version>${project.version}</version>
<exclusions>
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/CodeColorizerFormat.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/CodeColorizerFormat.java
deleted file mode 100644
index 30a8cca29fd..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/CodeColorizerFormat.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.web;
-
-import com.google.common.base.MoreObjects;
-import java.util.List;
-import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.api.task.TaskExtension;
-import org.sonar.colorizer.Tokenizer;
-
-/**
- * Extend the library sonar-colorizer to support new languages.
- *
- * @since 1.12
- * @deprecated since 4.5.2 use {@link SensorContext#newHighlighting()}
- */
-@Deprecated
-public abstract class CodeColorizerFormat implements TaskExtension {
-
- private String languageKey;
-
- /**
- * @param languageKey the unique sonar key. Not null.
- */
- protected CodeColorizerFormat(String languageKey) {
- this.languageKey = languageKey;
- }
-
- public final String getLanguageKey() {
- return languageKey;
- }
-
- /**
- * sonar-colorizer tokenizers for HTML output.
- *
- * @return a not null list (empty if no tokenizers)
- */
- public abstract List<Tokenizer> getTokenizers();
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof CodeColorizerFormat)) {
- return false;
- }
-
- CodeColorizerFormat format = (CodeColorizerFormat) o;
- return languageKey.equals(format.languageKey);
-
- }
-
- @Override
- public int hashCode() {
- return languageKey.hashCode();
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("lang", languageKey)
- .toString();
- }
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/web/CodeColorizerFormatTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/web/CodeColorizerFormatTest.java
deleted file mode 100644
index 1bb318a0e73..00000000000
--- a/sonar-plugin-api/src/test/java/org/sonar/api/web/CodeColorizerFormatTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.web;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.junit.Test;
-import org.sonar.colorizer.Tokenizer;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class CodeColorizerFormatTest {
-
- @Test
- public void keyIsLanguage() {
- CodeColorizerFormat format = new FakeFormat("foo");
- assertThat(format.getLanguageKey()).isEqualTo("foo");
-
- assertThat(format.equals(new FakeFormat("foo"))).isTrue();
- assertThat(format.equals(new FakeFormat("bar"))).isFalse();
- assertThat(format.hashCode()).isEqualTo(format.hashCode());
- assertThat(format.hashCode()).isEqualTo(new FakeFormat("foo").hashCode());
- assertThat(format.toString()).isEqualTo("FakeFormat{lang=foo}");
- }
-
- private static class FakeFormat extends CodeColorizerFormat {
-
- public FakeFormat(String languageKey) {
- super(languageKey);
- }
-
- @Override
- public List<Tokenizer> getTokenizers() {
- return Collections.emptyList();
- }
- }
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java
index 8b6d40dd18b..94536420f0c 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java
@@ -39,7 +39,6 @@ import org.sonar.scanner.scan.report.RuleNameProvider;
import org.sonar.scanner.scan.report.SourceProvider;
import org.sonar.scanner.scm.ScmConfiguration;
import org.sonar.scanner.scm.ScmPublisher;
-import org.sonar.scanner.source.CodeColorizerSensor;
import org.sonar.scanner.source.ZeroCoverageSensor;
import org.sonar.scanner.task.ListTask;
import org.sonar.scanner.task.ScanTask;
@@ -67,7 +66,6 @@ public class BatchComponents {
components.add(ScmPublisher.class);
components.add(ZeroCoverageSensor.class);
- components.add(CodeColorizerSensor.class);
// CPD
components.addAll(CpdComponents.all());
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
index e905184a0ed..aede44cda81 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
@@ -92,7 +92,6 @@ import org.sonar.scanner.scan.filesystem.InputComponentStore;
import org.sonar.scanner.scan.measure.DefaultMetricFinder;
import org.sonar.scanner.scan.measure.DeprecatedMetricFinder;
import org.sonar.scanner.scan.measure.MeasureCache;
-import org.sonar.scanner.source.CodeColorizers;
import org.sonar.scanner.storage.Storages;
public class ProjectScanContainer extends ComponentContainer {
@@ -136,7 +135,6 @@ public class ProjectScanContainer extends ComponentContainer {
PhasesTimeProfiler.class,
ResourceTypes.class,
ProjectReactorValidator.class,
- CodeColorizers.class,
MetricProvider.class,
ProjectAnalysisInfo.class,
DefaultIndex.class,
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/CodeColorizerSensor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/CodeColorizerSensor.java
deleted file mode 100644
index 97a9f5f30d1..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/CodeColorizerSensor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.scanner.source;
-
-import org.sonar.api.batch.Phase;
-import org.sonar.api.batch.fs.FileSystem;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.sensor.Sensor;
-import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.api.batch.sensor.SensorDescriptor;
-import org.sonar.scanner.protocol.output.ScannerReportReader;
-import org.sonar.scanner.report.ReportPublisher;
-
-@Phase(name = Phase.Name.POST)
-public final class CodeColorizerSensor implements Sensor {
-
- private final ReportPublisher reportPublisher;
- private final CodeColorizers codeColorizers;
-
- public CodeColorizerSensor(ReportPublisher reportPublisher, CodeColorizers codeColorizers) {
- this.reportPublisher = reportPublisher;
- this.codeColorizers = codeColorizers;
- }
-
- @Override
- public void describe(SensorDescriptor descriptor) {
- descriptor.name("Code Colorizer Sensor")
- .global();
- }
-
- @Override
- public void execute(final SensorContext context) {
- FileSystem fs = context.fileSystem();
- for (InputFile f : fs.inputFiles(fs.predicates().all())) {
- ScannerReportReader reader = new ScannerReportReader(reportPublisher.getReportDir());
- DefaultInputFile inputFile = (DefaultInputFile) f;
- String language = f.language();
- if (reader.hasSyntaxHighlighting(inputFile.batchId()) || language == null) {
- continue;
- }
- codeColorizers.toSyntaxHighlighting(f.file(), fs.encoding(), language, context.newHighlighting().onFile(f));
- }
- }
-
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/CodeColorizers.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/CodeColorizers.java
deleted file mode 100644
index abe3acd642b..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/CodeColorizers.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.scanner.source;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.annotation.CheckForNull;
-import org.apache.commons.io.input.BOMInputStream;
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.batch.ScannerSide;
-import org.sonar.api.batch.sensor.highlighting.NewHighlighting;
-import org.sonar.api.utils.log.Loggers;
-import org.sonar.api.web.CodeColorizerFormat;
-import org.sonar.colorizer.JavaTokenizers;
-import org.sonar.colorizer.Tokenizer;
-
-/**
- * Central point for sonar-colorizer extensions
- */
-@ScannerSide
-public class CodeColorizers {
-
- private static final org.sonar.api.utils.log.Logger LOG = Loggers.get(CodeColorizers.class);
-
- private final Map<String, CodeColorizerFormat> byLang;
-
- public CodeColorizers(List<CodeColorizerFormat> formats) {
- byLang = new HashMap<>();
- for (CodeColorizerFormat format : formats) {
- byLang.put(format.getLanguageKey(), format);
- }
-
- LOG.debug(() -> "Code colorizer, supported languages: " + StringUtils.join(byLang.keySet(), ","));
- }
-
- /**
- * Used when no plugin is defining some CodeColorizerFormat
- */
- public CodeColorizers() {
- this(new ArrayList<>());
- }
-
- @CheckForNull
- public void toSyntaxHighlighting(File file, Charset charset, String language, NewHighlighting highlighting) {
- CodeColorizerFormat format = byLang.get(language);
- List<Tokenizer> tokenizers;
- if (format == null) {
- // Workaround for Java test code since Java plugin only provides highlighting for main source and no colorizer
- // TODO can be dropped when Java plugin embed its own CodeColorizerFormat or (better) provides highlighting for tests
- // See SONARJAVA-830
- if ("java".equals(language)) {
- tokenizers = JavaTokenizers.forHtml();
- } else {
- return;
- }
- } else {
- tokenizers = format.getTokenizers();
- }
- try (Reader reader = new BufferedReader(new InputStreamReader(new BOMInputStream(new FileInputStream(file)), charset))) {
- new HighlightingRenderer().render(reader, tokenizers, highlighting);
- } catch (Exception e) {
- LOG.warn("Unable to perform colorization of file " + file, e);
- }
- }
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/HighlightingCodeBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/HighlightingCodeBuilder.java
deleted file mode 100644
index 75a4edebeb9..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/HighlightingCodeBuilder.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.scanner.source;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.batch.sensor.highlighting.NewHighlighting;
-import org.sonar.api.batch.sensor.highlighting.TypeOfText;
-import org.sonar.colorizer.HtmlCodeBuilder;
-
-public class HighlightingCodeBuilder extends HtmlCodeBuilder {
-
- private static final Logger LOG = LoggerFactory.getLogger(HighlightingCodeBuilder.class);
-
- private int currentOffset = 0;
- private static final Pattern START_TAG_PATTERN = Pattern.compile("<span class=\"(.+)\">");
- private static final Pattern END_TAG_PATTERN = Pattern.compile("</span>");
- private int startOffset = -1;
- private String cssClass;
- private final NewHighlighting highlighting;
-
- public HighlightingCodeBuilder(NewHighlighting highlighting) {
- this.highlighting = highlighting;
- }
-
- @Override
- public Appendable append(CharSequence csq) {
- for (int i = 0; i < csq.length(); i++) {
- append(csq.charAt(i));
- }
- return this;
- }
-
- @Override
- public Appendable append(char c) {
- currentOffset++;
- return this;
- }
-
- @Override
- public void appendWithoutTransforming(String htmlTag) {
- if (startOffset == -1) {
- Matcher startMatcher = START_TAG_PATTERN.matcher(htmlTag);
- if (startMatcher.matches()) {
- startOffset = currentOffset;
- cssClass = startMatcher.group(1);
- } else {
- LOG.warn("Expected to match highlighting start html tag but was: {}", htmlTag);
- }
- } else {
- Matcher endMatcher = END_TAG_PATTERN.matcher(htmlTag);
- if (endMatcher.matches()) {
- highlighting.highlight(startOffset, currentOffset, TypeOfText.forCssClass(cssClass));
- startOffset = -1;
- } else {
- LOG.warn("Expected to match highlighting end html tag but was: {}", htmlTag);
- }
- }
- }
-
- @Override
- public String toString() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public StringBuilder getColorizedCode() {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/HighlightingRenderer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/HighlightingRenderer.java
deleted file mode 100644
index fad4a1a53be..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/HighlightingRenderer.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.scanner.source;
-
-import org.sonar.api.batch.sensor.highlighting.NewHighlighting;
-import org.sonar.channel.Channel;
-import org.sonar.channel.CodeReader;
-import org.sonar.colorizer.HtmlCodeBuilder;
-import org.sonar.colorizer.TokenizerDispatcher;
-
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.List;
-
-public class HighlightingRenderer {
-
- public void render(Reader code, List<? extends Channel<HtmlCodeBuilder>> tokenizers, NewHighlighting highlighting) {
- List<Channel<HtmlCodeBuilder>> allTokenizers = new ArrayList<>();
- HighlightingCodeBuilder codeBuilder = new HighlightingCodeBuilder(highlighting);
-
- allTokenizers.addAll(tokenizers);
-
- new TokenizerDispatcher(allTokenizers).colorize(new CodeReader(code), codeBuilder);
- highlighting.save();
- }
-}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/source/CodeColorizersTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/source/CodeColorizersTest.java
deleted file mode 100644
index 71339df7a61..00000000000
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/source/CodeColorizersTest.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.scanner.source;
-
-import com.google.common.collect.ImmutableList;
-import java.io.File;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import org.apache.commons.io.FileUtils;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.api.batch.fs.internal.FileMetadata;
-import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
-import org.sonar.api.batch.sensor.highlighting.NewHighlighting;
-import org.sonar.api.batch.sensor.highlighting.TypeOfText;
-import org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting;
-import org.sonar.api.batch.sensor.internal.SensorStorage;
-import org.sonar.api.web.CodeColorizerFormat;
-import org.sonar.colorizer.CDocTokenizer;
-import org.sonar.colorizer.CppDocTokenizer;
-import org.sonar.colorizer.JavadocTokenizer;
-import org.sonar.colorizer.KeywordsTokenizer;
-import org.sonar.colorizer.MultilinesDocTokenizer;
-import org.sonar.colorizer.RegexpTokenizer;
-import org.sonar.colorizer.StringTokenizer;
-import org.sonar.colorizer.Tokenizer;
-import org.sonar.scanner.source.CodeColorizers;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.tuple;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-public class CodeColorizersTest {
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- @Test
- public void testConvertToHighlighting() throws Exception {
- CodeColorizers codeColorizers = new CodeColorizers(Arrays.<CodeColorizerFormat>asList(new JavaScriptColorizerFormat(), new WebCodeColorizerFormat()));
- File jsFile = new File(this.getClass().getResource("CodeColorizersTest/Person.js").toURI());
- NewHighlighting highlighting = mock(NewHighlighting.class);
-
- codeColorizers.toSyntaxHighlighting(jsFile, StandardCharsets.UTF_8, "js", highlighting);
-
- verifyForJs(highlighting);
- }
-
- private void verifyForJs(NewHighlighting highlighting) {
- verify(highlighting).highlight(0, 4, TypeOfText.CPP_DOC);
- verify(highlighting).highlight(5, 11, TypeOfText.CPP_DOC);
- verify(highlighting).highlight(12, 15, TypeOfText.CPP_DOC);
- verify(highlighting).highlight(16, 19, TypeOfText.KEYWORD);
- verify(highlighting).highlight(29, 37, TypeOfText.KEYWORD);
- verify(highlighting).highlight(65, 69, TypeOfText.KEYWORD);
- verify(highlighting).highlight(85, 93, TypeOfText.COMMENT);
- verify(highlighting).highlight(98, 102, TypeOfText.KEYWORD);
- verify(highlighting).highlight(112, 114, TypeOfText.STRING);
- verify(highlighting).highlight(120, 124, TypeOfText.KEYWORD);
- }
-
- @Test
- public void testConvertToHighlightingIgnoreBOM() throws Exception {
- CodeColorizers codeColorizers = new CodeColorizers(Arrays.<CodeColorizerFormat>asList(new JavaScriptColorizerFormat(), new WebCodeColorizerFormat()));
-
- File fileWithBom = temp.newFile();
- FileUtils.write(fileWithBom, "\uFEFF", "UTF-8");
- File jsFile = new File(this.getClass().getResource("CodeColorizersTest/Person.js").toURI());
- FileUtils.write(fileWithBom, FileUtils.readFileToString(jsFile), "UTF-8", true);
-
- NewHighlighting highlighting = mock(NewHighlighting.class);
- codeColorizers.toSyntaxHighlighting(fileWithBom, StandardCharsets.UTF_8, "js", highlighting);
-
- verifyForJs(highlighting);
- }
-
- @Test
- public void shouldSupportJavaIfNotProvidedByJavaPluginForBackwardCompatibility() throws Exception {
- CodeColorizers codeColorizers = new CodeColorizers(Arrays.<CodeColorizerFormat>asList());
-
- File javaFile = new File(this.getClass().getResource("CodeColorizersTest/Person.java").toURI());
-
- NewHighlighting highlighting = mock(NewHighlighting.class);
- codeColorizers.toSyntaxHighlighting(javaFile, StandardCharsets.UTF_8, "java", highlighting);
-
- verify(highlighting).highlight(0, 4, TypeOfText.STRUCTURED_COMMENT);
- verify(highlighting).highlight(5, 11, TypeOfText.STRUCTURED_COMMENT);
- verify(highlighting).highlight(12, 15, TypeOfText.STRUCTURED_COMMENT);
- verify(highlighting).highlight(16, 22, TypeOfText.KEYWORD);
- verify(highlighting).highlight(23, 28, TypeOfText.KEYWORD);
- verify(highlighting).highlight(43, 50, TypeOfText.KEYWORD);
- verify(highlighting).highlight(51, 54, TypeOfText.KEYWORD);
- verify(highlighting).highlight(67, 78, TypeOfText.ANNOTATION);
- verify(highlighting).highlight(81, 87, TypeOfText.KEYWORD);
- verify(highlighting).highlight(88, 92, TypeOfText.KEYWORD);
- verify(highlighting).highlight(97, 100, TypeOfText.KEYWORD);
- verify(highlighting).highlight(142, 146, TypeOfText.KEYWORD);
- verify(highlighting).highlight(162, 170, TypeOfText.COMMENT);
- }
-
- @Test
- public void testConvertHtmlToHighlightingWithMacEoL() throws Exception {
- CodeColorizers codeColorizers = new CodeColorizers(Arrays.<CodeColorizerFormat>asList(new JavaScriptColorizerFormat(), new WebCodeColorizerFormat()));
- File htmlFile = new File(this.getClass().getResource("CodeColorizersTest/package.html").toURI());
- SensorStorage sensorStorage = mock(SensorStorage.class);
- DefaultHighlighting highlighting = new DefaultHighlighting(sensorStorage);
- highlighting.onFile(new TestInputFileBuilder("FOO", "package.html")
- .setMetadata(new FileMetadata().readMetadata(htmlFile, StandardCharsets.UTF_8))
- .build());
-
- codeColorizers.toSyntaxHighlighting(htmlFile, StandardCharsets.UTF_8, "web", highlighting);
-
- assertThat(highlighting.getSyntaxHighlightingRuleSet()).extracting("range.start.line", "range.start.lineOffset", "range.end.line", "range.end.lineOffset", "textType")
- .containsExactly(
- tuple(1, 0, 1, 132, TypeOfText.STRUCTURED_COMMENT),
- tuple(2, 0, 2, 6, TypeOfText.KEYWORD),
- tuple(3, 0, 3, 3, TypeOfText.KEYWORD),
- tuple(4, 0, 4, 3, TypeOfText.KEYWORD),
- // SONARWEB-26
- tuple(5, 42, 12, 0, TypeOfText.STRING));
- }
-
- public static class JavaScriptColorizerFormat extends CodeColorizerFormat {
-
- public JavaScriptColorizerFormat() {
- super("js");
- }
-
- @Override
- public List<Tokenizer> getTokenizers() {
- return ImmutableList.<Tokenizer>of(
- new StringTokenizer("<span class=\"s\">", "</span>"),
- new CDocTokenizer("<span class=\"cd\">", "</span>"),
- new JavadocTokenizer("<span class=\"cppd\">", "</span>"),
- new CppDocTokenizer("<span class=\"cppd\">", "</span>"),
- new KeywordsTokenizer("<span class=\"k\">", "</span>", "null",
- "true",
- "false",
- "break",
- "case",
- "catch",
- "class",
- "continue",
- "debugger",
- "default",
- "delete",
- "do",
- "extends",
- "else",
- "finally",
- "for",
- "function",
- "if",
- "import",
- "in",
- "instanceof",
- "new",
- "return",
- "super",
- "switch",
- "this",
- "throw",
- "try",
- "typeof",
- "var",
- "void",
- "while",
- "with",
- "yield",
- "const",
- "enum",
- "export"));
- }
-
- }
-
- public class WebCodeColorizerFormat extends CodeColorizerFormat {
-
- private final List<Tokenizer> tokenizers = new ArrayList<>();
-
- public WebCodeColorizerFormat() {
- super("web");
- String tagAfter = "</span>";
-
- // == tags ==
- tokenizers.add(new RegexpTokenizer("<span class=\"k\">", tagAfter, "</?[:\\w]+>?"));
- tokenizers.add(new RegexpTokenizer("<span class=\"k\">", tagAfter, ">"));
-
- // == doctype ==
- tokenizers.add(new RegexpTokenizer("<span class=\"j\">", tagAfter, "<!DOCTYPE.*>"));
-
- // == comments ==
- tokenizers.add(new MultilinesDocTokenizer("<!--", "-->", "<span class=\"j\">", tagAfter));
- tokenizers.add(new MultilinesDocTokenizer("<%--", "--%>", "<span class=\"j\">", tagAfter));
-
- // == expressions ==
- tokenizers.add(new MultilinesDocTokenizer("<%@", "%>", "<span class=\"a\">", tagAfter));
- tokenizers.add(new MultilinesDocTokenizer("<%", "%>", "<span class=\"a\">", tagAfter));
-
- // == tag properties ==
- tokenizers.add(new StringTokenizer("<span class=\"s\">", tagAfter));
- }
-
- @Override
- public List<Tokenizer> getTokenizers() {
- return tokenizers;
- }
-
- }
-
-}
diff --git a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/source/CodeColorizersTest/Person.java b/sonar-scanner-engine/src/test/resources/org/sonar/scanner/source/CodeColorizersTest/Person.java
deleted file mode 100644
index c5cc9793730..00000000000
--- a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/source/CodeColorizersTest/Person.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * Doc
- */
-public class Person {
-
- private int first;
-
- @Deprecated
- public void foo(int first, String last, Double middle) {
- this.first = first; // First
- }
-}
diff --git a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/source/CodeColorizersTest/Person.js b/sonar-scanner-engine/src/test/resources/org/sonar/scanner/source/CodeColorizersTest/Person.js
deleted file mode 100644
index fc36e5aa127..00000000000
--- a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/source/CodeColorizersTest/Person.js
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- * Doc
- */
-var Person = function(first, last, middle) {
- this.first = first; // First
- this.middle = '';
- this.last = 1;
-};
diff --git a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/source/CodeColorizersTest/package.html b/sonar-scanner-engine/src/test/resources/org/sonar/scanner/source/CodeColorizersTest/package.html
deleted file mode 100644
index f2d90e627d6..00000000000
--- a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/source/CodeColorizersTest/package.html
+++ /dev/null
@@ -1 +0,0 @@
-<!-- $Header: /cvshome/build/org.osgi.service.log/src/org/osgi/service/log/package.html,v 1.3 2005/08/10 01:43:20 hargrave Exp $ --> <BODY> <P>The OSGi Log Service Package. Specification Version 1.3. <p>Bundles wishing to use this package must list the package in the Import-Package header of the bundle's manifest. For example: <pre> Import-Package: org.osgi.service.log; version=1.3 </pre> </BODY> \ No newline at end of file