]> source.dussan.org Git - sonarqube.git/commitdiff
Rename for consistency
authorJulien HENRY <julien.henry@sonarsource.com>
Mon, 1 Sep 2014 16:16:10 +0000 (18:16 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Mon, 1 Sep 2014 16:16:10 +0000 (18:16 +0200)
sonar-batch/src/main/java/org/sonar/batch/scan/SensorContextAdaptor.java
sonar-batch/src/main/java/org/sonar/batch/scan2/BaseSensorContext.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/scan2/CommonSensorContext.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultSensorContext.java

index 6a117d7ec6a64b91b0723a720efc944aefcf9926..545c480381a432fdb92cbe2a21f151f54829777c 100644 (file)
@@ -46,7 +46,7 @@ import org.sonar.api.rule.RuleKey;
 import org.sonar.batch.duplication.BlockCache;
 import org.sonar.batch.duplication.DuplicationCache;
 import org.sonar.batch.index.ComponentDataCache;
-import org.sonar.batch.scan2.CommonSensorContext;
+import org.sonar.batch.scan2.BaseSensorContext;
 
 import java.io.Serializable;
 
@@ -55,7 +55,7 @@ import java.io.Serializable;
  * Will be dropped once old {@link Sensor} API is dropped.
  *
  */
-public class SensorContextAdaptor extends CommonSensorContext {
+public class SensorContextAdaptor extends BaseSensorContext {
 
   private final org.sonar.api.batch.SensorContext sensorContext;
   private final MetricFinder metricFinder;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/BaseSensorContext.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/BaseSensorContext.java
new file mode 100644 (file)
index 0000000..1246d4e
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * 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.batch.scan2;
+
+import com.google.common.base.Preconditions;
+import org.sonar.api.batch.fs.FileSystem;
+import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
+import org.sonar.api.batch.rule.ActiveRules;
+import org.sonar.api.batch.sensor.SensorContext;
+import org.sonar.api.batch.sensor.duplication.DuplicationBuilder;
+import org.sonar.api.batch.sensor.duplication.DuplicationGroup;
+import org.sonar.api.batch.sensor.duplication.DuplicationTokenBuilder;
+import org.sonar.api.batch.sensor.duplication.internal.DefaultDuplicationBuilder;
+import org.sonar.api.batch.sensor.highlighting.HighlightingBuilder;
+import org.sonar.api.batch.sensor.issue.IssueBuilder;
+import org.sonar.api.batch.sensor.issue.internal.DefaultIssueBuilder;
+import org.sonar.api.batch.sensor.measure.MeasureBuilder;
+import org.sonar.api.batch.sensor.measure.internal.DefaultMeasureBuilder;
+import org.sonar.api.batch.sensor.symbol.SymbolTableBuilder;
+import org.sonar.api.config.Settings;
+import org.sonar.batch.duplication.BlockCache;
+import org.sonar.batch.duplication.DefaultTokenBuilder;
+import org.sonar.batch.duplication.DuplicationCache;
+import org.sonar.batch.highlighting.DefaultHighlightingBuilder;
+import org.sonar.batch.index.ComponentDataCache;
+import org.sonar.batch.scan.SensorContextAdaptor;
+import org.sonar.batch.symbol.DefaultSymbolTableBuilder;
+import org.sonar.duplications.internal.pmd.PmdBlockChunker;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Common bits between {@link DefaultSensorContext} and {@link SensorContextAdaptor}
+ * @author julien
+ *
+ */
+public abstract class BaseSensorContext implements SensorContext {
+
+  private final Settings settings;
+  private final FileSystem fs;
+  private final ActiveRules activeRules;
+  private final ComponentDataCache componentDataCache;
+  private final BlockCache blockCache;
+  private final DuplicationCache duplicationCache;
+
+  protected BaseSensorContext(Settings settings, FileSystem fs, ActiveRules activeRules, ComponentDataCache componentDataCache,
+    BlockCache blockCache, DuplicationCache duplicationCache) {
+    this.settings = settings;
+    this.fs = fs;
+    this.activeRules = activeRules;
+    this.componentDataCache = componentDataCache;
+    this.blockCache = blockCache;
+    this.duplicationCache = duplicationCache;
+  }
+
+  @Override
+  public Settings settings() {
+    return settings;
+  }
+
+  @Override
+  public FileSystem fileSystem() {
+    return fs;
+  }
+
+  @Override
+  public ActiveRules activeRules() {
+    return activeRules;
+  }
+
+  @Override
+  public <G extends Serializable> MeasureBuilder<G> measureBuilder() {
+    return new DefaultMeasureBuilder<G>();
+  }
+
+  @Override
+  public IssueBuilder issueBuilder() {
+    return new DefaultIssueBuilder();
+  }
+
+  @Override
+  public HighlightingBuilder highlightingBuilder(InputFile inputFile) {
+    return new DefaultHighlightingBuilder(((DefaultInputFile) inputFile).key(), componentDataCache);
+  }
+
+  @Override
+  public SymbolTableBuilder symbolTableBuilder(InputFile inputFile) {
+    return new DefaultSymbolTableBuilder(((DefaultInputFile) inputFile).key(), componentDataCache);
+  }
+
+  @Override
+  public DuplicationTokenBuilder duplicationTokenBuilder(InputFile inputFile) {
+    PmdBlockChunker blockChunker = new PmdBlockChunker(getBlockSize(inputFile.language()));
+
+    return new DefaultTokenBuilder(inputFile, blockCache, blockChunker);
+  }
+
+  @Override
+  public DuplicationBuilder duplicationBuilder(InputFile inputFile) {
+    return new DefaultDuplicationBuilder(inputFile);
+  }
+
+  @Override
+  public void saveDuplications(InputFile inputFile, List<DuplicationGroup> duplications) {
+    Preconditions.checkState(!duplications.isEmpty(), "Empty duplications");
+    String effectiveKey = ((DefaultInputFile) inputFile).key();
+    for (DuplicationGroup duplicationGroup : duplications) {
+      Preconditions.checkState(effectiveKey.equals(duplicationGroup.originBlock().resourceKey()), "Invalid duplication group");
+    }
+    duplicationCache.put(effectiveKey, duplications);
+  }
+
+  private int getBlockSize(String languageKey) {
+    int blockSize = settings.getInt("sonar.cpd." + languageKey + ".minimumLines");
+    if (blockSize == 0) {
+      blockSize = getDefaultBlockSize(languageKey);
+    }
+    return blockSize;
+  }
+
+  private static int getDefaultBlockSize(String languageKey) {
+    if ("cobol".equals(languageKey)) {
+      return 30;
+    } else if ("abap".equals(languageKey) || "natur".equals(languageKey)) {
+      return 20;
+    } else {
+      return 10;
+    }
+  }
+
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/CommonSensorContext.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/CommonSensorContext.java
deleted file mode 100644 (file)
index 6c3ed89..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * 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.batch.scan2;
-
-import com.google.common.base.Preconditions;
-import org.sonar.api.batch.fs.FileSystem;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.rule.ActiveRules;
-import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.api.batch.sensor.duplication.DuplicationBuilder;
-import org.sonar.api.batch.sensor.duplication.DuplicationGroup;
-import org.sonar.api.batch.sensor.duplication.DuplicationTokenBuilder;
-import org.sonar.api.batch.sensor.duplication.internal.DefaultDuplicationBuilder;
-import org.sonar.api.batch.sensor.highlighting.HighlightingBuilder;
-import org.sonar.api.batch.sensor.issue.IssueBuilder;
-import org.sonar.api.batch.sensor.issue.internal.DefaultIssueBuilder;
-import org.sonar.api.batch.sensor.measure.MeasureBuilder;
-import org.sonar.api.batch.sensor.measure.internal.DefaultMeasureBuilder;
-import org.sonar.api.batch.sensor.symbol.SymbolTableBuilder;
-import org.sonar.api.config.Settings;
-import org.sonar.batch.duplication.BlockCache;
-import org.sonar.batch.duplication.DefaultTokenBuilder;
-import org.sonar.batch.duplication.DuplicationCache;
-import org.sonar.batch.highlighting.DefaultHighlightingBuilder;
-import org.sonar.batch.index.ComponentDataCache;
-import org.sonar.batch.scan.SensorContextAdaptor;
-import org.sonar.batch.symbol.DefaultSymbolTableBuilder;
-import org.sonar.duplications.internal.pmd.PmdBlockChunker;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * Common bits between {@link DefaultSensorContext} and {@link SensorContextAdaptor}
- * @author julien
- *
- */
-public abstract class CommonSensorContext implements SensorContext {
-
-  private final Settings settings;
-  private final FileSystem fs;
-  private final ActiveRules activeRules;
-  private final ComponentDataCache componentDataCache;
-  private final BlockCache blockCache;
-  private final DuplicationCache duplicationCache;
-
-  protected CommonSensorContext(Settings settings, FileSystem fs, ActiveRules activeRules, ComponentDataCache componentDataCache,
-    BlockCache blockCache, DuplicationCache duplicationCache) {
-    this.settings = settings;
-    this.fs = fs;
-    this.activeRules = activeRules;
-    this.componentDataCache = componentDataCache;
-    this.blockCache = blockCache;
-    this.duplicationCache = duplicationCache;
-  }
-
-  @Override
-  public Settings settings() {
-    return settings;
-  }
-
-  @Override
-  public FileSystem fileSystem() {
-    return fs;
-  }
-
-  @Override
-  public ActiveRules activeRules() {
-    return activeRules;
-  }
-
-  @Override
-  public <G extends Serializable> MeasureBuilder<G> measureBuilder() {
-    return new DefaultMeasureBuilder<G>();
-  }
-
-  @Override
-  public IssueBuilder issueBuilder() {
-    return new DefaultIssueBuilder();
-  }
-
-  @Override
-  public HighlightingBuilder highlightingBuilder(InputFile inputFile) {
-    return new DefaultHighlightingBuilder(((DefaultInputFile) inputFile).key(), componentDataCache);
-  }
-
-  @Override
-  public SymbolTableBuilder symbolTableBuilder(InputFile inputFile) {
-    return new DefaultSymbolTableBuilder(((DefaultInputFile) inputFile).key(), componentDataCache);
-  }
-
-  @Override
-  public DuplicationTokenBuilder duplicationTokenBuilder(InputFile inputFile) {
-    PmdBlockChunker blockChunker = new PmdBlockChunker(getBlockSize(inputFile.language()));
-
-    return new DefaultTokenBuilder(inputFile, blockCache, blockChunker);
-  }
-
-  @Override
-  public DuplicationBuilder duplicationBuilder(InputFile inputFile) {
-    return new DefaultDuplicationBuilder(inputFile);
-  }
-
-  @Override
-  public void saveDuplications(InputFile inputFile, List<DuplicationGroup> duplications) {
-    Preconditions.checkState(!duplications.isEmpty(), "Empty duplications");
-    String effectiveKey = ((DefaultInputFile) inputFile).key();
-    for (DuplicationGroup duplicationGroup : duplications) {
-      Preconditions.checkState(effectiveKey.equals(duplicationGroup.originBlock().resourceKey()), "Invalid duplication group");
-    }
-    duplicationCache.put(effectiveKey, duplications);
-  }
-
-  private int getBlockSize(String languageKey) {
-    int blockSize = settings.getInt("sonar.cpd." + languageKey + ".minimumLines");
-    if (blockSize == 0) {
-      blockSize = getDefaultBlockSize(languageKey);
-    }
-    return blockSize;
-  }
-
-  private static int getDefaultBlockSize(String languageKey) {
-    if ("cobol".equals(languageKey)) {
-      return 30;
-    } else if ("abap".equals(languageKey) || "natur".equals(languageKey)) {
-      return 20;
-    } else {
-      return 10;
-    }
-  }
-
-}
index 6350622c72fa69bf2272dfa2fd61d847832634de..2df3de1b0e5490f92aa84609d0d523c9dce72176 100644 (file)
@@ -42,7 +42,7 @@ import org.sonar.core.component.ComponentKeys;
 
 import java.io.Serializable;
 
-public class DefaultSensorContext extends CommonSensorContext {
+public class DefaultSensorContext extends BaseSensorContext {
 
   private final AnalyzerMeasureCache measureCache;
   private final AnalyzerIssueCache issueCache;