diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2016-07-12 11:34:40 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2016-07-12 13:03:43 +0200 |
commit | 7bea09f6eb442441908de2df48b0ed7dd75e001f (patch) | |
tree | 8829c953087f6d78dc3d9b6fd921f517ad573ca8 /plugins | |
parent | f8719e3723661704e60c8902ab60d0a3b8b931cd (diff) | |
download | sonarqube-7bea09f6eb442441908de2df48b0ed7dd75e001f.tar.gz sonarqube-7bea09f6eb442441908de2df48b0ed7dd75e001f.zip |
SONAR-7883 Expose InputFile charset in API
Diffstat (limited to 'plugins')
4 files changed, 7 insertions, 7 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/CpdTokenizerSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/CpdTokenizerSensor.java index aa2c69faa57..ed06b22574a 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/CpdTokenizerSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/CpdTokenizerSensor.java @@ -42,7 +42,7 @@ public class CpdTokenizerSensor implements Sensor { NewCpdTokens newCpdTokens = context.newCpdTokens().onFile(inputFile); try { StringBuilder sb = new StringBuilder(); - for (String line : FileUtils.readLines(inputFile.file(), context.fileSystem().encoding())) { + for (String line : FileUtils.readLines(inputFile.file(), inputFile.charset())) { int startOffset = 0; int endOffset = 0; for (int i = 0; i < line.length(); i++) { diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/HasTagSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/HasTagSensor.java index 9f030e6db69..afea04da892 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/HasTagSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/HasTagSensor.java @@ -58,7 +58,7 @@ public class HasTagSensor extends AbstractXooRuleSensor { } try { int[] lineCounter = {1}; - Files.lines(inputFile.path(), context.fileSystem().encoding()).forEachOrdered(lineStr -> { + Files.lines(inputFile.path(), inputFile.charset()).forEachOrdered(lineStr -> { int startIndex = -1; while ((startIndex = lineStr.indexOf(tag, startIndex + 1)) != -1) { NewIssue newIssue = context.newIssue(); diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/MultilineIssuesSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/MultilineIssuesSensor.java index babb207377e..ef63c48adf3 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/MultilineIssuesSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/MultilineIssuesSensor.java @@ -84,7 +84,7 @@ public class MultilineIssuesSensor implements Sensor { Map<Integer, Table<Integer, Integer, TextPointer>> endFlowsPositions) { int currentLine = 0; try { - for (String lineStr : Files.readAllLines(file.path(), context.fileSystem().encoding())) { + for (String lineStr : Files.readAllLines(file.path(), file.charset())) { currentLine++; Matcher m = START_FLOW_PATTERN.matcher(lineStr); @@ -159,7 +159,7 @@ public class MultilineIssuesSensor implements Sensor { Map<Integer, TextPointer> endPositions) { int currentLine = 0; try { - for (String lineStr : Files.readAllLines(file.path(), context.fileSystem().encoding())) { + for (String lineStr : Files.readAllLines(file.path(), file.charset())) { currentLine++; Matcher m = START_ISSUE_PATTERN.matcher(lineStr); diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/NoSonarSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/NoSonarSensor.java index d57e2f1eb93..93e4d169070 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/NoSonarSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/NoSonarSensor.java @@ -50,15 +50,15 @@ public class NoSonarSensor implements Sensor { @Override public void execute(SensorContext context) { for (InputFile inputFile : context.fileSystem().inputFiles(context.fileSystem().predicates().hasLanguage(Xoo.KEY))) { - processFile(inputFile, context); + processFile(inputFile); } } - private void processFile(InputFile inputFile, SensorContext context) { + private void processFile(InputFile inputFile) { try { Set<Integer> noSonarLines = new HashSet<>(); int[] lineCounter = {1}; - try (Stream<String> stream = Files.lines(inputFile.path(), context.fileSystem().encoding())) { + try (Stream<String> stream = Files.lines(inputFile.path(), inputFile.charset())) { stream.forEachOrdered(lineStr -> { if (lineStr.contains("//NOSONAR")) { noSonarLines.add(lineCounter[0]); |