Skip to content

Commit d13da3f

Browse files
stereotype441Commit Queue
authored andcommitted
[linter/directives_ordering] Pluralize in Dart code rather than message template.
In a follow-up CL I will be changing the format of the `problemMessage` templates in `pkg/linter/messages.yaml`, so that instead of using numeric placeholders like `{0}`, it will use named placeholders of the form `#IDENTIFIER`. This will make the analyzer/linter diagnostic message code generation more similar to the CFE's diagnostic message code generation, which should help pave the way for one day unifying the two diagnostic message representations. This poses a problem for the `directives_ordering_dart` and `directives_ordering_package_before_relative` diagnostic messages: prior to this CL, they used `{0}s` in their `problemMessage` templates to pluarlize argument zero. That can't be done using placeholders of the form `#IDENTIFIER`, since `s` is a valid identifier character. In an ideal world we would probably fix this by adding support for a placeholder syntax like `#{IDENTIFIER}`. But since only these two messages are affected, it's more pragmatic to just do the pluralization in Dart code rather than in the templates. Change-Id: Ifbe2008aa1e252375c684b5770848eb143972703 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444386 Reviewed-by: Samuel Rawlins <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent 2206c9b commit d13da3f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

pkg/linter/lib/src/lint_codes.g.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ class LinterLintCode extends LintCode {
593593

594594
static const LintCode directives_ordering_dart = LinterLintCode(
595595
LintNames.directives_ordering,
596-
"Place 'dart:' {0}s before other {0}s.",
596+
"Place 'dart:' {0} before other {0}.",
597597
correctionMessage: "Try sorting the directives.",
598598
uniqueName: 'directives_ordering_dart',
599599
);
@@ -608,7 +608,7 @@ class LinterLintCode extends LintCode {
608608
static const LintCode directives_ordering_package_before_relative =
609609
LinterLintCode(
610610
LintNames.directives_ordering,
611-
"Place 'package:' {0}s before relative {0}s.",
611+
"Place 'package:' {0} before relative {0}.",
612612
correctionMessage: "Try sorting the directives.",
613613
uniqueName: 'directives_ordering_package_before_relative',
614614
);

pkg/linter/lib/src/rules/directives_ordering.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class DirectivesOrdering extends MultiAnalysisRule {
8282
reportAtNode(
8383
node,
8484
diagnosticCode: LinterLintCode.directives_ordering_dart,
85-
arguments: [type],
85+
arguments: ['${type}s'],
8686
);
8787
}
8888

@@ -110,7 +110,7 @@ class DirectivesOrdering extends MultiAnalysisRule {
110110
node,
111111
diagnosticCode:
112112
LinterLintCode.directives_ordering_package_before_relative,
113-
arguments: [type],
113+
arguments: ['${type}s'],
114114
);
115115
}
116116
}

pkg/linter/messages.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4098,7 +4098,7 @@ LintCode:
40984098
```
40994099
directives_ordering_dart:
41004100
sharedName: directives_ordering
4101-
problemMessage: "Place 'dart:' {0}s before other {0}s."
4101+
problemMessage: "Place 'dart:' {0} before other {0}."
41024102
correctionMessage: "Try sorting the directives."
41034103
hasPublishedDocs: false
41044104
directives_ordering_exports:
@@ -4108,7 +4108,7 @@ LintCode:
41084108
hasPublishedDocs: false
41094109
directives_ordering_package_before_relative:
41104110
sharedName: directives_ordering
4111-
problemMessage: "Place 'package:' {0}s before relative {0}s."
4111+
problemMessage: "Place 'package:' {0} before relative {0}."
41124112
correctionMessage: "Try sorting the directives."
41134113
hasPublishedDocs: false
41144114
discarded_futures:

0 commit comments

Comments
 (0)