Version 2.17.0-145.0.dev
Merge commit 'b7b5b25a3d497d3e0d590d7bcd3ab8c7cf6ea2d7' into 'dev'
diff --git a/BUILD.gn b/BUILD.gn
index 6295280..ad09ed8 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -39,7 +39,6 @@
# Fuchsia has run_vm_tests marked testonly.
testonly = true
}
-
deps = [
"runtime/bin:dart",
"runtime/bin:entrypoints_verification_test",
@@ -60,16 +59,6 @@
]
}
- # We do not support AOT on ia32 and should therefore cannot provide native
- # snapshot tooling.
- if (dart_target_arch != "ia32") {
- if (dart_runtime_mode == "release") {
- deps += [ "runtime/bin:analyze_snapshot_product" ]
- } else {
- deps += [ "runtime/bin:analyze_snapshot" ]
- }
- }
-
if (is_linux || is_android) {
deps += [ "runtime/bin:abstract_socket_test" ]
}
diff --git a/pkg/_fe_analyzer_shared/lib/src/macros/executor.dart b/pkg/_fe_analyzer_shared/lib/src/macros/executor.dart
index 3ac7616d..8fde94e 100644
--- a/pkg/_fe_analyzer_shared/lib/src/macros/executor.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/macros/executor.dart
@@ -275,8 +275,13 @@
/// All modifications are expressed in terms of library augmentation
/// declarations.
abstract class MacroExecutionResult implements Serializable {
- /// Any augmentations that should be applied as a result of executing a macro.
- Iterable<DeclarationCode> get augmentations;
+ /// Any augmentations that should be applied to a class as a result of
+ /// executing a macro, indexed by the name of the class.
+ Map<String, Iterable<DeclarationCode>> get classAugmentations;
+
+ /// Any augmentations that should be applied to the library as a result of
+ /// executing a macro.
+ Iterable<DeclarationCode> get libraryAugmentations;
/// The names of any new types declared in [augmentations].
Iterable<String> get newTypeNames;
diff --git a/pkg/_fe_analyzer_shared/lib/src/macros/executor/augmentation_library.dart b/pkg/_fe_analyzer_shared/lib/src/macros/executor/augmentation_library.dart
index d15e22b..fd0b26bc 100644
--- a/pkg/_fe_analyzer_shared/lib/src/macros/executor/augmentation_library.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/macros/executor/augmentation_library.dart
@@ -59,11 +59,27 @@
}
}
+ Map<String, List<DeclarationCode>> mergedClassResults = {};
for (MacroExecutionResult result in macroResults) {
- for (DeclarationCode augmentation in result.augmentations) {
+ for (DeclarationCode augmentation in result.libraryAugmentations) {
buildCode(augmentation);
directivesBuffer.writeln();
}
+ for (MapEntry<String, Iterable<DeclarationCode>> entry
+ in result.classAugmentations.entries) {
+ mergedClassResults.update(
+ entry.key, (value) => value..addAll(entry.value),
+ ifAbsent: () => entry.value.toList());
+ }
+ }
+ for (MapEntry<String, List<DeclarationCode>> entry
+ in mergedClassResults.entries) {
+ directivesBuffer.writeln('augment class ${entry.key} {');
+ for (DeclarationCode augmentation in entry.value) {
+ buildCode(augmentation);
+ directivesBuffer.writeln();
+ }
+ directivesBuffer.writeln('}');
}
return '$importsBuffer\n\n$directivesBuffer';
}
diff --git a/pkg/_fe_analyzer_shared/lib/src/macros/executor/builder_impls.dart b/pkg/_fe_analyzer_shared/lib/src/macros/executor/builder_impls.dart
index 7acddb2..5225d79 100644
--- a/pkg/_fe_analyzer_shared/lib/src/macros/executor/builder_impls.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/macros/executor/builder_impls.dart
@@ -12,28 +12,34 @@
class TypeBuilderBase {
/// The final result, will be built up over `augment` calls.
- final List<DeclarationCode> _augmentations;
+ final List<DeclarationCode> _libraryAugmentations;
- /// The names of any new types added in [_augmentations].
- final List<String> _newTypeNames;
+ /// The final result, will be built up over `augment` calls.
+ final Map<String, List<DeclarationCode>> _classAugmentations;
+
+ /// The names of any new types added in [_libraryAugmentations].
+ final List<String> _newTypeNames = [];
/// Creates and returns a [MacroExecutionResult] out of the [_augmentations]
/// created by this builder.
MacroExecutionResult get result => new MacroExecutionResultImpl(
- augmentations: _augmentations,
+ classAugmentations: _classAugmentations,
+ libraryAugmentations: _libraryAugmentations,
newTypeNames: _newTypeNames,
);
- TypeBuilderBase({List<DeclarationCode>? parentAugmentations})
- : _augmentations = parentAugmentations ?? [],
- _newTypeNames = [];
+ TypeBuilderBase(
+ {Map<String, List<DeclarationCode>>? parentClassAugmentations,
+ List<DeclarationCode>? parentLibraryAugmentations})
+ : _classAugmentations = parentClassAugmentations ?? {},
+ _libraryAugmentations = parentLibraryAugmentations ?? [];
}
class TypeBuilderImpl extends TypeBuilderBase implements TypeBuilder {
@override
void declareType(String name, DeclarationCode typeDeclaration) {
_newTypeNames.add(name);
- _augmentations.add(typeDeclaration);
+ _libraryAugmentations.add(typeDeclaration);
}
}
@@ -44,8 +50,11 @@
final TypeResolver typeResolver;
DeclarationBuilderBase(this.classIntrospector, this.typeResolver,
- {List<DeclarationCode>? parentAugmentations})
- : super(parentAugmentations: parentAugmentations);
+ {Map<String, List<DeclarationCode>>? parentClassAugmentations,
+ List<DeclarationCode>? parentLibraryAugmentations})
+ : super(
+ parentClassAugmentations: parentClassAugmentations,
+ parentLibraryAugmentations: parentLibraryAugmentations);
@override
Future<List<ConstructorDeclaration>> constructorsOf(ClassDeclaration clazz) =>
@@ -84,7 +93,7 @@
@override
void declareInLibrary(DeclarationCode declaration) {
- _augmentations.add(declaration);
+ _libraryAugmentations.add(declaration);
}
}
@@ -98,7 +107,9 @@
@override
void declareInClass(DeclarationCode declaration) {
- _augmentations.add(_buildClassAugmentation(definingClass, [declaration]));
+ _classAugmentations.update(
+ definingClass.name, (value) => value..add(declaration),
+ ifAbsent: () => [declaration]);
}
}
@@ -109,9 +120,11 @@
DefinitionBuilderBase(ClassIntrospector classIntrospector,
TypeResolver typeResolver, this.typeDeclarationResolver,
- {List<DeclarationCode>? parentAugmentations})
+ {Map<String, List<DeclarationCode>>? parentClassAugmentations,
+ List<DeclarationCode>? parentLibraryAugmentations})
: super(classIntrospector, typeResolver,
- parentAugmentations: parentAugmentations);
+ parentClassAugmentations: parentClassAugmentations,
+ parentLibraryAugmentations: parentLibraryAugmentations);
@override
Future<TypeDeclaration> declarationOf(IdentifierImpl identifier) =>
@@ -128,9 +141,11 @@
ClassIntrospector classIntrospector,
TypeResolver typeResolver,
TypeDeclarationResolver typeDeclarationResolver,
- {List<DeclarationCode>? parentAugmentations})
+ {Map<String, List<DeclarationCode>>? parentClassAugmentations,
+ List<DeclarationCode>? parentLibraryAugmentations})
: super(classIntrospector, typeResolver, typeDeclarationResolver,
- parentAugmentations: parentAugmentations);
+ parentClassAugmentations: parentClassAugmentations,
+ parentLibraryAugmentations: parentLibraryAugmentations);
@override
Future<ConstructorDefinitionBuilder> buildConstructor(
@@ -140,7 +155,8 @@
.firstWhere((constructor) => constructor.identifier == identifier);
return new ConstructorDefinitionBuilderImpl(
constructor, classIntrospector, typeResolver, typeDeclarationResolver,
- parentAugmentations: _augmentations);
+ parentClassAugmentations: _classAugmentations,
+ parentLibraryAugmentations: _libraryAugmentations);
}
@override
@@ -149,7 +165,8 @@
.firstWhere((field) => field.identifier == identifier);
return new VariableDefinitionBuilderImpl(
field, classIntrospector, typeResolver, typeDeclarationResolver,
- parentAugmentations: _augmentations);
+ parentClassAugmentations: _classAugmentations,
+ parentLibraryAugmentations: _libraryAugmentations);
}
@override
@@ -158,7 +175,8 @@
.firstWhere((method) => method.identifier == identifier);
return new FunctionDefinitionBuilderImpl(
method, classIntrospector, typeResolver, typeDeclarationResolver,
- parentAugmentations: _augmentations);
+ parentClassAugmentations: _classAugmentations,
+ parentLibraryAugmentations: _libraryAugmentations);
}
}
@@ -172,20 +190,24 @@
ClassIntrospector classIntrospector,
TypeResolver typeResolver,
TypeDeclarationResolver typeDeclarationResolver,
- {List<DeclarationCode>? parentAugmentations})
+ {Map<String, List<DeclarationCode>>? parentClassAugmentations,
+ List<DeclarationCode>? parentLibraryAugmentations})
: super(classIntrospector, typeResolver, typeDeclarationResolver,
- parentAugmentations: parentAugmentations);
+ parentClassAugmentations: parentClassAugmentations,
+ parentLibraryAugmentations: parentLibraryAugmentations);
@override
void augment(FunctionBodyCode body) {
DeclarationCode augmentation =
_buildFunctionAugmentation(body, declaration);
if (declaration is ClassMemberDeclaration) {
- augmentation = _buildClassAugmentation(
- (declaration as ClassMemberDeclaration).definingClass,
- [augmentation]);
+ _classAugmentations.update(
+ (declaration as ClassMemberDeclaration).definingClass.name,
+ (value) => value..add(augmentation),
+ ifAbsent: () => [augmentation]);
+ } else {
+ _libraryAugmentations.add(augmentation);
}
- _augmentations.add(augmentation);
}
}
@@ -198,18 +220,22 @@
ClassIntrospector classIntrospector,
TypeResolver typeResolver,
TypeDeclarationResolver typeDeclarationResolver,
- {List<DeclarationCode>? parentAugmentations})
+ {Map<String, List<DeclarationCode>>? parentClassAugmentations,
+ List<DeclarationCode>? parentLibraryAugmentations})
: super(classIntrospector, typeResolver, typeDeclarationResolver,
- parentAugmentations: parentAugmentations);
+ parentClassAugmentations: parentClassAugmentations,
+ parentLibraryAugmentations: parentLibraryAugmentations);
@override
void augment({FunctionBodyCode? body, List<Code>? initializers}) {
body ??= new FunctionBodyCode.fromString('''{
augment super();
}''');
- _augmentations.add(_buildClassAugmentation(declaration.definingClass, [
- _buildFunctionAugmentation(body, declaration, initializers: initializers)
- ]));
+ DeclarationCode augmentation = _buildFunctionAugmentation(body, declaration,
+ initializers: initializers);
+ _classAugmentations.update(
+ declaration.definingClass.name, (value) => value..add(augmentation),
+ ifAbsent: () => [augmentation]);
}
}
@@ -222,9 +248,11 @@
ClassIntrospector classIntrospector,
TypeResolver typeResolver,
TypeDeclarationResolver typeDeclarationResolver,
- {List<DeclarationCode>? parentAugmentations})
+ {Map<String, List<DeclarationCode>>? parentClassAugmentations,
+ List<DeclarationCode>? parentLibraryAugmentations})
: super(classIntrospector, typeResolver, typeDeclarationResolver,
- parentAugmentations: parentAugmentations);
+ parentClassAugmentations: parentClassAugmentations,
+ parentLibraryAugmentations: parentLibraryAugmentations);
@override
void augment(
@@ -237,28 +265,16 @@
setter: setter,
initializer: initializer);
if (declaration is ClassMemberDeclaration) {
- augmentations = [
- _buildClassAugmentation(
- (declaration as ClassMemberDeclaration).definingClass,
- augmentations)
- ];
+ _classAugmentations.update(
+ (declaration as ClassMemberDeclaration).definingClass.name,
+ (value) => value..addAll(augmentations),
+ ifAbsent: () => augmentations);
+ } else {
+ _libraryAugmentations.addAll(augmentations);
}
-
- _augmentations.addAll(augmentations);
}
}
-/// Creates an augmentation of [clazz] with member [augmentations].
-DeclarationCode _buildClassAugmentation(
- Identifier clazz, List<DeclarationCode> augmentations) =>
- new DeclarationCode.fromParts([
- 'augment class ',
- clazz.name,
- ' {\n',
- ...augmentations.joinAsCode('\n'),
- '\n}',
- ]);
-
/// Builds all the possible augmentations for a variable.
List<DeclarationCode> _buildVariableAugmentations(
VariableDeclaration declaration,
diff --git a/pkg/_fe_analyzer_shared/lib/src/macros/executor/response_impls.dart b/pkg/_fe_analyzer_shared/lib/src/macros/executor/response_impls.dart
index 3686842..eedc0bc 100644
--- a/pkg/_fe_analyzer_shared/lib/src/macros/executor/response_impls.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/macros/executor/response_impls.dart
@@ -207,20 +207,41 @@
/// Implementation of [MacroExecutionResult].
class MacroExecutionResultImpl implements MacroExecutionResult {
@override
- final List<DeclarationCode> augmentations;
+ final Map<String, List<DeclarationCode>> classAugmentations;
+
+ @override
+ final List<DeclarationCode> libraryAugmentations;
@override
final List<String> newTypeNames;
MacroExecutionResultImpl({
- required this.augmentations,
+ required this.classAugmentations,
+ required this.libraryAugmentations,
required this.newTypeNames,
});
factory MacroExecutionResultImpl.deserialize(Deserializer deserializer) {
deserializer.moveNext();
deserializer.expectList();
- List<DeclarationCode> augmentations = [
+ Map<String, List<DeclarationCode>> classAugmentations = {
+ for (bool hasNext = deserializer.moveNext();
+ hasNext;
+ hasNext = deserializer.moveNext())
+ deserializer.expectString(): [
+ for (bool hasNextCode = (deserializer
+ ..moveNext()
+ ..expectList())
+ .moveNext();
+ hasNextCode;
+ hasNextCode = deserializer.moveNext())
+ deserializer.expectCode(),
+ ]
+ };
+
+ deserializer.moveNext();
+ deserializer.expectList();
+ List<DeclarationCode> libraryAugmentations = [
for (bool hasNext = deserializer.moveNext();
hasNext;
hasNext = deserializer.moveNext())
@@ -236,14 +257,26 @@
];
return new MacroExecutionResultImpl(
- augmentations: augmentations,
+ classAugmentations: classAugmentations,
+ libraryAugmentations: libraryAugmentations,
newTypeNames: newTypeNames,
);
}
void serialize(Serializer serializer) {
serializer.startList();
- for (DeclarationCode augmentation in augmentations) {
+ for (String clazz in classAugmentations.keys) {
+ serializer.addString(clazz);
+ serializer.startList();
+ for (DeclarationCode augmentation in classAugmentations[clazz]!) {
+ augmentation.serialize(serializer);
+ }
+ serializer.endList();
+ }
+ serializer.endList();
+
+ serializer.startList();
+ for (DeclarationCode augmentation in libraryAugmentations) {
augmentation.serialize(serializer);
}
serializer.endList();
diff --git a/pkg/_fe_analyzer_shared/pubspec.yaml b/pkg/_fe_analyzer_shared/pubspec.yaml
index 87fb4f5..e4718a0 100644
--- a/pkg/_fe_analyzer_shared/pubspec.yaml
+++ b/pkg/_fe_analyzer_shared/pubspec.yaml
@@ -1,5 +1,5 @@
name: _fe_analyzer_shared
-version: 35.0.0
+version: 36.0.0
description: Logic that is shared between the front_end and analyzer packages.
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/_fe_analyzer_shared
diff --git a/pkg/_fe_analyzer_shared/test/macros/executor/augmentation_library_test.dart b/pkg/_fe_analyzer_shared/test/macros/executor/augmentation_library_test.dart
index 87e6bc3..af3d9d7 100644
--- a/pkg/_fe_analyzer_shared/test/macros/executor/augmentation_library_test.dart
+++ b/pkg/_fe_analyzer_shared/test/macros/executor/augmentation_library_test.dart
@@ -18,16 +18,15 @@
test('can combine multiple execution results', () {
var results = [
for (var i = 0; i < 2; i++)
- MacroExecutionResultImpl(augmentations: [
+ MacroExecutionResultImpl(classAugmentations: {
for (var j = 0; j < 3; j++)
- DeclarationCode.fromParts([
- 'augment class Foo$i$j {\n',
- DeclarationCode.fromParts([
- 'int get i => $i;\n',
- 'int get j => $j;\n',
- ]),
- '}',
- ]),
+ 'Foo$i$j': [
+ DeclarationCode.fromString('int get i => $i;\n'),
+ DeclarationCode.fromString('int get j => $j;\n'),
+ ]
+ }, libraryAugmentations: [
+ for (var j = 0; j < 3; j++)
+ DeclarationCode.fromString('int get i${i}j$j => ${i + j};\n'),
], newTypeNames: [
'Foo${i}0',
'Foo${i}1',
@@ -37,6 +36,12 @@
var library = _TestExecutor().buildAugmentationLibrary(
results, (Identifier i) => (i as TestIdentifier).resolved);
expect(library, equalsIgnoringWhitespace('''
+ int get i0j0 => 0;
+ int get i0j1 => 1;
+ int get i0j2 => 2;
+ int get i1j0 => 1;
+ int get i1j1 => 2;
+ int get i1j2 => 3;
augment class Foo00 {
int get i => 0;
int get j => 0;
@@ -96,29 +101,33 @@
staticScope: 'Bar',
uri: Uri.parse('package:bar/bar.dart'));
var results = [
- MacroExecutionResultImpl(augmentations: [
- DeclarationCode.fromParts([
- 'class FooBuilder<T extends ',
- fooIdentifier,
- '> implements ',
- builderIdentifier,
- '<',
- barIdentifier,
- '<T>> {\n',
- 'late int ${barInstanceMember.name};\n',
- barIdentifier,
- '<T> build() => new ',
- barIdentifier,
- '()..',
- barInstanceMember,
- ' = ',
- barStaticMember,
- ';',
- '\n}',
- ]),
- ], newTypeNames: [
- 'FooBuilder',
- ])
+ MacroExecutionResultImpl(
+ classAugmentations: {},
+ libraryAugmentations: [
+ DeclarationCode.fromParts([
+ 'class FooBuilder<T extends ',
+ fooIdentifier,
+ '> implements ',
+ builderIdentifier,
+ '<',
+ barIdentifier,
+ '<T>> {\n',
+ 'late int ${barInstanceMember.name};\n',
+ barIdentifier,
+ '<T> build() => new ',
+ barIdentifier,
+ '()..',
+ barInstanceMember,
+ ' = ',
+ barStaticMember,
+ ';',
+ '\n}',
+ ]),
+ ],
+ newTypeNames: [
+ 'FooBuilder',
+ ],
+ )
];
var library = _TestExecutor().buildAugmentationLibrary(
results, (Identifier i) => (i as TestIdentifier).resolved);
diff --git a/pkg/_fe_analyzer_shared/test/macros/executor/executor_test.dart b/pkg/_fe_analyzer_shared/test/macros/executor/executor_test.dart
index 9f35c52..f4e5601 100644
--- a/pkg/_fe_analyzer_shared/test/macros/executor/executor_test.dart
+++ b/pkg/_fe_analyzer_shared/test/macros/executor/executor_test.dart
@@ -110,14 +110,18 @@
test('on functions', () async {
var result = await executor.executeTypesPhase(
instanceId, Fixtures.myFunction);
- expect(result.augmentations.single.debugString().toString(),
+ expect(result.classAugmentations, isEmpty);
+ expect(
+ result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace('class GeneratedByMyFunction {}'));
});
test('on methods', () async {
var result = await executor.executeTypesPhase(
instanceId, Fixtures.myMethod);
- expect(result.augmentations.single.debugString().toString(),
+ expect(result.classAugmentations, isEmpty);
+ expect(
+ result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace('class GeneratedByMyMethod {}'));
});
@@ -126,8 +130,9 @@
instanceId,
Fixtures.myVariableGetter,
);
+ expect(result.classAugmentations, isEmpty);
expect(
- result.augmentations.single.debugString().toString(),
+ result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace(
'class GeneratedByMyVariableGetter {}'));
});
@@ -137,8 +142,9 @@
instanceId,
Fixtures.myVariableSetter,
);
+ expect(result.classAugmentations, isEmpty);
expect(
- result.augmentations.single.debugString().toString(),
+ result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace(
'class GeneratedByMyVariableSetter {}'));
});
@@ -148,8 +154,9 @@
instanceId,
Fixtures.myVariable,
);
+ expect(result.classAugmentations, isEmpty);
expect(
- result.augmentations.single.debugString().toString(),
+ result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace(
'class GeneratedBy_myVariable {}'));
});
@@ -157,8 +164,9 @@
test('on constructors', () async {
var result = await executor.executeTypesPhase(
instanceId, Fixtures.myConstructor);
+ expect(result.classAugmentations, isEmpty);
expect(
- result.augmentations.single.debugString().toString(),
+ result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace(
'class GeneratedByMyConstructor {}'));
});
@@ -166,15 +174,18 @@
test('on fields', () async {
var result = await executor.executeTypesPhase(
instanceId, Fixtures.myField);
- expect(result.augmentations.single.debugString().toString(),
+ expect(result.classAugmentations, isEmpty);
+ expect(
+ result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace('class GeneratedByMyField {}'));
});
test('on classes', () async {
var result = await executor.executeTypesPhase(
instanceId, Fixtures.myClass);
+ expect(result.classAugmentations, isEmpty);
expect(
- result.augmentations.single.debugString().toString(),
+ result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace(
'class MyClassBuilder implements Builder<MyClass> {}'));
});
@@ -187,8 +198,9 @@
Fixtures.myFunction,
Fixtures.testTypeResolver,
Fixtures.testClassIntrospector);
+ expect(result.classAugmentations, isEmpty);
expect(
- result.augmentations.single.debugString().toString(),
+ result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace(
'String delegateMyFunction() => myFunction();'));
});
@@ -199,8 +211,9 @@
Fixtures.myMethod,
Fixtures.testTypeResolver,
Fixtures.testClassIntrospector);
+ expect(result.classAugmentations, isEmpty);
expect(
- result.augmentations.single.debugString().toString(),
+ result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace(
'String delegateMemberMyMethod() => myMethod();'));
});
@@ -211,11 +224,15 @@
Fixtures.myConstructor,
Fixtures.testTypeResolver,
Fixtures.testClassIntrospector);
- expect(result.augmentations.single.debugString().toString(),
+ expect(result.classAugmentations, hasLength(1));
+ expect(
+ result.classAugmentations['MyClass']!.single
+ .debugString()
+ .toString(),
equalsIgnoringWhitespace('''
- augment class MyClass {
factory MyClass.myConstructorDelegate() => MyClass.myConstructor();
- }'''));
+ '''));
+ expect(result.libraryAugmentations, isEmpty);
});
test('on getters', () async {
@@ -224,7 +241,9 @@
Fixtures.myVariableGetter,
Fixtures.testTypeResolver,
Fixtures.testClassIntrospector);
- expect(result.augmentations.single.debugString().toString(),
+ expect(result.classAugmentations, isEmpty);
+ expect(
+ result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace('''
String get delegateMyVariable => myVariable;'''));
});
@@ -235,7 +254,9 @@
Fixtures.myVariableSetter,
Fixtures.testTypeResolver,
Fixtures.testClassIntrospector);
- expect(result.augmentations.single.debugString().toString(),
+ expect(result.classAugmentations, isEmpty);
+ expect(
+ result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace('''
void set delegateMyVariable(String value) => myVariable = value;'''));
});
@@ -246,7 +267,9 @@
Fixtures.myVariable,
Fixtures.testTypeResolver,
Fixtures.testClassIntrospector);
- expect(result.augmentations.single.debugString().toString(),
+ expect(result.classAugmentations, isEmpty);
+ expect(
+ result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace('''
String get delegate_myVariable => _myVariable;'''));
});
@@ -257,11 +280,15 @@
Fixtures.myField,
Fixtures.testTypeResolver,
Fixtures.testClassIntrospector);
- expect(result.augmentations.single.debugString().toString(),
+ expect(result.classAugmentations, hasLength(1));
+ expect(
+ result.classAugmentations['MyClass']!.single
+ .debugString()
+ .toString(),
equalsIgnoringWhitespace('''
- augment class MyClass {
String get delegateMyField => myField;
- }'''));
+ '''));
+ expect(result.libraryAugmentations, isEmpty);
});
test('on classes', () async {
@@ -270,11 +297,15 @@
Fixtures.myClass,
Fixtures.testTypeResolver,
Fixtures.testClassIntrospector);
- expect(result.augmentations.single.debugString().toString(),
+ expect(result.classAugmentations, hasLength(1));
+ expect(
+ result.classAugmentations['MyClass']!.single
+ .debugString()
+ .toString(),
equalsIgnoringWhitespace('''
- augment class MyClass {
static const List<String> fieldNames = ['myField',];
- }'''));
+ '''));
+ expect(result.libraryAugmentations, isEmpty);
});
});
@@ -286,7 +317,9 @@
Fixtures.testTypeResolver,
Fixtures.testClassIntrospector,
Fixtures.testTypeDeclarationResolver);
- expect(result.augmentations.single.debugString().toString(),
+ expect(result.classAugmentations, isEmpty);
+ expect(
+ result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace('''
augment String myFunction() {
print('isAbstract: false');
@@ -305,12 +338,14 @@
Fixtures.testTypeResolver,
Fixtures.testClassIntrospector,
Fixtures.testTypeDeclarationResolver);
- expect(definitionResult.augmentations, hasLength(2));
- var augmentationStrings = definitionResult.augmentations
+ expect(definitionResult.classAugmentations, hasLength(1));
+ var augmentationStrings = definitionResult
+ .classAugmentations['MyClass']!
.map((a) => a.debugString().toString())
.toList();
expect(augmentationStrings,
unorderedEquals(methodDefinitionMatchers));
+ expect(definitionResult.libraryAugmentations, isEmpty);
});
test('on constructors', () async {
@@ -320,12 +355,13 @@
Fixtures.testTypeResolver,
Fixtures.testClassIntrospector,
Fixtures.testTypeDeclarationResolver);
- expect(definitionResult.augmentations, hasLength(1));
+ expect(definitionResult.classAugmentations, hasLength(1));
expect(
- definitionResult.augmentations.first
+ definitionResult.classAugmentations['MyClass']!.first
.debugString()
.toString(),
constructorDefinitionMatcher);
+ expect(definitionResult.libraryAugmentations, isEmpty);
});
test('on getters', () async {
@@ -335,7 +371,9 @@
Fixtures.testTypeResolver,
Fixtures.testClassIntrospector,
Fixtures.testTypeDeclarationResolver);
- expect(result.augmentations.single.debugString().toString(),
+ expect(result.classAugmentations, isEmpty);
+ expect(
+ result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace('''
augment String myVariable() {
print('isAbstract: false');
@@ -354,7 +392,9 @@
Fixtures.testTypeResolver,
Fixtures.testClassIntrospector,
Fixtures.testTypeDeclarationResolver);
- expect(result.augmentations.single.debugString().toString(),
+ expect(result.classAugmentations, isEmpty);
+ expect(
+ result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace('''
augment void myVariable(String value, ) {
print('isAbstract: false');
@@ -374,8 +414,10 @@
Fixtures.testTypeResolver,
Fixtures.testClassIntrospector,
Fixtures.testTypeDeclarationResolver);
+ expect(result.classAugmentations, isEmpty);
expect(
- result.augmentations.map((a) => a.debugString().toString()),
+ result.libraryAugmentations
+ .map((a) => a.debugString().toString()),
unorderedEquals([
equalsIgnoringWhitespace('''
augment String get _myVariable {
@@ -402,12 +444,12 @@
Fixtures.testTypeResolver,
Fixtures.testClassIntrospector,
Fixtures.testTypeDeclarationResolver);
- expect(definitionResult.augmentations, hasLength(1));
+ expect(definitionResult.classAugmentations, hasLength(1));
expect(
- definitionResult.augmentations.first
- .debugString()
- .toString(),
- fieldDefinitionMatcher);
+ definitionResult.classAugmentations['MyClass']!
+ .map((a) => a.debugString().toString()),
+ unorderedEquals(fieldDefinitionMatchers));
+ expect(definitionResult.libraryAugmentations, isEmpty);
});
test('on classes', () async {
@@ -417,7 +459,9 @@
Fixtures.testTypeResolver,
Fixtures.testClassIntrospector,
Fixtures.testTypeDeclarationResolver);
- var augmentationStrings = definitionResult.augmentations
+ expect(definitionResult.classAugmentations, hasLength(1));
+ var augmentationStrings = definitionResult
+ .classAugmentations['MyClass']!
.map((a) => a.debugString().toString())
.toList();
expect(
@@ -425,7 +469,7 @@
unorderedEquals([
...methodDefinitionMatchers,
constructorDefinitionMatcher,
- fieldDefinitionMatcher
+ ...fieldDefinitionMatchers,
]));
});
});
@@ -437,60 +481,55 @@
}
final constructorDefinitionMatcher = equalsIgnoringWhitespace('''
-augment class MyClass {
- augment MyClass.myConstructor() {
- print('definingClass: MyClass');
- print('isFactory: false');
- print('isAbstract: false');
- print('isExternal: false');
- print('isGetter: false');
- print('isSetter: false');
- print('returnType: MyClass');
- return augment super();
- }
+augment MyClass.myConstructor() {
+ print('definingClass: MyClass');
+ print('isFactory: false');
+ print('isAbstract: false');
+ print('isExternal: false');
+ print('isGetter: false');
+ print('isSetter: false');
+ print('returnType: MyClass');
+ return augment super();
}''');
-final fieldDefinitionMatcher = equalsIgnoringWhitespace('''
-augment class MyClass {
- augment String get myField {
- print('parentClass: MyClass');
- print('isExternal: false');
- print('isFinal: false');
- print('isLate: false');
- return augment super;
- }
- augment set myField(String value) {
- augment super = value;
- }
- augment String myField = \'new initial value\' + augment super;
-}''');
+final fieldDefinitionMatchers = [
+ equalsIgnoringWhitespace('''
+ augment String get myField {
+ print('parentClass: MyClass');
+ print('isExternal: false');
+ print('isFinal: false');
+ print('isLate: false');
+ return augment super;
+ }'''),
+ equalsIgnoringWhitespace('''
+ augment set myField(String value) {
+ augment super = value;
+ }'''),
+ equalsIgnoringWhitespace('''
+ augment String myField = \'new initial value\' + augment super;'''),
+];
final methodDefinitionMatchers = [
equalsIgnoringWhitespace('''
- augment class MyClass {
- augment String myMethod() {
- print('definingClass: MyClass');
- print('isAbstract: false');
- print('isExternal: false');
- print('isGetter: false');
- print('isSetter: false');
- print('returnType: String');
- return augment super();
- }
- }
- '''),
+ augment String myMethod() {
+ print('definingClass: MyClass');
+ print('isAbstract: false');
+ print('isExternal: false');
+ print('isGetter: false');
+ print('isSetter: false');
+ print('returnType: String');
+ return augment super();
+ }'''),
equalsIgnoringWhitespace('''
- augment class MyClass {
- augment String myMethod() {
- print('x: 1, y: 2');
- print('parentClass: MyClass');
- print('superClass: MySuperclass');
- print('interface: MyInterface');
- print('mixin: MyMixin');
- print('field: myField');
- print('method: myMethod');
- print('constructor: myConstructor');
- return augment super();
- }
+ augment String myMethod() {
+ print('x: 1, y: 2');
+ print('parentClass: MyClass');
+ print('superClass: MySuperclass');
+ print('interface: MyInterface');
+ print('mixin: MyMixin');
+ print('field: myField');
+ print('method: myMethod');
+ print('constructor: myConstructor');
+ return augment super();
}'''),
];
diff --git a/pkg/analysis_server/lib/src/computer/computer_outline.dart b/pkg/analysis_server/lib/src/computer/computer_outline.dart
index c4247be..61e3abb 100644
--- a/pkg/analysis_server/lib/src/computer/computer_outline.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_outline.dart
@@ -29,12 +29,13 @@
unitContents.add(_newMixinOutline(
unitMember, _outlinesForMembers(unitMember.members)));
} else if (unitMember is EnumDeclaration) {
- var enumDeclaration = unitMember;
- var constantOutlines = <Outline>[];
- for (var constant in enumDeclaration.constants) {
- constantOutlines.add(_newEnumConstant(constant));
- }
- unitContents.add(_newEnumOutline(enumDeclaration, constantOutlines));
+ unitContents.add(
+ _newEnumOutline(unitMember, [
+ for (var constant in unitMember.constants)
+ _newEnumConstant(constant),
+ ..._outlinesForMembers(unitMember.members),
+ ]),
+ );
} else if (unitMember is ExtensionDeclaration) {
unitContents.add(_newExtensionOutline(
unitMember, _outlinesForMembers(unitMember.members)));
diff --git a/pkg/analysis_server/test/analysis/notification_occurrences_test.dart b/pkg/analysis_server/test/analysis/notification_occurrences_test.dart
index 1b04dee..e0cc0f7 100644
--- a/pkg/analysis_server/test/analysis/notification_occurrences_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_occurrences_test.dart
@@ -219,6 +219,26 @@
assertHasOffset('ddd: 3');
}
+ Future<void> test_superFormalParameter_requiredPositional() async {
+ addTestFile('''
+class A {
+ A(int x);
+}
+
+class B extends A {
+ int y;
+
+ B(super.x) : y = x * 2;
+}
+''');
+ await prepareOccurrences();
+ assertHasRegion('x) :');
+ expect(testOccurrences.element.kind, ElementKind.PARAMETER);
+ expect(testOccurrences.element.name, 'x');
+ assertHasOffset('x) :');
+ assertHasOffset('x * 2');
+ }
+
Future<void> test_topLevelVariable() async {
addTestFile('''
var VVV = 1;
diff --git a/pkg/analysis_server/test/integration/support/integration_tests.dart b/pkg/analysis_server/test/integration/support/integration_tests.dart
index 46858e0..3ef73c2 100644
--- a/pkg/analysis_server/test/integration/support/integration_tests.dart
+++ b/pkg/analysis_server/test/integration/support/integration_tests.dart
@@ -521,11 +521,11 @@
var trimmedLine = line.trim();
// Guard against lines like:
- // {"event":"server.connected","params":{...}}The Dart VM service is listening on ...
- var dartVMServiceMessage = 'The Dart VM service is listening on ';
- if (trimmedLine.contains(dartVMServiceMessage)) {
+ // {"event":"server.connected","params":{...}}Observatory listening on ...
+ var observatoryMessage = 'Observatory listening on ';
+ if (trimmedLine.contains(observatoryMessage)) {
trimmedLine = trimmedLine
- .substring(0, trimmedLine.indexOf(dartVMServiceMessage))
+ .substring(0, trimmedLine.indexOf(observatoryMessage))
.trim();
}
if (trimmedLine.isEmpty) {
diff --git a/pkg/analysis_server/test/src/computer/outline_computer_test.dart b/pkg/analysis_server/test/src/computer/outline_computer_test.dart
index c215a6c..79818f0 100644
--- a/pkg/analysis_server/test/src/computer/outline_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/outline_computer_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'dart:convert';
+
import 'package:analysis_server/src/computer/computer_outline.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
@@ -137,6 +139,24 @@
@reflectiveTest
class OutlineComputerTest extends AbstractOutlineComputerTest {
+ String get testPathJson => jsonOfPath(testPath);
+
+ void assertJsonText(Object object, String expected) {
+ expected = expected.trimRight();
+ var actual = JsonEncoder.withIndent(' ').convert(object);
+ if (actual != expected) {
+ print('-----');
+ print(actual);
+ print('-----');
+ }
+ expect(actual, expected);
+ }
+
+ String jsonOfPath(String path) {
+ path = convertPath(path);
+ return json.encode(path);
+ }
+
Future<void> test_class() async {
var unitOutline = await _computeOutline('''
abstract class A<K, V> {
@@ -382,34 +402,270 @@
}
}
- Future<void> test_enum() async {
+ Future<void> test_enum_constants() async {
var unitOutline = await _computeOutline('''
-enum MyEnum {
- A, B, C
+enum E {
+ v1, v2
}
''');
+
var topOutlines = unitOutline.children!;
expect(topOutlines, hasLength(1));
- // MyEnum
+
+ assertJsonText(topOutlines[0], '''
+{
+ "element": {
+ "kind": "ENUM",
+ "name": "E",
+ "location": {
+ "file": $testPathJson,
+ "offset": 5,
+ "length": 1,
+ "startLine": 1,
+ "startColumn": 6,
+ "endLine": 1,
+ "endColumn": 7
+ },
+ "flags": 0
+ },
+ "offset": 0,
+ "length": 19,
+ "codeOffset": 0,
+ "codeLength": 19,
+ "children": [
{
- var outline_MyEnum = topOutlines[0];
- var element_MyEnum = outline_MyEnum.element;
- expect(element_MyEnum.kind, ElementKind.ENUM);
- expect(element_MyEnum.name, 'MyEnum');
- {
- var location = element_MyEnum.location!;
- expect(location.offset, testCode.indexOf('MyEnum {'));
- expect(location.length, 'MyEnum'.length);
- }
- expect(element_MyEnum.parameters, null);
- expect(element_MyEnum.returnType, null);
- // MyEnum children
- var outlines_MyEnum = outline_MyEnum.children!;
- expect(outlines_MyEnum, hasLength(3));
- _isEnumConstant(outlines_MyEnum[0], 'A');
- _isEnumConstant(outlines_MyEnum[1], 'B');
- _isEnumConstant(outlines_MyEnum[2], 'C');
+ "element": {
+ "kind": "ENUM_CONSTANT",
+ "name": "v1",
+ "location": {
+ "file": $testPathJson,
+ "offset": 11,
+ "length": 2,
+ "startLine": 2,
+ "startColumn": 3,
+ "endLine": 2,
+ "endColumn": 5
+ },
+ "flags": 0
+ },
+ "offset": 11,
+ "length": 2,
+ "codeOffset": 11,
+ "codeLength": 2
+ },
+ {
+ "element": {
+ "kind": "ENUM_CONSTANT",
+ "name": "v2",
+ "location": {
+ "file": $testPathJson,
+ "offset": 15,
+ "length": 2,
+ "startLine": 2,
+ "startColumn": 7,
+ "endLine": 2,
+ "endColumn": 9
+ },
+ "flags": 0
+ },
+ "offset": 15,
+ "length": 2,
+ "codeOffset": 15,
+ "codeLength": 2
}
+ ]
+}
+''');
+ }
+
+ Future<void> test_enum_members() async {
+ var unitOutline = await _computeOutline('''
+enum E {
+ v;
+ final int f = 0;
+ const E();
+ const E.named();
+ void aMethod() {}
+ int get aGetter => 0;
+ set aSetter(int value) {}
+}
+''');
+
+ var topOutlines = unitOutline.children!;
+ expect(topOutlines, hasLength(1));
+
+ assertJsonText(topOutlines[0], '''
+{
+ "element": {
+ "kind": "ENUM",
+ "name": "E",
+ "location": {
+ "file": $testPathJson,
+ "offset": 5,
+ "length": 1,
+ "startLine": 1,
+ "startColumn": 6,
+ "endLine": 1,
+ "endColumn": 7
+ },
+ "flags": 0
+ },
+ "offset": 0,
+ "length": 138,
+ "codeOffset": 0,
+ "codeLength": 138,
+ "children": [
+ {
+ "element": {
+ "kind": "ENUM_CONSTANT",
+ "name": "v",
+ "location": {
+ "file": $testPathJson,
+ "offset": 11,
+ "length": 1,
+ "startLine": 2,
+ "startColumn": 3,
+ "endLine": 2,
+ "endColumn": 4
+ },
+ "flags": 0
+ },
+ "offset": 11,
+ "length": 1,
+ "codeOffset": 11,
+ "codeLength": 1
+ },
+ {
+ "element": {
+ "kind": "FIELD",
+ "name": "f",
+ "location": {
+ "file": $testPathJson,
+ "offset": 26,
+ "length": 1,
+ "startLine": 3,
+ "startColumn": 13,
+ "endLine": 3,
+ "endColumn": 14
+ },
+ "flags": 4,
+ "returnType": "int"
+ },
+ "offset": 16,
+ "length": 16,
+ "codeOffset": 26,
+ "codeLength": 5
+ },
+ {
+ "element": {
+ "kind": "CONSTRUCTOR",
+ "name": "E",
+ "location": {
+ "file": $testPathJson,
+ "offset": 41,
+ "length": 1,
+ "startLine": 4,
+ "startColumn": 9,
+ "endLine": 4,
+ "endColumn": 10
+ },
+ "flags": 0,
+ "parameters": "()"
+ },
+ "offset": 35,
+ "length": 10,
+ "codeOffset": 35,
+ "codeLength": 10
+ },
+ {
+ "element": {
+ "kind": "CONSTRUCTOR",
+ "name": "E.named",
+ "location": {
+ "file": $testPathJson,
+ "offset": 56,
+ "length": 5,
+ "startLine": 5,
+ "startColumn": 11,
+ "endLine": 5,
+ "endColumn": 16
+ },
+ "flags": 0,
+ "parameters": "()"
+ },
+ "offset": 48,
+ "length": 16,
+ "codeOffset": 48,
+ "codeLength": 16
+ },
+ {
+ "element": {
+ "kind": "METHOD",
+ "name": "aMethod",
+ "location": {
+ "file": $testPathJson,
+ "offset": 72,
+ "length": 7,
+ "startLine": 6,
+ "startColumn": 8,
+ "endLine": 6,
+ "endColumn": 15
+ },
+ "flags": 0,
+ "parameters": "()",
+ "returnType": "void"
+ },
+ "offset": 67,
+ "length": 17,
+ "codeOffset": 67,
+ "codeLength": 17
+ },
+ {
+ "element": {
+ "kind": "GETTER",
+ "name": "aGetter",
+ "location": {
+ "file": $testPathJson,
+ "offset": 95,
+ "length": 7,
+ "startLine": 7,
+ "startColumn": 11,
+ "endLine": 7,
+ "endColumn": 18
+ },
+ "flags": 0,
+ "returnType": "int"
+ },
+ "offset": 87,
+ "length": 21,
+ "codeOffset": 87,
+ "codeLength": 21
+ },
+ {
+ "element": {
+ "kind": "SETTER",
+ "name": "aSetter",
+ "location": {
+ "file": $testPathJson,
+ "offset": 115,
+ "length": 7,
+ "startLine": 8,
+ "startColumn": 7,
+ "endLine": 8,
+ "endColumn": 14
+ },
+ "flags": 0,
+ "parameters": "(int value)",
+ "returnType": ""
+ },
+ "offset": 111,
+ "length": 25,
+ "codeOffset": 111,
+ "codeLength": 25
+ }
+ ]
+}
+''');
}
Future<void> test_extension_named() async {
@@ -1350,12 +1606,4 @@
expect(element.returnType, returnType);
}
}
-
- void _isEnumConstant(Outline outline, String name) {
- var element = outline.element;
- expect(element.kind, ElementKind.ENUM_CONSTANT);
- expect(element.name, name);
- expect(element.parameters, isNull);
- expect(element.returnType, isNull);
- }
}
diff --git a/pkg/analysis_server/test/stress/utilities/server.dart b/pkg/analysis_server/test/stress/utilities/server.dart
index 68ef712..b2eefa3 100644
--- a/pkg/analysis_server/test/stress/utilities/server.dart
+++ b/pkg/analysis_server/test/stress/utilities/server.dart
@@ -762,7 +762,7 @@
var trimmedLine = line.trim();
if (trimmedLine.isEmpty ||
- trimmedLine.startsWith('The Dart VM service is listening on ')) {
+ trimmedLine.startsWith('Observatory listening on ')) {
return;
}
logger?.log(fromServer, '$trimmedLine');
diff --git a/pkg/analysis_server_client/lib/src/server_base.dart b/pkg/analysis_server_client/lib/src/server_base.dart
index 34f3f2e..dd9668c 100644
--- a/pkg/analysis_server_client/lib/src/server_base.dart
+++ b/pkg/analysis_server_client/lib/src/server_base.dart
@@ -113,11 +113,11 @@
var trimmedLine = line.trim();
// Guard against lines like:
- // {"event":"server.connected","params":{...}}The Dart VM service is listening on ...
- const dartVMServiceMessage = 'The Dart VM service is listening on ';
- if (trimmedLine.contains(dartVMServiceMessage)) {
+ // {"event":"server.connected","params":{...}}Observatory listening on ...
+ const observatoryMessage = 'Observatory listening on ';
+ if (trimmedLine.contains(observatoryMessage)) {
trimmedLine = trimmedLine
- .substring(0, trimmedLine.indexOf(dartVMServiceMessage))
+ .substring(0, trimmedLine.indexOf(observatoryMessage))
.trim();
}
if (trimmedLine.isEmpty) {
diff --git a/pkg/analysis_server_client/test/server_test.dart b/pkg/analysis_server_client/test/server_test.dart
index 504f9f0..286938d 100644
--- a/pkg/analysis_server_client/test/server_test.dart
+++ b/pkg/analysis_server_client/test/server_test.dart
@@ -173,7 +173,7 @@
};
Stream<List<int>> _badMessage() async* {
- yield utf8.encoder.convert('The Dart VM service is listening on foo bar\n');
+ yield utf8.encoder.convert('Observatory listening on foo bar\n');
final sampleJson = {
'id': '0',
'error': _badErrorMessage,
@@ -182,7 +182,7 @@
}
Stream<List<int>> _eventMessage() async* {
- yield utf8.encoder.convert('The Dart VM service is listening on foo bar\n');
+ yield utf8.encoder.convert('Observatory listening on foo bar\n');
final sampleJson = {
'event': 'fooEvent',
'params': {'foo': 'bar', 'baz': 'bang'}
@@ -191,7 +191,7 @@
}
Stream<List<int>> _goodMessage() async* {
- yield utf8.encoder.convert('The Dart VM service is listening on foo bar\n');
+ yield utf8.encoder.convert('Observatory listening on foo bar\n');
final sampleJson = {
'id': '0',
'result': {'foo': 'bar'}
diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md
index fb6f6dd..0b6f526 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -1,3 +1,6 @@
+## 3.3.1
+* Report HintCode.OVERRIDE_ON_NON_OVERRIDING_xyz on enum.
+
## 3.3.0
* Added `getField` to `ExtensionElement`.
* Added `isGenerative` to `ConstructorElement`.
diff --git a/pkg/analyzer/lib/src/dart/ast/ast.dart b/pkg/analyzer/lib/src/dart/ast/ast.dart
index aa0806f..31e08bd 100644
--- a/pkg/analyzer/lib/src/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/src/dart/ast/ast.dart
@@ -58,6 +58,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitAdjacentStrings(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitAdjacentStrings(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_strings.accept(visitor);
}
@@ -455,6 +460,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitAsExpression(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitAsExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_expression.accept(visitor);
_type.accept(visitor);
@@ -700,6 +710,11 @@
visitor.visitAssignmentExpression(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitAssignmentExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_leftHandSide.accept(visitor);
_rightHandSide.accept(visitor);
@@ -874,6 +889,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitAwaitExpression(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitAwaitExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_expression.accept(visitor);
}
@@ -942,6 +962,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitBinaryExpression(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitBinaryExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_leftOperand.accept(visitor);
_rightOperand.accept(visitor);
@@ -1099,6 +1124,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitBooleanLiteral(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitBooleanLiteral(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
// There are no children to visit.
}
@@ -1230,6 +1260,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitCascadeExpression(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitCascadeExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_target.accept(visitor);
_cascadeSections.accept(visitor);
@@ -2303,6 +2338,11 @@
visitor.visitConditionalExpression(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitConditionalExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_condition.accept(visitor);
_thenExpression.accept(visitor);
@@ -2805,6 +2845,11 @@
visitor.visitConstructorReference(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitConstructorReference(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
constructorName.accept(visitor);
}
@@ -3290,6 +3335,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitDoubleLiteral(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitDoubleLiteral(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
// There are no children to visit.
}
@@ -3847,6 +3897,14 @@
ResolverVisitor resolver, CollectionLiteralContext? context) {
resolver.analyzeExpression(this, context?.elementType);
}
+
+ /// Dispatches this expression to the [resolver], with the given [contextType]
+ /// information.
+ ///
+ /// Note: most code shouldn't call this method directly, but should instead
+ /// call [ResolverVisitor.analyzeExpression], which has some special logic for
+ /// handling dynamic contexts.
+ void resolveExpression(ResolverVisitor resolver, DartType? contextType);
}
/// An expression used as a statement.
@@ -4183,6 +4241,11 @@
}
@override
+ void resolveExpression(ResolverVisitor resolver, DartType? contextType) {
+ resolver.visitExtensionOverride(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_extensionName.accept(visitor);
_typeArguments?.accept(visitor);
@@ -5268,6 +5331,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitFunctionExpression(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitFunctionExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_typeParameters?.accept(visitor);
_parameters?.accept(visitor);
@@ -5330,6 +5398,11 @@
visitor.visitFunctionExpressionInvocation(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitFunctionExpressionInvocation(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_function.accept(visitor);
_typeArguments?.accept(visitor);
@@ -5390,6 +5463,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitFunctionReference(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitFunctionReference(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
function.accept(visitor);
typeArguments?.accept(visitor);
@@ -6171,6 +6249,11 @@
}
@override
+ void resolveExpression(ResolverVisitor resolver, DartType? contextType) {
+ resolver.visitImplicitCallReference(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
expression.accept(visitor);
typeArguments?.accept(visitor);
@@ -6436,6 +6519,11 @@
}
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitIndexExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_target?.accept(visitor);
_index.accept(visitor);
@@ -6544,6 +6632,11 @@
visitor.visitInstanceCreationExpression(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitInstanceCreationExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_constructorName.accept(visitor);
_typeArguments?.accept(visitor);
@@ -6601,6 +6694,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitIntegerLiteral(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitIntegerLiteral(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
// There are no children to visit.
}
@@ -6872,6 +6970,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitIsExpression(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitIsExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_expression.accept(visitor);
_type.accept(visitor);
@@ -7090,6 +7193,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitLibraryIdentifier(this);
@override
+ void resolveExpression(ResolverVisitor resolver, DartType? contextType) {
+ resolver.visitLibraryIdentifier(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_components.accept(visitor);
}
@@ -7161,6 +7269,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitListLiteral(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitListLiteral(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
super.visitChildren(visitor);
_elements.accept(visitor);
@@ -7575,6 +7688,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitMethodInvocation(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitMethodInvocation(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_target?.accept(visitor);
_methodName.accept(visitor);
@@ -7758,6 +7876,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitNamedExpression(this);
@override
+ void resolveExpression(ResolverVisitor resolver, DartType? contextType) {
+ resolver.visitNamedExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_name.accept(visitor);
_expression.accept(visitor);
@@ -8258,6 +8381,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitNullLiteral(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitNullLiteral(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
// There are no children to visit.
}
@@ -8395,6 +8523,11 @@
visitor.visitParenthesizedExpression(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitParenthesizedExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_expression.accept(visitor);
}
@@ -8593,6 +8726,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitPostfixExpression(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitPostfixExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_operand.accept(visitor);
}
@@ -8679,6 +8817,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitPrefixedIdentifier(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitPrefixedIdentifier(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_prefix.accept(visitor);
_identifier.accept(visitor);
@@ -8753,6 +8896,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitPrefixExpression(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitPrefixExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_operand.accept(visitor);
}
@@ -8867,6 +9015,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitPropertyAccess(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitPropertyAccess(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_target?.accept(visitor);
_propertyName.accept(visitor);
@@ -8983,6 +9136,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitRethrowExpression(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitRethrowExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
// There are no children to visit.
}
@@ -9159,6 +9317,11 @@
}
@override
+ void resolveExpression(ResolverVisitor resolver, DartType? contextType) {
+ resolver.visitSetOrMapLiteral(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
super.visitChildren(visitor);
_elements.accept(visitor);
@@ -9577,6 +9740,11 @@
}
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitSimpleIdentifier(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
// There are no children to visit.
}
@@ -9651,6 +9819,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitSimpleStringLiteral(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitSimpleStringLiteral(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
// There are no children to visit.
}
@@ -9823,6 +9996,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitStringInterpolation(this);
@override
+ void resolveExpression(ResolverVisitor resolver, DartType? contextType) {
+ resolver.visitStringInterpolation(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_elements.accept(visitor);
}
@@ -10052,6 +10230,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitSuperExpression(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitSuperExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
// There are no children to visit.
}
@@ -10431,6 +10614,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitSymbolLiteral(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitSymbolLiteral(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
// There are no children to visit.
}
@@ -10465,6 +10653,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitThisExpression(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitThisExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
// There are no children to visit.
}
@@ -10514,6 +10707,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitThrowExpression(this);
@override
+ void resolveExpression(ResolverVisitor visitor, DartType? contextType) {
+ visitor.visitThrowExpression(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_expression.accept(visitor);
}
@@ -10845,6 +11043,11 @@
E? accept<E>(AstVisitor<E> visitor) => visitor.visitTypeLiteral(this);
@override
+ void resolveExpression(ResolverVisitor resolver, DartType? contextType) {
+ resolver.visitTypeLiteral(this, contextType: contextType);
+ }
+
+ @override
void visitChildren(AstVisitor visitor) {
_typeName.accept(visitor);
}
diff --git a/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
index 87c4e6c..0cc6306 100644
--- a/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
@@ -928,7 +928,6 @@
);
NodeReplacer.replace(node, invocation);
node.setProperty(_rewriteResultKey, invocation);
- InferenceContext.setType(invocation, contextType);
_resolver.flowAnalysis.transferTestData(node, invocation);
}
diff --git a/pkg/analyzer/lib/src/error/override_verifier.dart b/pkg/analyzer/lib/src/error/override_verifier.dart
index 795a093..5a87250 100644
--- a/pkg/analyzer/lib/src/error/override_verifier.dart
+++ b/pkg/analyzer/lib/src/error/override_verifier.dart
@@ -37,6 +37,13 @@
}
@override
+ void visitEnumDeclaration(EnumDeclaration node) {
+ _currentClass = node.declaredElement;
+ super.visitEnumDeclaration(node);
+ _currentClass = null;
+ }
+
+ @override
void visitFieldDeclaration(FieldDeclaration node) {
for (VariableDeclaration field in node.fields.variables) {
var fieldElement = field.declaredElement as FieldElement;
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index f2eb111..5d242c3 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -82,11 +82,6 @@
/// Maintains and manages contextual type information used for
/// inferring types.
class InferenceContext {
- // TODO(leafp): Consider replacing these node properties with a
- // hash table help in an instance of this class.
- static const String _typeProperty =
- 'analyzer.src.generated.InferenceContext.contextType';
-
final ResolverVisitor _resolver;
/// The type system in use.
@@ -126,43 +121,6 @@
),
);
}
-
- /// Clear the type information associated with [node].
- static void clearType(AstNode? node) {
- node?.setProperty(_typeProperty, null);
- }
-
- /// Look for contextual type information attached to [node], and returns
- /// the type if found.
- ///
- /// The returned type may be partially or completely unknown, denoted with an
- /// unknown type `_`, for example `List<_>` or `(_, int) -> void`.
- /// You can use [TypeSystemImpl.upperBoundForType] or
- /// [TypeSystemImpl.lowerBoundForType] if you would prefer a known type
- /// that represents the bound of the context type.
- static DartType? getContext(AstNode? node) {
- if (node is ArgumentList ||
- node is VariableDeclaration ||
- node is FunctionBody) {
- assert(false, 'Nodes of type ${node.runtimeType} should use context');
- }
- return node?.getProperty(_typeProperty);
- }
-
- /// Attach contextual type information [type] to [node] for use during
- /// inference.
- static void setType(AstNode? node, DartType? type) {
- if (node is ArgumentList ||
- node is VariableDeclaration ||
- node is FunctionBody) {
- assert(false, 'Nodes of type ${node.runtimeType} should use context');
- }
- if (type == null || type.isDynamic) {
- clearType(node);
- } else {
- node?.setProperty(_typeProperty, type);
- }
- }
}
/// Instances of the class `ResolverVisitor` are used to resolve the nodes
@@ -513,8 +471,10 @@
}
void analyzeExpression(Expression expression, DartType? contextType) {
- InferenceContext.setType(expression, contextType);
- expression.accept(this);
+ if (contextType != null && contextType.isDynamic) {
+ contextType = null;
+ }
+ (expression as ExpressionImpl).resolveExpression(this, contextType);
}
/// Verify that the arguments in the given [argumentList] can be assigned to
@@ -1064,8 +1024,7 @@
}
@override
- void visitAdjacentStrings(AdjacentStrings node) {
- var contextType = InferenceContext.getContext(node);
+ void visitAdjacentStrings(AdjacentStrings node, {DartType? contextType}) {
checkUnreachableNode(node);
node.visitChildren(this);
typeAnalyzer.visitAdjacentStrings(node as AdjacentStringsImpl,
@@ -1089,8 +1048,7 @@
}
@override
- void visitAsExpression(AsExpression node) {
- var contextType = InferenceContext.getContext(node);
+ void visitAsExpression(AsExpression node, {DartType? contextType}) {
checkUnreachableNode(node);
node.visitChildren(this);
typeAnalyzer.visitAsExpression(node as AsExpressionImpl,
@@ -1130,8 +1088,8 @@
}
@override
- void visitAssignmentExpression(AssignmentExpression node) {
- var contextType = InferenceContext.getContext(node);
+ void visitAssignmentExpression(AssignmentExpression node,
+ {DartType? contextType}) {
_assignmentExpressionResolver.resolve(node as AssignmentExpressionImpl,
contextType: contextType);
_insertImplicitCallReference(
@@ -1140,8 +1098,7 @@
}
@override
- void visitAwaitExpression(AwaitExpression node) {
- var contextType = InferenceContext.getContext(node);
+ void visitAwaitExpression(AwaitExpression node, {DartType? contextType}) {
DartType? futureUnion;
if (contextType != null) {
futureUnion = _createFutureOr(contextType);
@@ -1156,8 +1113,7 @@
}
@override
- void visitBinaryExpression(BinaryExpression node) {
- var contextType = InferenceContext.getContext(node);
+ void visitBinaryExpression(BinaryExpression node, {DartType? contextType}) {
var migrationResolutionHooks = this.migrationResolutionHooks;
if (migrationResolutionHooks != null) {
migrationResolutionHooks.reportBinaryExpressionContext(node, contextType);
@@ -1191,8 +1147,7 @@
}
@override
- void visitBooleanLiteral(BooleanLiteral node) {
- var contextType = InferenceContext.getContext(node);
+ void visitBooleanLiteral(BooleanLiteral node, {DartType? contextType}) {
flowAnalysis.flow?.booleanLiteral(node, node.value);
checkUnreachableNode(node);
node.visitChildren(this);
@@ -1211,8 +1166,8 @@
}
@override
- void visitCascadeExpression(covariant CascadeExpressionImpl node) {
- var contextType = InferenceContext.getContext(node);
+ void visitCascadeExpression(covariant CascadeExpressionImpl node,
+ {DartType? contextType}) {
analyzeExpression(node.target, contextType);
if (node.isNullAware) {
@@ -1288,8 +1243,8 @@
}
@override
- void visitConditionalExpression(ConditionalExpression node) {
- var contextType = InferenceContext.getContext(node);
+ void visitConditionalExpression(ConditionalExpression node,
+ {DartType? contextType}) {
Expression condition = node.condition;
var flow = flowAnalysis.flow;
flow?.conditional_conditionBegin();
@@ -1399,8 +1354,8 @@
}
@override
- void visitConstructorReference(covariant ConstructorReferenceImpl node) {
- var contextType = InferenceContext.getContext(node);
+ void visitConstructorReference(covariant ConstructorReferenceImpl node,
+ {DartType? contextType}) {
_constructorReferenceResolver.resolve(node, contextType: contextType);
_insertImplicitCallReference(node, contextType: contextType);
}
@@ -1463,8 +1418,7 @@
}
@override
- void visitDoubleLiteral(DoubleLiteral node) {
- var contextType = InferenceContext.getContext(node);
+ void visitDoubleLiteral(DoubleLiteral node, {DartType? contextType}) {
checkUnreachableNode(node);
node.visitChildren(this);
typeAnalyzer.visitDoubleLiteral(node as DoubleLiteralImpl,
@@ -1646,20 +1600,20 @@
}
@override
- void visitExtensionOverride(ExtensionOverride node) {
+ void visitExtensionOverride(ExtensionOverride node, {DartType? contextType}) {
var whyNotPromotedList = <Map<DartType, NonPromotionReason> Function()>[];
node.extensionName.accept(this);
node.typeArguments?.accept(this);
- var contextType =
+ var receiverContextType =
ExtensionMemberResolver(this).computeOverrideReceiverContextType(node);
analyzeArgumentList(
node.argumentList,
- contextType == null
+ receiverContextType == null
? null
: [
ParameterElementImpl.synthetic(
- null, contextType, ParameterKind.REQUIRED)
+ null, receiverContextType, ParameterKind.REQUIRED)
],
whyNotPromotedList: whyNotPromotedList);
@@ -1762,8 +1716,8 @@
}
@override
- void visitFunctionExpression(covariant FunctionExpressionImpl node) {
- var contextType = InferenceContext.getContext(node);
+ void visitFunctionExpression(covariant FunctionExpressionImpl node,
+ {DartType? contextType}) {
var outerFunction = _enclosingFunction;
_enclosingFunction = node.declaredElement;
@@ -1774,8 +1728,8 @@
}
@override
- void visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
- var contextType = InferenceContext.getContext(node);
+ void visitFunctionExpressionInvocation(FunctionExpressionInvocation node,
+ {DartType? contextType}) {
var whyNotPromotedList = <Map<DartType, NonPromotionReason> Function()>[];
node.function.accept(this);
_functionExpressionInvocationResolver.resolve(
@@ -1790,7 +1744,7 @@
}
@override
- void visitFunctionReference(FunctionReference node) {
+ void visitFunctionReference(FunctionReference node, {DartType? contextType}) {
_functionReferenceResolver.resolve(node as FunctionReferenceImpl);
}
@@ -1884,7 +1838,8 @@
}
@override
- void visitImplicitCallReference(ImplicitCallReference node) {
+ void visitImplicitCallReference(ImplicitCallReference node,
+ {DartType? contextType}) {
checkUnreachableNode(node);
analyzeExpression(node.expression, null);
node.typeArguments?.accept(this);
@@ -1898,8 +1853,8 @@
}
@override
- void visitIndexExpression(covariant IndexExpressionImpl node) {
- var contextType = InferenceContext.getContext(node);
+ void visitIndexExpression(covariant IndexExpressionImpl node,
+ {DartType? contextType}) {
node.target?.accept(this);
startNullAwareIndexExpression(node);
@@ -1939,15 +1894,14 @@
@override
void visitInstanceCreationExpression(
- covariant InstanceCreationExpressionImpl node) {
- var contextType = InferenceContext.getContext(node);
+ covariant InstanceCreationExpressionImpl node,
+ {DartType? contextType}) {
_instanceCreationExpressionResolver.resolve(node, contextType: contextType);
_insertImplicitCallReference(node, contextType: contextType);
}
@override
- void visitIntegerLiteral(IntegerLiteral node) {
- var contextType = InferenceContext.getContext(node);
+ void visitIntegerLiteral(IntegerLiteral node, {DartType? contextType}) {
checkUnreachableNode(node);
node.visitChildren(this);
typeAnalyzer.visitIntegerLiteral(node as IntegerLiteralImpl,
@@ -1967,8 +1921,7 @@
}
@override
- void visitIsExpression(IsExpression node) {
- var contextType = InferenceContext.getContext(node);
+ void visitIsExpression(IsExpression node, {DartType? contextType}) {
checkUnreachableNode(node);
node.visitChildren(this);
typeAnalyzer.visitIsExpression(node as IsExpressionImpl,
@@ -1995,11 +1948,12 @@
}
@override
- void visitLibraryIdentifier(LibraryIdentifier node) {}
+ void visitLibraryIdentifier(LibraryIdentifier node,
+ {DartType? contextType}) {}
@override
- void visitListLiteral(covariant ListLiteralImpl node) {
- var contextType = InferenceContext.getContext(node);
+ void visitListLiteral(covariant ListLiteralImpl node,
+ {DartType? contextType}) {
checkUnreachableNode(node);
_typedLiteralResolver.resolveListLiteral(node, contextType: contextType);
}
@@ -2050,8 +2004,8 @@
}
@override
- void visitMethodInvocation(covariant MethodInvocationImpl node) {
- var contextType = InferenceContext.getContext(node);
+ void visitMethodInvocation(covariant MethodInvocationImpl node,
+ {DartType? contextType}) {
var whyNotPromotedList = <Map<DartType, NonPromotionReason> Function()>[];
var target = node.target;
target?.accept(this);
@@ -2108,8 +2062,7 @@
}
@override
- void visitNamedExpression(NamedExpression node) {
- var contextType = InferenceContext.getContext(node);
+ void visitNamedExpression(NamedExpression node, {DartType? contextType}) {
checkUnreachableNode(node);
node.name.accept(this);
analyzeExpression(node.expression, contextType);
@@ -2145,8 +2098,7 @@
}
@override
- void visitNullLiteral(NullLiteral node) {
- var contextType = InferenceContext.getContext(node);
+ void visitNullLiteral(NullLiteral node, {DartType? contextType}) {
flowAnalysis.flow?.nullLiteral(node);
checkUnreachableNode(node);
node.visitChildren(this);
@@ -2161,8 +2113,8 @@
}
@override
- void visitParenthesizedExpression(ParenthesizedExpression node) {
- var contextType = InferenceContext.getContext(node);
+ void visitParenthesizedExpression(ParenthesizedExpression node,
+ {DartType? contextType}) {
checkUnreachableNode(node);
analyzeExpression(node.expression, contextType);
typeAnalyzer.visitParenthesizedExpression(
@@ -2186,8 +2138,7 @@
}
@override
- void visitPostfixExpression(PostfixExpression node) {
- var contextType = InferenceContext.getContext(node);
+ void visitPostfixExpression(PostfixExpression node, {DartType? contextType}) {
_postfixExpressionResolver.resolve(node as PostfixExpressionImpl,
contextType: contextType);
_insertImplicitCallReference(
@@ -2196,8 +2147,8 @@
}
@override
- void visitPrefixedIdentifier(covariant PrefixedIdentifierImpl node) {
- var contextType = InferenceContext.getContext(node);
+ void visitPrefixedIdentifier(covariant PrefixedIdentifierImpl node,
+ {DartType? contextType}) {
_prefixedIdentifierResolver.resolve(node, contextType: contextType);
_insertImplicitCallReference(
insertGenericFunctionInstantiation(node, contextType: contextType),
@@ -2205,8 +2156,7 @@
}
@override
- void visitPrefixExpression(PrefixExpression node) {
- var contextType = InferenceContext.getContext(node);
+ void visitPrefixExpression(PrefixExpression node, {DartType? contextType}) {
_prefixExpressionResolver.resolve(node as PrefixExpressionImpl,
contextType: contextType);
_insertImplicitCallReference(
@@ -2215,8 +2165,8 @@
}
@override
- void visitPropertyAccess(covariant PropertyAccessImpl node) {
- var contextType = InferenceContext.getContext(node);
+ void visitPropertyAccess(covariant PropertyAccessImpl node,
+ {DartType? contextType}) {
node.target?.accept(this);
startNullAwarePropertyAccess(node);
@@ -2280,8 +2230,7 @@
}
@override
- void visitRethrowExpression(RethrowExpression node) {
- var contextType = InferenceContext.getContext(node);
+ void visitRethrowExpression(RethrowExpression node, {DartType? contextType}) {
checkUnreachableNode(node);
node.visitChildren(this);
typeAnalyzer.visitRethrowExpression(node as RethrowExpressionImpl,
@@ -2307,8 +2256,7 @@
}
@override
- void visitSetOrMapLiteral(SetOrMapLiteral node) {
- var contextType = InferenceContext.getContext(node);
+ void visitSetOrMapLiteral(SetOrMapLiteral node, {DartType? contextType}) {
checkUnreachableNode(node);
_typedLiteralResolver.resolveSetOrMapLiteral(node,
contextType: contextType);
@@ -2325,8 +2273,8 @@
}
@override
- void visitSimpleIdentifier(covariant SimpleIdentifierImpl node) {
- var contextType = InferenceContext.getContext(node);
+ void visitSimpleIdentifier(covariant SimpleIdentifierImpl node,
+ {DartType? contextType}) {
_simpleIdentifierResolver.resolve(node, contextType: contextType);
_insertImplicitCallReference(
insertGenericFunctionInstantiation(node, contextType: contextType),
@@ -2334,8 +2282,8 @@
}
@override
- void visitSimpleStringLiteral(SimpleStringLiteral node) {
- var contextType = InferenceContext.getContext(node);
+ void visitSimpleStringLiteral(SimpleStringLiteral node,
+ {DartType? contextType}) {
checkUnreachableNode(node);
node.visitChildren(this);
typeAnalyzer.visitSimpleStringLiteral(node as SimpleStringLiteralImpl,
@@ -2361,8 +2309,8 @@
}
@override
- void visitStringInterpolation(StringInterpolation node) {
- var contextType = InferenceContext.getContext(node);
+ void visitStringInterpolation(StringInterpolation node,
+ {DartType? contextType}) {
checkUnreachableNode(node);
node.visitChildren(this);
typeAnalyzer.visitStringInterpolation(node as StringInterpolationImpl,
@@ -2386,8 +2334,7 @@
}
@override
- void visitSuperExpression(SuperExpression node) {
- var contextType = InferenceContext.getContext(node);
+ void visitSuperExpression(SuperExpression node, {DartType? contextType}) {
checkUnreachableNode(node);
node.visitChildren(this);
elementResolver.visitSuperExpression(node);
@@ -2466,8 +2413,7 @@
}
@override
- void visitSymbolLiteral(SymbolLiteral node) {
- var contextType = InferenceContext.getContext(node);
+ void visitSymbolLiteral(SymbolLiteral node, {DartType? contextType}) {
checkUnreachableNode(node);
node.visitChildren(this);
typeAnalyzer.visitSymbolLiteral(node as SymbolLiteralImpl,
@@ -2475,8 +2421,7 @@
}
@override
- void visitThisExpression(ThisExpression node) {
- var contextType = InferenceContext.getContext(node);
+ void visitThisExpression(ThisExpression node, {DartType? contextType}) {
checkUnreachableNode(node);
node.visitChildren(this);
typeAnalyzer.visitThisExpression(node as ThisExpressionImpl,
@@ -2485,8 +2430,7 @@
}
@override
- void visitThrowExpression(ThrowExpression node) {
- var contextType = InferenceContext.getContext(node);
+ void visitThrowExpression(ThrowExpression node, {DartType? contextType}) {
checkUnreachableNode(node);
node.visitChildren(this);
typeAnalyzer.visitThrowExpression(node as ThrowExpressionImpl,
@@ -2555,7 +2499,7 @@
}
@override
- void visitTypeLiteral(TypeLiteral node) {
+ void visitTypeLiteral(TypeLiteral node, {DartType? contextType}) {
checkUnreachableNode(node);
node.visitChildren(this);
}
@@ -2920,12 +2864,12 @@
migrationResolutionHooks);
@override
- void visitConditionalExpression(covariant ConditionalExpressionImpl node) {
- var contextType = InferenceContext.getContext(node);
+ void visitConditionalExpression(covariant ConditionalExpressionImpl node,
+ {DartType? contextType}) {
var conditionalKnownValue =
_migrationResolutionHooks.getConditionalKnownValue(node);
if (conditionalKnownValue == null) {
- super.visitConditionalExpression(node);
+ super.visitConditionalExpression(node, contextType: contextType);
return;
} else {
var subexpressionToKeep =
diff --git a/pkg/analyzer/pubspec.yaml b/pkg/analyzer/pubspec.yaml
index ce58cd3..064de4b 100644
--- a/pkg/analyzer/pubspec.yaml
+++ b/pkg/analyzer/pubspec.yaml
@@ -1,5 +1,5 @@
name: analyzer
-version: 3.3.0
+version: 3.3.1
description: This package provides a library that performs static analysis of Dart code.
homepage: https://github.com/dart-lang/sdk/tree/main/pkg/analyzer
@@ -7,7 +7,7 @@
sdk: '>=2.14.0 <3.0.0'
dependencies:
- _fe_analyzer_shared: ^35.0.0
+ _fe_analyzer_shared: ^36.0.0
collection: ^1.15.0
convert: ^3.0.0
crypto: ^3.0.0
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
index 0bcce79..ebf8025 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
@@ -796,11 +796,20 @@
}
''');
- assertBinaryExpression(
- findNode.binary('>>> 3'),
- element: findElement.method('>>>'),
- type: 'A',
- );
+ assertResolvedNodeText(findNode.binary('>>> 3'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@54
+ staticType: A
+ operator: >>>
+ rightOperand: IntegerLiteral
+ literal: 3
+ staticType: int
+ staticElement: self::@class::A::@method::>>>
+ staticInvokeType: A Function(int)
+ staticType: A
+''');
}
test_binaryExpression_ifNull() async {
diff --git a/pkg/analyzer/test/src/dart/resolution/binary_expression_test.dart b/pkg/analyzer/test/src/dart/resolution/binary_expression_test.dart
index 47869ef..c5ad2dc 100644
--- a/pkg/analyzer/test/src/dart/resolution/binary_expression_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/binary_expression_test.dart
@@ -4,7 +4,6 @@
import 'package:analyzer/src/dart/error/syntactic_errors.dart';
import 'package:analyzer/src/error/codes.dart';
-import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'context_collection_resolution.dart';
@@ -25,19 +24,32 @@
int g() => f(null) ?? 0;
''');
- assertMethodInvocation2(
- findNode.methodInvocation('f(null)'),
- element: findElement.topFunction('f'),
- typeArgumentTypes: ['int?'],
- invokeType: 'int? Function(int?)',
- type: 'int?',
- );
-
- assertBinaryExpression(
- findNode.binary('?? 0'),
- element: null,
- type: 'int',
- );
+ assertResolvedNodeText(findNode.binary('?? 0'), r'''
+BinaryExpression
+ leftOperand: MethodInvocation
+ methodName: SimpleIdentifier
+ token: f
+ staticElement: self::@function::f
+ staticType: T Function<T>(T)
+ argumentList: ArgumentList
+ leftParenthesis: (
+ arguments
+ NullLiteral
+ literal: null
+ staticType: Null
+ rightParenthesis: )
+ staticInvokeType: int? Function(int?)
+ staticType: int?
+ typeArgumentTypes
+ int?
+ operator: ??
+ rightOperand: IntegerLiteral
+ literal: 0
+ staticType: int
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: int
+''');
}
test_ifNull_nullableInt_int() async {
@@ -47,11 +59,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('x ?? y'),
- element: null,
- type: 'int',
- );
+ assertResolvedNodeText(findNode.binary('x ?? y'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: x
+ staticElement: x@12
+ staticType: int?
+ operator: ??
+ rightOperand: SimpleIdentifier
+ token: y
+ staticElement: y@19
+ staticType: int
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: int
+''');
}
test_ifNull_nullableInt_nullableDouble() async {
@@ -61,11 +83,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('x ?? y'),
- element: null,
- type: 'num?',
- );
+ assertResolvedNodeText(findNode.binary('x ?? y'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: x
+ staticElement: x@12
+ staticType: int?
+ operator: ??
+ rightOperand: SimpleIdentifier
+ token: y
+ staticElement: y@23
+ staticType: double?
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: num?
+''');
}
test_ifNull_nullableInt_nullableInt() async {
@@ -75,11 +107,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('x ?? x'),
- element: null,
- type: 'int?',
- );
+ assertResolvedNodeText(findNode.binary('x ?? x'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: x
+ staticElement: x@12
+ staticType: int?
+ operator: ??
+ rightOperand: SimpleIdentifier
+ token: x
+ staticElement: x@12
+ staticType: int?
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: int?
+''');
}
test_plus_int_never() async {
@@ -89,8 +131,21 @@
}
''');
- assertBinaryExpression(findNode.binary('a + b'),
- element: numElement.getMethod('+'), type: 'num');
+ assertResolvedNodeText(findNode.binary('a + b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@6
+ staticType: int
+ operator: +
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@15
+ staticType: Never
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: num Function(num)
+ staticType: num
+''');
}
test_plus_never_int() async {
@@ -103,11 +158,21 @@
error(HintCode.DEAD_CODE, 26, 2),
]);
- assertBinaryExpression(
- findNode.binary('a + b'),
- element: isNull,
- type: 'Never',
- );
+ assertResolvedNodeText(findNode.binary('a + b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@8
+ staticType: Never
+ operator: +
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@15
+ staticType: int
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: Never
+''');
}
}
@@ -119,14 +184,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a != b'),
- element: elementMatcher(
- numElement.getMethod('=='),
- isLegacy: isLegacyLibrary,
- ),
- type: 'bool',
- );
+ assertResolvedNodeText(findNode.binary('a != b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@6
+ staticType: int
+ operator: !=
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@13
+ staticType: int
+ staticElement: dart:core::@class::num::@method::==
+ staticInvokeType: bool Function(Object)
+ staticType: bool
+''');
}
test_bangEq_extensionOverride_left() async {
@@ -140,11 +212,31 @@
error(CompileTimeErrorCode.UNDEFINED_EXTENSION_OPERATOR, 46, 2),
]);
- assertBinaryExpression(
- findNode.binary('!= 0'),
- element: null,
- type: 'dynamic',
- );
+ assertResolvedNodeText(findNode.binary('!= 0'), r'''
+BinaryExpression
+ leftOperand: ExtensionOverride
+ extensionName: SimpleIdentifier
+ token: E
+ staticElement: self::@extension::E
+ staticType: null
+ argumentList: ArgumentList
+ leftParenthesis: (
+ arguments
+ SimpleIdentifier
+ token: a
+ staticElement: a@34
+ staticType: int
+ rightParenthesis: )
+ extendedType: int
+ staticType: null
+ operator: !=
+ rightOperand: IntegerLiteral
+ literal: 0
+ staticType: int
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: dynamic
+''');
}
test_bangEqEq() async {
@@ -156,14 +248,21 @@
error(ScannerErrorCode.UNSUPPORTED_OPERATOR, 22, 1),
]);
- assertBinaryExpression(
- findNode.binary('a !== b'),
- element: null,
- type: 'dynamic',
- );
-
- assertType(findNode.simple('a !=='), 'int');
- assertType(findNode.simple('b;'), 'int');
+ assertResolvedNodeText(findNode.binary('a !== b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@6
+ staticType: int
+ operator: !==
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@13
+ staticType: int
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: dynamic
+''');
}
test_eqEq() async {
@@ -173,14 +272,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a == b'),
- element: elementMatcher(
- numElement.getMethod('=='),
- isLegacy: isLegacyLibrary,
- ),
- type: 'bool',
- );
+ assertResolvedNodeText(findNode.binary('a == b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@6
+ staticType: int
+ operator: ==
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@13
+ staticType: int
+ staticElement: dart:core::@class::num::@method::==
+ staticInvokeType: bool Function(Object)
+ staticType: bool
+''');
}
test_eqEq_extensionOverride_left() async {
@@ -194,11 +300,31 @@
error(CompileTimeErrorCode.UNDEFINED_EXTENSION_OPERATOR, 46, 2),
]);
- assertBinaryExpression(
- findNode.binary('== 0'),
- element: null,
- type: 'dynamic',
- );
+ assertResolvedNodeText(findNode.binary('== 0'), r'''
+BinaryExpression
+ leftOperand: ExtensionOverride
+ extensionName: SimpleIdentifier
+ token: E
+ staticElement: self::@extension::E
+ staticType: null
+ argumentList: ArgumentList
+ leftParenthesis: (
+ arguments
+ SimpleIdentifier
+ token: a
+ staticElement: a@34
+ staticType: int
+ rightParenthesis: )
+ extendedType: int
+ staticType: null
+ operator: ==
+ rightOperand: IntegerLiteral
+ literal: 0
+ staticType: int
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: dynamic
+''');
}
test_eqEqEq() async {
@@ -210,14 +336,21 @@
error(ScannerErrorCode.UNSUPPORTED_OPERATOR, 22, 1),
]);
- assertBinaryExpression(
- findNode.binary('a === b'),
- element: null,
- type: 'dynamic',
- );
-
- assertType(findNode.simple('a ==='), 'int');
- assertType(findNode.simple('b;'), 'int');
+ assertResolvedNodeText(findNode.binary('a === b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@6
+ staticType: int
+ operator: ===
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@13
+ staticType: int
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: dynamic
+''');
}
test_ifNull() async {
@@ -228,11 +361,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a ?? b'),
- element: null,
- type: 'num',
- );
+ assertResolvedNodeText(findNode.binary('a ?? b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@7
+ staticType: int?
+ operator: ??
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@17
+ staticType: double
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: num
+''');
}
test_logicalAnd() async {
@@ -242,11 +385,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a && b'),
- element: boolElement.getMethod('&&'),
- type: 'bool',
- );
+ assertResolvedNodeText(findNode.binary('a && b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@7
+ staticType: bool
+ operator: &&
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@15
+ staticType: bool
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: bool
+''');
}
test_logicalOr() async {
@@ -256,11 +409,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a || b'),
- element: boolElement.getMethod('||'),
- type: 'bool',
- );
+ assertResolvedNodeText(findNode.binary('a || b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@7
+ staticType: bool
+ operator: ||
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@15
+ staticType: bool
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: bool
+''');
}
test_minus_int_context_int() async {
@@ -283,14 +446,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a - b'),
- element: elementMatcher(
- numElement.getMethod('-'),
- isLegacy: isLegacyLibrary,
- ),
- type: 'double',
- );
+ assertResolvedNodeText(findNode.binary('a - b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@6
+ staticType: int
+ operator: -
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@16
+ staticType: double
+ staticElement: dart:core::@class::num::@method::-
+ staticInvokeType: num Function(num)
+ staticType: double
+''');
}
test_minus_int_int() async {
@@ -300,14 +470,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a - b'),
- element: elementMatcher(
- numElement.getMethod('-'),
- isLegacy: isLegacyLibrary,
- ),
- type: 'int',
- );
+ assertResolvedNodeText(findNode.binary('a - b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@6
+ staticType: int
+ operator: -
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@13
+ staticType: int
+ staticElement: dart:core::@class::num::@method::-
+ staticInvokeType: num Function(num)
+ staticType: int
+''');
}
test_mod_int_context_int() async {
@@ -330,14 +507,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a % b'),
- element: elementMatcher(
- numElement.getMethod('%'),
- isLegacy: isLegacyLibrary,
- ),
- type: 'double',
- );
+ assertResolvedNodeText(findNode.binary('a % b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@6
+ staticType: int
+ operator: %
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@16
+ staticType: double
+ staticElement: dart:core::@class::num::@method::%
+ staticInvokeType: num Function(num)
+ staticType: double
+''');
}
test_mod_int_int() async {
@@ -347,14 +531,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a % b'),
- element: elementMatcher(
- numElement.getMethod('%'),
- isLegacy: isLegacyLibrary,
- ),
- type: 'int',
- );
+ assertResolvedNodeText(findNode.binary('a % b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@6
+ staticType: int
+ operator: %
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@13
+ staticType: int
+ staticElement: dart:core::@class::num::@method::%
+ staticInvokeType: num Function(num)
+ staticType: int
+''');
}
test_plus_double_context_double() async {
@@ -401,14 +592,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a + b'),
- element: elementMatcher(
- doubleElement.getMethod('+'),
- isLegacy: isLegacyLibrary,
- ),
- type: 'double',
- );
+ assertResolvedNodeText(findNode.binary('a + b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@9
+ staticType: double
+ operator: +
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@20
+ staticType: dynamic
+ staticElement: dart:core::@class::double::@method::+
+ staticInvokeType: double Function(num)
+ staticType: double
+''');
}
test_plus_int_context_double() async {
@@ -485,14 +683,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a + b'),
- element: elementMatcher(
- numElement.getMethod('+'),
- isLegacy: isLegacyLibrary,
- ),
- type: 'double',
- );
+ assertResolvedNodeText(findNode.binary('a + b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@6
+ staticType: int
+ operator: +
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@16
+ staticType: double
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: num Function(num)
+ staticType: double
+''');
}
test_plus_int_dynamic() async {
@@ -502,14 +707,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a + b'),
- element: elementMatcher(
- numElement.getMethod('+'),
- isLegacy: isLegacyLibrary,
- ),
- type: 'num',
- );
+ assertResolvedNodeText(findNode.binary('a + b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@6
+ staticType: int
+ operator: +
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@17
+ staticType: dynamic
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: num Function(num)
+ staticType: num
+''');
}
test_plus_int_int() async {
@@ -519,14 +731,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a + b'),
- element: elementMatcher(
- numElement.getMethod('+'),
- isLegacy: isLegacyLibrary,
- ),
- type: 'int',
- );
+ assertResolvedNodeText(findNode.binary('a + b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@6
+ staticType: int
+ operator: +
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@13
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: num Function(num)
+ staticType: int
+''');
}
test_plus_int_int_target_rewritten() async {
@@ -536,14 +755,28 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a() + b'),
- element: elementMatcher(
- numElement.getMethod('+'),
- isLegacy: isLegacyLibrary,
- ),
- type: 'int',
- );
+ assertResolvedNodeText(findNode.binary('a() + b'), r'''
+BinaryExpression
+ leftOperand: FunctionExpressionInvocation
+ function: SimpleIdentifier
+ token: a
+ staticElement: a@17
+ staticType: int Function()
+ argumentList: ArgumentList
+ leftParenthesis: (
+ rightParenthesis: )
+ staticElement: <null>
+ staticInvokeType: int Function()
+ staticType: int
+ operator: +
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@24
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: num Function(num)
+ staticType: int
+''');
}
test_plus_int_int_via_extension_explicit() async {
@@ -556,14 +789,32 @@
}
''');
- assertBinaryExpression(
- findNode.binary('E(a) + b'),
- element: elementMatcher(
- findElement.method('+', of: 'E'),
- isLegacy: false,
- ),
- type: 'String',
- );
+ assertResolvedNodeText(findNode.binary('E(a) + b'), r'''
+BinaryExpression
+ leftOperand: ExtensionOverride
+ extensionName: SimpleIdentifier
+ token: E
+ staticElement: self::@extension::E
+ staticType: null
+ argumentList: ArgumentList
+ leftParenthesis: (
+ arguments
+ SimpleIdentifier
+ token: a
+ staticElement: a@66
+ staticType: int
+ rightParenthesis: )
+ extendedType: int
+ staticType: null
+ operator: +
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@73
+ staticType: int
+ staticElement: self::@extension::E::@method::+
+ staticInvokeType: String Function(int)
+ staticType: String
+''');
}
test_plus_int_num() async {
@@ -573,14 +824,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a + b'),
- element: elementMatcher(
- numElement.getMethod('+'),
- isLegacy: isLegacyLibrary,
- ),
- type: 'num',
- );
+ assertResolvedNodeText(findNode.binary('a + b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@6
+ staticType: int
+ operator: +
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@13
+ staticType: num
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: num Function(num)
+ staticType: num
+''');
}
test_plus_num_context_int() async {
@@ -664,14 +922,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a + b'),
- element: elementMatcher(
- findElement.method('+', of: 'A'),
- isLegacy: false,
- ),
- type: 'String',
- );
+ assertResolvedNodeText(findNode.binary('a + b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@59
+ staticType: A
+ operator: +
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@69
+ staticType: double
+ staticElement: self::@class::A::@method::+
+ staticInvokeType: String Function(double)
+ staticType: String
+''');
}
test_plus_other_int_via_extension_explicit() async {
@@ -685,14 +950,32 @@
}
''');
- assertBinaryExpression(
- findNode.binary('E(a) + b'),
- element: elementMatcher(
- findElement.method('+', of: 'E'),
- isLegacy: false,
- ),
- type: 'String',
- );
+ assertResolvedNodeText(findNode.binary('E(a) + b'), r'''
+BinaryExpression
+ leftOperand: ExtensionOverride
+ extensionName: SimpleIdentifier
+ token: E
+ staticElement: self::@extension::E
+ staticType: null
+ argumentList: ArgumentList
+ leftParenthesis: (
+ arguments
+ SimpleIdentifier
+ token: a
+ staticElement: a@73
+ staticType: A
+ rightParenthesis: )
+ extendedType: A
+ staticType: null
+ operator: +
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@80
+ staticType: int
+ staticElement: self::@extension::E::@method::+
+ staticInvokeType: String Function(int)
+ staticType: String
+''');
}
test_plus_other_int_via_extension_implicit() async {
@@ -706,14 +989,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a + b'),
- element: elementMatcher(
- findElement.method('+', of: 'E'),
- isLegacy: false,
- ),
- type: 'String',
- );
+ assertResolvedNodeText(findNode.binary('a + b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@73
+ staticType: A
+ operator: +
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@80
+ staticType: int
+ staticElement: self::@extension::E::@method::+
+ staticInvokeType: String Function(int)
+ staticType: String
+''');
}
test_receiverTypeParameter_bound_dynamic() async {
@@ -723,11 +1013,20 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a + 0'),
- element: null,
- type: 'dynamic',
- );
+ assertResolvedNodeText(findNode.binary('a + 0'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@23
+ staticType: T
+ operator: +
+ rightOperand: IntegerLiteral
+ literal: 0
+ staticType: int
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: dynamic
+''');
}
test_receiverTypeParameter_bound_num() async {
@@ -737,14 +1036,20 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a + 0'),
- element: elementMatcher(
- numElement.getMethod('+'),
- isLegacy: isLegacyLibrary,
- ),
- type: 'num',
- );
+ assertResolvedNodeText(findNode.binary('a + 0'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@19
+ staticType: T
+ operator: +
+ rightOperand: IntegerLiteral
+ literal: 0
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: num Function(num)
+ staticType: num
+''');
}
test_slash() async {
@@ -754,14 +1059,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a / b'),
- element: elementMatcher(
- numElement.getMethod('/'),
- isLegacy: isLegacyLibrary,
- ),
- type: 'double',
- );
+ assertResolvedNodeText(findNode.binary('a / b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@6
+ staticType: int
+ operator: /
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@13
+ staticType: int
+ staticElement: dart:core::@class::num::@method::/
+ staticInvokeType: double Function(num)
+ staticType: double
+''');
}
test_star_int_context_int() async {
@@ -784,14 +1096,21 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a * b'),
- element: elementMatcher(
- numElement.getMethod('*'),
- isLegacy: isLegacyLibrary,
- ),
- type: 'double',
- );
+ assertResolvedNodeText(findNode.binary('a * b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@6
+ staticType: int
+ operator: *
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@16
+ staticType: double
+ staticElement: dart:core::@class::num::@method::*
+ staticInvokeType: num Function(num)
+ staticType: double
+''');
}
test_star_int_int() async {
@@ -801,13 +1120,20 @@
}
''');
- assertBinaryExpression(
- findNode.binary('a * b'),
- element: elementMatcher(
- numElement.getMethod('*'),
- isLegacy: isLegacyLibrary,
- ),
- type: 'int',
- );
+ assertResolvedNodeText(findNode.binary('a * b'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: a
+ staticElement: a@6
+ staticType: int
+ operator: *
+ rightOperand: SimpleIdentifier
+ token: b
+ staticElement: b@13
+ staticType: int
+ staticElement: dart:core::@class::num::@method::*
+ staticInvokeType: num Function(num)
+ staticType: int
+''');
}
}
diff --git a/pkg/analyzer/test/src/dart/resolution/resolution.dart b/pkg/analyzer/test/src/dart/resolution/resolution.dart
index cce0e84..99d38f1 100644
--- a/pkg/analyzer/test/src/dart/resolution/resolution.dart
+++ b/pkg/analyzer/test/src/dart/resolution/resolution.dart
@@ -114,15 +114,6 @@
_assertUnresolvedAssignmentTarget(node.leftHandSide);
}
- void assertBinaryExpression(
- BinaryExpression node, {
- required Object? element,
- required String type,
- }) {
- assertElement(node.staticElement, element);
- assertType(node, type);
- }
-
/// Assert that the given [identifier] is a reference to a class, in the
/// form that is not a separate expression, e.g. in a static method
/// invocation like `C.staticMethod()`, or a type annotation `C c = null`.
diff --git a/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_field_test.dart b/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_field_test.dart
index 21454e6..6e67586 100644
--- a/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_field_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_field_test.dart
@@ -15,27 +15,18 @@
@reflectiveTest
class OverrideOnNonOverridingFieldTest extends PubPackageResolutionTest {
- test_inInterface() async {
+ test_class() async {
await assertErrorsInCode(r'''
class A {
- int get a => 0;
- void set b(_) {}
- int c = 0;
+ @override
+ int? foo;
}
-class B implements A {
- @override
- final int a = 1;
- @override
- int b = 0;
- @override
- int c = 0;
-}''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 134, 1,
- contextMessages: [message('/home/test/lib/test.dart', 39, 1)]),
+''', [
+ error(HintCode.OVERRIDE_ON_NON_OVERRIDING_FIELD, 29, 3),
]);
}
- test_inSuperclass() async {
+ test_class_extends() async {
await assertErrorsInCode(r'''
class A {
int get a => 0;
@@ -55,15 +46,75 @@
]);
}
- test_invalid() async {
+ test_class_implements() async {
await assertErrorsInCode(r'''
class A {
+ int get a => 0;
+ void set b(_) {}
+ int c = 0;
}
-class B extends A {
+class B implements A {
@override
- final int m = 1;
+ final int a = 1;
+ @override
+ int b = 0;
+ @override
+ int c = 0;
}''', [
- error(HintCode.OVERRIDE_ON_NON_OVERRIDING_FIELD, 56, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 134, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 39, 1)]),
]);
}
+
+ test_enum() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ @override
+ int? foo;
+}
+''', [
+ error(HintCode.OVERRIDE_ON_NON_OVERRIDING_FIELD, 33, 3),
+ ]);
+ }
+
+ test_enum_implements() async {
+ await assertNoErrorsInCode(r'''
+class A {
+ int get a => 0;
+ void set b(int _) {}
+ int c = 0;
+}
+
+enum E implements A {
+ v;
+ @override
+ final int a = 1;
+
+ @override
+ int b = 0;
+
+ @override
+ int c = 0;
+}
+''');
+ }
+
+ test_enum_with() async {
+ await assertNoErrorsInCode(r'''
+mixin M {
+ int get a => 0;
+ void set b(int _) {}
+}
+
+enum E with M {
+ v;
+ @override
+ final int a = 1;
+
+ @override
+ int b = 0;
+}
+''');
+ }
}
diff --git a/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_getter_test.dart b/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_getter_test.dart
index 44ce6f8..edef46f 100644
--- a/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_getter_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_getter_test.dart
@@ -15,42 +15,84 @@
@reflectiveTest
class OverrideOnNonOverridingGetterTest extends PubPackageResolutionTest {
- test_inInterface() async {
- await assertNoErrorsInCode(r'''
-class A {
- int get m => 0;
-}
-class B implements A {
- @override
- int get m => 1;
-}''');
- }
-
- test_inSupertype() async {
- await assertNoErrorsInCode(r'''
-class A {
- int get m => 0;
-}
-class B extends A {
- @override
- int get m => 1;
-}''');
- }
-
- test_invalid_class() async {
+ test_class() async {
await assertErrorsInCode(r'''
-class A {}
-
-class B extends A {
+class A {
@override
- int get foo => 1;
+ int get foo => 0;
}
''', [
- error(HintCode.OVERRIDE_ON_NON_OVERRIDING_GETTER, 54, 3),
+ error(HintCode.OVERRIDE_ON_NON_OVERRIDING_GETTER, 32, 3),
]);
}
- test_invalid_extension() async {
+ test_class_extends() async {
+ await assertNoErrorsInCode(r'''
+class A {
+ int get foo => 0;
+}
+
+class B extends A {
+ @override
+ int get foo => 0;
+}
+''');
+ }
+
+ test_class_implements() async {
+ await assertNoErrorsInCode(r'''
+class A {
+ int get foo => 0;
+}
+
+class B implements A {
+ @override
+ int get foo => 0;
+}
+''');
+ }
+
+ test_enum() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ @override
+ int get foo => 0;
+}
+''', [
+ error(HintCode.OVERRIDE_ON_NON_OVERRIDING_GETTER, 36, 3),
+ ]);
+ }
+
+ test_enum_implements() async {
+ await assertNoErrorsInCode(r'''
+class A {
+ int get foo => 0;
+}
+
+enum E implements A {
+ v;
+ @override
+ int get foo => 0;
+}
+''');
+ }
+
+ test_enum_with() async {
+ await assertNoErrorsInCode(r'''
+mixin M {
+ int get foo => 0;
+}
+
+enum E with M {
+ v;
+ @override
+ int get foo => 0;
+}
+''');
+ }
+
+ test_extension() async {
await assertErrorsInCode(r'''
extension E on int {
@override
@@ -61,16 +103,14 @@
]);
}
- test_invalid_mixin() async {
+ test_mixin() async {
await assertErrorsInCode(r'''
-class A {}
-
-mixin M on A {
+mixin M {
@override
- int get foo => 1;
+ int get foo => 0;
}
''', [
- error(HintCode.OVERRIDE_ON_NON_OVERRIDING_GETTER, 49, 3),
+ error(HintCode.OVERRIDE_ON_NON_OVERRIDING_GETTER, 32, 3),
]);
}
}
diff --git a/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_method_test.dart b/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_method_test.dart
index 2d47c68..e70f549 100644
--- a/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_method_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_method_test.dart
@@ -15,18 +15,56 @@
@reflectiveTest
class OverrideOnNonOverridingMethodTest extends PubPackageResolutionTest {
- test_inInterface() async {
+ test_class() async {
+ await assertErrorsInCode(r'''
+class A {}
+
+class B extends A {
+ @override
+ void foo() {}
+}
+''', [
+ error(HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD, 51, 3),
+ ]);
+ }
+
+ test_class_extends() async {
await assertNoErrorsInCode(r'''
class A {
- int m() => 1;
+ void foo() {}
}
-class B implements A {
+
+class B extends A {
@override
- int m() => 1;
+ void foo() {}
}''');
}
- test_inInterfaces() async {
+ test_class_extends_abstract() async {
+ await assertNoErrorsInCode(r'''
+abstract class A {
+ void foo();
+}
+
+class B extends A {
+ @override
+ void foo() {}
+}''');
+ }
+
+ test_class_implements() async {
+ await assertNoErrorsInCode(r'''
+class A {
+ void foo() {}
+}
+
+class B implements A {
+ @override
+ void foo() {}
+}''');
+ }
+
+ test_class_implements2() async {
await assertNoErrorsInCode(r'''
abstract class I {
void foo(int _);
@@ -42,42 +80,19 @@
}''');
}
- test_inSuperclass() async {
- await assertNoErrorsInCode(r'''
-class A {
- int m() => 1;
-}
-class B extends A {
- @override
- int m() => 1;
-}''');
- }
-
- test_inSuperclass_abstract() async {
- await assertNoErrorsInCode(r'''
-abstract class A {
- int m();
-}
-class B extends A {
- @override
- int m() => 1;
-}''');
- }
-
- test_invalid_class() async {
+ test_enum() async {
await assertErrorsInCode(r'''
-class A {}
-
-class B extends A {
+enum E {
+ v;
@override
void foo() {}
}
''', [
- error(HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD, 51, 3),
+ error(HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD, 33, 3),
]);
}
- test_invalid_extension() async {
+ test_extension() async {
await assertErrorsInCode(r'''
extension E on int {
@override
@@ -88,7 +103,7 @@
]);
}
- test_invalid_mixin() async {
+ test_mixin() async {
await assertErrorsInCode(r'''
class A {}
@@ -100,4 +115,30 @@
error(HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD, 46, 3),
]);
}
+
+ test_mixin_implements() async {
+ await assertNoErrorsInCode(r'''
+class A {
+ void foo() {}
+}
+
+mixin M implements A {
+ @override
+ void foo() {}
+}
+''');
+ }
+
+ test_mixin_on() async {
+ await assertNoErrorsInCode(r'''
+class A {
+ void foo() {}
+}
+
+mixin M on A {
+ @override
+ void foo() {}
+}
+''');
+ }
}
diff --git a/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_setter_test.dart b/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_setter_test.dart
index ae370bf..b6c9e1f 100644
--- a/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_setter_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_setter_test.dart
@@ -15,29 +15,7 @@
@reflectiveTest
class OverrideOnNonOverridingSetterTest extends PubPackageResolutionTest {
- test_inInterface() async {
- await assertNoErrorsInCode(r'''
-class A {
- set m(int x) {}
-}
-class B implements A {
- @override
- set m(int x) {}
-}''');
- }
-
- test_inSupertype() async {
- await assertNoErrorsInCode(r'''
-class A {
- set m(int x) {}
-}
-class B extends A {
- @override
- set m(int x) {}
-}''');
- }
-
- test_invalid_class() async {
+ test_class() async {
await assertErrorsInCode(r'''
class A {}
@@ -50,7 +28,69 @@
]);
}
- test_invalid_extension() async {
+ test_class_extends() async {
+ await assertNoErrorsInCode(r'''
+class A {
+ set m(int x) {}
+}
+class B extends A {
+ @override
+ set m(int x) {}
+}''');
+ }
+
+ test_class_implements() async {
+ await assertNoErrorsInCode(r'''
+class A {
+ set m(int x) {}
+}
+class B implements A {
+ @override
+ set m(int x) {}
+}''');
+ }
+
+ test_enum() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ @override
+ set foo(int _) {}
+}
+''', [
+ error(HintCode.OVERRIDE_ON_NON_OVERRIDING_SETTER, 32, 3),
+ ]);
+ }
+
+ test_enum_implements() async {
+ await assertNoErrorsInCode(r'''
+class A {
+ set foo(int _) {}
+}
+
+enum E implements A {
+ v;
+ @override
+ set foo(int _) {}
+}
+''');
+ }
+
+ test_enum_with() async {
+ await assertNoErrorsInCode(r'''
+mixin M {
+ set foo(int _) {}
+}
+
+enum E with M {
+ v;
+ @override
+ set foo(int _) {}
+}
+''');
+ }
+
+ test_extension() async {
await assertErrorsInCode(r'''
extension E on int {
@override
@@ -61,7 +101,7 @@
]);
}
- test_invalid_mixin() async {
+ test_mixin() async {
await assertErrorsInCode(r'''
class A {}
diff --git a/pkg/analyzer/test/src/diagnostics/receiver_of_type_never_test.dart b/pkg/analyzer/test/src/diagnostics/receiver_of_type_never_test.dart
index a32dce8..5707c74 100644
--- a/pkg/analyzer/test/src/diagnostics/receiver_of_type_never_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/receiver_of_type_never_test.dart
@@ -26,13 +26,28 @@
error(HintCode.DEAD_CODE, 25, 6),
]);
- assertBinaryExpression(
- findNode.binary('x =='),
- element: null,
- type: 'Never',
- );
-
- assertType(findNode.binary('1 + 2'), 'int');
+ assertResolvedNodeText(findNode.binary('x =='), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: x
+ staticElement: x@13
+ staticType: Never
+ operator: ==
+ rightOperand: BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1
+ staticType: int
+ operator: +
+ rightOperand: IntegerLiteral
+ literal: 2
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: num Function(num)
+ staticType: int
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: Never
+''');
}
test_binaryExpression_never_plus() async {
@@ -45,13 +60,32 @@
error(HintCode.DEAD_CODE, 24, 8),
]);
- assertBinaryExpression(
- findNode.binary('x +'),
- element: null,
- type: 'Never',
- );
-
- assertType(findNode.binary('1 + 2'), 'int');
+ assertResolvedNodeText(findNode.binary('x +'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: x
+ staticElement: x@13
+ staticType: Never
+ operator: +
+ rightOperand: ParenthesizedExpression
+ leftParenthesis: (
+ expression: BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1
+ staticType: int
+ operator: +
+ rightOperand: IntegerLiteral
+ literal: 2
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: num Function(num)
+ staticType: int
+ rightParenthesis: )
+ staticType: int
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: Never
+''');
}
test_binaryExpression_neverQ_eqEq() async {
@@ -61,13 +95,28 @@
}
''');
- assertBinaryExpression(
- findNode.binary('x =='),
- element: objectElement.getMethod('=='),
- type: 'bool',
- );
-
- assertType(findNode.binary('1 + 2'), 'int');
+ assertResolvedNodeText(findNode.binary('x =='), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: x
+ staticElement: x@14
+ staticType: Never?
+ operator: ==
+ rightOperand: BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1
+ staticType: int
+ operator: +
+ rightOperand: IntegerLiteral
+ literal: 2
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: num Function(num)
+ staticType: int
+ staticElement: dart:core::@class::Object::@method::==
+ staticInvokeType: bool Function(Object)
+ staticType: bool
+''');
}
test_binaryExpression_neverQ_plus() async {
@@ -82,13 +131,32 @@
1),
]);
- assertBinaryExpression(
- findNode.binary('x +'),
- element: null,
- type: 'dynamic',
- );
-
- assertType(findNode.binary('1 + 2'), 'int');
+ assertResolvedNodeText(findNode.binary('x +'), r'''
+BinaryExpression
+ leftOperand: SimpleIdentifier
+ token: x
+ staticElement: x@14
+ staticType: Never?
+ operator: +
+ rightOperand: ParenthesizedExpression
+ leftParenthesis: (
+ expression: BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1
+ staticType: int
+ operator: +
+ rightOperand: IntegerLiteral
+ literal: 2
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: num Function(num)
+ staticType: int
+ rightParenthesis: )
+ staticType: int
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: dynamic
+''');
}
test_conditionalExpression_falseBranch() async {
@@ -615,16 +683,37 @@
}
''');
- assertBinaryExpression(
- findNode.binary('=='),
- element: elementMatcher(
- objectElement.getMethod('=='),
- isLegacy: isLegacyLibrary,
- ),
- type: 'bool',
- );
-
- assertType(findNode.binary('1 + 2'), 'int');
+ assertResolvedNodeText(findNode.binary('=='), r'''
+BinaryExpression
+ leftOperand: ParenthesizedExpression
+ leftParenthesis: (
+ expression: ThrowExpression
+ throwKeyword: throw
+ expression: SimpleStringLiteral
+ literal: ''
+ staticType: Never*
+ rightParenthesis: )
+ staticType: Never*
+ operator: ==
+ rightOperand: BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1
+ staticType: int*
+ operator: +
+ rightOperand: IntegerLiteral
+ literal: 2
+ staticType: int*
+ staticElement: MethodMember
+ base: dart:core::@class::num::@method::+
+ isLegacy: true
+ staticInvokeType: num* Function(num*)*
+ staticType: int*
+ staticElement: MethodMember
+ base: dart:core::@class::Object::@method::==
+ isLegacy: true
+ staticInvokeType: bool* Function(Object*)*
+ staticType: bool*
+''');
}
test_binaryExpression_plus() async {
@@ -634,11 +723,39 @@
}
''');
- assertBinaryExpression(
- findNode.binary('+ ('),
- element: null,
- type: 'dynamic',
- );
+ assertResolvedNodeText(findNode.binary('+ ('), r'''
+BinaryExpression
+ leftOperand: ParenthesizedExpression
+ leftParenthesis: (
+ expression: ThrowExpression
+ throwKeyword: throw
+ expression: SimpleStringLiteral
+ literal: ''
+ staticType: Never*
+ rightParenthesis: )
+ staticType: Never*
+ operator: +
+ rightOperand: ParenthesizedExpression
+ leftParenthesis: (
+ expression: BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1
+ staticType: int*
+ operator: +
+ rightOperand: IntegerLiteral
+ literal: 2
+ staticType: int*
+ staticElement: MethodMember
+ base: dart:core::@class::num::@method::+
+ isLegacy: true
+ staticInvokeType: num* Function(num*)*
+ staticType: int*
+ rightParenthesis: )
+ staticType: int*
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: dynamic
+''');
assertType(findNode.binary('1 + 2'), 'int');
}
diff --git a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
index 107d0d6..317d7c5 100644
--- a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
+++ b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
@@ -1361,9 +1361,16 @@
_sink.writeln(_nameOfMemberClass(element));
_withIndent(() {
_writeElement('base', element.declaration);
+
+ if (element.isLegacy) {
+ _writelnWithIndent('isLegacy: true');
+ }
+
var map = element.substitution.map;
- var mapStr = _substitutionMapStr(map);
- _writelnWithIndent('substitution: $mapStr');
+ if (map.isNotEmpty) {
+ var mapStr = _substitutionMapStr(map);
+ _writelnWithIndent('substitution: $mapStr');
+ }
});
} else if (element is MultiplyDefinedElement) {
_sink.writeln('<null>');
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index 4192d31..87c34e9 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -16268,11 +16268,11 @@
token: compare @43
staticElement: MethodMember
base: dart:core::@class::Comparable::@method::compare
- substitution: {}
+ isLegacy: true
staticType: int* Function(Comparable<dynamic>*, Comparable<dynamic>*)*
staticElement: MethodMember
base: dart:core::@class::Comparable::@method::compare
- substitution: {}
+ isLegacy: true
staticType: int* Function(Comparable<dynamic>*, Comparable<dynamic>*)*
returnType: void
''');
diff --git a/pkg/analyzer_plugin/test/integration/support/integration_tests.dart b/pkg/analyzer_plugin/test/integration/support/integration_tests.dart
index 52dbfbd..8fd6bff 100644
--- a/pkg/analyzer_plugin/test/integration/support/integration_tests.dart
+++ b/pkg/analyzer_plugin/test/integration/support/integration_tests.dart
@@ -443,7 +443,7 @@
.listen((String line) {
lastCommunicationTime = currentElapseTime;
var trimmedLine = line.trim();
- if (trimmedLine.startsWith('The Dart VM service is listening on ')) {
+ if (trimmedLine.startsWith('Observatory listening on ')) {
return;
}
_recordStdio('RECV: $trimmedLine');
diff --git a/pkg/dartdev/lib/src/analysis_server.dart b/pkg/dartdev/lib/src/analysis_server.dart
index af19b56..c02c75c 100644
--- a/pkg/dartdev/lib/src/analysis_server.dart
+++ b/pkg/dartdev/lib/src/analysis_server.dart
@@ -82,7 +82,7 @@
final Map<String, Completer<Map<String, dynamic>>> _requestCompleters = {};
- Future<void> start() async {
+ Future<void> start({bool setAnalysisRoots = true}) async {
preAnalysisServerStart?.call(commandName, analysisRoots, argResults);
final List<String> command = <String>[
sdk.analysisServerSnapshot,
@@ -138,10 +138,12 @@
}
});
- await _sendCommand('analysis.setAnalysisRoots', params: <String, dynamic>{
- 'included': analysisRootPaths,
- 'excluded': <String>[]
- });
+ if (setAnalysisRoots) {
+ await _sendCommand('analysis.setAnalysisRoots', params: <String, dynamic>{
+ 'included': analysisRootPaths,
+ 'excluded': <String>[]
+ });
+ }
}
Future<String> getVersion() {
diff --git a/pkg/dartdev/lib/src/commands/doc.dart b/pkg/dartdev/lib/src/commands/doc.dart
index fb9d38a..9a9c4a2 100644
--- a/pkg/dartdev/lib/src/commands/doc.dart
+++ b/pkg/dartdev/lib/src/commands/doc.dart
@@ -90,7 +90,7 @@
if (verbose) ...['--verbose-warnings', '--show-stats'],
]);
- final config = parseOptions(pubPackageMetaProvider, options);
+ final config = await parseOptions(pubPackageMetaProvider, options);
if (config == null) {
// There was an error while parsing options.
return 2;
@@ -105,7 +105,7 @@
config, pubPackageMetaProvider, packageConfigProvider);
final dartdoc = config.generateDocs
? await Dartdoc.fromContext(config, packageBuilder)
- : Dartdoc.withEmptyGenerator(config, packageBuilder);
+ : await Dartdoc.withEmptyGenerator(config, packageBuilder);
dartdoc.executeGuarded();
return 0;
}
diff --git a/pkg/dartdev/lib/src/commands/fix.dart b/pkg/dartdev/lib/src/commands/fix.dart
index 8fd6db9..aea2ecb 100644
--- a/pkg/dartdev/lib/src/commands/fix.dart
+++ b/pkg/dartdev/lib/src/commands/fix.dart
@@ -102,7 +102,7 @@
argResults: argResults,
);
- await server.start();
+ await server.start(setAnalysisRoots: false);
server.onExit.then((int exitCode) {
if (computeFixesProgress != null && exitCode != 0) {
diff --git a/pkg/dartdev/test/commands/run_test.dart b/pkg/dartdev/test/commands/run_test.dart
index 23e575f..40978d9 100644
--- a/pkg/dartdev/test/commands/run_test.dart
+++ b/pkg/dartdev/test/commands/run_test.dart
@@ -14,8 +14,7 @@
const String soundNullSafetyMessage = 'Info: Compiling with sound null safety';
const devToolsMessagePrefix =
'The Dart DevTools debugger and profiler is available at: http://127.0.0.1:';
-const dartVMServiceMessagePrefix =
- 'The Dart VM service is listening on http://127.0.0.1:';
+const observatoryMessagePrefix = 'Observatory listening on http://127.0.0.1:';
void main() {
group('run', run, timeout: longTimeout);
@@ -215,7 +214,7 @@
expect(
result.stdout,
matches(
- r'The Dart VM service is listening on http:\/\/127.0.0.1:8181\/[a-zA-Z0-9_-]+=\/\n.*'),
+ r'Observatory listening on http:\/\/127.0.0.1:8181\/[a-zA-Z0-9_-]+=\/\n.*'),
);
expect(result.stderr, isEmpty);
expect(result.exitCode, 0);
@@ -237,7 +236,7 @@
expect(
result.stdout,
- contains('The Dart VM service is listening on http://127.0.0.1:8181/\n'),
+ contains('Observatory listening on http://127.0.0.1:8181/\n'),
);
expect(result.stderr, isEmpty);
expect(result.exitCode, 0);
@@ -259,7 +258,7 @@
expect(
result.stdout,
matches(
- r'The Dart VM service is listening on http:\/\/\[::1\]:8181\/[a-zA-Z0-9_-]+=\/\n.*'),
+ r'Observatory listening on http:\/\/\[::1\]:8181\/[a-zA-Z0-9_-]+=\/\n.*'),
);
expect(result.stderr, isEmpty);
expect(result.exitCode, 0);
@@ -362,7 +361,7 @@
p.relativeFilePath,
]);
expect(result.stdout, isNot(contains(devToolsMessagePrefix)));
- expect(result.stdout, contains(dartVMServiceMessagePrefix));
+ expect(result.stdout, contains(observatoryMessagePrefix));
});
test('dart simple', () async {
@@ -373,7 +372,7 @@
p.relativeFilePath,
]);
expect(result.stdout, isNot(contains(devToolsMessagePrefix)));
- expect(result.stdout, contains(dartVMServiceMessagePrefix));
+ expect(result.stdout, contains(observatoryMessagePrefix));
});
});
@@ -387,7 +386,7 @@
p.relativeFilePath,
]);
expect(result.stdout, contains(devToolsMessagePrefix));
- expect(result.stdout, contains(dartVMServiceMessagePrefix));
+ expect(result.stdout, contains(observatoryMessagePrefix));
});
test('dart simple', () async {
@@ -398,7 +397,7 @@
p.relativeFilePath,
]);
expect(result.stdout, contains(devToolsMessagePrefix));
- expect(result.stdout, contains(dartVMServiceMessagePrefix));
+ expect(result.stdout, contains(observatoryMessagePrefix));
});
});
});
diff --git a/pkg/dds/test/dap/integration/debug_attach_test.dart b/pkg/dds/test/dap/integration/debug_attach_test.dart
index 846b3db..810a15f 100644
--- a/pkg/dds/test/dap/integration/debug_attach_test.dart
+++ b/pkg/dds/test/dap/integration/debug_attach_test.dart
@@ -50,7 +50,7 @@
// The stdout also contains the Observatory+DevTools banners.
.where(
(line) =>
- !line.startsWith('The Dart VM service is listening on') &&
+ !line.startsWith('Observatory listening on') &&
!line.startsWith(
'The Dart DevTools debugger and profiler is available at'),
)
@@ -103,7 +103,7 @@
// The stdout also contains the Observatory+DevTools banners.
.where(
(line) =>
- !line.startsWith('The Dart VM service is listening on') &&
+ !line.startsWith('Observatory listening on') &&
!line.startsWith(
'The Dart DevTools debugger and profiler is available at'),
)
diff --git a/pkg/dds/test/dap/integration/test_support.dart b/pkg/dds/test/dap/integration/test_support.dart
index 1c0dc21..7a55bb2 100644
--- a/pkg/dds/test/dap/integration/test_support.dart
+++ b/pkg/dds/test/dap/integration/test_support.dart
@@ -44,10 +44,9 @@
/// an authentication token.
final vmServiceAuthCodePathPattern = RegExp(r'^/[\w_\-=]{5,15}/ws$');
-/// A [RegExp] that matches the "The Dart VM service is listening on" banner that is sent
+/// A [RegExp] that matches the "Observatory listening on" banner that is sent
/// by the VM when not using --write-service-info.
-final vmServiceBannerPattern =
- RegExp(r'The Dart VM service is listening on ([^\s]+)\s');
+final vmServiceBannerPattern = RegExp(r'Observatory listening on ([^\s]+)\s');
/// The root of the SDK containing the current running VM.
final sdkRoot = path.dirname(path.dirname(Platform.resolvedExecutable));
diff --git a/pkg/front_end/lib/src/fasta/kernel/benchmarker.dart b/pkg/front_end/lib/src/fasta/kernel/benchmarker.dart
index 7b52198..404b3ad 100644
--- a/pkg/front_end/lib/src/fasta/kernel/benchmarker.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/benchmarker.dart
@@ -122,6 +122,7 @@
outline_computeVariances,
outline_computeDefaultTypes,
outline_applyTypeMacros,
+ outline_buildMacroTypesForPhase1,
outline_checkSemantics,
outline_finishTypeVariables,
outline_createTypeInferenceEngine,
@@ -134,6 +135,8 @@
outline_buildClassHierarchy,
outline_checkSupertypes,
outline_applyDeclarationMacros,
+ outline_buildMacroDeclarationsForPhase1,
+ outline_buildMacroDeclarationsForPhase2,
outline_buildClassHierarchyMembers,
outline_computeHierarchy,
outline_computeShowHideElements,
@@ -156,6 +159,9 @@
body_finishNoSuchMethodForwarders,
body_collectSourceClasses,
body_applyDefinitionMacros,
+ body_buildMacroDefinitionsForPhase1,
+ body_buildMacroDefinitionsForPhase2,
+ body_buildMacroDefinitionsForPhase3,
body_finishNativeMethods,
body_finishPatchMethods,
body_finishAllConstructors,
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
index d3aa340..e5aa742 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
@@ -497,6 +497,8 @@
benchmarker?.enterPhase(BenchmarkPhases.outline_applyTypeMacros);
List<SourceLibraryBuilder> augmentationLibraries =
await macroApplications.applyTypeMacros();
+ benchmarker
+ ?.enterPhase(BenchmarkPhases.outline_buildMacroTypesForPhase1);
await _buildForPhase1(augmentationLibraries);
}
@@ -545,7 +547,11 @@
List<SourceLibraryBuilder> augmentationLibraries = [
augmentationLibrary
];
+ benchmarker?.enterPhase(
+ BenchmarkPhases.outline_buildMacroDeclarationsForPhase1);
await _buildForPhase1(augmentationLibraries);
+ benchmarker?.enterPhase(
+ BenchmarkPhases.outline_buildMacroDeclarationsForPhase2);
_buildForPhase2(augmentationLibraries);
});
}
@@ -636,8 +642,14 @@
benchmarker?.enterPhase(BenchmarkPhases.body_applyDefinitionMacros);
List<SourceLibraryBuilder> augmentationLibraries =
await macroApplications.applyDefinitionMacros();
+ benchmarker
+ ?.enterPhase(BenchmarkPhases.body_buildMacroDefinitionsForPhase1);
await _buildForPhase1(augmentationLibraries);
+ benchmarker
+ ?.enterPhase(BenchmarkPhases.body_buildMacroDefinitionsForPhase2);
_buildForPhase2(augmentationLibraries);
+ benchmarker
+ ?.enterPhase(BenchmarkPhases.body_buildMacroDefinitionsForPhase3);
_buildForPhase3(augmentationLibraries);
}
diff --git a/pkg/front_end/lib/src/fasta/kernel/macro.dart b/pkg/front_end/lib/src/fasta/kernel/macro.dart
index 048df44..64974dc 100644
--- a/pkg/front_end/lib/src/fasta/kernel/macro.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/macro.dart
@@ -1033,5 +1033,6 @@
}
extension on macro.MacroExecutionResult {
- bool get isNotEmpty => augmentations.isNotEmpty;
+ bool get isNotEmpty =>
+ libraryAugmentations.isNotEmpty || classAugmentations.isNotEmpty;
}
diff --git a/pkg/front_end/test/hot_reload_e2e_test.dart b/pkg/front_end/test/hot_reload_e2e_test.dart
index aa8e855..07cf63b 100644
--- a/pkg/front_end/test/hot_reload_e2e_test.dart
+++ b/pkg/front_end/test/hot_reload_e2e_test.dart
@@ -86,8 +86,8 @@
Future<int> computeVmPort() async {
var portLine = await lines[0];
- Expect.isTrue(dartVMServicePortRegExp.hasMatch(portLine));
- var match = dartVMServicePortRegExp.firstMatch(portLine);
+ Expect.isTrue(observatoryPortRegExp.hasMatch(portLine));
+ var match = observatoryPortRegExp.firstMatch(portLine);
return int.parse(match!.group(1)!);
}
@@ -384,5 +384,5 @@
void g() {}
''';
-RegExp dartVMServicePortRegExp = new RegExp(
- "The Dart VM service is listening on http://127.0.0.1:\([0-9]*\)/");
+RegExp observatoryPortRegExp =
+ new RegExp("Observatory listening on http://127.0.0.1:\([0-9]*\)/");
diff --git a/pkg/front_end/test/macro_application/data/tests/sequence.dart b/pkg/front_end/test/macro_application/data/tests/sequence.dart
index 7d43bf3..b27f58f 100644
--- a/pkg/front_end/test/macro_application/data/tests/sequence.dart
+++ b/pkg/front_end/test/macro_application/data/tests/sequence.dart
@@ -16,8 +16,6 @@
/*class: Class2:
augment class Class2 {
method() {}
-}
-augment class Class2 {
method1() {}
}*/
class Class2 {}
@@ -37,11 +35,7 @@
/*class: Class4:
augment class Class4 {
method1() {}
-}
-augment class Class4 {
method3() {}
-}
-augment class Class4 {
method4() {}
}*/
class Class4 {
diff --git a/pkg/front_end/test/macro_application/macro_application_test.dart b/pkg/front_end/test/macro_application/macro_application_test.dart
index c563333..4974822 100644
--- a/pkg/front_end/test/macro_application/macro_application_test.dart
+++ b/pkg/front_end/test/macro_application/macro_application_test.dart
@@ -191,13 +191,16 @@
.dataForTesting!
.macroApplicationData;
StringBuffer sb = new StringBuffer();
+ List<DeclarationCode> mergedClassAugmentations = [];
for (MapEntry<SourceClassBuilder, List<MacroExecutionResult>> entry
in macroApplicationData.classTypesResults.entries) {
if (entry.key.cls == cls) {
for (MacroExecutionResult result in entry.value) {
- if (result.augmentations.isNotEmpty) {
- sb.write('\n${codeToString(result.augmentations.first)}');
+ if (result.libraryAugmentations.isNotEmpty) {
+ sb.write('\n${codeToString(result.libraryAugmentations.single)}');
}
+ mergedClassAugmentations
+ .addAll(result.classAugmentations[entry.key.name] ?? const []);
}
}
}
@@ -205,9 +208,11 @@
in macroApplicationData.classDeclarationsResults.entries) {
if (entry.key.cls == cls) {
for (MacroExecutionResult result in entry.value) {
- if (result.augmentations.isNotEmpty) {
- sb.write('\n${codeToString(result.augmentations.first)}');
+ if (result.libraryAugmentations.isNotEmpty) {
+ sb.write('\n${codeToString(result.libraryAugmentations.single)}');
}
+ mergedClassAugmentations
+ .addAll(result.classAugmentations[entry.key.name] ?? const []);
}
}
}
@@ -215,12 +220,21 @@
in macroApplicationData.classDefinitionsResults.entries) {
if (entry.key.cls == cls) {
for (MacroExecutionResult result in entry.value) {
- if (result.augmentations.isNotEmpty) {
- sb.write('\n${codeToString(result.augmentations.first)}');
+ if (result.libraryAugmentations.isNotEmpty) {
+ sb.write('\n${codeToString(result.libraryAugmentations.single)}');
}
+ mergedClassAugmentations
+ .addAll(result.classAugmentations[entry.key.name] ?? const []);
}
}
}
+ if (mergedClassAugmentations.isNotEmpty) {
+ sb.write('\naugment class ${cls.name} {');
+ for (var result in mergedClassAugmentations) {
+ sb.write('\n${codeToString(result)}');
+ }
+ sb.write('\n}');
+ }
if (sb.isNotEmpty) {
Id id = new ClassId(cls.name);
registry.registerValue(
@@ -240,12 +254,20 @@
.loader
.dataForTesting!
.macroApplicationData;
- StringBuffer sb = new StringBuffer();
+ StringBuffer sb = StringBuffer();
+ List<DeclarationCode> mergedAugmentations = [];
for (MapEntry<MemberBuilder, List<MacroExecutionResult>> entry
in macroApplicationData.memberTypesResults.entries) {
if (_isMember(entry.key, member)) {
for (MacroExecutionResult result in entry.value) {
- sb.write('\n${codeToString(result.augmentations.first)}');
+ if (result.libraryAugmentations.isNotEmpty) {
+ sb.write('\n${codeToString(result.libraryAugmentations.single)}');
+ }
+ if (member.enclosingClass != null) {
+ mergedAugmentations.addAll(
+ result.classAugmentations[member.enclosingClass!.name] ??
+ const []);
+ }
}
}
}
@@ -253,7 +275,14 @@
in macroApplicationData.memberDeclarationsResults.entries) {
if (_isMember(entry.key, member)) {
for (MacroExecutionResult result in entry.value) {
- sb.write('\n${codeToString(result.augmentations.first)}');
+ if (result.libraryAugmentations.isNotEmpty) {
+ sb.write('\n${codeToString(result.libraryAugmentations.single)}');
+ }
+ if (member.enclosingClass != null) {
+ mergedAugmentations.addAll(
+ result.classAugmentations[member.enclosingClass!.name] ??
+ const []);
+ }
}
}
}
@@ -261,10 +290,28 @@
in macroApplicationData.memberDefinitionsResults.entries) {
if (_isMember(entry.key, member)) {
for (MacroExecutionResult result in entry.value) {
- sb.write('\n${codeToString(result.augmentations.first)}');
+ if (result.libraryAugmentations.isNotEmpty) {
+ sb.write('\n${codeToString(result.libraryAugmentations.single)}');
+ }
+ if (member.enclosingClass != null) {
+ mergedAugmentations.addAll(
+ result.classAugmentations[member.enclosingClass!.name] ??
+ const []);
+ }
}
}
}
+ if (mergedAugmentations.isNotEmpty) {
+ if (member.enclosingClass != null) {
+ sb.write('\naugment class ${member.enclosingClass!.name} {');
+ }
+ for (DeclarationCode augmentation in mergedAugmentations) {
+ sb.write('\n${codeToString(augmentation)}');
+ }
+ if (member.enclosingClass != null) {
+ sb.write('\n}');
+ }
+ }
if (sb.isNotEmpty) {
Id id = computeMemberId(member);
MemberBuilder memberBuilder =
diff --git a/pkg/front_end/test/macros/macro_test.dart b/pkg/front_end/test/macros/macro_test.dart
index a20eaf2..7ee8ddf 100644
--- a/pkg/front_end/test/macros/macro_test.dart
+++ b/pkg/front_end/test/macros/macro_test.dart
@@ -396,7 +396,10 @@
class _MacroExecutionResult implements MacroExecutionResult {
@override
- Iterable<DeclarationCode> augmentations = const [];
+ Map<String, Iterable<DeclarationCode>> classAugmentations = const {};
+
+ @override
+ Iterable<DeclarationCode> libraryAugmentations = const [];
@override
Iterable<String> newTypeNames = const [];
diff --git a/pkg/front_end/test/vm_service_helper.dart b/pkg/front_end/test/vm_service_helper.dart
index ac33557..f2d3cb6 100644
--- a/pkg/front_end/test/vm_service_helper.dart
+++ b/pkg/front_end/test/vm_service_helper.dart
@@ -166,10 +166,10 @@
.transform(utf8.decoder)
.transform(new LineSplitter())
.listen((line) {
- const kDartVMServiceListening = 'The Dart VM service is listening on ';
- if (line.startsWith(kDartVMServiceListening)) {
+ const kObservatoryListening = 'Observatory listening on ';
+ if (line.startsWith(kObservatoryListening)) {
Uri observatoryUri =
- Uri.parse(line.substring(kDartVMServiceListening.length));
+ Uri.parse(line.substring(kObservatoryListening.length));
_setupAndRun(observatoryUri).catchError((e, st) {
// Manually kill the process or it will leak,
// see http://dartbug.com/42918
diff --git a/pkg/front_end/test/weekly_tester.dart b/pkg/front_end/test/weekly_tester.dart
index 5f52e98..077210e 100644
--- a/pkg/front_end/test/weekly_tester.dart
+++ b/pkg/front_end/test/weekly_tester.dart
@@ -169,7 +169,7 @@
.transform(new LineSplitter())
.listen((line) {
print("$id stderr> $line");
- if (line.contains("The Dart VM service is listening on")) {
+ if (line.contains("Observatory listening on")) {
observatoryLines.add(line);
}
});
@@ -178,7 +178,7 @@
.transform(new LineSplitter())
.listen((line) {
print("$id stdout> $line");
- if (line.contains("The Dart VM service is listening on")) {
+ if (line.contains("Observatory listening on")) {
observatoryLines.add(line);
}
});
diff --git a/pkg/vm/test/incremental_compiler_test.dart b/pkg/vm/test/incremental_compiler_test.dart
index 6e0473c..ef627ac 100644
--- a/pkg/vm/test/incremental_compiler_test.dart
+++ b/pkg/vm/test/incremental_compiler_test.dart
@@ -499,9 +499,9 @@
list.path
]);
- const kDartVMServiceListening = 'The Dart VM service is listening on ';
- final RegExp dartVMServicePortRegExp = new RegExp(
- "The Dart VM service is listening on http://127.0.0.1:\([0-9]*\)");
+ const kObservatoryListening = 'Observatory listening on ';
+ final RegExp observatoryPortRegExp =
+ new RegExp("Observatory listening on http://127.0.0.1:\([0-9]*\)");
int port;
final splitter = new LineSplitter();
Completer<String> portLineCompleter = new Completer<String>();
@@ -509,9 +509,9 @@
.transform(utf8.decoder)
.transform(splitter)
.listen((String s) async {
- if (s.startsWith(kDartVMServiceListening)) {
- expect(dartVMServicePortRegExp.hasMatch(s), isTrue);
- final match = dartVMServicePortRegExp.firstMatch(s)!;
+ if (s.startsWith(kObservatoryListening)) {
+ expect(observatoryPortRegExp.hasMatch(s), isTrue);
+ final match = observatoryPortRegExp.firstMatch(s)!;
port = int.parse(match.group(1)!);
await collectAndCheckCoverageData(port, true);
if (!portLineCompleter.isCompleted) {
@@ -603,9 +603,9 @@
list.path
]);
- const kDartVMServiceListening = 'The Dart VM service is listening on ';
- final RegExp dartVMServicePortRegExp = new RegExp(
- "The Dart VM service is listening on http://127.0.0.1:\([0-9]*\)");
+ const kObservatoryListening = 'Observatory listening on ';
+ final RegExp observatoryPortRegExp =
+ new RegExp("Observatory listening on http://127.0.0.1:\([0-9]*\)");
int port;
final splitter = new LineSplitter();
Completer<String> portLineCompleter = new Completer<String>();
@@ -618,9 +618,9 @@
if (s == expectStdoutContains) {
foundExpectedString = true;
}
- if (s.startsWith(kDartVMServiceListening)) {
- expect(dartVMServicePortRegExp.hasMatch(s), isTrue);
- final match = dartVMServicePortRegExp.firstMatch(s)!;
+ if (s.startsWith(kObservatoryListening)) {
+ expect(observatoryPortRegExp.hasMatch(s), isTrue);
+ final match = observatoryPortRegExp.firstMatch(s)!;
port = int.parse(match.group(1)!);
await collectAndCheckCoverageData(port, true,
onGetAllVerifyCount: false, coverageForLines: coverageLines);
@@ -869,9 +869,9 @@
list.path
]);
- const kDartVMServiceListening = 'The Dart VM service is listening on ';
- final RegExp dartVMServicePortRegExp = new RegExp(
- "The Dart VM service is listening on http://127.0.0.1:\([0-9]*\)");
+ const kObservatoryListening = 'Observatory listening on ';
+ final RegExp observatoryPortRegExp =
+ new RegExp("Observatory listening on http://127.0.0.1:\([0-9]*\)");
int port;
final splitter = new LineSplitter();
Completer<String> portLineCompleter = new Completer<String>();
@@ -879,9 +879,9 @@
.transform(utf8.decoder)
.transform(splitter)
.listen((String s) async {
- if (s.startsWith(kDartVMServiceListening)) {
- expect(dartVMServicePortRegExp.hasMatch(s), isTrue);
- final match = dartVMServicePortRegExp.firstMatch(s)!;
+ if (s.startsWith(kObservatoryListening)) {
+ expect(observatoryPortRegExp.hasMatch(s), isTrue);
+ final match = observatoryPortRegExp.firstMatch(s)!;
port = int.parse(match.group(1)!);
Set<int> hits1 =
await collectAndCheckCoverageData(port, true, resume: false);
@@ -972,10 +972,10 @@
String portLine = await portLineCompleter.future;
- final RegExp dartVMServicePortRegExp = new RegExp(
- "The Dart VM service is listening on http://127.0.0.1:\([0-9]*\)");
- expect(dartVMServicePortRegExp.hasMatch(portLine), isTrue);
- final match = dartVMServicePortRegExp.firstMatch(portLine)!;
+ final RegExp observatoryPortRegExp =
+ new RegExp("Observatory listening on http://127.0.0.1:\([0-9]*\)");
+ expect(observatoryPortRegExp.hasMatch(portLine), isTrue);
+ final match = observatoryPortRegExp.firstMatch(portLine)!;
final port = int.parse(match.group(1)!);
var remoteVm = new RemoteVm(port);
@@ -1256,9 +1256,9 @@
scriptOrDill.path
]);
- const kDartVMServiceListening = 'The Dart VM service is listening on ';
- final RegExp dartVMServicePortRegExp = new RegExp(
- "The Dart VM service is listening on http://127.0.0.1:\([0-9]*\)");
+ const kObservatoryListening = 'Observatory listening on ';
+ final RegExp observatoryPortRegExp =
+ new RegExp("Observatory listening on http://127.0.0.1:\([0-9]*\)");
int port;
final splitter = new LineSplitter();
Completer<String> portLineCompleter = new Completer<String>();
@@ -1267,9 +1267,9 @@
.transform(splitter)
.listen((String s) async {
print("vm stdout: $s");
- if (s.startsWith(kDartVMServiceListening)) {
- expect(dartVMServicePortRegExp.hasMatch(s), isTrue);
- final match = dartVMServicePortRegExp.firstMatch(s)!;
+ if (s.startsWith(kObservatoryListening)) {
+ expect(observatoryPortRegExp.hasMatch(s), isTrue);
+ final match = observatoryPortRegExp.firstMatch(s)!;
port = int.parse(match.group(1)!);
RemoteVm remoteVm = new RemoteVm(port);
diff --git a/pkg/vm_service/test/common/test_helper.dart b/pkg/vm_service/test/common/test_helper.dart
index 7561ce0..8415c74 100644
--- a/pkg/vm_service/test/common/test_helper.dart
+++ b/pkg/vm_service/test/common/test_helper.dart
@@ -205,9 +205,9 @@
.transform(utf8.decoder)
.transform(LineSplitter())
.listen((line) {
- const kDartVMServiceListening = 'The Dart VM service is listening on ';
- if (line.startsWith(kDartVMServiceListening)) {
- uri = Uri.parse(line.substring(kDartVMServiceListening.length));
+ const kObservatoryListening = 'Observatory listening on ';
+ if (line.startsWith(kObservatoryListening)) {
+ uri = Uri.parse(line.substring(kObservatoryListening.length));
}
if (pause_on_start || line == '') {
// Received blank line.
diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn
index 12d3dfb..a4c477a 100644
--- a/runtime/BUILD.gn
+++ b/runtime/BUILD.gn
@@ -242,7 +242,6 @@
source_set("dart_api") {
public_configs = [ ":dart_public_config" ]
sources = [
- "include/analyze_snapshot_api.h",
"include/dart_api.h",
"include/dart_api_dl.c",
"include/dart_api_dl.h",
@@ -290,11 +289,9 @@
public_configs = [ ":dart_public_config" ]
sources = [
"$target_gen_dir/version.cc",
- "include/analyze_snapshot_api.h",
"include/dart_api.h",
"include/dart_native_api.h",
"include/dart_tools_api.h",
- "vm/analyze_snapshot_api_impl.cc",
"vm/dart_api_impl.cc",
"vm/native_api_impl.cc",
"vm/version.h",
diff --git a/runtime/bin/BUILD.gn b/runtime/bin/BUILD.gn
index 04e73a2..ea7d40d 100644
--- a/runtime/bin/BUILD.gn
+++ b/runtime/bin/BUILD.gn
@@ -880,45 +880,6 @@
extra_deps += [ ":elf_loader_product" ]
}
-dart_executable("analyze_snapshot") {
- extra_configs = [ "..:dart_precompiled_runtime_config" ]
- extra_deps = [
- "..:libdart_precompiled_runtime",
- "../platform:libdart_platform_precompiled_runtime",
- ]
-
- extra_sources = [
- "analyze_snapshot.cc",
- "builtin.cc",
- "loader.cc",
- "loader.h",
- ]
-
- if (dart_runtime_mode == "release") {
- extra_deps += [ ":elf_loader_product" ]
- } else {
- extra_deps += [ ":elf_loader" ]
- }
-}
-
-dart_executable("analyze_snapshot_product") {
- use_product_mode = true
- extra_configs = [ "..:dart_precompiled_runtime_config" ]
- extra_deps = [
- "..:libdart_precompiled_runtime_product",
- "../platform:libdart_platform_precompiled_runtime_product",
- ]
-
- extra_sources = [
- "analyze_snapshot.cc",
- "builtin.cc",
- "loader.cc",
- "loader.h",
- ]
-
- extra_deps += [ ":elf_loader_product" ]
-}
-
executable("process_test") {
sources = [ "process_test.cc" ]
}
diff --git a/runtime/bin/analyze_snapshot.cc b/runtime/bin/analyze_snapshot.cc
deleted file mode 100644
index 85d4429..0000000
--- a/runtime/bin/analyze_snapshot.cc
+++ /dev/null
@@ -1,258 +0,0 @@
-// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-#include "bin/elf_loader.h"
-#include "bin/error_exit.h"
-#include "bin/file.h"
-
-#include "bin/options.h"
-#include "bin/platform.h"
-
-#if !defined(DART_HOST_OS_FUCHSIA)
-#include "include/analyze_snapshot_api.h"
-#endif
-
-namespace dart {
-namespace bin {
-#if !defined(DART_HOST_OS_FUCHSIA)
-
-#define STRING_OPTIONS_LIST(V) V(out, out_path)
-
-#define BOOL_OPTIONS_LIST(V) \
- V(help, help) \
- V(version, version)
-
-#define STRING_OPTION_DEFINITION(flag, variable) \
- static const char* variable = nullptr; \
- DEFINE_STRING_OPTION(flag, variable)
-STRING_OPTIONS_LIST(STRING_OPTION_DEFINITION)
-#undef STRING_OPTION_DEFINITION
-
-#define BOOL_OPTION_DEFINITION(flag, variable) \
- static bool variable = false; \
- DEFINE_BOOL_OPTION(flag, variable)
-BOOL_OPTIONS_LIST(BOOL_OPTION_DEFINITION)
-#undef BOOL_OPTION_DEFINITION
-
-// clang-format off
-static void PrintUsage() {
- Syslog::PrintErr(
-"Usage: analyze_snapshot [<vm-flags>] [<options>] <snapshot_data> \n"
-" \n"
-"Common options: \n"
-"--help \n"
-" Display this message. \n"
-"--version \n"
-" Print the SDK version. \n"
-"--out \n"
-" Path to generate the analysis results JSON. \n"
-" \n"
-"If omitting [<vm-flags>] the VM parsing the snapshot is created with the \n"
-"following default flags: \n"
-"--enable_mirrors=false \n"
-"--background_compilation \n"
-"--lazy_async_stacks \n"
-"--precompilation \n"
-" \n"
-"\n");
-}
-// clang-format on
-
-const uint8_t* vm_snapshot_data = nullptr;
-const uint8_t* vm_snapshot_instructions = nullptr;
-const uint8_t* vm_isolate_data = nullptr;
-const uint8_t* vm_isolate_instructions = nullptr;
-
-// Parse out the command line arguments. Returns -1 if the arguments
-// are incorrect, 0 otherwise.
-static int ParseArguments(int argc,
- char** argv,
- CommandLineOptions* vm_options,
- CommandLineOptions* inputs) {
- // Skip the binary name.
- int i = 1;
-
- // Parse out the vm options.
- while ((i < argc) && OptionProcessor::IsValidShortFlag(argv[i])) {
- if (OptionProcessor::TryProcess(argv[i], vm_options)) {
- i += 1;
- continue;
- }
- vm_options->AddArgument(argv[i]);
- i += 1;
- }
-
- // Parse out the kernel inputs.
- while (i < argc) {
- inputs->AddArgument(argv[i]);
- i++;
- }
-
- if (help) {
- PrintUsage();
- Platform::Exit(0);
- } else if (version) {
- Syslog::PrintErr("Dart SDK version: %s\n", Dart_VersionString());
- Platform::Exit(0);
- }
-
- // Verify consistency of arguments.
- if (inputs->count() < 1) {
- Syslog::PrintErr("At least one input is required\n");
- return -1;
- }
-
- if (out_path == nullptr) {
- Syslog::PrintErr(
- "Please specify an output path for analysis with the --out flag.\n\n");
- return -1;
- }
-
- return 0;
-}
-
-PRINTF_ATTRIBUTE(1, 2) static void PrintErrAndExit(const char* format, ...) {
- va_list args;
- va_start(args, format);
- Syslog::VPrintErr(format, args);
- va_end(args);
-
- Dart_ExitScope();
- Dart_ShutdownIsolate();
- exit(kErrorExitCode);
-}
-
-static File* OpenFile(const char* filename) {
- File* file = File::Open(nullptr, filename, File::kWriteTruncate);
- if (file == nullptr) {
- PrintErrAndExit("Error: Unable to write file: %s\n\n", filename);
- }
- return file;
-}
-
-static void WriteFile(const char* filename,
- const char* buffer,
- const intptr_t size) {
- File* file = OpenFile(filename);
- RefCntReleaseScope<File> rs(file);
- if (!file->WriteFully(buffer, size)) {
- PrintErrAndExit("Error: Unable to write file: %s\n\n", filename);
- }
-}
-
-int RunAnalyzer(int argc, char** argv) {
- // Constant mirrors gen_snapshot binary, subject to change.
- const int EXTRA_VM_ARGUMENTS = 7;
- CommandLineOptions vm_options(argc + EXTRA_VM_ARGUMENTS);
- CommandLineOptions inputs(argc);
- // Parse command line arguments.
- if (ParseArguments(argc, argv, &vm_options, &inputs) < 0) {
- PrintUsage();
- return kErrorExitCode;
- }
-
- // Initialize VM with default flags if none are provided.
- // TODO(#47924): Implement auto-parsing of flags from the snapshot file.
- if (vm_options.count() == 0) {
- vm_options.AddArgument("--enable_mirrors=false");
- vm_options.AddArgument("--background_compilation");
- vm_options.AddArgument("--lazy_async_stacks");
- vm_options.AddArgument("--precompilation");
- }
-
- char* error = Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
- if (error != nullptr) {
- Syslog::PrintErr("Setting VM flags failed: %s\n", error);
- free(error);
- return kErrorExitCode;
- }
-
- // Dart_LoadELF will crash on nonexistant file non-gracefully
- // even though it should return `nullptr`.
- File* const file =
- File::Open(/*namespc=*/nullptr, inputs.GetArgument(0), File::kRead);
- if (file == nullptr) {
- Syslog::PrintErr("Snapshot file does not exist\n");
- return kErrorExitCode;
- }
- file->Release();
-
- const char* loader_error = nullptr;
- Dart_LoadedElf* loaded_elf = Dart_LoadELF(
- inputs.GetArgument(0), 0, &loader_error, &vm_snapshot_data,
- &vm_snapshot_instructions, &vm_isolate_data, &vm_isolate_instructions);
-
- if (loaded_elf == nullptr) {
- Syslog::PrintErr("Failure calling Dart_LoadELF:\n%s\n", loader_error);
- return kErrorExitCode;
- }
-
- // Begin initialization
- Dart_InitializeParams init_params = {};
- memset(&init_params, 0, sizeof(init_params));
- init_params.version = DART_INITIALIZE_PARAMS_CURRENT_VERSION;
- init_params.vm_snapshot_data = vm_snapshot_data;
- init_params.vm_snapshot_instructions = vm_snapshot_instructions;
-
- init_params.file_open = DartUtils::OpenFile;
- init_params.file_read = DartUtils::ReadFile;
- init_params.file_write = DartUtils::WriteFile;
- init_params.file_close = DartUtils::CloseFile;
- init_params.entropy_source = DartUtils::EntropySource;
-
- error = Dart_Initialize(&init_params);
- if (error != nullptr) {
- Syslog::PrintErr("VM initialization failed: %s\n", error);
- free(error);
- return kErrorExitCode;
- }
-
- auto isolate_group_data = std::unique_ptr<IsolateGroupData>(
- new IsolateGroupData(nullptr, nullptr, nullptr, false));
-
- Dart_IsolateFlags isolate_flags;
- Dart_IsolateFlagsInitialize(&isolate_flags);
- // Null safety can be determined from the snapshot itself
- isolate_flags.null_safety =
- Dart_DetectNullSafety(nullptr, nullptr, nullptr, vm_snapshot_data,
- vm_snapshot_instructions, nullptr, -1);
-
- Dart_CreateIsolateGroup(nullptr, nullptr, vm_isolate_data,
- vm_isolate_instructions, &isolate_flags,
- isolate_group_data.get(),
- /*isolate_data=*/nullptr, &error);
-
- if (error != nullptr) {
- Syslog::PrintErr("Dart_CreateIsolateGroup Error: %s\n", error);
- free(error);
- return kErrorExitCode;
- }
-
- dart::snapshot_analyzer::Dart_SnapshotAnalyzerInformation info = {
- vm_snapshot_data, vm_snapshot_instructions, vm_isolate_data,
- vm_isolate_instructions};
-
- char* out = NULL;
- intptr_t out_len = 0;
-
- Dart_EnterScope();
- Dart_DumpSnapshotInformationAsJson(&out, &out_len, &info);
- WriteFile(out_path, out, out_len);
- // Since ownership of the JSON buffer is ours, free before we exit.
- free(out);
- Dart_ExitScope();
- Dart_ShutdownIsolate();
- return 0;
-}
-#endif
-} // namespace bin
-} // namespace dart
-
-int main(int argc, char** argv) {
-#if !defined(DART_HOST_OS_FUCHSIA)
- return dart::bin::RunAnalyzer(argc, argv);
-#endif
- dart::Syslog::PrintErr("Cannot run on Fuchsia.\n");
- return dart::bin::kErrorExitCode;
-}
diff --git a/runtime/bin/main_options.cc b/runtime/bin/main_options.cc
index 9c03b89..83c1408 100644
--- a/runtime/bin/main_options.cc
+++ b/runtime/bin/main_options.cc
@@ -168,7 +168,7 @@
"--write-service-info=<file_uri>\n"
" Outputs information necessary to connect to the VM service to the\n"
" specified file in JSON format. Useful for clients which are unable to\n"
-" listen to stdout for the Dart VM service listening message.\n"
+" listen to stdout for the Observatory listening message.\n"
#endif // !defined(PRODUCT)
"--snapshot-kind=<snapshot_kind>\n"
"--snapshot=<file_name>\n"
diff --git a/runtime/include/analyze_snapshot_api.h b/runtime/include/analyze_snapshot_api.h
deleted file mode 100644
index e02f461..0000000
--- a/runtime/include/analyze_snapshot_api.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
- * for details. All rights reserved. Use of this source code is governed by a
- * BSD-style license that can be found in the LICENSE file.
- */
-
-#ifndef RUNTIME_INCLUDE_ANALYZE_SNAPSHOT_API_H_
-#define RUNTIME_INCLUDE_ANALYZE_SNAPSHOT_API_H_
-
-#include <stdint.h>
-
-namespace dart {
-namespace snapshot_analyzer {
-typedef struct {
- const uint8_t* vm_snapshot_data;
- const uint8_t* vm_snapshot_instructions;
- const uint8_t* vm_isolate_data;
- const uint8_t* vm_isolate_instructions;
-} Dart_SnapshotAnalyzerInformation;
-
-void Dart_DumpSnapshotInformationAsJson(char** buffer,
- intptr_t* buffer_length,
- Dart_SnapshotAnalyzerInformation* info);
-} // namespace snapshot_analyzer
-} // namespace dart
-
-#endif // RUNTIME_INCLUDE_ANALYZE_SNAPSHOT_API_H_
diff --git a/runtime/observatory/tests/service/sigquit_starts_service_test.dart b/runtime/observatory/tests/service/sigquit_starts_service_test.dart
index 357a986..911c12d 100644
--- a/runtime/observatory/tests/service/sigquit_starts_service_test.dart
+++ b/runtime/observatory/tests/service/sigquit_starts_service_test.dart
@@ -23,7 +23,7 @@
sub = process.stdout.transform(utf8.decoder).listen((e) async {
if (e.contains('ready') && !readyCompleter.isCompleted) {
readyCompleter.complete();
- } else if (e.contains('The Dart VM service is listening on')) {
+ } else if (e.contains('Observatory listening on')) {
await sub.cancel();
completer.complete();
}
diff --git a/runtime/observatory_2/tests/service_2/sigquit_starts_service_test.dart b/runtime/observatory_2/tests/service_2/sigquit_starts_service_test.dart
index 7320f09..b056477 100644
--- a/runtime/observatory_2/tests/service_2/sigquit_starts_service_test.dart
+++ b/runtime/observatory_2/tests/service_2/sigquit_starts_service_test.dart
@@ -23,7 +23,7 @@
sub = process.stdout.transform(utf8.decoder).listen((e) async {
if (e.contains('ready') && !readyCompleter.isCompleted) {
readyCompleter.complete();
- } else if (e.contains('The Dart VM service is listening on')) {
+ } else if (e.contains('Observatory listening on')) {
await sub.cancel();
completer.complete();
}
diff --git a/runtime/tests/vm/dart/analyze_snapshot_binary_test.dart b/runtime/tests/vm/dart/analyze_snapshot_binary_test.dart
deleted file mode 100644
index 088e519..0000000
--- a/runtime/tests/vm/dart/analyze_snapshot_binary_test.dart
+++ /dev/null
@@ -1,294 +0,0 @@
-// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'dart:convert';
-import 'dart:io';
-import 'dart:async';
-
-import 'package:expect/expect.dart';
-import 'package:native_stack_traces/elf.dart';
-import 'package:path/path.dart' as path;
-
-import 'use_flag_test_helper.dart';
-
-// Used to ensure we don't have multiple equivalent calls to test.
-final _seenDescriptions = <String>{};
-
-Future<void> testAOT(String dillPath,
- {bool useAsm = false,
- bool forceDrops = false,
- bool stripUtil = false, // Note: forced true if useAsm.
- bool stripFlag = false,
- bool disassemble = false}) async {
- if (const bool.fromEnvironment('dart.vm.product') && disassemble) {
- Expect.isFalse(disassemble, 'no use of disassembler in PRODUCT mode');
- }
-
- final analyzeSnapshot = path.join(
- buildDir,
- bool.fromEnvironment('dart.vm.product')
- ? 'analyze_snapshot_product'
- : 'analyze_snapshot');
-
- // For assembly, we can't test the sizes of the snapshot sections, since we
- // don't have a Mach-O reader for Mac snapshots and for ELF, the assembler
- // merges the text/data sections and the VM/isolate section symbols may not
- // have length information. Thus, we force external stripping so we can test
- // the approximate size of the stripped snapshot.
- if (useAsm) {
- stripUtil = true;
- }
-
- final descriptionBuilder = StringBuffer()..write(useAsm ? 'assembly' : 'elf');
- if (forceDrops) {
- descriptionBuilder.write('-dropped');
- }
- if (stripFlag) {
- descriptionBuilder.write('-intstrip');
- }
- if (stripUtil) {
- descriptionBuilder.write('-extstrip');
- }
- if (disassemble) {
- descriptionBuilder.write('-disassembled');
- }
-
- final description = descriptionBuilder.toString();
- Expect.isTrue(_seenDescriptions.add(description),
- "test configuration $description would be run multiple times");
-
- await withTempDir('analyze_snapshot_binary-$description',
- (String tempDir) async {
- // Generate the snapshot
- final snapshotPath = path.join(tempDir, 'test.snap');
- final commonSnapshotArgs = [
- if (stripFlag) '--strip', // gen_snapshot specific and not a VM flag.
- if (forceDrops) ...[
- '--dwarf-stack-traces',
- '--no-retain-function-objects',
- '--no-retain-code-objects'
- ],
- if (disassemble) '--disassemble', // Not defined in PRODUCT mode.
- dillPath,
- ];
-
- if (useAsm) {
- final assemblyPath = path.join(tempDir, 'test.S');
-
- await run(genSnapshot, <String>[
- '--snapshot-kind=app-aot-assembly',
- '--assembly=$assemblyPath',
- ...commonSnapshotArgs,
- ]);
-
- await assembleSnapshot(assemblyPath, snapshotPath);
- } else {
- await run(genSnapshot, <String>[
- '--snapshot-kind=app-aot-elf',
- '--elf=$snapshotPath',
- ...commonSnapshotArgs,
- ]);
- }
-
- print("Snapshot generated at $snapshotPath.");
-
- // May not be ELF, but another format.
- final elf = Elf.fromFile(snapshotPath);
- if (!useAsm) {
- Expect.isNotNull(elf);
- }
-
- if (elf != null) {
- // Verify some ELF file format parameters.
- final textSections = elf.namedSections(".text");
- Expect.isNotEmpty(textSections);
- Expect.isTrue(
- textSections.length <= 2, "More text sections than expected");
- final dataSections = elf.namedSections(".rodata");
- Expect.isNotEmpty(dataSections);
- Expect.isTrue(
- dataSections.length <= 2, "More data sections than expected");
- }
-
- final analyzerOutputPath = path.join(tempDir, 'analyze_test.json');
-
- // This will throw if exit code is not 0.
- await run(analyzeSnapshot, <String>[
- '--out=$analyzerOutputPath',
- '$snapshotPath',
- ]);
-
- final analyzerJsonBytes = await readFile(analyzerOutputPath);
- final analyzerJson = json.decode(analyzerJsonBytes);
- Expect.isFalse(analyzerJson.isEmpty);
- Expect.isTrue(analyzerJson.keys
- .toSet()
- .containsAll(['snapshot_data', 'class_table', 'object_pool']));
- });
-}
-
-Match? matchComplete(RegExp regexp, String line) {
- Match? match = regexp.firstMatch(line);
- if (match == null) return match;
- if (match.start != 0 || match.end != line.length) return null;
- return match;
-}
-
-// All fields of "Raw..." classes defined in "raw_object.h" must be included in
-// the giant macro in "raw_object_fields.cc". This function attempts to check
-// that with some basic regexes.
-testMacros() async {
- const String className = "([a-z0-9A-Z]+)";
- const String rawClass = "Raw$className";
- const String fieldName = "([a-z0-9A-Z_]+)";
-
- final Map<String, Set<String>> fields = {};
-
- final String rawObjectFieldsPath =
- path.join(sdkDir, 'runtime', 'vm', 'raw_object_fields.cc');
- final RegExp fieldEntry = RegExp(" *F\\($className, $fieldName\\) *\\\\?");
-
- await for (String line in File(rawObjectFieldsPath)
- .openRead()
- .cast<List<int>>()
- .transform(utf8.decoder)
- .transform(LineSplitter())) {
- Match? match = matchComplete(fieldEntry, line);
- if (match != null) {
- fields
- .putIfAbsent(match.group(1)!, () => Set<String>())
- .add(match.group(2)!);
- }
- }
-
- final RegExp classStart = RegExp("class $rawClass : public $rawClass {");
- final RegExp classEnd = RegExp("}");
- final RegExp field = RegExp(" $rawClass. +$fieldName;.*");
-
- final String rawObjectPath =
- path.join(sdkDir, 'runtime', 'vm', 'raw_object.h');
-
- String? currentClass;
- bool hasMissingFields = false;
- await for (String line in File(rawObjectPath)
- .openRead()
- .cast<List<int>>()
- .transform(utf8.decoder)
- .transform(LineSplitter())) {
- Match? match = matchComplete(classStart, line);
- if (match != null) {
- currentClass = match.group(1);
- continue;
- }
- match = matchComplete(classEnd, line);
- if (match != null) {
- currentClass = null;
- continue;
- }
- match = matchComplete(field, line);
- if (match != null && currentClass != null) {
- if (fields[currentClass] == null) {
- hasMissingFields = true;
- print("$currentClass is missing entirely.");
- continue;
- }
- if (!fields[currentClass]!.contains(match.group(2)!)) {
- hasMissingFields = true;
- print("$currentClass is missing ${match.group(2)!}.");
- }
- }
- }
-
- if (hasMissingFields) {
- Expect.fail("$rawObjectFieldsPath is missing some fields. "
- "Please update it to match $rawObjectPath.");
- }
-}
-
-main() async {
- void printSkip(String description) =>
- print('Skipping $description for ${path.basename(buildDir)} '
- 'on ${Platform.operatingSystem}' +
- (clangBuildToolsDir == null ? ' without //buildtools' : ''));
-
- // We don't have access to the SDK on Android.
- if (Platform.isAndroid) {
- printSkip('all tests');
- return;
- }
-
- await testMacros();
-
- await withTempDir('analyze_snapshot_binary', (String tempDir) async {
- // We only need to generate the dill file once for all JIT tests.
- final _thisTestPath = path.join(sdkDir, 'runtime', 'tests', 'vm', 'dart',
- 'analyze_snapshot_binary_test.dart');
-
- // We only need to generate the dill file once for all AOT tests.
- final aotDillPath = path.join(tempDir, 'aot_test.dill');
- await run(genKernel, <String>[
- '--aot',
- '--platform',
- platformDill,
- ...Platform.executableArguments.where((arg) =>
- arg.startsWith('--enable-experiment=') ||
- arg == '--sound-null-safety' ||
- arg == '--no-sound-null-safety'),
- '-o',
- aotDillPath,
- _thisTestPath
- ]);
-
- // Just as a reminder for AOT tests:
- // * If useAsm is true, then stripUtil is forced (as the assembler may add
- // extra information that needs stripping), so no need to specify
- // stripUtil for useAsm tests.
-
- // Test unstripped ELF generation directly.
- await testAOT(aotDillPath);
- await testAOT(aotDillPath, forceDrops: true);
-
- // Test flag-stripped ELF generation.
- await testAOT(aotDillPath, stripFlag: true);
-
- // Since we can't force disassembler support after the fact when running
- // in PRODUCT mode, skip any --disassemble tests. Do these tests last as
- // they have lots of output and so the log will be truncated.
- if (!const bool.fromEnvironment('dart.vm.product')) {
- // Regression test for dartbug.com/41149.
- await testAOT(aotDillPath, disassemble: true);
- }
-
- // We neither generate assembly nor have a stripping utility on Windows.
- if (Platform.isWindows) {
- printSkip('external stripping and assembly tests');
- return;
- }
-
- // The native strip utility on Mac OS X doesn't recognize ELF files.
- if (Platform.isMacOS && clangBuildToolsDir == null) {
- printSkip('ELF external stripping test');
- } else {
- // Test unstripped ELF generation that is then externally stripped.
- await testAOT(aotDillPath, stripUtil: true);
- }
-
- // TODO(sstrickl): Currently we can't assemble for SIMARM64 on MacOSX.
- // For example, the test runner still uses blobs for
- // dartkp-mac-*-simarm64. Change assembleSnapshot and remove this check
- // when we can.
- if (Platform.isMacOS && buildDir.endsWith('SIMARM64')) {
- printSkip('assembly tests');
- return;
- }
- // Test unstripped assembly generation that is then externally stripped.
- await testAOT(aotDillPath, useAsm: true);
- // Test stripped assembly generation that is then externally stripped.
- await testAOT(aotDillPath, useAsm: true, stripFlag: true);
- });
-}
-
-Future<String> readFile(String file) {
- return new File(file).readAsString();
-}
diff --git a/runtime/tests/vm/dart_2/analyze_snapshot_binary_test.dart b/runtime/tests/vm/dart_2/analyze_snapshot_binary_test.dart
deleted file mode 100644
index 058e7ea..0000000
--- a/runtime/tests/vm/dart_2/analyze_snapshot_binary_test.dart
+++ /dev/null
@@ -1,294 +0,0 @@
-// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// @dart = 2.9
-
-import 'dart:convert';
-import 'dart:io';
-import 'dart:async';
-
-import 'package:expect/expect.dart';
-import 'package:native_stack_traces/elf.dart';
-import 'package:path/path.dart' as path;
-
-import 'use_flag_test_helper.dart';
-
-// Used to ensure we don't have multiple equivalent calls to test.
-final _seenDescriptions = <String>{};
-
-Future<void> testAOT(String dillPath,
- {bool useAsm = false,
- bool forceDrops = false,
- bool stripUtil = false, // Note: forced true if useAsm.
- bool stripFlag = false,
- bool disassemble = false}) async {
- if (const bool.fromEnvironment('dart.vm.product') && disassemble) {
- Expect.isFalse(disassemble, 'no use of disassembler in PRODUCT mode');
- }
-
- final analyzeSnapshot = path.join(
- buildDir,
- bool.fromEnvironment('dart.vm.product')
- ? 'analyze_snapshot_product'
- : 'analyze_snapshot');
-
- // For assembly, we can't test the sizes of the snapshot sections, since we
- // don't have a Mach-O reader for Mac snapshots and for ELF, the assembler
- // merges the text/data sections and the VM/isolate section symbols may not
- // have length information. Thus, we force external stripping so we can test
- // the approximate size of the stripped snapshot.
- if (useAsm) {
- stripUtil = true;
- }
-
- final descriptionBuilder = StringBuffer()..write(useAsm ? 'assembly' : 'elf');
- if (forceDrops) {
- descriptionBuilder.write('-dropped');
- }
- if (stripFlag) {
- descriptionBuilder.write('-intstrip');
- }
- if (stripUtil) {
- descriptionBuilder.write('-extstrip');
- }
- if (disassemble) {
- descriptionBuilder.write('-disassembled');
- }
-
- final description = descriptionBuilder.toString();
- Expect.isTrue(_seenDescriptions.add(description),
- "test configuration $description would be run multiple times");
-
- await withTempDir('analyze_snapshot_binary-$description',
- (String tempDir) async {
- // Generate the snapshot
- final snapshotPath = path.join(tempDir, 'test.snap');
- final commonSnapshotArgs = [
- if (stripFlag) '--strip', // gen_snapshot specific and not a VM flag.
- if (forceDrops) ...[
- '--dwarf-stack-traces',
- '--no-retain-function-objects',
- '--no-retain-code-objects'
- ],
- if (disassemble) '--disassemble', // Not defined in PRODUCT mode.
- dillPath,
- ];
-
- if (useAsm) {
- final assemblyPath = path.join(tempDir, 'test.S');
-
- await run(genSnapshot, <String>[
- '--snapshot-kind=app-aot-assembly',
- '--assembly=$assemblyPath',
- ...commonSnapshotArgs,
- ]);
-
- await assembleSnapshot(assemblyPath, snapshotPath);
- } else {
- await run(genSnapshot, <String>[
- '--snapshot-kind=app-aot-elf',
- '--elf=$snapshotPath',
- ...commonSnapshotArgs,
- ]);
- }
-
- print("Snapshot generated at $snapshotPath.");
-
- // May not be ELF, but another format.
- final elf = Elf.fromFile(snapshotPath);
- if (!useAsm) {
- Expect.isNotNull(elf);
- }
-
- if (elf != null) {
- // Verify some ELF file format parameters.
- final textSections = elf.namedSections(".text");
- Expect.isNotEmpty(textSections);
- Expect.isTrue(
- textSections.length <= 2, "More text sections than expected");
- final dataSections = elf.namedSections(".rodata");
- Expect.isNotEmpty(dataSections);
- Expect.isTrue(
- dataSections.length <= 2, "More data sections than expected");
- }
-
- final analyzerOutputPath = path.join(tempDir, 'analyze_test.json');
-
- // This will throw if exit code is not 0.
- await run(analyzeSnapshot, <String>[
- '--out=$analyzerOutputPath',
- '$snapshotPath',
- ]);
-
- final analyzerJsonBytes = await readFile(analyzerOutputPath);
- final analyzerJson = json.decode(analyzerJsonBytes);
- Expect.isFalse(analyzerJson.isEmpty);
- Expect.isTrue(analyzerJson.keys
- .toSet()
- .containsAll(['snapshot_data', 'class_table', 'object_pool']));
- });
-}
-
-Match matchComplete(RegExp regexp, String line) {
- Match match = regexp.firstMatch(line);
- if (match == null) return match;
- if (match.start != 0 || match.end != line.length) return null;
- return match;
-}
-
-// All fields of "Raw..." classes defined in "raw_object.h" must be included in
-// the giant macro in "raw_object_fields.cc". This function attempts to check
-// that with some basic regexes.
-testMacros() async {
- const String className = "([a-z0-9A-Z]+)";
- const String rawClass = "Raw$className";
- const String fieldName = "([a-z0-9A-Z_]+)";
-
- final Map<String, Set<String>> fields = {};
-
- final String rawObjectFieldsPath =
- path.join(sdkDir, 'runtime', 'vm', 'raw_object_fields.cc');
- final RegExp fieldEntry = RegExp(" *F\\($className, $fieldName\\) *\\\\?");
-
- await for (String line in File(rawObjectFieldsPath)
- .openRead()
- .cast<List<int>>()
- .transform(utf8.decoder)
- .transform(LineSplitter())) {
- Match match = matchComplete(fieldEntry, line);
- if (match != null) {
- fields
- .putIfAbsent(match.group(1), () => Set<String>())
- .add(match.group(2));
- }
- }
-
- final RegExp classStart = RegExp("class $rawClass : public $rawClass {");
- final RegExp classEnd = RegExp("}");
- final RegExp field = RegExp(" $rawClass. +$fieldName;.*");
-
- final String rawObjectPath =
- path.join(sdkDir, 'runtime', 'vm', 'raw_object.h');
-
- String currentClass;
- bool hasMissingFields = false;
- await for (String line in File(rawObjectPath)
- .openRead()
- .cast<List<int>>()
- .transform(utf8.decoder)
- .transform(LineSplitter())) {
- Match match = matchComplete(classStart, line);
- if (match != null) {
- currentClass = match.group(1);
- continue;
- }
-
- match = matchComplete(classEnd, line);
- if (match != null) {
- currentClass = null;
- continue;
- }
-
- match = matchComplete(field, line);
- if (match != null && currentClass != null) {
- if (fields[currentClass] == null) {
- hasMissingFields = true;
- print("$currentClass is missing entirely.");
- continue;
- }
- if (!fields[currentClass].contains(match.group(2))) {
- hasMissingFields = true;
- print("$currentClass is missing ${match.group(2)}.");
- }
- }
- }
-
- if (hasMissingFields) {
- Expect.fail("$rawObjectFieldsPath is missing some fields. "
- "Please update it to match $rawObjectPath.");
- }
-}
-
-main() async {
- void printSkip(String description) =>
- print('Skipping $description for ${path.basename(buildDir)} '
- 'on ${Platform.operatingSystem}' +
- (clangBuildToolsDir == null ? ' without //buildtools' : ''));
-
- // We don't have access to the SDK on Android.
- if (Platform.isAndroid) {
- printSkip('all tests');
- return;
- }
-
- await testMacros();
-
- await withTempDir('analyze_snapshot_binary', (String tempDir) async {
- // We only need to generate the dill file once for all JIT tests.
- final _thisTestPath = path.join(sdkDir, 'runtime', 'tests', 'vm', 'dart_2',
- 'analyze_snapshot_binary_test.dart');
-
- // We only need to generate the dill file once for all AOT tests.
- final aotDillPath = path.join(tempDir, 'aot_test.dill');
- await run(genKernel, <String>[
- '--aot',
- '--platform',
- platformDill,
- '-o',
- aotDillPath,
- _thisTestPath
- ]);
-
- // Just as a reminder for AOT tests:
- // * If useAsm is true, then stripUtil is forced (as the assembler may add
- // extra information that needs stripping), so no need to specify
- // stripUtil for useAsm tests.
-
- // Test unstripped ELF generation directly.
- await testAOT(aotDillPath);
- await testAOT(aotDillPath, forceDrops: true);
-
- // Test flag-stripped ELF generation.
- await testAOT(aotDillPath, stripFlag: true);
-
- // Since we can't force disassembler support after the fact when running
- // in PRODUCT mode, skip any --disassemble tests. Do these tests last as
- // they have lots of output and so the log will be truncated.
- if (!const bool.fromEnvironment('dart.vm.product')) {
- // Regression test for dartbug.com/41149.
- await testAOT(aotDillPath, disassemble: true);
- }
-
- // We neither generate assembly nor have a stripping utility on Windows.
- if (Platform.isWindows) {
- printSkip('external stripping and assembly tests');
- return;
- }
-
- // The native strip utility on Mac OS X doesn't recognize ELF files.
- if (Platform.isMacOS && clangBuildToolsDir == null) {
- printSkip('ELF external stripping test');
- } else {
- // Test unstripped ELF generation that is then externally stripped.
- await testAOT(aotDillPath, stripUtil: true);
- }
-
- // TODO(sstrickl): Currently we can't assemble for SIMARM64 on MacOSX.
- // For example, the test runner still uses blobs for
- // dartkp-mac-*-simarm64. Change assembleSnapshot and remove this check
- // when we can.
- if (Platform.isMacOS && buildDir.endsWith('SIMARM64')) {
- printSkip('assembly tests');
- return;
- }
- // Test unstripped assembly generation that is then externally stripped.
- await testAOT(aotDillPath, useAsm: true);
- // Test stripped assembly generation that is then externally stripped.
- await testAOT(aotDillPath, useAsm: true, stripFlag: true);
- });
-}
-
-Future<String> readFile(String file) {
- return new File(file).readAsString();
-}
diff --git a/runtime/tests/vm/dart_2/isolates/reload_utils.dart b/runtime/tests/vm/dart_2/isolates/reload_utils.dart
index c1c9e96..c973017 100644
--- a/runtime/tests/vm/dart_2/isolates/reload_utils.dart
+++ b/runtime/tests/vm/dart_2/isolates/reload_utils.dart
@@ -166,7 +166,7 @@
}
Future _waitUntilService() async {
- final needle = 'The Dart VM service is listening on ';
+ final needle = 'Observatory listening on ';
final line = await waitUntilStdoutContains(needle);
final Uri uri = Uri.parse(line.substring(needle.length));
assert(_remoteVm == null);
diff --git a/runtime/tests/vm/vm.status b/runtime/tests/vm/vm.status
index 7b19ec9..5fe1fbf 100644
--- a/runtime/tests/vm/vm.status
+++ b/runtime/tests/vm/vm.status
@@ -41,9 +41,7 @@
dart_2/stack_overflow_shared_test: Pass, Slow # Uses --shared-slow-path-triggers-gc flag.
[ $arch == ia32 ]
-dart/analyze_snapshot_binary_test: SkipByDesign # IA32 does not support AOT.
dart/disassemble_aot_test: SkipByDesign # IA32 does not support AOT.
-dart_2/analyze_snapshot_binary_test: SkipByDesign # IA32 does not support AOT.
dart_2/disassemble_aot_test: SkipByDesign # IA32 does not support AOT.
[ $builder_tag == asan ]
@@ -165,10 +163,8 @@
[ $system == fuchsia ]
cc/CorelibIsolateStartup: Skip # OOM crash can bring down the OS.
cc/Read: Fail # TODO(zra): Investigate, ../../dart/runtime/bin/file_test.cc: 34: error: expected: !file->WriteByte(1)
-dart/analyze_snapshot_binary_test: SkipByDesign # Not supported for Fuchsia.
dart/data_uri_spawn_test: Skip # TODO(zra): package:unittest is not in the image.
dart/spawn_shutdown_test: Skip # OOM crash can bring down the OS.
-dart_2/analyze_snapshot_binary_test: SkipByDesign # Not supported for Fuchsia.
dart_2/data_uri_spawn_test: Skip # TODO(zra): package:unittest is not in the image.
dart_2/spawn_shutdown_test: Skip # OOM crash can bring down the OS.
@@ -325,10 +321,8 @@
[ $system != fuchsia && ($arch != x64 || $system != linux) ]
cc/CodeExecutability: SkipByDesign # --dual-map-code not supported on non-Linux/Fuchsia
-[ $arch == arm || $arch == arm64 || $builder_tag == crossword || $builder_tag == crossword_ast || $compiler != dartkp || $system == linux && ($arch == simarm || $arch == simarm64 || $arch == simarm64c) ]
-dart/analyze_snapshot_binary_test: SkipByDesign # These tests should only run on AOT. On Linux/simarm64 and Linux/simarm this test requires buildtools/clang which is not always available on testing shards.
+[ $arch == arm || $arch == arm64 || $builder_tag == crossword || $builder_tag == crossword_ast || $compiler != dartkp || $system == linux && ($arch == simarm || $arch == simarm64 || $arch == simarm64c || $arch == simriscv32 || $arch == simriscv64) ]
dart/v8_snapshot_profile_writer_test: SkipByDesign # Only relevant for AOT. Doesn't work in cross-compilation (has to run on the host). On Linux/simarm64 and Linux/simarm this test requires buildtools/clang which is not always available on testing shards.
-dart_2/analyze_snapshot_binary_test: SkipByDesign # These tests should only run on AOT. On Linux/simarm64 and Linux/simarm this test requires buildtools/clang which is not always available on testing shards.
dart_2/v8_snapshot_profile_writer_test: SkipByDesign # Only relevant for AOT. Doesn't work in cross-compilation (has to run on the host). On Linux/simarm64 and Linux/simarm this test requires buildtools/clang which is not always available on testing shards.
# On the simluator stack traces produced by the Profiler do not match
diff --git a/runtime/vm/analyze_snapshot_api_impl.cc b/runtime/vm/analyze_snapshot_api_impl.cc
deleted file mode 100644
index ef73e76..0000000
--- a/runtime/vm/analyze_snapshot_api_impl.cc
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-#include "include/analyze_snapshot_api.h"
-#include "vm/dart_api_impl.h"
-#include "vm/json_writer.h"
-#include "vm/object.h"
-#include "vm/object_store.h"
-#include "vm/thread.h"
-
-namespace dart {
-namespace snapshot_analyzer {
-void DumpClassTable(Thread* thread, dart::JSONWriter* js) {
- auto class_table = thread->isolate_group()->class_table();
-
- Class& cls = Class::Handle();
- String& name = String::Handle();
- js->OpenArray("class_table");
-
- for (intptr_t i = 1; i < class_table->NumCids(); i++) {
- if (!class_table->HasValidClassAt(i)) {
- continue;
- }
- cls = class_table->At(i);
- if (!cls.IsNull()) {
- name = cls.Name();
- js->OpenObject();
- js->PrintProperty("id", i);
- js->PrintProperty("name", name.ToCString());
-
- // Note: Some meta info is stripped from the snapshot, it's important
- // to check every field for NULL to avoid segfaults.
- const Library& library = Library::Handle(cls.library());
- if (!library.IsNull()) {
- String& lib_name = String::Handle();
- lib_name = String::NewFormatted(
- Heap::kOld, "%s%s", String::Handle(library.url()).ToCString(),
- String::Handle(library.private_key()).ToCString());
- js->PrintProperty("library", lib_name.ToCString());
- }
-
- const AbstractType& super_type = AbstractType::Handle(cls.super_type());
- if (super_type.IsNull()) {
- } else {
- const String& super_name = String::Handle(super_type.Name());
- js->PrintProperty("super_class", super_name.ToCString());
- }
-
- const Array& interfaces_array = Array::Handle(cls.interfaces());
- if (!interfaces_array.IsNull()) {
- if (interfaces_array.Length() > 0) {
- js->OpenArray("interfaces");
- AbstractType& interface = AbstractType::Handle();
- intptr_t len = interfaces_array.Length();
- for (intptr_t i = 0; i < len; i++) {
- interface ^= interfaces_array.At(i);
- js->PrintValue(interface.ToCString());
- }
- js->CloseArray();
- }
- }
- const Array& functions_array = Array::Handle(cls.functions());
- if (!functions_array.IsNull()) {
- if (functions_array.Length() > 0) {
- js->OpenArray("functions");
- Function& function = Function::Handle();
- intptr_t len = functions_array.Length();
- for (intptr_t i = 0; i < len; i++) {
- function ^= functions_array.At(i);
- if (function.IsNull() || !function.HasCode()) {
- continue;
- }
- const Code& code = Code::Handle(function.CurrentCode());
- intptr_t size = code.Size();
-
- // Note: Some entry points here will be pointing to the VM
- // instructions buffer.
-
- // Note: code_entry will contain the address in the memory
- // In order to resolve it to a relative offset in the instructions
- // buffer we need to pick the base address and substract it from
- // the entry point address.
- auto code_entry = code.EntryPoint();
- // On different architectures the type of the underlying
- // dart::uword can result in an unsigned long long vs unsigned long
- // mismatch.
- uint64_t code_addr = static_cast<uint64_t>(code_entry);
- js->OpenObject();
- js->PrintProperty("name", function.ToCString());
- js->PrintfProperty("code_entry", "0x%" PRIx64 "", code_addr);
- js->PrintProperty("size", size);
- js->CloseObject();
- }
- js->CloseArray();
- }
- }
- const Array& fields_array = Array::Handle(cls.fields());
- if (fields_array.IsNull()) {
- } else {
- if (fields_array.Length() > 0) {
- js->OpenArray("fields");
- Field& field = Field::Handle();
- for (intptr_t i = 0; i < fields_array.Length(); i++) {
- field ^= fields_array.At(i);
- js->PrintValue(field.ToCString());
- }
- js->CloseArray();
- }
- }
- }
- js->CloseObject();
- }
- js->CloseArray();
-}
-void DumpObjectPool(Thread* thread, dart::JSONWriter* js) {
- js->OpenArray("object_pool");
-
- auto pool_ptr = thread->isolate_group()->object_store()->global_object_pool();
- const auto& pool = ObjectPool::Handle(ObjectPool::RawCast(pool_ptr));
- for (intptr_t i = 0; i < pool.Length(); i++) {
- auto type = pool.TypeAt(i);
- // Only interested in tagged objects.
- // All these checks are required otherwise ToCString() will segfault.
- if (type != ObjectPool::EntryType::kTaggedObject) {
- continue;
- }
-
- auto entry = pool.ObjectAt(i);
- if (!entry.IsHeapObject()) {
- continue;
- }
-
- intptr_t cid = entry.GetClassId();
-
- switch (cid) {
- case kOneByteStringCid: {
- js->OpenObject();
- js->PrintProperty("type", "kOneByteString");
- js->PrintProperty("id", i);
- js->PrintProperty("offset", pool.element_offset(i));
- js->PrintProperty("value", Object::Handle(entry).ToCString());
- js->CloseObject();
- break;
- }
- case kTwoByteStringCid: {
- // TODO(#47924): Add support.
- break;
- }
- default:
- // TODO(#47924): Investigate other types of objects to parse.
- break;
- }
- }
- js->CloseArray();
-}
-// TODO(#47924): Add processing of the entires in the dispatch table.
-// Below is an example skeleton
-// void DumpDispatchTable(dart::Thread* thread) {
-// auto dispatch = thread->isolate_group()->dispatch_table();
-// auto length = dispatch->length();
-// We must unbias the array entries so we don't crash on null access.
-// auto entries = dispatch->ArrayOrigin() - DispatchTable::OriginElement();
-// for (intptr_t i = 0; i < length; i++) {
-// OS::Print("0x%lx at %ld\n", entries[i], i);
-// }
-// }
-
-void Dart_DumpSnapshotInformationAsJson(
- char** buffer,
- intptr_t* buffer_length,
- Dart_SnapshotAnalyzerInformation* info) {
- Thread* thread = Thread::Current();
- DARTSCOPE(thread);
- JSONWriter js;
- // Open empty object so output is valid/parsable JSON.
- js.OpenObject();
- js.OpenObject("snapshot_data");
- // Base addreses of the snapshot data, useful to calculate relative offsets.
- js.PrintfProperty("vm_data", "%p", info->vm_snapshot_data);
- js.PrintfProperty("vm_instructions", "%p", info->vm_snapshot_instructions);
- js.PrintfProperty("isolate_data", "%p", info->vm_isolate_data);
- js.PrintfProperty("isolate_instructions", "%p",
- info->vm_isolate_instructions);
- js.CloseObject();
-
- {
- // Debug builds assert that our thread has a lock before accessing
- // vm internal fields.
- SafepointReadRwLocker ml(thread, thread->isolate_group()->program_lock());
- DumpClassTable(thread, &js);
- DumpObjectPool(thread, &js);
- }
-
- // Close our empty object.
- js.CloseObject();
-
- // Give ownership to caller.
- js.Steal(buffer, buffer_length);
-}
-} // namespace snapshot_analyzer
-} // namespace dart
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index b761a93..336cd88 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -1205,9 +1205,9 @@
if (!ServiceIsolate::IsRunning()) {
OS::PrintErr(" Start the vm-service to debug.\n");
} else if (ServiceIsolate::server_address() == NULL) {
- OS::PrintErr(" Connect to the Dart VM service to debug.\n");
+ OS::PrintErr(" Connect to Observatory to debug.\n");
} else {
- OS::PrintErr(" Connect to the Dart VM service at %s to debug.\n",
+ OS::PrintErr(" Connect to Observatory at %s to debug.\n",
ServiceIsolate::server_address());
}
const Error& err = Error::Handle(Thread::Current()->sticky_error());
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index 4cef3d4..867dd32 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -26,7 +26,6 @@
dart_stripped_binary = "dart"
dart_precompiled_runtime_stripped_binary = "dart_precompiled_runtime_product"
gen_snapshot_stripped_binary = "gen_snapshot_product"
- analyze_snapshot_binary = "analyze_snapshot_product"
}
# The directory layout of the SDK is as follows:
@@ -322,15 +321,6 @@
]
}
-copy("copy_analyze_snapshot") {
- visibility = [ ":group_dart2native" ]
- deps = [ "../runtime/bin:analyze_snapshot_product" ]
- src_dir =
- get_label_info("../runtime/bin:analyze_snapshot_product", "root_out_dir")
- sources = [ "$src_dir/${analyze_snapshot_binary}${executable_suffix}" ]
- outputs = [ "$root_out_dir/$dart_sdk_output/bin/utils/analyze_snapshot${executable_suffix}" ]
-}
-
copy("copy_vm_platform_strong_product") {
visibility = [ ":group_dart2native" ]
deps = [ "../runtime/vm:vm_platform_product" ]
@@ -350,7 +340,6 @@
group("group_dart2native") {
deps = [
- ":copy_analyze_snapshot",
":copy_dartaotruntime",
":copy_gen_kernel_snapshot",
":copy_gen_snapshot",
diff --git a/sdk/lib/_internal/vm/bin/vmservice_server.dart b/sdk/lib/_internal/vm/bin/vmservice_server.dart
index f804398..c8e61b2 100644
--- a/sdk/lib/_internal/vm/bin/vmservice_server.dart
+++ b/sdk/lib/_internal/vm/bin/vmservice_server.dart
@@ -4,12 +4,10 @@
part of vmservice_io;
-// TODO(bkonyi): deprecate SILENT_OBSERVATORY in favor of SILENT_VM_SERVICE
bool silentObservatory = bool.fromEnvironment('SILENT_OBSERVATORY');
-bool silentVMService = bool.fromEnvironment('SILENT_VM_SERVICE');
void serverPrint(String s) {
- if (silentObservatory || silentVMService) {
+ if (silentObservatory) {
// We've been requested to be silent.
return;
}
@@ -438,10 +436,9 @@
final maxAttempts = 10;
while (!await poll()) {
attempts++;
- serverPrint(
- 'Dart VM service server failed to start after $attempts tries');
+ serverPrint('Observatory server failed to start after $attempts tries');
if (attempts > maxAttempts) {
- serverPrint('Could not start Dart VM service HTTP server:\n'
+ serverPrint('Could not start Observatory HTTP server:\n'
'$pollError\n$pollStack\n');
_notifyServerState('');
onServerAddressChange(null);
@@ -454,7 +451,7 @@
await Future<void>.delayed(const Duration(seconds: 1));
}
if (_service.isExiting) {
- serverPrint('Dart VM service HTTP server exiting before listening as '
+ serverPrint('Observatory HTTP server exiting before listening as '
'vm service has received exit request\n');
await shutdown(true);
return this;
@@ -471,7 +468,7 @@
}
Future<void> outputConnectionInformation() async {
- serverPrint('The Dart VM service is listening on $serverAddress');
+ serverPrint('Observatory listening on $serverAddress');
if (Platform.isFuchsia) {
// Create a file with the port number.
final tmp = Directory.systemTemp.path;
@@ -510,14 +507,14 @@
// Shutdown HTTP server and subscription.
Uri oldServerAddress = serverAddress!;
return cleanup(forced).then((_) {
- serverPrint('Dart VM service no longer listening on $oldServerAddress');
+ serverPrint('Observatory no longer listening on $oldServerAddress');
_server = null;
_notifyServerState('');
onServerAddressChange(null);
return this;
}).catchError((e, st) {
_server = null;
- serverPrint('Could not shutdown Dart VM service HTTP server:\n$e\n$st\n');
+ serverPrint('Could not shutdown Observatory HTTP server:\n$e\n$st\n');
_notifyServerState('');
onServerAddressChange(null);
return this;
diff --git a/tools/VERSION b/tools/VERSION
index de4d810..e6ff919 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 17
PATCH 0
-PRERELEASE 144
+PRERELEASE 145
PRERELEASE_PATCH 0
\ No newline at end of file
diff --git a/tools/gn.py b/tools/gn.py
index 373fa60..b895393 100755
--- a/tools/gn.py
+++ b/tools/gn.py
@@ -282,8 +282,6 @@
'exe.stripped/dart_precompiled_runtime_product')
gn_args['gen_snapshot_stripped_binary'] = (
'exe.stripped/gen_snapshot_product')
- gn_args['analyze_snapshot_binary'] = (
- 'exe.stripped/analyze_snapshot_product')
# Setup the user-defined sysroot.
if UseSysroot(args, gn_args):