diff options
author | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-07-31 13:52:16 +0200 |
---|---|---|
committer | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-07-31 13:52:16 +0200 |
commit | a62ea5d4b00352588f883e15bbaaae6d64b60b59 (patch) | |
tree | b1b487136a9e67aef6a5b1217afd456ddbd13e87 /sonar-plugin-api | |
parent | 9969f45f30ada6c30cc2045f8284b309418bae8e (diff) | |
parent | 86c81b2b63375bc87c52c4bebbefe62aa77a8bf7 (diff) | |
download | sonarqube-a62ea5d4b00352588f883e15bbaaae6d64b60b59.tar.gz sonarqube-a62ea5d4b00352588f883e15bbaaae6d64b60b59.zip |
Merge branch 'master' into SONAR-4898
Conflicts:
server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java
Diffstat (limited to 'sonar-plugin-api')
7 files changed, 121 insertions, 3 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java index aad1de5ea03..b73e0a0ecee 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java @@ -344,10 +344,10 @@ public interface CoreProperties { /** * @since 2.11 */ - String CPD_CROSS_RPOJECT = "sonar.cpd.cross_project"; + String CPD_CROSS_PROJECT = "sonar.cpd.cross_project"; /** - * @see #CPD_CROSS_RPOJECT + * @see #CPD_CROSS_PROJECT * @since 2.11 */ boolean CPD_CROSS_RPOJECT_DEFAULT_VALUE = false; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DeprecatedDefaultInputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DeprecatedDefaultInputFile.java index 156e140fa57..7c82aa501d0 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DeprecatedDefaultInputFile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DeprecatedDefaultInputFile.java @@ -50,8 +50,9 @@ public class DeprecatedDefaultInputFile extends DefaultInputFile implements org. return new File(basedir); } - public void setBasedir(File basedir) { + public DeprecatedDefaultInputFile setBasedir(File basedir) { this.basedir = PathUtils.sanitize(basedir.getAbsolutePath()); + return this; } /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java index 787d2fddb3d..647cab3f3f9 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java @@ -24,6 +24,8 @@ import org.sonar.api.batch.fs.FileSystem; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.measure.Metric; import org.sonar.api.batch.rule.ActiveRules; +import org.sonar.api.batch.sensor.duplication.DuplicationBuilder; +import org.sonar.api.batch.sensor.duplication.TokenBuilder; import org.sonar.api.batch.sensor.highlighting.HighlightingBuilder; import org.sonar.api.batch.sensor.issue.Issue; import org.sonar.api.batch.sensor.issue.IssueBuilder; @@ -126,4 +128,19 @@ public interface SensorContext { */ SymbolTableBuilder symbolTableBuilder(InputFile inputFile); + // ------------ DUPLICATIONS ------------ + + /** + * Builder to define tokens in a file. Tokens are used to compute duplication by the core. + * @since 4.5 + */ + TokenBuilder tokenBuilder(InputFile inputFile); + + /** + * Builder to manually define duplications in a file. When duplication are manually computed then + * no need to use {@link #tokenBuilder(InputFile)}. + * @since 4.5 + */ + DuplicationBuilder duplicationBuilder(InputFile inputFile); + } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/DuplicationBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/DuplicationBuilder.java new file mode 100644 index 00000000000..2f37220b1a3 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/DuplicationBuilder.java @@ -0,0 +1,38 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 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.batch.sensor.duplication; + +import org.sonar.api.batch.fs.InputFile; + +/** + * This builder is used to declare duplications on files of the project. + * @since 4.5 + */ +public interface DuplicationBuilder { + + DuplicationBuilder originBlock(int startLine, int endLine); + + DuplicationBuilder isDuplicatedBy(InputFile sameOrOtherFile, int startLine, int endLine); + + /** + * Call this method only once when your are done with defining all duplicates of origin block. + */ + void done(); +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/TokenBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/TokenBuilder.java new file mode 100644 index 00000000000..f4de9fffc8c --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/TokenBuilder.java @@ -0,0 +1,40 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 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.batch.sensor.duplication; + +/** + * This builder is used to define token on files. Tokens are later used to compute duplication. + * Tokens should be declared in sequential order. + * @since 4.5 + */ +public interface TokenBuilder { + + /** + * Call this method to register a new token. + * @param line Line number of the token. Line starts at 1. + * @param image Text of the token. + */ + TokenBuilder addToken(int line, String image); + + /** + * Call this method only once when your are done with defining tokens of the file. + */ + void done(); +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/package-info.java new file mode 100644 index 00000000000..4973316830a --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/package-info.java @@ -0,0 +1,21 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 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. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.sonar.api.batch.sensor.duplication; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java index 7a86f7b145c..870a8519271 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java @@ -343,6 +343,7 @@ public class Measure<G extends Serializable> implements Serializable { /** * @return the data field of the measure */ + @CheckForNull public String getData() { return data; } |