aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api-impl
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2022-06-22 16:17:26 -0500
committersonartech <sonartech@sonarsource.com>2022-07-23 20:02:53 +0000
commit0fb5e45d935ad212aa3fe32202c33dd8395078c5 (patch)
tree4c2afc044dc034f9c70a11b58f02a762b3ba3448 /sonar-plugin-api-impl
parent1220331cf405fb916a005284120b0ed02ea67ac2 (diff)
downloadsonarqube-0fb5e45d935ad212aa3fe32202c33dd8395078c5.tar.gz
sonarqube-0fb5e45d935ad212aa3fe32202c33dd8395078c5.zip
SONAR-17044 Optimize Compute Engine issue tracking and persisting of measures when file is marked as unchanged
Diffstat (limited to 'sonar-plugin-api-impl')
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputComponent.java2
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java12
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java7
3 files changed, 19 insertions, 2 deletions
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputComponent.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputComponent.java
index cb37d133823..431575f1b54 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputComponent.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputComponent.java
@@ -52,6 +52,7 @@ public abstract class DefaultInputComponent implements InputComponent {
return id;
}
+
@Override
public int hashCode() {
return key().hashCode();
@@ -68,5 +69,6 @@ public abstract class DefaultInputComponent implements InputComponent {
public boolean hasMeasureFor(Metric metric) {
return storedMetricKeys.contains(metric.key());
+
}
}
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java
index 888763dfdb7..382461fbc5a 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java
@@ -70,6 +70,8 @@ public class DefaultInputFile extends DefaultInputComponent implements InputFile
private Metadata metadata;
private Collection<int[]> ignoreIssuesOnlineRanges;
private BitSet executableLines;
+ private boolean markedAsUnchanged;
+
public DefaultInputFile(DefaultIndexedFile indexedFile, Consumer<DefaultInputFile> metadataGenerator) {
this(indexedFile, metadataGenerator, null);
@@ -81,6 +83,7 @@ public class DefaultInputFile extends DefaultInputComponent implements InputFile
this.indexedFile = indexedFile;
this.metadataGenerator = metadataGenerator;
this.metadata = null;
+ this.markedAsUnchanged = false;
this.published = false;
this.excludedForCoverage = false;
this.contents = contents;
@@ -99,6 +102,15 @@ public class DefaultInputFile extends DefaultInputComponent implements InputFile
ByteOrderMark.UTF_8, ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_32LE, ByteOrderMark.UTF_32BE);
}
+ public boolean isMarkedAsUnchanged() {
+ return markedAsUnchanged;
+ }
+
+ public DefaultInputComponent setMarkedAsUnchanged(boolean markedAsUnchanged) {
+ this.markedAsUnchanged = markedAsUnchanged;
+ return this;
+ }
+
@Override
public String contents() throws IOException {
if (contents != null) {
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java
index 98b48f12382..5c03698dc68 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java
@@ -414,6 +414,11 @@ public class SensorContextTester implements SensorContext {
}
@Override
+ public void markAsUnchanged(InputFile inputFile) {
+ ((DefaultInputFile) inputFile).setMarkedAsUnchanged(true);
+ }
+
+ @Override
public WriteCache nextCache() {
return writeCache;
}
@@ -427,7 +432,6 @@ public class SensorContextTester implements SensorContext {
return readCache;
}
-
public void setPreviousCache(ReadCache cache) {
this.readCache = cache;
}
@@ -437,7 +441,6 @@ public class SensorContextTester implements SensorContext {
return cacheEnabled;
}
-
public void setCacheEnabled(boolean enabled) {
this.cacheEnabled = enabled;
}