aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2012-02-09 17:23:05 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2012-02-09 18:48:53 +0400
commit90a3277d3f57a4414fc6bbc48986345d56af23b6 (patch)
tree55e78d0b2fa1861d5827ca82bf5ad3913edb8aac /sonar-plugin-api
parentefaa03159609208211d8271e2db44c847b1ea7c8 (diff)
downloadsonarqube-90a3277d3f57a4414fc6bbc48986345d56af23b6.tar.gz
sonarqube-90a3277d3f57a4414fc6bbc48986345d56af23b6.zip
SONAR-3209,SONAR-3210 Provide API to save and retrieve measures by line
+ Use this API to save LoC in Java files
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java8
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/FileLinesContext.java58
2 files changed, 66 insertions, 0 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 fc9189410c2..1cc5b291403 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
@@ -19,7 +19,9 @@
*/
package org.sonar.api.batch;
+import com.google.common.annotations.Beta;
import org.sonar.api.design.Dependency;
+import org.sonar.api.measures.FileLinesContext;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.MeasuresFilter;
import org.sonar.api.measures.Metric;
@@ -150,6 +152,12 @@ public interface SensorContext {
*/
Measure saveMeasure(Resource resource, Measure measure);
+ /**
+ * @since 2.14
+ */
+ @Beta
+ FileLinesContext createFileLinesContext(Resource resource);
+
// ----------- RULE VIOLATIONS --------------
/**
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
new file mode 100644
index 00000000000..f2fe4dcaf18
--- /dev/null
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/FileLinesContext.java
@@ -0,0 +1,58 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.measures;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Provides access to measures for the lines of file.
+ * Examples:
+ * <ul>
+ * <li>line 1 is a line of code</li>
+ * <li>line 2 contains comment</li>
+ * <li>line 3 contains 2 branches</li>
+ * <li>author of line 4 is Simon</li>
+ * </ul>
+ * Numbering of lines starts from 1.
+ *
+ * <p>This interface is not intended to be implemented by clients.</p>
+ *
+ * @since 2.14
+ */
+@Beta
+public interface FileLinesContext {
+
+ void setIntValue(String metricKey, int line, int value);
+
+ /**
+ * @return value, or null if no such metric for given line
+ */
+ Integer getIntValue(String metricKey, int line);
+
+ void setStringValue(String metricKey, int line, String value);
+
+ /**
+ * @return value, or null if no such metric for given line
+ */
+ String getStringValue(String metricKey, int line);
+
+ void save();
+
+}