aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
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 /sonar-scanner-engine
parent77cf76d3531ea6cdd5f7b60808ac00867e902c58 (diff)
downloadsonarqube-6a03df65cc0c91a26150ea172a2c480e07326ea1.tar.gz
sonarqube-6a03df65cc0c91a26150ea172a2c480e07326ea1.zip
SONAR-7860 Remove CodeColorizerFormat API
Diffstat (limited to 'sonar-scanner-engine')
-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
10 files changed, 0 insertions, 543 deletions
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