From 5e0a5c49081f3bf6003b9c3fedd8aec60523c8b4 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Vilain Date: Tue, 7 May 2013 09:29:27 +0200 Subject: [PATCH] SONAR-3893 Removed deprecated classes and perspectives --- .../batch/scan/ProjectScanContainer.java | 5 +- .../scan/source/DefaultHighlightable.java | 69 -------- .../batch/scan/source/DefaultSymbol.java | 86 ---------- .../scan/source/DefaultSymbolPerspective.java | 71 --------- .../scan/source/HighlightableBuilder.java | 62 -------- .../scan/source/SymbolDataRepository.java | 97 ----------- .../scan/source/SymbolPerspectiveBuilder.java | 41 ----- .../scan/source/SyntaxHighlightingRule.java | 52 ------ .../source/SyntaxHighlightingRuleSet.java | 150 ------------------ .../sonar/batch/scan/source/package-info.java | 23 --- .../scan/source/DefaultHighlightableTest.java | 60 ------- .../source/DefaultSymbolPerspectiveTest.java | 68 -------- .../batch/scan/source/DefaultSymbolTest.java | 45 ------ .../scan/source/HighlightableBuilderTest.java | 68 -------- .../scan/source/SymbolDataRepositoryTest.java | 76 --------- .../source/SymbolPerspectiveBuilderTest.java | 46 ------ .../source/SyntaxHighlightingRuleSetTest.java | 84 ---------- .../sonar/api/scan/source/Highlightable.java | 38 ----- .../org/sonar/api/scan/source/Symbol.java | 31 ---- .../api/scan/source/SymbolPerspective.java | 55 ------- .../sonar/api/scan/source/package-info.java | 24 --- 21 files changed, 1 insertion(+), 1250 deletions(-) delete mode 100644 sonar-batch/src/main/java/org/sonar/batch/scan/source/DefaultHighlightable.java delete mode 100644 sonar-batch/src/main/java/org/sonar/batch/scan/source/DefaultSymbol.java delete mode 100644 sonar-batch/src/main/java/org/sonar/batch/scan/source/DefaultSymbolPerspective.java delete mode 100644 sonar-batch/src/main/java/org/sonar/batch/scan/source/HighlightableBuilder.java delete mode 100644 sonar-batch/src/main/java/org/sonar/batch/scan/source/SymbolDataRepository.java delete mode 100644 sonar-batch/src/main/java/org/sonar/batch/scan/source/SymbolPerspectiveBuilder.java delete mode 100644 sonar-batch/src/main/java/org/sonar/batch/scan/source/SyntaxHighlightingRule.java delete mode 100644 sonar-batch/src/main/java/org/sonar/batch/scan/source/SyntaxHighlightingRuleSet.java delete mode 100644 sonar-batch/src/main/java/org/sonar/batch/scan/source/package-info.java delete mode 100644 sonar-batch/src/test/java/org/sonar/batch/scan/source/DefaultHighlightableTest.java delete mode 100644 sonar-batch/src/test/java/org/sonar/batch/scan/source/DefaultSymbolPerspectiveTest.java delete mode 100644 sonar-batch/src/test/java/org/sonar/batch/scan/source/DefaultSymbolTest.java delete mode 100644 sonar-batch/src/test/java/org/sonar/batch/scan/source/HighlightableBuilderTest.java delete mode 100644 sonar-batch/src/test/java/org/sonar/batch/scan/source/SymbolDataRepositoryTest.java delete mode 100644 sonar-batch/src/test/java/org/sonar/batch/scan/source/SymbolPerspectiveBuilderTest.java delete mode 100644 sonar-batch/src/test/java/org/sonar/batch/scan/source/SyntaxHighlightingRuleSetTest.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/scan/source/Highlightable.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/scan/source/Symbol.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/scan/source/SymbolPerspective.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/scan/source/package-info.java diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java index e006f37bf37..c6dc6f927fe 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java @@ -40,8 +40,7 @@ import org.sonar.batch.phases.GraphPersister; import org.sonar.batch.profiling.PhasesSumUpTimeProfiler; import org.sonar.batch.scan.maven.FakeMavenPluginExecutor; import org.sonar.batch.scan.maven.MavenPluginExecutor; -import org.sonar.batch.scan.source.HighlightableBuilder; -import org.sonar.batch.scan.source.SymbolPerspectiveBuilder; +import org.sonar.batch.source.HighlightableBuilder; import org.sonar.batch.source.SymbolizableBuilder; import org.sonar.core.component.ScanGraph; import org.sonar.core.issue.IssueUpdater; @@ -111,8 +110,6 @@ public class ProjectScanContainer extends ComponentContainer { // lang HighlightableBuilder.class, - org.sonar.batch.source.HighlightableBuilder.class, - SymbolPerspectiveBuilder.class, SymbolizableBuilder.class); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/source/DefaultHighlightable.java b/sonar-batch/src/main/java/org/sonar/batch/scan/source/DefaultHighlightable.java deleted file mode 100644 index daa3bc3ce58..00000000000 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/source/DefaultHighlightable.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.batch.scan.source; - -import org.sonar.api.component.Component; -import org.sonar.api.scan.source.Highlightable; -import org.sonar.batch.index.ComponentDataCache; -import org.sonar.core.source.SnapshotDataType; - -/** - * @since 3.6 - */ -public class DefaultHighlightable implements Highlightable { - - private final Component component; - private final ComponentDataCache cache; - private final SyntaxHighlightingRuleSet.Builder builder; - - public DefaultHighlightable(Component component, ComponentDataCache cache) { - this.component = component; - this.cache = cache; - this.builder = SyntaxHighlightingRuleSet.builder(); - } - - @Override - public HighlightingBuilder newHighlighting() { - return new DefaultHighlightingBuilder(); - } - - @Override - public Component component() { - return component; - } - - public SyntaxHighlightingRuleSet getHighlightingRules() { - return builder.build(); - } - - private class DefaultHighlightingBuilder implements HighlightingBuilder { - - @Override - public HighlightingBuilder highlight(int startOffset, int endOffset, String typeOfText) { - builder.registerHighlightingRule(startOffset, endOffset, typeOfText); - return this; - } - - @Override - public void done() { - cache.setStringData(component().key(), SnapshotDataType.SYNTAX_HIGHLIGHTING.getValue(), builder.build().writeString()); - } - } -} diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/source/DefaultSymbol.java b/sonar-batch/src/main/java/org/sonar/batch/scan/source/DefaultSymbol.java deleted file mode 100644 index f66fe9cda07..00000000000 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/source/DefaultSymbol.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.batch.scan.source; - -import org.sonar.api.scan.source.Symbol; -import org.sonar.api.scan.source.SymbolPerspective; - -public class DefaultSymbol implements Symbol { - - private int declarationStartOffset; - private int declarationEndOffset; - private String fullyQualifiedName; - - private DefaultSymbol(int startOffset, int endOffset, String fullyQualifiedName) { - this.declarationStartOffset = startOffset; - this.declarationEndOffset = endOffset; - this.fullyQualifiedName = fullyQualifiedName; - } - - public static Builder builder(SymbolDataRepository dataRepository) { - return new Builder(dataRepository); - } - - public int getDeclarationStartOffset() { - return declarationStartOffset; - } - - public int getDeclarationEndOffset() { - return declarationEndOffset; - } - - public String getFullyQualifiedName() { - return fullyQualifiedName; - } - - public static class Builder implements SymbolPerspective.SymbolBuilder { - - private int declarationStartOffset; - private int declarationEndOffset; - private String fullyQualifiedName; - private final SymbolDataRepository dataRepository; - - - public Builder(SymbolDataRepository dataRepository) { - this.dataRepository = dataRepository; - } - - @Override - public SymbolPerspective.SymbolBuilder setDeclaration(int startOffset, int endOffset) { - this.declarationStartOffset = startOffset; - this.declarationEndOffset = endOffset; - return this; - } - - @Override - public SymbolPerspective.SymbolBuilder setFullyQualifiedName(String fullyQualifiedName) { - this.fullyQualifiedName = fullyQualifiedName; - return this; - } - - @Override - public Symbol build() { - Symbol symbol = new DefaultSymbol(declarationStartOffset, declarationEndOffset, fullyQualifiedName); - dataRepository.registerSymbol(symbol); - return symbol; - } - } -} diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/source/DefaultSymbolPerspective.java b/sonar-batch/src/main/java/org/sonar/batch/scan/source/DefaultSymbolPerspective.java deleted file mode 100644 index 96e29ac5072..00000000000 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/source/DefaultSymbolPerspective.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.batch.scan.source; - -import org.sonar.api.component.Component; -import org.sonar.api.scan.source.Symbol; -import org.sonar.api.scan.source.SymbolPerspective; -import org.sonar.batch.index.ComponentDataCache; -import org.sonar.core.source.SnapshotDataType; - -public class DefaultSymbolPerspective implements SymbolPerspective { - - private final ComponentDataCache cache; - private final Component component; - private final SymbolDataRepository symbolDataRepository; - - public DefaultSymbolPerspective(ComponentDataCache cache, Component component, SymbolDataRepository symbolDataRepository) { - this.cache = cache; - this.component = component; - this.symbolDataRepository = symbolDataRepository; - } - - @Override - public SymbolPerspective begin() { - return this; - } - - @Override - public SymbolBuilder newSymbol() { - return new DefaultSymbol.Builder(symbolDataRepository); - } - - @Override - public ReferencesBuilder declareReferences(final Symbol symbol) { - return new ReferencesBuilder() { - @Override - public ReferencesBuilder addReference(int startOffset) { - symbolDataRepository.registerSymbolReference(symbol, startOffset); - return this; - } - }; - } - - @Override - public void end() { - cache.setStringData(component().key(), SnapshotDataType.SYMBOL_HIGHLIGHTING.getValue(), symbolDataRepository.writeString()); - } - - @Override - public Component component() { - return component; - } -} diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/source/HighlightableBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/scan/source/HighlightableBuilder.java deleted file mode 100644 index 0f04f64ba5d..00000000000 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/source/HighlightableBuilder.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.batch.scan.source; - -import com.google.common.collect.ImmutableSet; -import org.sonar.api.component.Component; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; -import org.sonar.api.scan.source.Highlightable; -import org.sonar.batch.index.ComponentDataCache; -import org.sonar.core.component.PerspectiveBuilder; -import org.sonar.core.component.ResourceComponent; - -import javax.annotation.CheckForNull; - -import java.util.Set; - -/** - * @since 3.6 - */ -public class HighlightableBuilder extends PerspectiveBuilder { - - private static final Set SUPPORTED_QUALIFIERS = ImmutableSet.of(Qualifiers.FILE, Qualifiers.CLASS, Qualifiers.UNIT_TEST_FILE); - private final ComponentDataCache cache; - - public HighlightableBuilder(ComponentDataCache cache) { - super(Highlightable.class); - this.cache = cache; - } - - @CheckForNull - @Override - protected Highlightable loadPerspective(Class perspectiveClass, Component component) { - boolean supported = SUPPORTED_QUALIFIERS.contains(component.qualifier()); - if (supported && component instanceof ResourceComponent) { - // temporary hack waiting for the removal of JavaClass. - // JavaClass has the same qualifier than JavaFile, so they have to distinguished by their scope - supported = Scopes.FILE.equals(((ResourceComponent) component).scope()); - } - if (supported) { - return new DefaultHighlightable(component, cache); - } - return null; - } -} diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/source/SymbolDataRepository.java b/sonar-batch/src/main/java/org/sonar/batch/scan/source/SymbolDataRepository.java deleted file mode 100644 index 42ef94d4af3..00000000000 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/source/SymbolDataRepository.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.batch.scan.source; - -import com.google.common.collect.Multimap; -import com.google.common.collect.TreeMultimap; -import org.sonar.api.scan.source.Symbol; -import org.sonar.batch.index.Data; - -import java.util.Collection; -import java.util.Comparator; - -public class SymbolDataRepository implements Data { - - private static final String FIELD_SEPARATOR = ","; - private static final String SYMBOL_SEPARATOR = ";"; - - private Multimap referencesBySymbol; - - public SymbolDataRepository() { - referencesBySymbol = TreeMultimap.create(new SymbolComparator(), new ReferenceComparator()); - } - - public void registerSymbol(Symbol symbol) { - referencesBySymbol.put(symbol, symbol.getDeclarationStartOffset()); - } - - public void registerSymbolReference(Symbol symbol, int startOffset) { - if (startOffset >= symbol.getDeclarationStartOffset() && startOffset < symbol.getDeclarationEndOffset()) { - throw new UnsupportedOperationException("Cannot add reference overlapping the symbol declaration"); - } - referencesBySymbol.put(symbol, startOffset); - } - - @Override - public String writeString() { - StringBuilder sb = new StringBuilder(); - - for (Symbol symbol : referencesBySymbol.keySet()) { - - sb.append(symbol.getDeclarationStartOffset()) - .append(FIELD_SEPARATOR) - .append(symbol.getDeclarationEndOffset()); - Collection symbolReferences = referencesBySymbol.get(symbol); - for (Integer symbolReference : symbolReferences) { - sb.append(FIELD_SEPARATOR).append(symbolReference); - } - sb.append(SYMBOL_SEPARATOR); - } - - return sb.toString(); - } - - @Override - public void readString(String s) { - throw new UnsupportedOperationException(); - } - - - private class SymbolComparator implements Comparator { - @Override - public int compare(Symbol left, Symbol right) { - return left.getDeclarationStartOffset() - right.getDeclarationStartOffset(); - } - } - - private class ReferenceComparator implements Comparator { - @Override - public int compare(Integer left, Integer right) { - int result; - if (left != null & right != null) { - result = left - right; - } else { - result = left == null ? -1 : 1; - } - return result; - } - } -} diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/source/SymbolPerspectiveBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/scan/source/SymbolPerspectiveBuilder.java deleted file mode 100644 index f9239e5aff5..00000000000 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/source/SymbolPerspectiveBuilder.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.batch.scan.source; - -import org.sonar.api.component.Component; -import org.sonar.api.scan.source.SymbolPerspective; -import org.sonar.batch.index.ComponentDataCache; -import org.sonar.core.component.PerspectiveBuilder; - -public class SymbolPerspectiveBuilder extends PerspectiveBuilder { - - private final ComponentDataCache cache; - - public SymbolPerspectiveBuilder(ComponentDataCache cache) { - super(SymbolPerspective.class); - this.cache = cache; - } - - @Override - protected SymbolPerspective loadPerspective(Class perspectiveClass, Component component) { - return new DefaultSymbolPerspective(cache, component, new SymbolDataRepository()); - } -} diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/source/SyntaxHighlightingRule.java b/sonar-batch/src/main/java/org/sonar/batch/scan/source/SyntaxHighlightingRule.java deleted file mode 100644 index 35cd32091e2..00000000000 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/source/SyntaxHighlightingRule.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.batch.scan.source; - -/** - * @since 3.6 - */ -public class SyntaxHighlightingRule { - - private final int startPosition; - private final int endPosition; - private final String textType; - - private SyntaxHighlightingRule(int startPosition, int endPosition, String textType) { - this.startPosition = startPosition; - this.endPosition = endPosition; - this.textType = textType; - } - - public static SyntaxHighlightingRule create(int startPosition, int endPosition, String textType) { - return new SyntaxHighlightingRule(startPosition, endPosition, textType); - } - - public int getStartPosition() { - return startPosition; - } - - public int getEndPosition() { - return endPosition; - } - - public String getTextType() { - return textType; - } -} diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/source/SyntaxHighlightingRuleSet.java b/sonar-batch/src/main/java/org/sonar/batch/scan/source/SyntaxHighlightingRuleSet.java deleted file mode 100644 index 090393dc0c1..00000000000 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/source/SyntaxHighlightingRuleSet.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.batch.scan.source; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Predicate; -import com.google.common.collect.Collections2; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Ordering; -import org.slf4j.LoggerFactory; -import org.sonar.batch.index.Data; - -import javax.annotation.Nullable; - -import java.util.Collection; -import java.util.List; - -import static com.google.common.collect.Lists.newArrayList; - -/** - * @since 3.6 - */ -public class SyntaxHighlightingRuleSet implements Data { - - private static final String FIELD_SEPARATOR = ","; - private static final String RULE_SEPARATOR = ";"; - - private List syntaxHighlightingRuleSet; - - private SyntaxHighlightingRuleSet(List syntaxHighlightingRules) { - syntaxHighlightingRuleSet = syntaxHighlightingRules; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - private List syntaxHighlightingRuleSet; - - public Builder() { - syntaxHighlightingRuleSet = newArrayList(); - } - - public Builder registerHighlightingRule(int startOffset, int endOffset, String typeOfText) { - if (ruleConflictsWithExistingRules(startOffset, endOffset)) { - String errorMsg = String.format("Cannot register highlighting rule for characters from %s to %s as it " + - "overlaps at least one existing rule", startOffset, endOffset); - LoggerFactory.getLogger(SyntaxHighlightingRuleSet.class).error(errorMsg); - throw new UnsupportedOperationException(errorMsg); - } - SyntaxHighlightingRule syntaxHighlightingRule = SyntaxHighlightingRule.create(startOffset, endOffset, - typeOfText); - this.syntaxHighlightingRuleSet.add(syntaxHighlightingRule); - return this; - } - - public SyntaxHighlightingRuleSet build() { - return new SyntaxHighlightingRuleSet(ImmutableList.copyOf(syntaxHighlightingRuleSet)); - } - - private boolean ruleConflictsWithExistingRules(final int startOffset, final int endOffset) { - Collection conflictingRules = Collections2 - .filter(syntaxHighlightingRuleSet, new Predicate() { - @Override - public boolean apply(@Nullable SyntaxHighlightingRule syntaxHighlightingRule) { - - if (syntaxHighlightingRule != null) { - boolean overlapsStartBoundary = startOffset < syntaxHighlightingRule.getStartPosition() - && endOffset >= syntaxHighlightingRule.getStartPosition() + 1 - && endOffset < syntaxHighlightingRule.getEndPosition(); - - boolean overlapsEndBoundary = startOffset > syntaxHighlightingRule.getStartPosition() - && startOffset < syntaxHighlightingRule.getEndPosition() - && endOffset > syntaxHighlightingRule.getEndPosition(); - - return overlapsStartBoundary || overlapsEndBoundary; - } - return false; - } - }); - return !conflictingRules.isEmpty(); - } - } - - public List getSyntaxHighlightingRuleSet() { - return syntaxHighlightingRuleSet; - } - - @Override - public String writeString() { - StringBuilder sb = new StringBuilder(); - List orderedRules = getOrderedHighlightingRules(); - - for (SyntaxHighlightingRule highlightingRule : orderedRules) { - sb.append(highlightingRule.getStartPosition()) - .append(FIELD_SEPARATOR) - .append(highlightingRule.getEndPosition()) - .append(FIELD_SEPARATOR) - .append(highlightingRule.getTextType()) - .append(RULE_SEPARATOR); - } - - return sb.toString(); - } - - @Override - public void readString(String s) { - throw new UnsupportedOperationException(); - } - - @VisibleForTesting - protected List getOrderedHighlightingRules() { - Ordering ruleOrdering = new Ordering() { - @Override - public int compare(@Nullable SyntaxHighlightingRule left, - @Nullable SyntaxHighlightingRule right) { - int result = 0; - if (left != null && right != null) { - result = left.getStartPosition() - right.getStartPosition(); - if (result == 0) { - result = left.getEndPosition() - right.getEndPosition(); - } - return result; - } - return left != null ? 1 : -1; - } - }; - - return ruleOrdering.sortedCopy(syntaxHighlightingRuleSet); - } -} diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/source/package-info.java b/sonar-batch/src/main/java/org/sonar/batch/scan/source/package-info.java deleted file mode 100644 index a2e0bae2d1c..00000000000 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/source/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.batch.scan.source; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/source/DefaultHighlightableTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/source/DefaultHighlightableTest.java deleted file mode 100644 index 164656fe6a2..00000000000 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/source/DefaultHighlightableTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.batch.scan.source; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.component.Component; -import org.sonar.batch.index.ComponentDataCache; -import org.sonar.core.source.SnapshotDataType; - -import static org.fest.assertions.Assertions.assertThat; -import static org.mockito.Mockito.*; - -public class DefaultHighlightableTest { - - @Rule - public ExpectedException throwable = ExpectedException.none(); - - @Test - public void should_store_highlighting_rules() throws Exception { - DefaultHighlightable highlightablePerspective = new DefaultHighlightable(null, null); - highlightablePerspective.newHighlighting().highlight(0, 10, "k").highlight(20, 30, "cppd"); - - assertThat(highlightablePerspective.getHighlightingRules().getSyntaxHighlightingRuleSet()).hasSize(2); - } - - @Test - public void should_apply_registered_highlighting() throws Exception { - Component component = mock(Component.class); - when(component.key()).thenReturn("myComponent"); - - ComponentDataCache cache = mock(ComponentDataCache.class); - - DefaultHighlightable highlightable = new DefaultHighlightable(component, cache); - highlightable.newHighlighting() - .highlight(0, 10, "k") - .highlight(20, 30, "cppd") - .done(); - - verify(cache).setStringData("myComponent", SnapshotDataType.SYNTAX_HIGHLIGHTING.getValue(), "0,10,k;20,30,cppd;"); - } -} diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/source/DefaultSymbolPerspectiveTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/source/DefaultSymbolPerspectiveTest.java deleted file mode 100644 index cf7fa982e62..00000000000 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/source/DefaultSymbolPerspectiveTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.batch.scan.source; - -import org.junit.Test; -import org.sonar.api.component.Component; -import org.sonar.api.scan.source.Symbol; -import org.sonar.batch.index.ComponentDataCache; -import org.sonar.core.source.SnapshotDataType; - -import static org.mockito.Mockito.*; - -public class DefaultSymbolPerspectiveTest { - - @Test - public void should_store_references_for_new_symbol() throws Exception { - - Component component = mock(Component.class); - ComponentDataCache cache = mock(ComponentDataCache.class); - SymbolDataRepository symbolDataRepository = mock(SymbolDataRepository.class); - - DefaultSymbolPerspective symbolPerspective = new DefaultSymbolPerspective(cache, component, symbolDataRepository); - - Symbol symbol = symbolPerspective.newSymbol().build(); - symbolPerspective.declareReferences(symbol).addReference(1).addReference(20); - - verify(symbolDataRepository).registerSymbol(symbol); - verify(symbolDataRepository).registerSymbolReference(symbol, 1); - verify(symbolDataRepository).registerSymbolReference(symbol, 20); - } - - @Test - public void should_update_cache_when_done() throws Exception { - - Component component = mock(Component.class); - when(component.key()).thenReturn("myComponent"); - - ComponentDataCache cache = mock(ComponentDataCache.class); - - DefaultSymbolPerspective symbolPerspective = new DefaultSymbolPerspective(cache, component, new SymbolDataRepository()); - Symbol firstSymbol = symbolPerspective.newSymbol().setDeclaration(4, 8).build(); - symbolPerspective.declareReferences(firstSymbol).addReference(12).addReference(70); - Symbol otherSymbol = symbolPerspective.newSymbol().setDeclaration(25, 33).build(); - symbolPerspective.declareReferences(otherSymbol).addReference(44).addReference(60).addReference(108); - - symbolPerspective.end(); - - verify(cache).setStringData("myComponent", SnapshotDataType.SYMBOL_HIGHLIGHTING.getValue(), "4,8,4,12,70;25,33,25,44,60,108;"); - } -} diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/source/DefaultSymbolTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/source/DefaultSymbolTest.java deleted file mode 100644 index b1c1f724bea..00000000000 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/source/DefaultSymbolTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.batch.scan.source; - -import org.junit.Test; -import org.sonar.api.scan.source.Symbol; - -import static org.fest.assertions.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -public class DefaultSymbolTest { - - @Test - public void should_build_default_symbol() throws Exception { - - SymbolDataRepository dataRepository = mock(SymbolDataRepository.class); - - Symbol symbol = DefaultSymbol.builder(dataRepository).setDeclaration(10, 20).setFullyQualifiedName("org.foo.Bar#myMethod").build(); - - assertThat(symbol.getDeclarationStartOffset()).isEqualTo(10); - assertThat(symbol.getDeclarationEndOffset()).isEqualTo(20); - assertThat(symbol.getFullyQualifiedName()).isEqualTo("org.foo.Bar#myMethod"); - - verify(dataRepository).registerSymbol(symbol); - } -} diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/source/HighlightableBuilderTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/source/HighlightableBuilderTest.java deleted file mode 100644 index 6f9b6c732b5..00000000000 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/source/HighlightableBuilderTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.batch.scan.source; - -import org.junit.Test; -import org.sonar.api.component.Component; -import org.sonar.api.resources.File; -import org.sonar.api.resources.Project; -import org.sonar.api.scan.source.Highlightable; -import org.sonar.batch.index.ComponentDataCache; -import org.sonar.core.component.ResourceComponent; -import org.sonar.java.api.JavaClass; - -import static org.fest.assertions.Assertions.assertThat; -import static org.mockito.Mockito.mock; - -public class HighlightableBuilderTest { - - ComponentDataCache cache = mock(ComponentDataCache.class); - - @Test - public void should_load_default_perspective() throws Exception { - Component component = new ResourceComponent(new File("foo/bar.c")); - - HighlightableBuilder builder = new HighlightableBuilder(cache); - Highlightable perspective = builder.loadPerspective(Highlightable.class, component); - - assertThat(perspective).isNotNull().isInstanceOf(DefaultHighlightable.class); - assertThat(perspective.component()).isSameAs(component); - } - - @Test - public void project_should_not_be_highlightable() { - Component component = new ResourceComponent(new Project("Foo")); - - HighlightableBuilder builder = new HighlightableBuilder(cache); - Highlightable perspective = builder.loadPerspective(Highlightable.class, component); - - assertThat(perspective).isNull(); - } - - @Test - public void java_class_should_not_be_highlightable() { - Component component = new ResourceComponent(JavaClass.create("foo", "Bar")); - - HighlightableBuilder builder = new HighlightableBuilder(cache); - Highlightable perspective = builder.loadPerspective(Highlightable.class, component); - - assertThat(perspective).isNull(); - } -} diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/source/SymbolDataRepositoryTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/source/SymbolDataRepositoryTest.java deleted file mode 100644 index 30ac5548ed0..00000000000 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/source/SymbolDataRepositoryTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.batch.scan.source; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.scan.source.Symbol; - -import static org.fest.assertions.Assertions.assertThat; - -public class SymbolDataRepositoryTest { - - @Rule - public ExpectedException throwable = ExpectedException.none(); - - @Test - public void should_serialize_symbols_in_natural_order() throws Exception { - - SymbolDataRepository dataRepository = new SymbolDataRepository(); - - Symbol firstSymbol = DefaultSymbol.builder(dataRepository).setDeclaration(10, 20).build(); - Symbol secondSymbol = DefaultSymbol.builder(dataRepository).setDeclaration(84, 92).build(); - Symbol thirdSymbol = DefaultSymbol.builder(dataRepository).setDeclaration(55, 62).build(); - - dataRepository.registerSymbolReference(firstSymbol, 32); - dataRepository.registerSymbolReference(secondSymbol, 124); - dataRepository.registerSymbolReference(thirdSymbol, 70); - - String serializedSymbolData = dataRepository.writeString(); - - assertThat(serializedSymbolData).isEqualTo("10,20,10,32;55,62,55,70;84,92,84,124;"); - } - - @Test - public void should_serialize_unused_symbol() throws Exception { - - SymbolDataRepository dataRepository = new SymbolDataRepository(); - - Symbol unusedSymbol = DefaultSymbol.builder(dataRepository).setDeclaration(10, 20).build(); - dataRepository.registerSymbol(unusedSymbol); - - String serializedSymbolData = dataRepository.writeString(); - - assertThat(serializedSymbolData).isEqualTo("10,20,10;"); - } - - @Test - public void should_reject_reference_conflicting_with_declaration() throws Exception { - - throwable.expect(UnsupportedOperationException.class); - - SymbolDataRepository dataRepository = new SymbolDataRepository(); - - Symbol symbol = DefaultSymbol.builder(dataRepository).setDeclaration(10, 20).build(); - dataRepository.registerSymbolReference(symbol, 15); - } -} diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/source/SymbolPerspectiveBuilderTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/source/SymbolPerspectiveBuilderTest.java deleted file mode 100644 index a806429ad13..00000000000 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/source/SymbolPerspectiveBuilderTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.batch.scan.source; - -import org.junit.Test; -import org.sonar.api.component.Component; -import org.sonar.api.component.Perspective; -import org.sonar.api.scan.source.SymbolPerspective; -import org.sonar.batch.index.ComponentDataCache; - -import static org.fest.assertions.Assertions.assertThat; -import static org.mockito.Mockito.mock; - -public class SymbolPerspectiveBuilderTest { - - ComponentDataCache dataCache = mock(ComponentDataCache.class); - - @Test - public void should_load_perspective() throws Exception { - Component component = mock(Component.class); - - SymbolPerspectiveBuilder perspectiveBuilder = new SymbolPerspectiveBuilder(dataCache); - Perspective perspective = perspectiveBuilder.loadPerspective(SymbolPerspective.class, component); - - assertThat(perspective).isInstanceOf(SymbolPerspective.class); - assertThat(perspective.component()).isEqualTo(component); - } -} diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/source/SyntaxHighlightingRuleSetTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/source/SyntaxHighlightingRuleSetTest.java deleted file mode 100644 index 14a45f933ff..00000000000 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/source/SyntaxHighlightingRuleSetTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.batch.scan.source; - - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import java.util.List; - -import static org.fest.assertions.Assertions.assertThat; - -public class SyntaxHighlightingRuleSetTest { - - private SyntaxHighlightingRuleSet highlightingRules; - - @Rule - public ExpectedException throwable = ExpectedException.none(); - - @Before - public void setUpSampleRules() { - - SyntaxHighlightingRuleSet.Builder highlightingRuleSet = SyntaxHighlightingRuleSet.builder(); - highlightingRuleSet.registerHighlightingRule(0, 10, "cd"); - highlightingRuleSet.registerHighlightingRule(10, 12, "k"); - highlightingRuleSet.registerHighlightingRule(24, 38, "k"); - highlightingRuleSet.registerHighlightingRule(42, 50, "k"); - highlightingRuleSet.registerHighlightingRule(24, 65, "cppd"); - highlightingRuleSet.registerHighlightingRule(12, 20, "cd"); - - highlightingRules = highlightingRuleSet.build(); - } - - @Test - public void should_register_highlighting_rule() throws Exception { - assertThat(highlightingRules.getSyntaxHighlightingRuleSet()).hasSize(6); - } - - @Test - public void should_order_by_start_then_end_offset() throws Exception { - - List orderedRules = highlightingRules.getOrderedHighlightingRules(); - - assertThat(orderedRules).onProperty("startPosition").containsExactly(0, 10, 12, 24, 24, 42); - assertThat(orderedRules).onProperty("endPosition").containsExactly(10, 12, 20, 38, 65, 50); - assertThat(orderedRules).onProperty("textType").containsExactly("cd", "k", "cd", "k", "cppd", "k"); - } - - @Test - public void should_serialize_rules_to_string() throws Exception { - - String serializedRules = highlightingRules.writeString(); - assertThat(serializedRules).isEqualTo("0,10,cd;10,12,k;12,20,cd;24,38,k;24,65,cppd;42,50,k;"); - } - - @Test - public void should_prevent_rules_overlapping() throws Exception { - - throwable.expect(UnsupportedOperationException.class); - - SyntaxHighlightingRuleSet.Builder builder = SyntaxHighlightingRuleSet.builder(); - builder.registerHighlightingRule(0, 10, "k"); - builder.registerHighlightingRule(8, 15, "k"); - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/source/Highlightable.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/source/Highlightable.java deleted file mode 100644 index 78bcbc6256f..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/source/Highlightable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.scan.source; - -import org.sonar.api.component.Perspective; - -/** - * @since 3.6 - */ -@Deprecated -public interface Highlightable extends Perspective { - - interface HighlightingBuilder { - - HighlightingBuilder highlight(int startOffset, int endOffset, String typeOfText); - - void done(); - } - - HighlightingBuilder newHighlighting(); -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/source/Symbol.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/source/Symbol.java deleted file mode 100644 index df9d1e8d6cc..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/source/Symbol.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.scan.source; - -@Deprecated -public interface Symbol { - - public int getDeclarationStartOffset(); - - public int getDeclarationEndOffset(); - - public String getFullyQualifiedName(); -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/source/SymbolPerspective.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/source/SymbolPerspective.java deleted file mode 100644 index 0a82f58a476..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/source/SymbolPerspective.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.scan.source; - -import org.sonar.api.component.Perspective; - -/** - * @since 3.6 - */ -@Deprecated -public interface SymbolPerspective extends Perspective { - - interface SymbolBuilder { - - SymbolBuilder setDeclaration(int startOffset, int endOffset); - - SymbolBuilder setFullyQualifiedName(String fullyQualifiedName); - - Symbol build(); - } - - interface ReferencesBuilder { - - ReferencesBuilder addReference(int startOffset); - } - - SymbolPerspective begin(); - - SymbolBuilder newSymbol(); - - ReferencesBuilder declareReferences(Symbol symbol); - - void end(); -} - - - diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/source/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/source/package-info.java deleted file mode 100644 index 2fb6805472c..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/source/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.api.scan.source; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file -- 2.39.5