diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2016-08-29 17:01:13 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2016-08-29 17:02:57 +0200 |
commit | 443ad96989ae5f3e5c3388da90a36dcb90d09bf7 (patch) | |
tree | 1192a91eeeb4d23f02fe9b82132e7b159594754e /plugins | |
parent | 0fa7bac665d9c3a29af5db01a445e71d7af23ca5 (diff) | |
download | sonarqube-443ad96989ae5f3e5c3388da90a36dcb90d09bf7.tar.gz sonarqube-443ad96989ae5f3e5c3388da90a36dcb90d09bf7.zip |
SONAR-7864 Drop org.sonar.api.scan.filesystem.ModuleFileSystem from API
SONAR-8038 Deprecate ProjectDefinition::getBuildDir
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/DeprecatedResourceApiSensor.java | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/DeprecatedResourceApiSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/DeprecatedResourceApiSensor.java index 3e51d046716..ffd70020956 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/DeprecatedResourceApiSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/DeprecatedResourceApiSensor.java @@ -21,14 +21,14 @@ package org.sonar.xoo.rule; import java.io.File; import org.sonar.api.batch.Sensor; +import org.sonar.api.batch.fs.FileSystem; +import org.sonar.api.batch.fs.InputFile.Type; import org.sonar.api.batch.rule.ActiveRules; import org.sonar.api.component.ResourcePerspectives; import org.sonar.api.issue.Issuable; import org.sonar.api.resources.Directory; import org.sonar.api.resources.Project; import org.sonar.api.rule.RuleKey; -import org.sonar.api.scan.filesystem.FileQuery; -import org.sonar.api.scan.filesystem.ModuleFileSystem; import org.sonar.api.scan.filesystem.PathResolver; import org.sonar.xoo.Xoo; @@ -36,26 +36,27 @@ import org.sonar.xoo.Xoo; public class DeprecatedResourceApiSensor implements Sensor { public static final String RULE_KEY = "DeprecatedResourceApi"; - private final ModuleFileSystem fileSystem; + private final FileSystem fs; private final ResourcePerspectives perspectives; private final ActiveRules activeRules; - public DeprecatedResourceApiSensor(ModuleFileSystem fileSystem, ResourcePerspectives perspectives, ActiveRules activeRules) { - this.fileSystem = fileSystem; + public DeprecatedResourceApiSensor(FileSystem fileSystem, ResourcePerspectives perspectives, ActiveRules activeRules) { + this.fs = fileSystem; this.perspectives = perspectives; this.activeRules = activeRules; } @Override public boolean shouldExecuteOnProject(Project project) { - return !fileSystem.files(FileQuery.onMain().onLanguage(Xoo.KEY)).isEmpty() && activeRules.find(RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY)) != null; + return fs.hasFiles(fs.predicates().and(fs.predicates().hasType(Type.MAIN), fs.predicates().hasLanguage(Xoo.KEY))) + && activeRules.find(RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY)) != null; } @Override public void analyse(Project module, org.sonar.api.batch.SensorContext context) { - for (File f : fileSystem.files(FileQuery.onMain().onLanguage(Xoo.KEY))) { - String relativePathFromSourceDir = new PathResolver().relativePath(fileSystem.baseDir(), f); - org.sonar.api.resources.File sonarFile = org.sonar.api.resources.File.create(relativePathFromSourceDir); + for (File f : fs.files(fs.predicates().and(fs.predicates().hasType(Type.MAIN), fs.predicates().hasLanguage(Xoo.KEY)))) { + String relativePathFromBaseDir = new PathResolver().relativePath(fs.baseDir(), f); + org.sonar.api.resources.File sonarFile = org.sonar.api.resources.File.create(relativePathFromBaseDir); Issuable issuable = perspectives.as(Issuable.class, sonarFile); issuable.addIssue(issuable.newIssueBuilder() .ruleKey(RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY)) |