|
1 | | -import 'dart:io'; |
2 | | - |
3 | 1 | import 'package:analyzer/error/listener.dart'; |
4 | 2 | import 'package:custom_lint_builder/custom_lint_builder.dart'; |
5 | 3 | import 'package:meta/meta.dart'; |
@@ -31,23 +29,25 @@ abstract class PluralLintRule extends LintRule { |
31 | 29 | ErrorReporter reporter, |
32 | 30 | CustomLintContext context, |
33 | 31 | ) { |
34 | | - final file = File(reporter.source.uri.path); |
| 32 | + final filePath = resolver.path; |
35 | 33 | final plurals = <(List<String>, int)>[]; |
36 | | - final jsonParseResult = |
37 | | - JsonDefinition(plurals.add).build().parse(file.readAsStringSync()); |
| 34 | + final jsonParseResult = JsonDefinition(plurals.add) |
| 35 | + .build() |
| 36 | + .parse(resolver.source.contents.data); |
38 | 37 | if (jsonParseResult is Failure) { |
39 | 38 | print( |
40 | | - 'Ignoring ARB: $file. JSON parsing error: ${jsonParseResult.message}'); |
| 39 | + 'Ignoring ARB: $filePath. JSON parsing error: ${jsonParseResult.message}'); |
41 | 40 | return; |
42 | 41 | } |
43 | 42 | final json = jsonParseResult.value; |
44 | 43 | final locale = json['@@locale'] ?? |
45 | 44 | json['_locale'] ?? |
46 | | - basenameWithoutExtension(file.path).split('_').skip(1).join('_'); |
| 45 | + basenameWithoutExtension(filePath).split('_').skip(1).join('_'); |
47 | 46 |
|
48 | 47 | final quantitiesForLocale = CldrData().pluralRules()[locale]; |
49 | 48 | if (quantitiesForLocale == null) { |
50 | | - print('Ignoring ARB: $file. No CLDR plural rules for locale: $locale'); |
| 49 | + print( |
| 50 | + 'Ignoring ARB: $filePath. No CLDR plural rules for locale: $locale'); |
51 | 51 | return; |
52 | 52 | } |
53 | 53 |
|
|
0 commit comments