Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 7f2b3f0

Browse files
author
Dart CI
committed
Version 2.11.0-235.0.dev
Merge commit '23b9cce2a1219a122529d68a4e702ac10bcf7522' into 'dev'
2 parents 5c59a47 + 23b9cce commit 7f2b3f0

File tree

3,313 files changed

+114249
-66981
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,313 files changed

+114249
-66981
lines changed

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ vars = {
131131
"pub_rev": "f0c7771b38155d3829a60d60b5dba2784b100811",
132132
"pub_semver_tag": "v1.4.4",
133133
"quiver-dart_tag": "246e754fe45cecb6aa5f3f13b4ed61037ff0d784",
134-
"resource_rev": "f8e37558a1c4f54550aa463b88a6a831e3e33cd6",
134+
"resource_rev": "6b79867d0becf5395e5819a75720963b8298e9a7",
135135
"root_certificates_rev": "7e5ec82c99677a2e5b95ce296c4d68b0d3378ed8",
136136
"rust_revision": "b7856f695d65a8ebc846754f97d15814bcb1c244",
137137
"shelf_static_rev": "v0.2.8",

pkg/analysis_server/test/src/services/correction/fix/add_super_constructor_invocation_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class B extends A {
6262
Future<void> test_named_private() async {
6363
await resolveTestUnit('''
6464
class A {
65-
A._named(int p); // ignore: unused_element
65+
A._named(int p);
6666
}
6767
class B extends A {
6868
B() {}

pkg/analysis_server/test/src/services/correction/fix/create_constructor_super_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class B extends A {
128128
Future<void> test_private() async {
129129
await resolveTestUnit('''
130130
class A {
131-
A._named(p); // ignore: unused_element
131+
A._named(p);
132132
}
133133
class B extends A {
134134
}

pkg/analyzer/lib/error/error.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ const List<ErrorCode> errorCodeValues = [
481481
HintCode.DEPRECATED_MIXIN_FUNCTION,
482482
HintCode.DIVISION_OPTIMIZATION,
483483
HintCode.DUPLICATE_HIDDEN_NAME,
484+
HintCode.DUPLICATE_IGNORE,
484485
HintCode.DUPLICATE_IMPORT,
485486
HintCode.DUPLICATE_SHOWN_NAME,
486487
HintCode.EQUAL_ELEMENTS_IN_SET,
@@ -560,7 +561,9 @@ const List<ErrorCode> errorCodeValues = [
560561
HintCode.TYPE_CHECK_IS_NULL,
561562
HintCode.UNDEFINED_HIDDEN_NAME,
562563
HintCode.UNDEFINED_SHOWN_NAME,
564+
HintCode.UNIGNORABLE_IGNORE,
563565
HintCode.UNNECESSARY_CAST,
566+
HintCode.UNNECESSARY_IGNORE,
564567
HintCode.UNNECESSARY_NO_SUCH_METHOD,
565568
HintCode.UNNECESSARY_NULL_COMPARISON_FALSE,
566569
HintCode.UNNECESSARY_NULL_COMPARISON_TRUE,

pkg/analyzer/lib/src/dart/analysis/file_state.dart

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import 'package:analyzer/dart/ast/ast.dart';
1313
import 'package:analyzer/dart/ast/standard_ast_factory.dart';
1414
import 'package:analyzer/dart/ast/token.dart';
1515
import 'package:analyzer/dart/element/element.dart';
16-
import 'package:analyzer/error/error.dart';
1716
import 'package:analyzer/error/listener.dart';
1817
import 'package:analyzer/file_system/file_system.dart';
1918
import 'package:analyzer/src/dart/analysis/byte_store.dart';
@@ -27,7 +26,6 @@ import 'package:analyzer/src/dart/analysis/unlinked_api_signature.dart';
2726
import 'package:analyzer/src/dart/ast/ast.dart';
2827
import 'package:analyzer/src/dart/scanner/reader.dart';
2928
import 'package:analyzer/src/dart/scanner/scanner.dart';
30-
import 'package:analyzer/src/error/codes.dart';
3129
import 'package:analyzer/src/generated/engine.dart';
3230
import 'package:analyzer/src/generated/parser.dart';
3331
import 'package:analyzer/src/generated/source.dart';
@@ -590,7 +588,11 @@ $content
590588
''');
591589
}
592590

593-
_setLanguageVersion(unit, scanner.languageVersion, errorListener);
591+
var unitImpl = unit as CompilationUnitImpl;
592+
unitImpl.languageVersion = LibraryLanguageVersion(
593+
package: packageLanguageVersion,
594+
override: scanner.overrideVersion,
595+
);
594596

595597
// StringToken uses a static instance of StringCanonicalizer, so we need
596598
// to clear it explicitly once we are done using it for this file.
@@ -613,38 +615,6 @@ $content
613615
return directive.uri;
614616
}
615617

616-
/// Set the language version for the file, from the [versionToken], or from
617-
/// the package language version.
618-
void _setLanguageVersion(
619-
CompilationUnit unit,
620-
LanguageVersionToken versionToken,
621-
AnalysisErrorListener errorListener,
622-
) {
623-
Version overrideVersion;
624-
if (versionToken != null) {
625-
overrideVersion = Version(versionToken.major, versionToken.minor, 0);
626-
var latestVersion = ExperimentStatus.currentVersion;
627-
if (overrideVersion > latestVersion) {
628-
errorListener.onError(
629-
AnalysisError(
630-
source,
631-
versionToken.offset,
632-
versionToken.length,
633-
HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_GREATER,
634-
[latestVersion.major, latestVersion.minor],
635-
),
636-
);
637-
overrideVersion = null;
638-
}
639-
}
640-
641-
var unitImpl = unit as CompilationUnitImpl;
642-
unitImpl.languageVersion = LibraryLanguageVersion(
643-
package: packageLanguageVersion,
644-
override: overrideVersion,
645-
);
646-
}
647-
648618
static UnlinkedUnit2Builder serializeAstUnlinked2(CompilationUnit unit) {
649619
var exports = <UnlinkedNamespaceDirectiveBuilder>[];
650620
var imports = <UnlinkedNamespaceDirectiveBuilder>[];
@@ -847,6 +817,19 @@ class FileSystemState {
847817
return featureSetProvider.getFeatureSet(path, uri);
848818
}
849819

820+
Version contextLanguageVersion(
821+
String path,
822+
Uri uri,
823+
WorkspacePackage workspacePackage,
824+
) {
825+
var workspaceLanguageVersion = workspacePackage?.languageVersion;
826+
if (workspaceLanguageVersion != null) {
827+
return workspaceLanguageVersion;
828+
}
829+
830+
return featureSetProvider.getLanguageVersion(path, uri);
831+
}
832+
850833
/// Return the canonical [FileState] for the given absolute [path]. The
851834
/// returned file has the last known state since if was last refreshed.
852835
///
@@ -870,7 +853,7 @@ class FileSystemState {
870853
WorkspacePackage workspacePackage = _workspace?.findPackageFor(path);
871854
FeatureSet featureSet = contextFeatureSet(path, uri, workspacePackage);
872855
Version packageLanguageVersion =
873-
featureSetProvider.getLanguageVersion(path, uri);
856+
contextLanguageVersion(path, uri, workspacePackage);
874857
file = FileState._(this, path, uri, uriSource, workspacePackage,
875858
featureSet, packageLanguageVersion);
876859
_uriToFile[uri] = file;
@@ -914,7 +897,7 @@ class FileSystemState {
914897
WorkspacePackage workspacePackage = _workspace?.findPackageFor(path);
915898
FeatureSet featureSet = contextFeatureSet(path, uri, workspacePackage);
916899
Version packageLanguageVersion =
917-
featureSetProvider.getLanguageVersion(path, uri);
900+
contextLanguageVersion(path, uri, workspacePackage);
918901
file = FileState._(this, path, uri, source, workspacePackage, featureSet,
919902
packageLanguageVersion);
920903
_uriToFile[uri] = file;

pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ import 'package:analyzer/src/dart/element/element.dart';
2222
import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
2323
import 'package:analyzer/src/dart/element/type_provider.dart';
2424
import 'package:analyzer/src/dart/element/type_system.dart';
25-
import 'package:analyzer/src/dart/error/syntactic_errors.dart';
2625
import 'package:analyzer/src/dart/resolver/flow_analysis_visitor.dart';
2726
import 'package:analyzer/src/dart/resolver/legacy_type_asserter.dart';
2827
import 'package:analyzer/src/dart/resolver/resolution_visitor.dart';
2928
import 'package:analyzer/src/error/best_practices_verifier.dart';
3029
import 'package:analyzer/src/error/codes.dart';
3130
import 'package:analyzer/src/error/dead_code_verifier.dart';
31+
import 'package:analyzer/src/error/ignore_validator.dart';
3232
import 'package:analyzer/src/error/imports_verifier.dart';
3333
import 'package:analyzer/src/error/inheritance_override.dart';
3434
import 'package:analyzer/src/error/language_version_override_verifier.dart';
@@ -181,6 +181,16 @@ class LibraryAnalyzer {
181181

182182
_checkForInconsistentLanguageVersionOverride(units);
183183

184+
// This must happen after all other diagnostics have been computed but
185+
// before the list of diagnostics has been filtered.
186+
for (var file in _library.libraryFiles) {
187+
if (file.source != null) {
188+
IgnoreValidator(_getErrorReporter(file), _getErrorListener(file).errors,
189+
_fileToIgnoreInfo[file], _fileToLineInfo[file])
190+
.reportErrors();
191+
}
192+
}
193+
184194
timerLibraryAnalyzerVerify.stop();
185195

186196
// Return full results.
@@ -428,39 +438,8 @@ class LibraryAnalyzer {
428438
bool isIgnored(AnalysisError error) {
429439
var code = error.errorCode;
430440
// Don't allow error severity issues to be ignored.
431-
if (!code.isIgnorable) {
432-
// The [code] is not ignorable, but we've allowed a few "privileged"
433-
// cases. Each is annotated with an issue which represents technical
434-
// debt. Once cleaned up, we may remove this notion of "privileged".
435-
// In the case of [CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY], we may
436-
// just decide that it happens enough in tests that it can be declared
437-
// an ignorable error, and in practice other back ends will prevent
438-
// non-internal code from importing internal code.
439-
bool privileged = false;
440-
441-
if (code == CompileTimeErrorCode.UNDEFINED_FUNCTION ||
442-
code == CompileTimeErrorCode.UNDEFINED_PREFIXED_NAME) {
443-
// Special case a small number of errors in Flutter code which are
444-
// ignored. The erroneous code is found in a conditionally imported
445-
// library, which uses a special version of the "dart:ui" library
446-
// which the Analyzer does not use during analysis. See
447-
// https://github.com/flutter/flutter/issues/52899.
448-
if (file.path.contains('flutter')) {
449-
privileged = true;
450-
}
451-
}
452-
453-
if ((code == CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY ||
454-
code == CompileTimeErrorCode.UNDEFINED_ANNOTATION ||
455-
code == ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE) &&
456-
(file.path.contains('tests/compiler/dart2js') ||
457-
file.path.contains('pkg/compiler/test'))) {
458-
// Special case the dart2js language tests. Some of these import
459-
// various internal libraries.
460-
privileged = true;
461-
}
462-
463-
if (!privileged) return false;
441+
if (!IgnoreValidator.isIgnorable(file.path, code)) {
442+
return false;
464443
}
465444

466445
int errorLine = lineInfo.getLocation(error.offset).lineNumber;

pkg/analyzer/lib/src/dart/error/hint_codes.dart

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,18 @@ class HintCode extends AnalyzerErrorCode {
338338
correction: "Try removing the repeated name from the list of hidden "
339339
"members.");
340340

341+
/**
342+
* Parameters:
343+
* 0: the name of the diagnostic being ignored
344+
*/
345+
static const HintCode DUPLICATE_IGNORE = HintCode(
346+
'DUPLICATE_IGNORE',
347+
"The diagnostic '{0}' does not need to be ignored here because it is "
348+
"already being ignored.",
349+
correction:
350+
"Try removing the name from the list, or removing the whole comment "
351+
"if this is the only name in the list.");
352+
341353
/**
342354
* Duplicate imports.
343355
*
@@ -2349,6 +2361,16 @@ class HintCode extends AnalyzerErrorCode {
23492361
correction: "Try removing the name from the list of shown members.",
23502362
hasPublishedDocs: true);
23512363

2364+
/**
2365+
* Parameters:
2366+
* 0: the name of the non-diagnostic being ignored
2367+
*/
2368+
static const HintCode UNIGNORABLE_IGNORE = HintCode(
2369+
'UNIGNORABLE_IGNORE', "The diagnostic '{0}' can't be ignored.",
2370+
correction:
2371+
"Try removing the name from the list, or removing the whole comment "
2372+
"if this is the only name in the list.");
2373+
23522374
/**
23532375
* No parameters.
23542376
*/
@@ -2385,6 +2407,18 @@ class HintCode extends AnalyzerErrorCode {
23852407
'UNNECESSARY_CAST', "Unnecessary cast.",
23862408
correction: "Try removing the cast.", hasPublishedDocs: true);
23872409

2410+
/**
2411+
* Parameters:
2412+
* 0: the name of the diagnostic being ignored
2413+
*/
2414+
static const HintCode UNNECESSARY_IGNORE = HintCode(
2415+
'UNNECESSARY_IGNORE',
2416+
"The diagnostic '{0}' isn't produced at this location so it doesn't "
2417+
"need to be ignored.",
2418+
correction:
2419+
"Try removing the name from the list, or removing the whole comment "
2420+
"if this is the only name in the list.");
2421+
23882422
/**
23892423
* Unnecessary `noSuchMethod` declaration.
23902424
*/

pkg/analyzer/lib/src/dart/micro/library_analyzer.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import 'package:analyzer/src/dart/resolver/resolution_visitor.dart';
2828
import 'package:analyzer/src/error/best_practices_verifier.dart';
2929
import 'package:analyzer/src/error/codes.dart';
3030
import 'package:analyzer/src/error/dead_code_verifier.dart';
31+
import 'package:analyzer/src/error/ignore_validator.dart';
3132
import 'package:analyzer/src/error/imports_verifier.dart';
3233
import 'package:analyzer/src/error/inheritance_override.dart';
3334
import 'package:analyzer/src/error/override_verifier.dart';
@@ -245,6 +246,16 @@ class LibraryAnalyzer {
245246
}
246247
});
247248
}
249+
250+
// This must happen after all other diagnostics have been computed but
251+
// before the list of diagnostics has been filtered.
252+
for (var file in _library.libraryFiles) {
253+
if (file.source != null) {
254+
IgnoreValidator(_getErrorReporter(file), _getErrorListener(file).errors,
255+
_fileToIgnoreInfo[file], _fileToLineInfo[file])
256+
.reportErrors();
257+
}
258+
}
248259
}
249260

250261
void _computeHints(FileState file, CompilationUnit unit) {

pkg/analyzer/lib/src/dart/micro/library_graph.dart

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,19 @@ class FileSystemState {
521521
return featureSetProvider.getFeatureSet(path, uri);
522522
}
523523

524+
Version contextLanguageVersion(
525+
String path,
526+
Uri uri,
527+
WorkspacePackage workspacePackage,
528+
) {
529+
var workspaceLanguageVersion = workspacePackage?.languageVersion;
530+
if (workspaceLanguageVersion != null) {
531+
return workspaceLanguageVersion;
532+
}
533+
534+
return featureSetProvider.getLanguageVersion(path, uri);
535+
}
536+
524537
FileState getFileForPath({
525538
@required String path,
526539
@required OperationPerformanceImpl performance,
@@ -536,7 +549,7 @@ class FileSystemState {
536549
var workspacePackage = _workspace?.findPackageFor(path);
537550
var featureSet = contextFeatureSet(path, uri, workspacePackage);
538551
var packageLanguageVersion =
539-
featureSetProvider.getLanguageVersion(path, uri);
552+
contextLanguageVersion(path, uri, workspacePackage);
540553
file = FileState._(this, path, uri, source, workspacePackage, featureSet,
541554
packageLanguageVersion);
542555

@@ -567,7 +580,7 @@ class FileSystemState {
567580
var workspacePackage = _workspace?.findPackageFor(path);
568581
var featureSet = contextFeatureSet(path, uri, workspacePackage);
569582
var packageLanguageVersion =
570-
featureSetProvider.getLanguageVersion(path, uri);
583+
contextLanguageVersion(path, uri, workspacePackage);
571584

572585
file = FileState._(this, path, uri, source, workspacePackage, featureSet,
573586
packageLanguageVersion);

0 commit comments

Comments
 (0)