[analyzer etc] Add ignores for codegen to prepare for new syntax.
(Part of https://github.com/dart-lang/sdk/issues/63288) Updates the `CodeGenerator` mixin so that it outputs `ignore_for_file` comments to ignore the following lints: - unnecessary_type_name_in_constructor - unnecessary_ignore - duplicate_ignore This mixin is used by the code generators that produce the Dart wrappers for the analysis server and analyzer plugin wire protocols. This is a first step towards migrating the packages `analysis_server`, `analysis_server_client`, and `analyzer_plugin` packages to use the new constructor declaration syntax, since it will allow the `unnecessary_type_name_in_constructor` lint to be enabled without breaking generated code. Once all the packages have had their SDK constraints bumped to a language version that supports the new syntax, I'll update the code generator to use the new syntax, and remove the ignores. For more information about the new constructor declaration syntax, see https://github.com/dart-lang/language/blob/main/accepted/future-releases/primary-constructors/feature-specification.md#abbreviations-of-in-body-constructor-declarations. Change-Id: Ied17e3ea772546675aad48efc324f6f16a6a6964 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505521 Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
committed by
dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
1e1ecd8b41
commit
643733b42e
@@ -6,6 +6,9 @@
|
||||
// To regenerate the file, use the script
|
||||
// "pkg/analysis_server/tool/spec/generate_files".
|
||||
|
||||
// ignore_for_file: unnecessary_ignore, duplicate_ignore
|
||||
// ignore_for_file: unnecessary_type_name_in_constructor
|
||||
|
||||
/// Convenience methods for running integration tests.
|
||||
library;
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
// To regenerate the file, use the script
|
||||
// "pkg/analysis_server/tool/spec/generate_files".
|
||||
|
||||
// ignore_for_file: unnecessary_ignore, duplicate_ignore
|
||||
// ignore_for_file: unnecessary_type_name_in_constructor
|
||||
|
||||
/// Matchers for data types defined in the analysis server API.
|
||||
library;
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
// To regenerate the file, use the script
|
||||
// "pkg/analysis_server/tool/spec/generate_files".
|
||||
|
||||
// ignore_for_file: unnecessary_ignore, duplicate_ignore
|
||||
// ignore_for_file: unnecessary_type_name_in_constructor
|
||||
|
||||
// ignore: constant_identifier_names
|
||||
const String PROTOCOL_VERSION = '1.40.1';
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
// To regenerate the file, use the script
|
||||
// "pkg/analysis_server/tool/spec/generate_files".
|
||||
|
||||
// ignore_for_file: unnecessary_ignore, duplicate_ignore
|
||||
// ignore_for_file: unnecessary_type_name_in_constructor
|
||||
|
||||
import 'dart:convert' hide JsonDecoder;
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
// To regenerate the file, use the script
|
||||
// "pkg/analysis_server/tool/spec/generate_files".
|
||||
|
||||
// ignore_for_file: unnecessary_ignore, duplicate_ignore
|
||||
// ignore_for_file: unnecessary_type_name_in_constructor
|
||||
|
||||
import 'package:analysis_server_client/protocol.dart';
|
||||
|
||||
/// [NotificationHandler] processes analysis server notifications
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
// To regenerate the file, use the script
|
||||
// "pkg/analysis_server/tool/spec/generate_files".
|
||||
|
||||
// ignore_for_file: unnecessary_ignore, duplicate_ignore
|
||||
// ignore_for_file: unnecessary_type_name_in_constructor
|
||||
|
||||
import 'dart:convert' hide JsonDecoder;
|
||||
|
||||
import 'package:collection/collection.dart' show QueueList;
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
// To regenerate the file, use the script
|
||||
// "pkg/analysis_server/tool/spec/generate_files".
|
||||
|
||||
// ignore_for_file: unnecessary_ignore, duplicate_ignore
|
||||
// ignore_for_file: unnecessary_type_name_in_constructor
|
||||
|
||||
// ignore: constant_identifier_names
|
||||
const String PROTOCOL_VERSION = '1.40.1';
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
// To regenerate the file, use the script
|
||||
// "pkg/analysis_server/tool/spec/generate_files".
|
||||
|
||||
// ignore_for_file: unnecessary_ignore, duplicate_ignore
|
||||
// ignore_for_file: unnecessary_type_name_in_constructor
|
||||
|
||||
import 'dart:convert' hide JsonDecoder;
|
||||
|
||||
import 'package:analysis_server_client/src/protocol/protocol_base.dart';
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
// To regenerate the file, use the script
|
||||
// "pkg/analysis_server/tool/spec/generate_files".
|
||||
|
||||
// ignore_for_file: unnecessary_ignore, duplicate_ignore
|
||||
// ignore_for_file: unnecessary_type_name_in_constructor
|
||||
|
||||
import 'dart:convert' hide JsonDecoder;
|
||||
|
||||
import 'package:collection/collection.dart' show QueueList;
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
// To regenerate the file, use the script
|
||||
// "pkg/analysis_server/tool/spec/generate_files".
|
||||
|
||||
// ignore_for_file: unnecessary_ignore, duplicate_ignore
|
||||
// ignore_for_file: unnecessary_type_name_in_constructor
|
||||
|
||||
const String ANALYSIS_NOTIFICATION_ERRORS = 'analysis.errors';
|
||||
const String ANALYSIS_NOTIFICATION_ERRORS_ERRORS = 'errors';
|
||||
const String ANALYSIS_NOTIFICATION_ERRORS_FILE = 'file';
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
// To regenerate the file, use the script
|
||||
// "pkg/analysis_server/tool/spec/generate_files".
|
||||
|
||||
// ignore_for_file: unnecessary_ignore, duplicate_ignore
|
||||
// ignore_for_file: unnecessary_type_name_in_constructor
|
||||
|
||||
import 'dart:convert' hide JsonDecoder;
|
||||
|
||||
import 'package:analyzer_plugin/protocol/protocol.dart';
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
// To regenerate the file, use the script
|
||||
// "pkg/analysis_server/tool/spec/generate_files".
|
||||
|
||||
// ignore_for_file: unnecessary_ignore, duplicate_ignore
|
||||
// ignore_for_file: unnecessary_type_name_in_constructor
|
||||
|
||||
/// Convenience methods for running integration tests.
|
||||
library;
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
// To regenerate the file, use the script
|
||||
// "pkg/analysis_server/tool/spec/generate_files".
|
||||
|
||||
// ignore_for_file: unnecessary_ignore, duplicate_ignore
|
||||
// ignore_for_file: unnecessary_type_name_in_constructor
|
||||
|
||||
/// Matchers for data types defined in the analysis server API.
|
||||
library;
|
||||
|
||||
|
||||
@@ -40,8 +40,9 @@ String capitalize(String string) {
|
||||
|
||||
/// Type of functions used to compute the contents of a set of generated files.
|
||||
/// [pkgRoot] is the path to the SDK's `pkg` directory.
|
||||
typedef DirectoryContentsComputer =
|
||||
Map<String, FileContentsComputer> Function(String pkgRoot);
|
||||
typedef DirectoryContentsComputer = Map<String, FileContentsComputer> Function(
|
||||
String pkgRoot,
|
||||
);
|
||||
|
||||
/// Type of functions used to compute the contents of a generated file.
|
||||
/// [pkgRoot] is the path to the SDK's `pkg` directory.
|
||||
@@ -191,6 +192,22 @@ mixin CodeGenerator {
|
||||
// This file has been automatically generated. Please do not edit it manually.
|
||||
// To regenerate the file, use the script
|
||||
// "pkg/analysis_server/tool/spec/generate_files".
|
||||
''';
|
||||
// During the transition period to Dart language version 3.13, some
|
||||
// generated files will be using language version 3.13, and will have the
|
||||
// `unnecessary_type_name_in_constructor` lint enabled in order to
|
||||
// encourage use of the new constructor declaration syntax. Others will be
|
||||
// using older language versions that don't support this syntax. To ease
|
||||
// the transition, ignore the `unnecessary_type_name_in_constructor` lint
|
||||
// in generated code. Also ignore the `unnecessary_ignore` and
|
||||
// `duplicate_ignore` lints, which would otherwise sometimes be triggered
|
||||
// by the ignores we're adding.
|
||||
// TODO(paulberry): clean this up once all generated code is using Dart
|
||||
// language version 3.13.
|
||||
header += '''
|
||||
|
||||
// ignore_for_file: unnecessary_ignore, duplicate_ignore
|
||||
// ignore_for_file: unnecessary_type_name_in_constructor
|
||||
''';
|
||||
}
|
||||
writeln(header.trim());
|
||||
|
||||
Reference in New Issue
Block a user