[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 <brianwilkerson@google.com> Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
@@ -115,20 +115,6 @@ const hintCodesFile = GeneratedErrorCodeFile(
|
||||
parentLibrary: 'package:analyzer/src/dart/error/hint_codes.dart',
|
||||
);
|
||||
|
||||
/// If `true`, the new literate API should be generated.
|
||||
///
|
||||
/// This flag exists as a temporary measure, so that the literate API generation
|
||||
/// logic can be introduced in steps:
|
||||
/// - First, the logic to generate templates is introduced, but disabled; it can
|
||||
/// be easily verified that this change is safe because it doesn't change the
|
||||
/// generated code.
|
||||
/// - Then, this constant is turned on, causing templates to be generated;
|
||||
/// although this causes a lot of generated code to change, it can be verified
|
||||
/// that this change is safe by inspecting the code that refers to this
|
||||
/// constant.
|
||||
/// - Then, this constant is inlined.
|
||||
const literateApiEnabled = true;
|
||||
|
||||
const manifestWarningCodeFile = GeneratedErrorCodeFile(
|
||||
path: 'analyzer/lib/src/manifest/manifest_warning_code.g.dart',
|
||||
parentLibrary: 'package:analyzer/src/manifest/manifest_warning_code.dart',
|
||||
@@ -744,7 +730,7 @@ abstract class ErrorCodeInfo {
|
||||
"Error code declares parameters using a `parameters` entry, but "
|
||||
"doesn't use them",
|
||||
);
|
||||
} else if (!literateApiEnabled || parameters == null) {
|
||||
} else if (parameters == null) {
|
||||
// Do not generate literate API yet.
|
||||
className = errorClassInfo.name;
|
||||
} else if (parameters.isNotEmpty) {
|
||||
|
||||
@@ -190,12 +190,10 @@ DiagnosticType get type => ${errorClass.typeCode};
|
||||
memberAccumulator.writeTo(out);
|
||||
out.writeln('}');
|
||||
|
||||
if (literateApiEnabled) {
|
||||
out.writeln();
|
||||
_outputDerivedClass(errorClass, withArguments: true);
|
||||
out.writeln();
|
||||
_outputDerivedClass(errorClass, withArguments: false);
|
||||
}
|
||||
out.writeln();
|
||||
_outputDerivedClass(errorClass, withArguments: true);
|
||||
out.writeln();
|
||||
_outputDerivedClass(errorClass, withArguments: false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,15 +51,9 @@ GeneratedFile get generatedCodesFile =>
|
||||
|
||||
// Generator currently outputs double quotes for simplicity.
|
||||
// ignore_for_file: prefer_single_quotes
|
||||
''');
|
||||
if (literateApiEnabled) {
|
||||
out.write('''
|
||||
|
||||
// Generated `withArguments` methods always use block bodies for simplicity.
|
||||
// ignore_for_file: prefer_expression_function_bodies
|
||||
''');
|
||||
}
|
||||
out.write('''
|
||||
|
||||
part of 'lint_codes.dart';
|
||||
|
||||
@@ -114,8 +108,7 @@ class LinterLintCode extends LintCodeWithExpectedTypes {
|
||||
memberAccumulator.writeTo(out);
|
||||
out.writeln('}');
|
||||
|
||||
if (literateApiEnabled) {
|
||||
out.write('''
|
||||
out.write('''
|
||||
|
||||
final class LinterLintTemplate<T extends Function> extends LinterLintCode {
|
||||
final T withArguments;
|
||||
@@ -145,7 +138,6 @@ final class LinterLintWithoutArguments extends LinterLintCode
|
||||
});
|
||||
}
|
||||
''');
|
||||
}
|
||||
return out.toString();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user