diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-06-19 23:25:55 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-06-19 23:26:57 +0200 |
commit | 369f12960fba6653e630042ab977c97e479a3076 (patch) | |
tree | c3896b2a5f2caf4fdc8037567a862e810b43b38f /sonar-plugin-api | |
parent | 71a6a922a2d07ae8db9f13036a9653e772380762 (diff) | |
download | sonarqube-369f12960fba6653e630042ab977c97e479a3076.tar.gz sonarqube-369f12960fba6653e630042ab977c97e479a3076.zip |
SONAR-5389 Add support of FileLinesContextFactory + publish analysis
Diffstat (limited to 'sonar-plugin-api')
4 files changed, 22 insertions, 20 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasureBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasureBuilder.java index e47c949ff52..76de69c6ce4 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasureBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasureBuilder.java @@ -20,7 +20,6 @@ package org.sonar.api.batch.analyzer.measure.internal; import com.google.common.base.Preconditions; -import org.sonar.api.batch.analyzer.measure.AnalyzerMeasure; import org.sonar.api.batch.analyzer.measure.AnalyzerMeasureBuilder; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.measure.Metric; @@ -35,7 +34,7 @@ public class DefaultAnalyzerMeasureBuilder<G extends Serializable> implements An G value; @Override - public AnalyzerMeasureBuilder<G> onFile(InputFile inputFile) { + public DefaultAnalyzerMeasureBuilder<G> onFile(InputFile inputFile) { onProject(false); Preconditions.checkNotNull(inputFile, "inputFile should be non null"); this.file = inputFile; @@ -43,7 +42,7 @@ public class DefaultAnalyzerMeasureBuilder<G extends Serializable> implements An } @Override - public AnalyzerMeasureBuilder<G> onProject() { + public DefaultAnalyzerMeasureBuilder<G> onProject() { onProject(true); this.file = null; return this; @@ -55,7 +54,7 @@ public class DefaultAnalyzerMeasureBuilder<G extends Serializable> implements An } @Override - public AnalyzerMeasureBuilder<G> forMetric(Metric<G> metric) { + public DefaultAnalyzerMeasureBuilder<G> forMetric(Metric<G> metric) { Preconditions.checkState(metric != null, "Metric already defined"); Preconditions.checkNotNull(metric, "metric should be non null"); this.metric = metric; @@ -63,7 +62,7 @@ public class DefaultAnalyzerMeasureBuilder<G extends Serializable> implements An } @Override - public AnalyzerMeasureBuilder<G> withValue(G value) { + public DefaultAnalyzerMeasureBuilder<G> withValue(G value) { Preconditions.checkState(this.value == null, "Measure value already defined"); Preconditions.checkNotNull(value, "Measure value can't be null"); this.value = value; @@ -71,7 +70,7 @@ public class DefaultAnalyzerMeasureBuilder<G extends Serializable> implements An } @Override - public AnalyzerMeasure<G> build() { + public DefaultAnalyzerMeasure<G> build() { return new DefaultAnalyzerMeasure<G>(this); } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/FileLinesContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/FileLinesContext.java index 606d103793d..f828a6f5660 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/FileLinesContext.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/FileLinesContext.java @@ -19,7 +19,6 @@ */ package org.sonar.api.measures; -import com.google.common.annotations.Beta; /** * Provides access to measures for the lines of file. @@ -39,7 +38,6 @@ import com.google.common.annotations.Beta; * * @since 2.14 */ -@Beta public interface FileLinesContext { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/FileLinesContextFactory.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/FileLinesContextFactory.java index 385ebfd1020..ad80aa5bb42 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/FileLinesContextFactory.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/FileLinesContextFactory.java @@ -19,7 +19,6 @@ */ package org.sonar.api.measures; -import com.google.common.annotations.Beta; import org.sonar.api.BatchComponent; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.resources.Resource; @@ -29,11 +28,17 @@ import org.sonar.api.resources.Resource; * * @since 2.14 */ -@Beta public interface FileLinesContextFactory extends BatchComponent { + /** + * @deprecated since 4.4 use {@link #createFor(InputFile)} + */ + @Deprecated FileLinesContext createFor(Resource resource); + /** + * @since 4.2 + */ FileLinesContext createFor(InputFile inputFile); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java index 528ef76edfb..7a8e905f8ed 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java @@ -42,7 +42,7 @@ import java.util.Set; */ public class RangeDistributionBuilder implements MeasureBuilder { - private Metric metric; + private Metric<String> metric; private SortedBag countBag; private boolean isEmpty = true; private Number[] bottomLimits; @@ -55,7 +55,7 @@ public class RangeDistributionBuilder implements MeasureBuilder { * @param metric the metric to record the measure against * @param bottomLimits the bottom limits of ranges to be used */ - public RangeDistributionBuilder(Metric metric, Number[] bottomLimits) { + public RangeDistributionBuilder(Metric<String> metric, Number[] bottomLimits) { setMetric(metric); init(bottomLimits); } @@ -72,18 +72,18 @@ public class RangeDistributionBuilder implements MeasureBuilder { private void changeDoublesToInts() { boolean onlyInts = true; for (Number bottomLimit : bottomLimits) { - if (NumberUtils.compare(bottomLimit.intValue(), bottomLimit.doubleValue())!=0) { - onlyInts=false; + if (NumberUtils.compare(bottomLimit.intValue(), bottomLimit.doubleValue()) != 0) { + onlyInts = false; } } if (onlyInts) { - for (int i=0 ; i<bottomLimits.length ; i++) { + for (int i = 0; i < bottomLimits.length; i++) { bottomLimits[i] = bottomLimits[i].intValue(); } } } - public RangeDistributionBuilder(Metric metric) { + public RangeDistributionBuilder(Metric<String> metric) { this.metric = metric; } @@ -144,7 +144,7 @@ public class RangeDistributionBuilder implements MeasureBuilder { * @param measure the measure to add to the current one * @return the current object */ - public RangeDistributionBuilder add(Measure measure) { + public RangeDistributionBuilder add(Measure<String> measure) { if (measure != null && measure.getData() != null) { Map<Double, Double> map = KeyValueFormat.parse(measure.getData(), new KeyValueFormat.DoubleNumbersPairTransformer()); Number[] limits = map.keySet().toArray(new Number[map.size()]); @@ -208,7 +208,7 @@ public class RangeDistributionBuilder implements MeasureBuilder { * * @return the built measure */ - public Measure build() { + public Measure<String> build() { return build(true); } @@ -218,9 +218,9 @@ public class RangeDistributionBuilder implements MeasureBuilder { * @param allowEmptyData should be built if current object is empty * @return the built measure */ - public Measure build(boolean allowEmptyData) { + public Measure<String> build(boolean allowEmptyData) { if (isValid && (!isEmpty || allowEmptyData)) { - return new Measure(metric, KeyValueFormat.format(countBag, -1)); + return new Measure<String>(metric, KeyValueFormat.format(countBag, -1)); } return null; } |