aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-duplications
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2018-07-05 11:51:17 +0200
committerSonarTech <sonartech@sonarsource.com>2018-07-17 20:21:27 +0200
commit8cfc544c1fb69e783c58d74ad3083a686c25f07a (patch)
tree141f98fc11a18e92e09a97233cc2a1620fcda0b0 /sonar-duplications
parent8bbe57990ec82e2419925b13b90a1e0869d09512 (diff)
downloadsonarqube-8cfc544c1fb69e783c58d74ad3083a686c25f07a.tar.gz
sonarqube-8cfc544c1fb69e783c58d74ad3083a686c25f07a.zip
SONAR-10541, SONAR-10331 Drop compatibility mode and clean plugin classloader
Diffstat (limited to 'sonar-duplications')
-rw-r--r--sonar-duplications/build.gradle1
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/CodeFragment.java44
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/block/Block.java6
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/index/ClonePart.java6
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/PmdBlockChunker.java3
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/TokenizerBridge.java1
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/TokensLine.java79
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/statement/Statement.java5
-rw-r--r--sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/PmdBlockChunkerTest.java6
-rw-r--r--sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/TokenizerBridgeTest.java1
10 files changed, 10 insertions, 142 deletions
diff --git a/sonar-duplications/build.gradle b/sonar-duplications/build.gradle
index a45feb6dca7..79e4b224640 100644
--- a/sonar-duplications/build.gradle
+++ b/sonar-duplications/build.gradle
@@ -8,6 +8,7 @@ dependencies {
// please keep list ordered
compile 'org.codehaus.sonar:sonar-channel'
+ compile project(':sonar-plugin-api')
compileOnly 'com.google.code.findbugs:jsr305'
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/CodeFragment.java b/sonar-duplications/src/main/java/org/sonar/duplications/CodeFragment.java
deleted file mode 100644
index 450259c72e6..00000000000
--- a/sonar-duplications/src/main/java/org/sonar/duplications/CodeFragment.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.duplications;
-
-
-/**
- * TODO Enforce contracts of this interface in concrete classes by using preconditions, currently this leads to failures of tests.
- *
- * <p>This interface is not intended to be implemented by clients.</p>
- *
- * @since 2.14
- */
-public interface CodeFragment {
-
- /**
- * Number of line where fragment starts.
- * Numbering starts from 1.
- */
- int getStartLine();
-
- /**
- * Number of line where fragment ends.
- * Numbering starts from 1.
- */
- int getEndLine();
-
-}
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/block/Block.java b/sonar-duplications/src/main/java/org/sonar/duplications/block/Block.java
index 7b2e5fe3dce..76b8bbc4b36 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/block/Block.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/block/Block.java
@@ -19,13 +19,11 @@
*/
package org.sonar.duplications.block;
-import org.sonar.duplications.CodeFragment;
-
/**
* Represents part of source code between two lines.
* If two blocks have the same {@link #getBlockHash() hash}, then we assume that there is a duplication in a code, which they represent.
*/
-public final class Block implements CodeFragment {
+public final class Block {
private final String resourceId;
private final ByteArray blockHash;
@@ -127,12 +125,10 @@ public final class Block implements CodeFragment {
return indexInFile;
}
- @Override
public int getStartLine() {
return startLine;
}
- @Override
public int getEndLine() {
return endLine;
}
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/index/ClonePart.java b/sonar-duplications/src/main/java/org/sonar/duplications/index/ClonePart.java
index da8cd64c543..5b62937268a 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/index/ClonePart.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/index/ClonePart.java
@@ -19,9 +19,7 @@
*/
package org.sonar.duplications.index;
-import org.sonar.duplications.CodeFragment;
-
-public class ClonePart implements CodeFragment {
+public class ClonePart {
private final String resourceId;
private final int startUnit;
@@ -48,12 +46,10 @@ public class ClonePart implements CodeFragment {
return startUnit;
}
- @Override
public int getStartLine() {
return startLine;
}
- @Override
public int getEndLine() {
return endLine;
}
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/PmdBlockChunker.java b/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/PmdBlockChunker.java
index 50a32621f0a..1e11b40dc9c 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/PmdBlockChunker.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/PmdBlockChunker.java
@@ -21,9 +21,8 @@ package org.sonar.duplications.internal.pmd;
import java.util.ArrayList;
import java.util.List;
-
import javax.annotation.concurrent.Immutable;
-
+import org.sonar.api.batch.sensor.cpd.internal.TokensLine;
import org.sonar.duplications.block.Block;
import org.sonar.duplications.block.ByteArray;
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/TokenizerBridge.java b/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/TokenizerBridge.java
index 44f1576dc75..e98f30e9e00 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/TokenizerBridge.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/TokenizerBridge.java
@@ -26,6 +26,7 @@ import net.sourceforge.pmd.cpd.SourceCode;
import net.sourceforge.pmd.cpd.TokenEntry;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.cpd.Tokens;
+import org.sonar.api.batch.sensor.cpd.internal.TokensLine;
import org.sonar.duplications.block.Block;
import org.sonar.duplications.cpd.FileCodeLoaderWithoutCache;
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/TokensLine.java b/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/TokensLine.java
deleted file mode 100644
index 62f3059b01d..00000000000
--- a/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/TokensLine.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.duplications.internal.pmd;
-
-import org.sonar.duplications.CodeFragment;
-
-/**
- * Immutable code fragment, which formed from tokens of one line.
- */
-public class TokensLine implements CodeFragment {
-
- private final String value;
-
- private final int startLine;
- private final int hashCode;
-
- private final int startUnit;
- private final int endUnit;
-
- public TokensLine(int startUnit, int endUnit, int startLine, String value) {
- if (startLine <= 0) {
- throw new IllegalArgumentException("Start line should be strictly positive");
- }
- // TODO do we have requirements for length and hashcode ?
- this.startLine = startLine;
- this.value = value;
- this.hashCode = value.hashCode();
-
- this.startUnit = startUnit;
- this.endUnit = endUnit;
- }
-
- public String getValue() {
- return value;
- }
-
- @Override
- public int getStartLine() {
- return startLine;
- }
-
- /**
- * Same as {@link #getStartLine()}
- */
- @Override
- public int getEndLine() {
- return startLine;
- }
-
- public int getHashCode() {
- return hashCode;
- }
-
- public int getStartUnit() {
- return startUnit;
- }
-
- public int getEndUnit() {
- return endUnit;
- }
-
-}
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/statement/Statement.java b/sonar-duplications/src/main/java/org/sonar/duplications/statement/Statement.java
index a18c6635381..c6a84d59a7b 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/statement/Statement.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/statement/Statement.java
@@ -21,10 +21,9 @@ package org.sonar.duplications.statement;
import java.util.List;
import javax.annotation.Nullable;
-import org.sonar.duplications.CodeFragment;
import org.sonar.duplications.token.Token;
-public class Statement implements CodeFragment {
+public class Statement {
private final int startLine;
private final int endLine;
@@ -54,12 +53,10 @@ public class Statement implements CodeFragment {
this.endLine = tokens.get(tokens.size() - 1).getLine();
}
- @Override
public int getStartLine() {
return startLine;
}
- @Override
public int getEndLine() {
return endLine;
}
diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/PmdBlockChunkerTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/PmdBlockChunkerTest.java
index 4335be00567..99d895c0b9b 100644
--- a/sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/PmdBlockChunkerTest.java
+++ b/sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/PmdBlockChunkerTest.java
@@ -19,13 +19,13 @@
*/
package org.sonar.duplications.internal.pmd;
+import java.util.Arrays;
+import java.util.List;
import org.junit.Test;
+import org.sonar.api.batch.sensor.cpd.internal.TokensLine;
import org.sonar.duplications.block.Block;
import org.sonar.duplications.block.ByteArray;
-import java.util.Arrays;
-import java.util.List;
-
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/TokenizerBridgeTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/TokenizerBridgeTest.java
index 7ff5dbe30d4..12f58bd8c9a 100644
--- a/sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/TokenizerBridgeTest.java
+++ b/sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/TokenizerBridgeTest.java
@@ -30,6 +30,7 @@ import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.cpd.Tokens;
import org.junit.Before;
import org.junit.Test;
+import org.sonar.api.batch.sensor.cpd.internal.TokensLine;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;