Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
679 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...r-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/InMemorySensorStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,82 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2016 SonarSource SA | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* This program 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. | |||
* | |||
* This program 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.api.batch.sensor.internal; | |||
|
|||
import com.google.common.collect.HashBasedTable; | |||
import com.google.common.collect.Table; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.EnumMap; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
import org.sonar.api.batch.sensor.coverage.CoverageType; | |||
import org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage; | |||
import org.sonar.api.batch.sensor.cpd.internal.DefaultCpdTokens; | |||
import org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting; | |||
import org.sonar.api.batch.sensor.issue.Issue; | |||
import org.sonar.api.batch.sensor.measure.Measure; | |||
import org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable; | |||
|
|||
class InMemorySensorStorage implements SensorStorage { | |||
|
|||
Table<String, String, Measure> measuresByComponentAndMetric = HashBasedTable.create(); | |||
|
|||
Collection<Issue> allIssues = new ArrayList<>(); | |||
|
|||
Map<String, DefaultHighlighting> highlightingByComponent = new HashMap<>(); | |||
Map<String, DefaultCpdTokens> cpdTokensByComponent = new HashMap<>(); | |||
Map<String, Map<CoverageType, DefaultCoverage>> coverageByComponent = new HashMap<>(); | |||
Map<String, DefaultSymbolTable> symbolsPerComponent = new HashMap<>(); | |||
|
|||
@Override | |||
public void store(Measure measure) { | |||
measuresByComponentAndMetric.row(measure.inputComponent().key()).put(measure.metric().key(), measure); | |||
} | |||
|
|||
@Override | |||
public void store(Issue issue) { | |||
allIssues.add(issue); | |||
} | |||
|
|||
@Override | |||
public void store(DefaultHighlighting highlighting) { | |||
highlightingByComponent.put(highlighting.inputFile().key(), highlighting); | |||
} | |||
|
|||
@Override | |||
public void store(DefaultCoverage defaultCoverage) { | |||
String key = defaultCoverage.inputFile().key(); | |||
if (!coverageByComponent.containsKey(key)) { | |||
coverageByComponent.put(key, new EnumMap<CoverageType, DefaultCoverage>(CoverageType.class)); | |||
} | |||
coverageByComponent.get(key).put(defaultCoverage.type(), defaultCoverage); | |||
} | |||
|
|||
@Override | |||
public void store(DefaultCpdTokens defaultCpdTokens) { | |||
cpdTokensByComponent.put(defaultCpdTokens.inputFile().key(), defaultCpdTokens); | |||
} | |||
|
|||
@Override | |||
public void store(DefaultSymbolTable symbolTable) { | |||
symbolsPerComponent.put(symbolTable.inputFile().key(), symbolTable); | |||
} | |||
|
|||
} |
50 changes: 50 additions & 0 deletions
50
sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/MockAnalysisMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,50 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2016 SonarSource SA | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* This program 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. | |||
* | |||
* This program 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.api.batch.sensor.internal; | |||
|
|||
import org.sonar.api.batch.AnalysisMode; | |||
|
|||
public class MockAnalysisMode implements AnalysisMode { | |||
private boolean isPreview = false; | |||
private boolean isIssues = false; | |||
|
|||
@Override | |||
public boolean isPreview() { | |||
return isPreview; | |||
} | |||
|
|||
public void setPreview(boolean value) { | |||
this.isPreview = value; | |||
} | |||
|
|||
@Override | |||
public boolean isIssues() { | |||
return this.isIssues; | |||
} | |||
|
|||
public void setIssues(boolean issues) { | |||
this.isIssues = issues; | |||
} | |||
|
|||
@Override | |||
public boolean isPublish() { | |||
return !isPreview && !isIssues; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/symbol/NewSymbol.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,50 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2016 SonarSource SA | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* This program 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. | |||
* | |||
* This program 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.api.batch.sensor.symbol; | |||
|
|||
import com.google.common.annotations.Beta; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.TextRange; | |||
|
|||
/** | |||
* This builder is used to define symbol references on files. | |||
* @since 5.6 | |||
*/ | |||
@Beta | |||
public interface NewSymbol { | |||
|
|||
/** | |||
* Register a new symbol reference. | |||
* @param startOffset Starting position in file for the declaration of this symbol. Beginning of a file starts with offset '0'. | |||
* @param endOffset End position in file for this symbol declaration. | |||
*/ | |||
NewSymbol newReference(int startOffset, int endOffset); | |||
|
|||
/** | |||
* Register a new symbol. | |||
* @param range Range of text for the symbol declaration. See for example {@link InputFile#newRange(int, int, int, int)}. | |||
*/ | |||
NewSymbol newReference(TextRange range); | |||
|
|||
/** | |||
* Shortcut to avoid calling {@link InputFile#newRange(int, int, int, int)} | |||
*/ | |||
NewSymbol newReference(int startLine, int startLineOffset, int endLine, int endLineOffset); | |||
} |
Oops, something went wrong.