aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-01-14 17:14:00 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2015-01-15 09:08:58 +0100
commit12c4a20acb61ff6f516c7e7bb8996db606b263ab (patch)
treeb831b5467f8e37d05b8329e398141f99caa98a4f /sonar-plugin-api
parent1e6facc12390d970ad259af550ea3dba8426a79f (diff)
downloadsonarqube-12c4a20acb61ff6f516c7e7bb8996db606b263ab.tar.gz
sonarqube-12c4a20acb61ff6f516c7e7bb8996db606b263ab.zip
SONAR-5931 Publish new measure API
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/maven/DependsUponMavenPlugin.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/Sensor.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java7
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/Measure.java30
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/NewMeasure.java59
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/internal/DefaultMeasure.java5
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java2
8 files changed, 75 insertions, 34 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java
index a21d421e6ac..b75209e1538 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java
@@ -40,7 +40,7 @@ import java.util.Set;
/**
* @since 1.10
*/
-public interface SensorContext {
+public interface SensorContext extends org.sonar.api.batch.sensor.SensorContext {
/**
* Indexes a resource as a direct child of project. This method does nothing and returns true if the resource already indexed.
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/maven/DependsUponMavenPlugin.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/maven/DependsUponMavenPlugin.java
index 0e590c84593..e83df0c84e6 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/maven/DependsUponMavenPlugin.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/maven/DependsUponMavenPlugin.java
@@ -33,7 +33,9 @@ import org.sonar.api.resources.Project;
* </p>
*
* @since 1.10
+ * @deprecated since 5.1 SQ platform don't want any dependency on Maven
*/
+@Deprecated
@SupportedEnvironment("maven")
public interface DependsUponMavenPlugin extends BatchExtension {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/Sensor.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/Sensor.java
index a0be6e447ab..01f0e109e53 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/Sensor.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/Sensor.java
@@ -31,7 +31,7 @@ import org.sonar.api.BatchExtension;
* For example the Cobertura Sensor parses Cobertura report and saves the first-level of measures on files.
* </p>
*
- * @since 5.0
+ * @since 5.1
*/
public interface Sensor extends BatchExtension {
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 805d9db2417..b32be9c7ab0 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
@@ -29,6 +29,7 @@ import org.sonar.api.batch.sensor.duplication.DuplicationTokenBuilder;
import org.sonar.api.batch.sensor.highlighting.HighlightingBuilder;
import org.sonar.api.batch.sensor.issue.Issue;
import org.sonar.api.batch.sensor.measure.Measure;
+import org.sonar.api.batch.sensor.measure.NewMeasure;
import org.sonar.api.batch.sensor.symbol.SymbolTableBuilder;
import org.sonar.api.batch.sensor.test.Coverage;
import org.sonar.api.batch.sensor.test.TestCaseCoverage;
@@ -40,7 +41,7 @@ import java.util.List;
/**
* See {@link Sensor#execute(SensorContext)}
- * @since 5.0
+ * @since 5.1
*/
public interface SensorContext {
@@ -62,9 +63,9 @@ public interface SensorContext {
// ----------- MEASURES --------------
/**
- * Fluent builder to create a new {@link Measure}. Don't forget to call {@link Measure#save()} once all parameters are provided.
+ * Fluent builder to create a new {@link Measure}. Don't forget to call {@link NewMeasure#save()} once all parameters are provided.
*/
- <G extends Serializable> Measure<G> newMeasure();
+ <G extends Serializable> NewMeasure<G> newMeasure();
// ----------- ISSUES --------------
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/Measure.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/Measure.java
index 86a0abdffad..c59f7a7be76 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/Measure.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/Measure.java
@@ -27,22 +27,13 @@ import javax.annotation.CheckForNull;
import java.io.Serializable;
/**
- * Builder to create new Measure.
- * @since 5.0
+ * Measure on File, Directory or Project.
+ * Should not be implemented by client.
+ * @since 5.1
*/
public interface Measure<G extends Serializable> {
/**
- * The file the measure belongs to.
- */
- Measure<G> onFile(InputFile file);
-
- /**
- * Tell that the measure is global to the project.
- */
- Measure<G> onProject();
-
- /**
* The file the measure belong to.
* @return null if measure is on project
*/
@@ -50,11 +41,6 @@ public interface Measure<G extends Serializable> {
InputFile inputFile();
/**
- * Set the metric this measure belong to.
- */
- Measure<G> forMetric(Metric<G> metric);
-
- /**
* The metric this measure belong to.
*/
Metric<G> metric();
@@ -62,16 +48,6 @@ public interface Measure<G extends Serializable> {
/**
* Value of the measure.
*/
- Measure<G> withValue(G value);
-
- /**
- * Value of the measure.
- */
G value();
- /**
- * Save the measure. It is not permitted so save several measures of the same metric on the same file/project.
- */
- void save();
-
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/NewMeasure.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/NewMeasure.java
new file mode 100644
index 00000000000..cf8bccba48b
--- /dev/null
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/NewMeasure.java
@@ -0,0 +1,59 @@
+/*
+ * 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.measure;
+
+import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.measure.Metric;
+
+import java.io.Serializable;
+
+/**
+ * Builder to create new Measure.
+ * Should not be implemented by client.
+ * @since 5.1
+ */
+public interface NewMeasure<G extends Serializable> {
+
+ /**
+ * The file the measure belongs to.
+ */
+ NewMeasure<G> onFile(InputFile file);
+
+ /**
+ * Tell that the measure is global to the project.
+ */
+ NewMeasure<G> onProject();
+
+ /**
+ * Set the metric this measure belong to.
+ */
+ NewMeasure<G> forMetric(Metric<G> metric);
+
+ /**
+ * Value of the measure.
+ */
+ NewMeasure<G> withValue(G value);
+
+ /**
+ * Save the measure. It is not permitted so save several measures of the same metric on the same file/project.
+ */
+ void save();
+
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/internal/DefaultMeasure.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/internal/DefaultMeasure.java
index 167f9e6af98..a6e4a0021fa 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/internal/DefaultMeasure.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/internal/DefaultMeasure.java
@@ -27,13 +27,14 @@ import org.sonar.api.batch.measure.Metric;
import org.sonar.api.batch.sensor.SensorStorage;
import org.sonar.api.batch.sensor.internal.DefaultStorable;
import org.sonar.api.batch.sensor.measure.Measure;
+import org.sonar.api.batch.sensor.measure.NewMeasure;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import java.io.Serializable;
-public class DefaultMeasure<G extends Serializable> extends DefaultStorable implements Measure<G> {
+public class DefaultMeasure<G extends Serializable> extends DefaultStorable implements Measure<G>, NewMeasure<G> {
private boolean onProject = false;
private InputFile file;
@@ -102,7 +103,7 @@ public class DefaultMeasure<G extends Serializable> extends DefaultStorable impl
Preconditions.checkNotNull(this.value, "Measure value can't be null");
Preconditions.checkNotNull(this.metric, "Measure metric can't be null");
Preconditions.checkState(this.metric.valueType().equals(this.value.getClass()), "Measure value should be of type " + this.metric.valueType());
- storage.store((Measure<Serializable>) this);
+ storage.store(this);
}
@Override
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java
index c6f68aaedce..bb89c172a07 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java
@@ -29,7 +29,9 @@ import java.util.List;
/**
* @since 2.5
+ * @deprecated since 5.1 use {@link org.sonar.api.batch.measure.MetricFinder} on batch side
*/
+@Deprecated
public interface MetricFinder extends TaskComponent, ServerComponent {
@CheckForNull