aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/main
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-10-16 15:58:26 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-10-16 16:52:40 +0200
commit229555a2030f9ea672654adf5087611ff2e60654 (patch)
treefcc28cc0c36f4a5670a22d651bc733822221fe07 /sonar-plugin-api/src/main
parent84c7aabe6ea304acaa96f14911b712bab02b51b8 (diff)
downloadsonarqube-229555a2030f9ea672654adf5087611ff2e60654.tar.gz
sonarqube-229555a2030f9ea672654adf5087611ff2e60654.zip
SONAR-5644 Apply some feedback on SCM API
Diffstat (limited to 'sonar-plugin-api/src/main')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameCommand.java34
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameLine.java49
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/ScmProvider.java5
3 files changed, 45 insertions, 43 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameCommand.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameCommand.java
index e8c74a03e36..b775385eabb 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameCommand.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameCommand.java
@@ -19,33 +19,55 @@
*/
package org.sonar.api.batch.scm;
+import org.sonar.api.BatchComponent;
+import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import java.util.List;
/**
+ * This class should be implemented by SCM providers.
* @since 5.0
*/
-public interface BlameCommand {
+@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
+public abstract class BlameCommand implements BatchComponent {
/**
- * Compute blame of the provided files. Computation can be done in parallel.
+ * Compute blame of the provided files.
+ * Computation can be done in parallel if this is more efficient.
* If there is an error that prevent to blame a file then an exception should be raised. If
* one file is new or contains local modifications then an exception should be raised.
*/
- void blame(FileSystem fs, Iterable<InputFile> files, BlameResult result);
+ public abstract void blame(BlameInput input, BlameOutput output);
/**
* Callback for the provider to report results of blame per file.
*/
- public static interface BlameResult {
+ public static interface BlameInput {
+
+ /**
+ * Filesystem of the current (sub )project.
+ */
+ FileSystem fileSystem();
+
+ /**
+ * List of files that should be blamed.
+ */
+ Iterable<InputFile> filesToBlame();
+
+ }
+
+ /**
+ * Callback for the provider to report results of blame per file.
+ */
+ public static interface BlameOutput {
/**
* Add result of the blame command for a single file. Number of lines should
- * be consistent with {@link InputFile#lines()}.
+ * be consistent with {@link InputFile#lines()}. This method is thread safe.
*/
- void add(InputFile file, List<BlameLine> lines);
+ void blameResult(InputFile file, List<BlameLine> lines);
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameLine.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameLine.java
index 7772d706ec2..9aed38d9f32 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameLine.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameLine.java
@@ -37,37 +37,14 @@ public class BlameLine {
private Date date;
private String revision;
private String author;
- private String committer;
- /**
- * @param date of the commit
- * @param revision of the commit
- * @param author will also be used as committer identification
- */
- public BlameLine(@Nullable Date date, String revision, @Nullable String author) {
- this(date, revision, author, author);
+ public String revision() {
+ return revision;
}
- /**
- *
- * @param date of the commit
- * @param revision of the commit
- * @param author the person who wrote the line
- * @param committer the person who committed the change
- */
- public BlameLine(@Nullable Date date, String revision, @Nullable String author, @Nullable String committer) {
- if (date != null) {
- this.date = new Date(date.getTime());
- } else {
- this.date = null;
- }
+ public BlameLine revision(String revision) {
this.revision = revision;
- this.author = author;
- this.committer = committer;
- }
-
- public String revision() {
- return revision;
+ return this;
}
@CheckForNull
@@ -75,9 +52,9 @@ public class BlameLine {
return author;
}
- @CheckForNull
- public String committer() {
- return committer;
+ public BlameLine author(@Nullable String author) {
+ this.author = author;
+ return this;
}
/**
@@ -85,10 +62,12 @@ public class BlameLine {
*/
@CheckForNull
public Date date() {
- if (date != null) {
- return (Date) date.clone();
- }
- return null;
+ return date;
+ }
+
+ public BlameLine date(@Nullable Date date) {
+ this.date = date;
+ return this;
}
// For testing purpose
@@ -109,7 +88,6 @@ public class BlameLine {
.append(date, rhs.date)
.append(revision, rhs.revision)
.append(author, rhs.author)
- .append(committer, rhs.committer)
.isEquals();
}
@@ -119,7 +97,6 @@ public class BlameLine {
append(date)
.append(revision)
.append(author)
- .append(committer)
.toHashCode();
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/ScmProvider.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/ScmProvider.java
index a32bec98538..c3f86878293 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/ScmProvider.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/ScmProvider.java
@@ -20,18 +20,21 @@
package org.sonar.api.batch.scm;
import org.sonar.api.BatchExtension;
+import org.sonar.api.CoreProperties;
import org.sonar.api.batch.InstantiationStrategy;
import java.io.File;
/**
+ * See {@link CoreProperties#LINKS_SOURCES_DEV} to get old Maven URL format.
* @since 5.0
*/
@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
public abstract class ScmProvider implements BatchExtension {
/**
- * Unique identifier of the provider. Can be used in SCM URL to define the provider to use.
+ * Unique identifier of the provider. Can be passed to {@link CoreProperties#SCM_PROVIDER_KEY}
+ * Can be used in SCM URL to define the provider to use.
*/
public abstract String key();