Skip to content

Commit ced0ef4

Browse files
stereotype441Commit Queue
authored andcommitted
[analyzer] Hardcode literateApiEnabled to true
The constant `literateApiEnabled` was a temporary artifact of the rollout of the analyzer's new literate API for diagnostic reporting. Now that the literate API is enabled, it is no longer needed. Hardcoding this constant simplifies the code generation logic for analyzer and linter diagnostics. This should help pave the way for sharing more of the code generation logic with the CFE. Change-Id: I6a6a6964c16db74613f6c7d9a3f8ee6789b38dda Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447944 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Paul Berry <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]>
1 parent dbdfb1e commit ced0ef4

File tree

3 files changed

+6
-30
lines changed

3 files changed

+6
-30
lines changed

pkg/analyzer/tool/messages/error_code_info.dart

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,6 @@ const hintCodesFile = GeneratedErrorCodeFile(
115115
parentLibrary: 'package:analyzer/src/dart/error/hint_codes.dart',
116116
);
117117

118-
/// If `true`, the new literate API should be generated.
119-
///
120-
/// This flag exists as a temporary measure, so that the literate API generation
121-
/// logic can be introduced in steps:
122-
/// - First, the logic to generate templates is introduced, but disabled; it can
123-
/// be easily verified that this change is safe because it doesn't change the
124-
/// generated code.
125-
/// - Then, this constant is turned on, causing templates to be generated;
126-
/// although this causes a lot of generated code to change, it can be verified
127-
/// that this change is safe by inspecting the code that refers to this
128-
/// constant.
129-
/// - Then, this constant is inlined.
130-
const literateApiEnabled = true;
131-
132118
const manifestWarningCodeFile = GeneratedErrorCodeFile(
133119
path: 'analyzer/lib/src/manifest/manifest_warning_code.g.dart',
134120
parentLibrary: 'package:analyzer/src/manifest/manifest_warning_code.dart',
@@ -744,7 +730,7 @@ abstract class ErrorCodeInfo {
744730
"Error code declares parameters using a `parameters` entry, but "
745731
"doesn't use them",
746732
);
747-
} else if (!literateApiEnabled || parameters == null) {
733+
} else if (parameters == null) {
748734
// Do not generate literate API yet.
749735
className = errorClassInfo.name;
750736
} else if (parameters.isNotEmpty) {

pkg/analyzer/tool/messages/generate.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,10 @@ DiagnosticType get type => ${errorClass.typeCode};
190190
memberAccumulator.writeTo(out);
191191
out.writeln('}');
192192

193-
if (literateApiEnabled) {
194-
out.writeln();
195-
_outputDerivedClass(errorClass, withArguments: true);
196-
out.writeln();
197-
_outputDerivedClass(errorClass, withArguments: false);
198-
}
193+
out.writeln();
194+
_outputDerivedClass(errorClass, withArguments: true);
195+
out.writeln();
196+
_outputDerivedClass(errorClass, withArguments: false);
199197
}
200198
}
201199

pkg/linter/tool/generate_lints.dart

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,9 @@ GeneratedFile get generatedCodesFile =>
5151
5252
// Generator currently outputs double quotes for simplicity.
5353
// ignore_for_file: prefer_single_quotes
54-
''');
55-
if (literateApiEnabled) {
56-
out.write('''
5754
5855
// Generated `withArguments` methods always use block bodies for simplicity.
5956
// ignore_for_file: prefer_expression_function_bodies
60-
''');
61-
}
62-
out.write('''
6357
6458
part of 'lint_codes.dart';
6559
@@ -114,8 +108,7 @@ class LinterLintCode extends LintCodeWithExpectedTypes {
114108
memberAccumulator.writeTo(out);
115109
out.writeln('}');
116110

117-
if (literateApiEnabled) {
118-
out.write('''
111+
out.write('''
119112
120113
final class LinterLintTemplate<T extends Function> extends LinterLintCode {
121114
final T withArguments;
@@ -145,7 +138,6 @@ final class LinterLintWithoutArguments extends LinterLintCode
145138
});
146139
}
147140
''');
148-
}
149141
return out.toString();
150142
});
151143

0 commit comments

Comments
 (0)