Version 2.14.0-194.0.dev
Merge commit '419fd676d2e9bf128b6cb18f057370947e7018a8' into 'dev'
diff --git a/pkg/analysis_server/lib/src/computer/computer_highlights.dart b/pkg/analysis_server/lib/src/computer/computer_highlights.dart
index 0d20c79..68e4192 100644
--- a/pkg/analysis_server/lib/src/computer/computer_highlights.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_highlights.dart
@@ -336,7 +336,11 @@
bool _addIdentifierRegion_keyword(SimpleIdentifier node) {
var name = node.name;
if (name == 'void') {
- return _addRegion_node(node, HighlightRegionType.KEYWORD);
+ return _addRegion_node(
+ node,
+ HighlightRegionType.KEYWORD,
+ semanticTokenModifiers: {CustomSemanticTokenModifiers.void_},
+ );
}
return false;
}
diff --git a/pkg/analysis_server/lib/src/computer/computer_hover.dart b/pkg/analysis_server/lib/src/computer/computer_hover.dart
index b6850c2..8ec1bb5 100644
--- a/pkg/analysis_server/lib/src/computer/computer_hover.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_hover.dart
@@ -20,8 +20,14 @@
final DartdocDirectiveInfo _dartdocInfo;
final CompilationUnit _unit;
final int _offset;
+ final bool multilineElementDescriptions;
- DartUnitHoverComputer(this._dartdocInfo, this._unit, this._offset);
+ DartUnitHoverComputer(
+ this._dartdocInfo,
+ this._unit,
+ this._offset, {
+ this.multilineElementDescriptions = false,
+ });
/// Returns the computed hover, maybe `null`.
HoverInformation? compute() {
@@ -133,6 +139,7 @@
String? _elementDisplayString(Element? element) {
return element?.getDisplayString(
withNullability: _unit.isNonNullableByDefault,
+ multiline: multilineElementDescriptions,
);
}
diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart
index 83249b9..047e8b1 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -268,9 +268,11 @@
var content = _readFile(path);
var lineInfo = _computeLineInfo(content);
var errors = analyzeAnalysisOptions(
- resourceProvider.getFile(path).createSource(),
- content,
- driver.sourceFactory);
+ resourceProvider.getFile(path).createSource(),
+ content,
+ driver.sourceFactory,
+ driver.currentSession.analysisContext.contextRoot.root.path,
+ );
var converter = AnalyzerConverter();
convertedErrors = converter.convertAnalysisErrors(errors,
lineInfo: lineInfo, options: driver.analysisOptions);
diff --git a/pkg/analysis_server/lib/src/edit/edit_domain.dart b/pkg/analysis_server/lib/src/edit/edit_domain.dart
index 4e08659..f4f16f9 100644
--- a/pkg/analysis_server/lib/src/edit/edit_domain.dart
+++ b/pkg/analysis_server/lib/src/edit/edit_domain.dart
@@ -586,7 +586,11 @@
var session = driver.currentSession;
var sourceFactory = driver.sourceFactory;
var errors = analyzeAnalysisOptions(
- optionsFile.createSource(), content, sourceFactory);
+ optionsFile.createSource(),
+ content,
+ sourceFactory,
+ driver.currentSession.analysisContext.contextRoot.root.path,
+ );
var options = _getOptions(sourceFactory, content);
if (options == null) {
return errorFixesList;
diff --git a/pkg/analysis_server/lib/src/lsp/constants.dart b/pkg/analysis_server/lib/src/lsp/constants.dart
index d13b6a8..b5c3a27 100644
--- a/pkg/analysis_server/lib/src/lsp/constants.dart
+++ b/pkg/analysis_server/lib/src/lsp/constants.dart
@@ -125,12 +125,23 @@
/// of the expression would show through the simple-colorings "string" colors.
static const interpolation = SemanticTokenModifiers('interpolation');
+ /// A modifier applied to the void keyword to users to color it differently
+ /// (for example as a type).
+ static const void_ = SemanticTokenModifiers('void');
+
/// All custom semantic token modifiers, used to populate the LSP Legend.
///
/// The legend must include all used modifiers. Modifiers used in the
/// HighlightRegion mappings will be automatically included, but should still
/// be listed here in case they are removed from mappings in the future.
- static const values = [control, label, constructor, escape, interpolation];
+ static const values = [
+ control,
+ label,
+ constructor,
+ escape,
+ interpolation,
+ void_,
+ ];
}
abstract class CustomSemanticTokenTypes {
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_hover.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_hover.dart
index 1bef994..3056895 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_hover.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_hover.dart
@@ -87,9 +87,13 @@
return success(null);
}
- final hover = DartUnitHoverComputer(
- server.getDartdocDirectiveInfoFor(unit), compilationUnit, offset)
- .compute();
+ final computer = DartUnitHoverComputer(
+ server.getDartdocDirectiveInfoFor(unit),
+ compilationUnit,
+ offset,
+ multilineElementDescriptions: true,
+ );
+ final hover = computer.compute();
return success(toHover(unit.lineInfo, hover));
}
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/create_file.dart b/pkg/analysis_server/lib/src/services/correction/dart/create_file.dart
index 455c0c8..5b1977e 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/create_file.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/create_file.dart
@@ -23,7 +23,7 @@
// TODO(brianwilkerson) Generalize this to allow other valid string literals.
if (node is SimpleStringLiteral) {
var parent = node.parent;
- if (parent is ImportDirective) {
+ if (parent is NamespaceDirective) {
// TODO(brianwilkerson) Support the case where the node's parent is a
// Configuration.
var source = parent.uriSource;
diff --git a/pkg/analysis_server/test/analysis/notification_errors_test.dart b/pkg/analysis_server/test/analysis/notification_errors_test.dart
index c7c58d8..2cf499c 100644
--- a/pkg/analysis_server/test/analysis/notification_errors_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_errors_test.dart
@@ -96,7 +96,7 @@
expect(error.type, AnalysisErrorType.STATIC_WARNING);
// Write a package file that allows resolving the include.
- newFile('$projectPath/.packages', content: '''
+ newDotPackagesFile(projectPath, content: '''
pedantic:${pedanticFolder.toUri()}
''');
diff --git a/pkg/analysis_server/test/analysis/set_priority_files_test.dart b/pkg/analysis_server/test/analysis/set_priority_files_test.dart
index 64d569a..658c3ff 100644
--- a/pkg/analysis_server/test/analysis/set_priority_files_test.dart
+++ b/pkg/analysis_server/test/analysis/set_priority_files_test.dart
@@ -83,8 +83,8 @@
}
Future<void> test_ignoredInAnalysisOptions_inChildContext() async {
- newFile('$projectPath/.packages');
- newFile('$projectPath/child/.packages');
+ newDotPackagesFile(projectPath);
+ newDotPackagesFile('$projectPath/child');
var sampleFile = convertPath('$projectPath/child/samples/sample.dart');
newFile('$projectPath/child/${file_paths.analysisOptionsYaml}',
content: r'''
@@ -99,8 +99,8 @@
}
Future<void> test_ignoredInAnalysisOptions_inRootContext() async {
- newFile('$projectPath/.packages');
- newFile('$projectPath/child/.packages');
+ newDotPackagesFile(projectPath);
+ newDotPackagesFile('$projectPath/child');
var sampleFile = convertPath('$projectPath/child/samples/sample.dart');
newFile('$projectPath/${file_paths.analysisOptionsYaml}', content: r'''
analyzer:
diff --git a/pkg/analysis_server/test/client/completion_driver_test.dart b/pkg/analysis_server/test/client/completion_driver_test.dart
index 15e7e41..9aac2e6 100644
--- a/pkg/analysis_server/test/client/completion_driver_test.dart
+++ b/pkg/analysis_server/test/client/completion_driver_test.dart
@@ -145,7 +145,7 @@
driver.createProject(packageRoots: packageRoots);
newPubspecYamlFile(projectPath, '');
- newFile('$projectPath/.packages', content: '''
+ newDotPackagesFile(projectPath, content: '''
project:${toUri('$projectPath/lib')}
''');
// todo (pq): add logic (possibly to driver) that waits for SDK suggestions
diff --git a/pkg/analysis_server/test/domain_analysis_test.dart b/pkg/analysis_server/test/domain_analysis_test.dart
index 653339c..dd97d60 100644
--- a/pkg/analysis_server/test/domain_analysis_test.dart
+++ b/pkg/analysis_server/test/domain_analysis_test.dart
@@ -536,7 +536,7 @@
assertHasErrors(testFilePath);
// Write `.packages`, recreate analysis contexts.
- newFile('$testPackageRootPath/.packages', content: '''
+ newDotPackagesFile(testPackageRootPath, content: '''
aaa:${toUriStr(aaaLibPath)}
''');
@@ -858,7 +858,7 @@
''');
// Write `.packages` empty, without `package:aaa`.
- newFile('$testPackageRootPath/.packages', content: '');
+ newDotPackagesFile(testPackageRootPath, content: '');
newFile(testFilePath, content: '''
import 'package:aaa/a.dart';
@@ -872,7 +872,7 @@
assertHasErrors(testFilePath);
// Write `.packages`, recreate analysis contexts.
- newFile('$testPackageRootPath/.packages', content: '''
+ newDotPackagesFile(testPackageRootPath, content: '''
aaa:${toUriStr(aaaLibPath)}
''');
@@ -1090,7 +1090,7 @@
class A {}
''');
- newFile('$testPackageRootPath/.packages', content: '''
+ newDotPackagesFile(testPackageRootPath, content: '''
aaa:${toUriStr(aaaLibPath)}
''');
@@ -1193,7 +1193,7 @@
class A {}
''');
- newFile('$testPackageRootPath/.packages', content: '''
+ newDotPackagesFile(testPackageRootPath, content: '''
aaa:${toUriStr(aaaLibPath)}
''');
@@ -1671,7 +1671,7 @@
library lib_a;
class A {}
''').path;
- newFile('/project/.packages', content: 'pkgA:file:///packages/pkgA/lib');
+ newDotPackagesFile('/project', content: 'pkgA:file:///packages/pkgA/lib');
//
addTestFile('''
import 'package:pkgA/libA.dart';
@@ -1722,7 +1722,7 @@
library lib_a;
class A {}
''').path;
- newFile('/project/.packages', content: 'pkgA:/packages/pkgA/lib');
+ newDotPackagesFile('/project', content: 'pkgA:/packages/pkgA/lib');
//
addTestFile('// no "pkgA" reference');
createProject();
diff --git a/pkg/analysis_server/test/edit/fixes_test.dart b/pkg/analysis_server/test/edit/fixes_test.dart
index 1a397f2..53ba68b 100644
--- a/pkg/analysis_server/test/edit/fixes_test.dart
+++ b/pkg/analysis_server/test/edit/fixes_test.dart
@@ -150,7 +150,7 @@
Future<void> test_suggestImportFromDifferentAnalysisRoot() async {
newFolder('/aaa');
- newFile('/aaa/.packages', content: '''
+ newDotPackagesFile('/aaa', content: '''
aaa:${toUri('/aaa/lib')}
bbb:${toUri('/bbb/lib')}
''');
@@ -160,7 +160,7 @@
''');
newFolder('/bbb');
- newFile('/bbb/.packages', content: '''
+ newDotPackagesFile('/bbb', content: '''
bbb:${toUri('/bbb/lib')}
''');
newFile('/bbb/lib/target.dart', content: 'class Foo() {}');
diff --git a/pkg/analysis_server/test/lsp/hover_test.dart b/pkg/analysis_server/test/lsp/hover_test.dart
index 9abd77a..19c80c0 100644
--- a/pkg/analysis_server/test/lsp/hover_test.dart
+++ b/pkg/analysis_server/test/lsp/hover_test.dart
@@ -174,6 +174,52 @@
expect(hover!.range, equals(rangeFromMarkers(content)));
}
+ Future<void> test_signatureFormatting_multiLine() async {
+ final content = '''
+ class Foo {
+ Foo(String arg1, String arg2, [String arg3]);
+ }
+
+ main() {
+ var a = Fo^o();
+ }
+ ''';
+
+ await initialize();
+ await openFile(mainFileUri, withoutMarkers(content));
+ final hover = await getHover(mainFileUri, positionFromMarker(content));
+ final contents = _getStringContents(hover!);
+ expect(contents, startsWith('''
+```dart
+(new) Foo Foo(
+ String arg1,
+ String arg2, [
+ String arg3,
+])
+```'''));
+ }
+
+ Future<void> test_signatureFormatting_singleLine() async {
+ final content = '''
+ class Foo {
+ Foo(String a, String b);
+ }
+
+ main() {
+ var a = Fo^o();
+ }
+ ''';
+
+ await initialize();
+ await openFile(mainFileUri, withoutMarkers(content));
+ final hover = await getHover(mainFileUri, positionFromMarker(content));
+ final contents = _getStringContents(hover!);
+ expect(contents, startsWith('''
+```dart
+(new) Foo Foo(String a, String b)
+```'''));
+ }
+
Future<void> test_string_noDocComment() async {
final content = '''
String [[a^bc]];
diff --git a/pkg/analysis_server/test/lsp/semantic_tokens_test.dart b/pkg/analysis_server/test/lsp/semantic_tokens_test.dart
index 1a7a8c2..c688729 100644
--- a/pkg/analysis_server/test/lsp/semantic_tokens_test.dart
+++ b/pkg/analysis_server/test/lsp/semantic_tokens_test.dart
@@ -297,13 +297,15 @@
[SemanticTokenModifiers.documentation]),
_Token('@', CustomSemanticTokenTypes.annotation),
_Token('override', SemanticTokenTypes.property),
- _Token('void', SemanticTokenTypes.keyword),
+ _Token('void', SemanticTokenTypes.keyword,
+ [CustomSemanticTokenModifiers.void_]),
_Token('myMethod', SemanticTokenTypes.method,
[SemanticTokenModifiers.declaration]),
_Token('/// static method docs', SemanticTokenTypes.comment,
[SemanticTokenModifiers.documentation]),
_Token('static', SemanticTokenTypes.keyword),
- _Token('void', SemanticTokenTypes.keyword),
+ _Token('void', SemanticTokenTypes.keyword,
+ [CustomSemanticTokenModifiers.void_]),
_Token('myStaticMethod', SemanticTokenTypes.method,
[SemanticTokenModifiers.declaration, SemanticTokenModifiers.static]),
_Token('// static method comment', SemanticTokenTypes.comment),
@@ -492,7 +494,8 @@
''';
final expected = [
- _Token('void', SemanticTokenTypes.keyword),
+ _Token('void', SemanticTokenTypes.keyword,
+ [CustomSemanticTokenModifiers.void_]),
_Token('main', SemanticTokenTypes.function,
[SemanticTokenModifiers.declaration, SemanticTokenModifiers.static]),
_Token('async', SemanticTokenTypes.keyword,
diff --git a/pkg/analysis_server/test/search/type_hierarchy_test.dart b/pkg/analysis_server/test/search/type_hierarchy_test.dart
index b257f54..4c54acd 100644
--- a/pkg/analysis_server/test/search/type_hierarchy_test.dart
+++ b/pkg/analysis_server/test/search/type_hierarchy_test.dart
@@ -166,10 +166,10 @@
class A {}
class B extends A {}
''');
- newFile('/packages/pkgA/.packages',
+ newDotPackagesFile('/packages/pkgA',
content: 'pkgA:${toUriStr('/packages/pkgA/lib')}');
// reference the package from a project
- newFile('$projectPath/.packages',
+ newDotPackagesFile(projectPath,
content: 'pkgA:${toUriStr('/packages/pkgA/lib')}');
addTestFile('''
import 'package:pkgA/libA.dart';
diff --git a/pkg/analysis_server/test/services/completion/dart/relevance/named_argument_test.dart b/pkg/analysis_server/test/services/completion/dart/relevance/named_argument_test.dart
index ff02ed2..beb0563 100644
--- a/pkg/analysis_server/test/services/completion/dart/relevance/named_argument_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/relevance/named_argument_test.dart
@@ -22,7 +22,7 @@
var metaLibFolder = MockPackages.instance.addMeta(resourceProvider);
- newFile('$projectPath/.packages', content: '''
+ newDotPackagesFile(projectPath, content: '''
meta:${metaLibFolder.toUri()}
project:${toUri('$projectPath/lib')}
''');
diff --git a/pkg/analysis_server/test/src/domains/completion/available_suggestions_base.dart b/pkg/analysis_server/test/src/domains/completion/available_suggestions_base.dart
index d9417a4..6172336 100644
--- a/pkg/analysis_server/test/src/domains/completion/available_suggestions_base.dart
+++ b/pkg/analysis_server/test/src/domains/completion/available_suggestions_base.dart
@@ -78,7 +78,7 @@
testFile = convertPath('/home/test/lib/test.dart');
newPubspecYamlFile('/home/test', '');
- newFile('/home/test/.packages', content: '''
+ newDotPackagesFile('/home/test', content: '''
test:${toUri('/home/test/lib')}
''');
diff --git a/pkg/analysis_server/test/src/domains/flutter/base.dart b/pkg/analysis_server/test/src/domains/flutter/base.dart
index 2cadf8b..0ab812c 100644
--- a/pkg/analysis_server/test/src/domains/flutter/base.dart
+++ b/pkg/analysis_server/test/src/domains/flutter/base.dart
@@ -44,7 +44,7 @@
testFile = convertPath('/home/test/lib/test.dart');
newPubspecYamlFile('/home/test', '');
- newFile('/home/test/.packages', content: '''
+ newDotPackagesFile('/home/test', content: '''
test:${toUri('/home/test/lib')}
''');
diff --git a/pkg/analysis_server/test/src/flutter/flutter_outline_notification_test.dart b/pkg/analysis_server/test/src/flutter/flutter_outline_notification_test.dart
index 6d57e25..df54552 100644
--- a/pkg/analysis_server/test/src/flutter/flutter_outline_notification_test.dart
+++ b/pkg/analysis_server/test/src/flutter/flutter_outline_notification_test.dart
@@ -72,7 +72,7 @@
}
Future<void> test_children() async {
- newFile('$projectPath/.packages', content: '''
+ newDotPackagesFile(projectPath, content: '''
flutter:${flutterFolder.toUri()}
''');
newFile('$projectPath/analysis_options.yaml', content: '''
diff --git a/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart b/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
index 39e4ddc..ffb6492 100644
--- a/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
+++ b/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
@@ -480,7 +480,7 @@
//
var pluginDirPath = newFolder('/plugin').path;
var pluginFilePath = newFile('/plugin/bin/plugin.dart').path;
- var packagesFilePath = newFile('/plugin/.packages').path;
+ var packagesFilePath = newDotPackagesFile('/plugin').path;
//
// Test path computation.
//
diff --git a/pkg/analysis_server/test/src/services/correction/fix/analysis_options/test_support.dart b/pkg/analysis_server/test/src/services/correction/fix/analysis_options/test_support.dart
index b9569d4..6090ba5 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/analysis_options/test_support.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/analysis_options/test_support.dart
@@ -36,7 +36,11 @@
var optionsFile = getFile('/analysis_options.yaml');
var sourceFactory = SourceFactory([]);
var errors = analyzeAnalysisOptions(
- optionsFile.createSource(), content, sourceFactory);
+ optionsFile.createSource(),
+ content,
+ sourceFactory,
+ '/',
+ );
expect(errors, hasLength(1));
var error = errors[0];
var options = _parseYaml(content);
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_file_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_file_test.dart
index 0c156d3..5f328c6 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_file_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_file_test.dart
@@ -20,6 +20,24 @@
@override
FixKind get kind => DartFixKind.CREATE_FILE;
+ Future<void> test_forExport() async {
+ await resolveTestCode('''
+export 'my_file.dart';
+''');
+ await assertHasFixWithoutApplying();
+ // validate change
+ var fileEdits = change.edits;
+ expect(fileEdits, hasLength(1));
+ var fileEdit = change.edits[0];
+ expect(fileEdit.file, convertPath('/home/test/lib/my_file.dart'));
+ expect(fileEdit.fileStamp, -1);
+ expect(fileEdit.edits, hasLength(1));
+ expect(
+ fileEdit.edits[0].replacement,
+ contains('// TODO Implement this library.'),
+ );
+ }
+
Future<void> test_forImport() async {
await resolveTestCode('''
import 'my_file.dart';
diff --git a/pkg/analyzer/lib/dart/analysis/context_root.dart b/pkg/analyzer/lib/dart/analysis/context_root.dart
index fc6862b..0e3e4cf5 100644
--- a/pkg/analyzer/lib/dart/analysis/context_root.dart
+++ b/pkg/analyzer/lib/dart/analysis/context_root.dart
@@ -35,7 +35,7 @@
File? get optionsFile;
/// The packages file that should be used when analyzing the files within this
- /// context root, or `null` if there is no options file.
+ /// context root, or `null` if there is no packages file.
File? get packagesFile;
/// The resource provider used to access the file system.
diff --git a/pkg/analyzer/lib/dart/element/element.dart b/pkg/analyzer/lib/dart/element/element.dart
index 236df2f..96d810b 100644
--- a/pkg/analyzer/lib/dart/element/element.dart
+++ b/pkg/analyzer/lib/dart/element/element.dart
@@ -686,9 +686,16 @@
/// If [withNullability] is `false`, nullability suffixes will not be
/// included into the presentation.
///
+ /// If [multiline] is `true`, the string may be wrapped over multiple lines
+ /// with newlines to improve formatting. For example function signatures may
+ /// be formatted as if they had trailing commas.
+ ///
/// Clients should not depend on the content of the returned value as it will
/// be changed if doing so would improve the UX.
- String getDisplayString({required bool withNullability});
+ String getDisplayString({
+ required bool withNullability,
+ bool multiline = false,
+ });
/// Return a display name for the given element that includes the path to the
/// compilation unit in which the type is defined. If [shortName] is `null`
diff --git a/pkg/analyzer/lib/src/analysis_options/error/option_codes.dart b/pkg/analyzer/lib/src/analysis_options/error/option_codes.dart
index 2b47fc1..33ea055 100644
--- a/pkg/analyzer/lib/src/analysis_options/error/option_codes.dart
+++ b/pkg/analyzer/lib/src/analysis_options/error/option_codes.dart
@@ -101,9 +101,10 @@
/// Parameters:
/// 0: the uri of the file to be included
/// 1: the path of the file containing the include directive
+ /// 2: the path of the context being analyzed
static const AnalysisOptionsWarningCode INCLUDE_FILE_NOT_FOUND =
AnalysisOptionsWarningCode('INCLUDE_FILE_NOT_FOUND',
- "The include file {0} in {1} cannot be found.");
+ "The include file '{0}' in '{1}' can't be found when analyzing '{2}'.");
/// An error code indicating a specified include file has a warning.
///
diff --git a/pkg/analyzer/lib/src/dart/element/display_string_builder.dart b/pkg/analyzer/lib/src/dart/element/display_string_builder.dart
index c5adcb6..612db53 100644
--- a/pkg/analyzer/lib/src/dart/element/display_string_builder.dart
+++ b/pkg/analyzer/lib/src/dart/element/display_string_builder.dart
@@ -16,10 +16,12 @@
final bool skipAllDynamicArguments;
final bool withNullability;
+ final bool multiline;
ElementDisplayStringBuilder({
required this.skipAllDynamicArguments,
required this.withNullability,
+ this.multiline = false,
});
@override
@@ -61,7 +63,11 @@
_write(element.displayName);
}
- _writeFormalParameters(element.parameters, forElement: true);
+ _writeFormalParameters(
+ element.parameters,
+ forElement: true,
+ allowMultiline: true,
+ );
}
void writeDynamicType() {
@@ -81,7 +87,11 @@
if (element.kind != ElementKind.GETTER) {
_writeTypeParameters(element.typeParameters);
- _writeFormalParameters(element.parameters, forElement: true);
+ _writeFormalParameters(
+ element.parameters,
+ forElement: true,
+ allowMultiline: true,
+ );
}
}
@@ -222,15 +232,34 @@
void _writeFormalParameters(
List<ParameterElement> parameters, {
required bool forElement,
+ bool allowMultiline = false,
}) {
+ // Assume the display string looks better wrapped when there are at least
+ // three parameters. This avoids having to pre-compute the single-line
+ // version and know the length of the function name/return type.
+ var multiline = allowMultiline && this.multiline && parameters.length >= 3;
+
+ // The prefix for open groups is included in seperator for single-line but
+ // not for multline so must be added explicitly.
+ var openGroupPrefix = multiline ? ' ' : '';
+ var separator = multiline ? ',' : ', ';
+ var trailingComma = multiline ? ',\n' : '';
+ var parameterPrefix = multiline ? '\n ' : '';
+
_write('(');
- var lastKind = _WriteFormalParameterKind.requiredPositional;
+ _WriteFormalParameterKind? lastKind;
var lastClose = '';
void openGroup(_WriteFormalParameterKind kind, String open, String close) {
if (lastKind != kind) {
_write(lastClose);
+ if (lastKind != null) {
+ // We only need to include the space before the open group if there
+ // was a previous parameter, otherwise it goes immediately after the
+ // open paren.
+ _write(openGroupPrefix);
+ }
_write(open);
lastKind = kind;
lastClose = close;
@@ -239,7 +268,7 @@
for (var i = 0; i < parameters.length; i++) {
if (i != 0) {
- _write(', ');
+ _write(separator);
}
var parameter = parameters[i];
@@ -250,9 +279,11 @@
} else if (parameter.isNamed) {
openGroup(_WriteFormalParameterKind.named, '{', '}');
}
+ _write(parameterPrefix);
_writeWithoutDelimiters(parameter, forElement: forElement);
}
+ _write(trailingComma);
_write(lastClose);
_write(')');
}
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 2a32921..2735e16 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -2390,10 +2390,14 @@
}
@override
- String getDisplayString({required bool withNullability}) {
+ String getDisplayString({
+ required bool withNullability,
+ bool multiline = false,
+ }) {
var builder = ElementDisplayStringBuilder(
skipAllDynamicArguments: false,
withNullability: withNullability,
+ multiline: multiline,
);
appendTo(builder);
return builder.toString();
@@ -4405,7 +4409,10 @@
visitor.visitMultiplyDefinedElement(this);
@override
- String getDisplayString({required bool withNullability}) {
+ String getDisplayString({
+ required bool withNullability,
+ bool multiline = false,
+ }) {
var elementsStr = conflictingElements.map((e) {
return e.getDisplayString(
withNullability: withNullability,
diff --git a/pkg/analyzer/lib/src/dart/element/member.dart b/pkg/analyzer/lib/src/dart/element/member.dart
index 0cb160f..119513f 100644
--- a/pkg/analyzer/lib/src/dart/element/member.dart
+++ b/pkg/analyzer/lib/src/dart/element/member.dart
@@ -576,10 +576,14 @@
void appendTo(ElementDisplayStringBuilder builder);
@override
- String getDisplayString({required bool withNullability}) {
+ String getDisplayString({
+ required bool withNullability,
+ bool multiline = false,
+ }) {
var builder = ElementDisplayStringBuilder(
skipAllDynamicArguments: false,
withNullability: withNullability,
+ multiline: multiline,
);
appendTo(builder);
return builder.toString();
diff --git a/pkg/analyzer/lib/src/dart/error/hint_codes.dart b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
index 05e7152..1d0d7d2 100644
--- a/pkg/analyzer/lib/src/dart/error/hint_codes.dart
+++ b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
@@ -307,11 +307,12 @@
hasPublishedDocs: true);
/**
- * `Function` should not be extended anymore.
+ * No parameters.
*/
static const HintCode DEPRECATED_EXTENDS_FUNCTION = HintCode(
- 'DEPRECATED_EXTENDS_FUNCTION', "Extending 'Function' is deprecated.",
- correction: "Try removing 'Function' from the 'extends' clause.");
+ 'DEPRECATED_SUBTYPE_OF_FUNCTION', "Extending 'Function' is deprecated.",
+ correction: "Try removing 'Function' from the 'extends' clause.",
+ uniqueName: 'DEPRECATED_EXTENDS_FUNCTION');
/**
* Users should not create a class named `Function` anymore.
@@ -322,13 +323,13 @@
correction: "Try renaming the class.");
/**
- * According to the specification: If a class or mixin declaration implements
- * Function, it has no effect.
+ * No parameters.
*/
static const HintCode DEPRECATED_IMPLEMENTS_FUNCTION = HintCode(
- 'DEPRECATED_IMPLEMENTS_FUNCTION',
+ 'DEPRECATED_SUBTYPE_OF_FUNCTION',
"Implementing 'Function' has no effect.",
- correction: "Try removing 'Function' from the 'implements' clause.");
+ correction: "Try removing 'Function' from the 'implements' clause.",
+ uniqueName: 'DEPRECATED_IMPLEMENTS_FUNCTION');
/**
* Parameters:
@@ -421,11 +422,12 @@
);
/**
- * `Function` should not be mixed in anymore.
+ * No parameters.
*/
static const HintCode DEPRECATED_MIXIN_FUNCTION = HintCode(
- 'DEPRECATED_MIXIN_FUNCTION', "Mixing in 'Function' is deprecated.",
- correction: "Try removing 'Function' from the 'with' clause.");
+ 'DEPRECATED_SUBTYPE_OF_FUNCTION', "Mixing in 'Function' is deprecated.",
+ correction: "Try removing 'Function' from the 'with' clause.",
+ uniqueName: 'DEPRECATED_MIXIN_FUNCTION');
/**
* Hint to use the ~/ operator.
diff --git a/pkg/analyzer/lib/src/task/options.dart b/pkg/analyzer/lib/src/task/options.dart
index 5110041..28b4452 100644
--- a/pkg/analyzer/lib/src/task/options.dart
+++ b/pkg/analyzer/lib/src/task/options.dart
@@ -26,7 +26,11 @@
final _OptionsProcessor _processor = _OptionsProcessor();
List<AnalysisError> analyzeAnalysisOptions(
- Source source, String content, SourceFactory sourceFactory) {
+ Source source,
+ String content,
+ SourceFactory sourceFactory,
+ String contextRoot,
+) {
List<AnalysisError> errors = <AnalysisError>[];
Source initialSource = source;
SourceSpan? initialIncludeSpan;
@@ -70,7 +74,7 @@
initialIncludeSpan!.start.offset,
initialIncludeSpan!.length,
AnalysisOptionsWarningCode.INCLUDE_FILE_NOT_FOUND,
- [includeUri, source.fullName]));
+ [includeUri, source.fullName, contextRoot]));
return;
}
try {
diff --git a/pkg/analyzer/test/generated/elements_types_mixin.dart b/pkg/analyzer/test/generated/elements_types_mixin.dart
index 68e092a..2933f98 100644
--- a/pkg/analyzer/test/generated/elements_types_mixin.dart
+++ b/pkg/analyzer/test/generated/elements_types_mixin.dart
@@ -496,11 +496,13 @@
String? name,
required DartType type,
bool isCovariant = false,
+ String? defaultValueCode,
}) {
var parameter = ParameterElementImpl(name ?? '', 0);
parameter.parameterKind = ParameterKind.POSITIONAL;
parameter.type = type;
parameter.isExplicitlyCovariant = isCovariant;
+ parameter.defaultValueCode = defaultValueCode;
return parameter;
}
diff --git a/pkg/analyzer/test/src/context/builder_test.dart b/pkg/analyzer/test/src/context/builder_test.dart
index 727364a..e439283 100644
--- a/pkg/analyzer/test/src/context/builder_test.dart
+++ b/pkg/analyzer/test/src/context/builder_test.dart
@@ -266,7 +266,7 @@
}
void test_createWorkspace_hasPackagesFile_hasDartToolAndPubspec() {
- newFile('/workspace/.packages');
+ newDotPackagesFile('/workspace');
newFolder('/workspace/.dart_tool/build/generated/project/lib');
newPubspecYamlFile('/workspace', 'name: project');
Workspace workspace = _createWorkspace('/workspace/project/lib/lib.dart');
@@ -274,14 +274,14 @@
}
void test_createWorkspace_hasPackagesFile_hasPubspec() {
- newFile('/workspace/.packages');
+ newDotPackagesFile('/workspace');
newPubspecYamlFile('/workspace', 'name: project');
Workspace workspace = _createWorkspace('/workspace/project/lib/lib.dart');
expect(workspace, TypeMatcher<PubWorkspace>());
}
void test_createWorkspace_hasPackagesFile_noMarkerFiles() {
- newFile('/workspace/.packages');
+ newDotPackagesFile('/workspace');
Workspace workspace = _createWorkspace('/workspace/project/lib/lib.dart');
expect(workspace, TypeMatcher<BasicWorkspace>());
}
diff --git a/pkg/analyzer/test/src/context/packages_test.dart b/pkg/analyzer/test/src/context/packages_test.dart
index 792753b..17cef59 100644
--- a/pkg/analyzer/test/src/context/packages_test.dart
+++ b/pkg/analyzer/test/src/context/packages_test.dart
@@ -21,7 +21,7 @@
}
void test_findPackagesFrom_fallbackToDotPackages() {
- newFile('/test/.packages', content: '''
+ newDotPackagesFile('/test', content: '''
test:lib/
bbb:${toUriStr('/packages/bbb/lib')}
''');
@@ -76,7 +76,7 @@
}
''');
- newFile('/test/.packages', content: '''
+ newDotPackagesFile('/test', content: '''
test:lib/
bbb:${toUriStr('/packages/bbb/lib')}
''');
@@ -138,7 +138,7 @@
}
test_parseDotPackagesFile() {
- var file = newFile('/test/.packages', content: '''
+ var file = newDotPackagesFile('/test', content: '''
# Generated by pub
aaa:${toUriStr('/packages/aaa/lib/')}
test:lib/
@@ -210,12 +210,11 @@
}
test_parsePackagesFile_dotPackages() {
- var path = convertPath('/test/.packages');
- newFile(path, content: '''
+ var dotPackagesFile = newDotPackagesFile('/test', content: '''
bbb:${toUriStr('/packages/bbb/lib')}
''');
- var packages = parsePackagesFile(resourceProvider, getFile(path));
+ var packages = parsePackagesFile(resourceProvider, dotPackagesFile);
_assertPackage(
packages,
@@ -266,14 +265,13 @@
}
''');
- var dotPackagesPath = '/test/.packages';
- newFile(dotPackagesPath, content: '''
+ var dotPackagesFile = newDotPackagesFile('/test', content: '''
bbb:${toUriStr('/packages/bbb/lib')}
''');
var packages = parsePackagesFile(
resourceProvider,
- getFile(dotPackagesPath),
+ dotPackagesFile,
);
_assertPackage(
diff --git a/pkg/analyzer/test/src/dart/analysis/session_test.dart b/pkg/analyzer/test/src/dart/analysis/session_test.dart
index 26d4849..b560691 100644
--- a/pkg/analyzer/test/src/dart/analysis/session_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/session_test.dart
@@ -233,7 +233,7 @@
aaaContextPath = newFolder('/home/aaa').path;
bbbContextPath = newFolder('/home/bbb').path;
- newFile('/home/test/.packages', content: r'''
+ newDotPackagesFile('/home/test', content: r'''
test:lib/
''');
diff --git a/pkg/analyzer/test/src/dart/element/display_string_test.dart b/pkg/analyzer/test/src/dart/element/display_string_test.dart
new file mode 100644
index 0000000..e5f4644
--- /dev/null
+++ b/pkg/analyzer/test/src/dart/element/display_string_test.dart
@@ -0,0 +1,126 @@
+// 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.
+
+import 'package:analyzer/dart/element/type_provider.dart';
+import 'package:analyzer/src/dart/element/element.dart';
+import 'package:analyzer/src/dart/element/type_system.dart';
+import 'package:test/test.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../../../generated/elements_types_mixin.dart';
+import '../../../generated/test_analysis_context.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(ElementDisplayStringTest);
+ });
+}
+
+@reflectiveTest
+class ElementDisplayStringTest with ElementsTypesMixin {
+ late final TestAnalysisContext _analysisContext;
+
+ @override
+ late final LibraryElementImpl testLibrary;
+
+ @override
+ late final TypeProvider typeProvider;
+
+ late final TypeSystemImpl typeSystem;
+
+ void setUp() {
+ _analysisContext = TestAnalysisContext();
+ typeProvider = _analysisContext.typeProviderLegacy;
+ typeSystem = _analysisContext.typeSystemLegacy;
+
+ testLibrary = library_(
+ uriStr: 'package:test/test.dart',
+ analysisContext: _analysisContext,
+ analysisSession: _analysisContext.analysisSession,
+ typeSystem: typeSystem,
+ );
+ }
+
+ void test_longMethod() {
+ final methodA = method(
+ 'longMethodName',
+ stringQuestion,
+ parameters: [
+ requiredParameter(name: 'aaa', type: stringQuestion),
+ positionalParameter(
+ name: 'bbb', type: stringQuestion, defaultValueCode: "'a'"),
+ positionalParameter(name: 'ccc', type: stringQuestion),
+ ],
+ );
+
+ final singleLine = methodA.getDisplayString(withNullability: true);
+ expect(singleLine, '''
+String? longMethodName(String? aaa, [String? bbb = 'a', String? ccc])''');
+
+ final multiLine =
+ methodA.getDisplayString(withNullability: true, multiline: true);
+ expect(multiLine, '''
+String? longMethodName(
+ String? aaa, [
+ String? bbb = 'a',
+ String? ccc,
+])''');
+ }
+
+ void test_longMethod_functionType() {
+ // Function types are always kept on one line, even nested within multiline
+ // signatures.
+ final methodA = method(
+ 'longMethodName',
+ stringQuestion,
+ parameters: [
+ requiredParameter(name: 'aaa', type: stringQuestion),
+ positionalParameter(
+ name: 'bbb',
+ type: functionTypeNone(
+ parameters: [
+ requiredParameter(name: 'xxx', type: stringQuestion),
+ requiredParameter(name: 'yyy', type: stringQuestion),
+ requiredParameter(name: 'zzz', type: stringQuestion),
+ ],
+ returnType: stringQuestion,
+ )),
+ positionalParameter(name: 'ccc', type: stringQuestion),
+ ],
+ );
+
+ final singleLine = methodA.getDisplayString(withNullability: true);
+ expect(singleLine, '''
+String? longMethodName(String? aaa, [String? Function(String?, String?, String?) bbb, String? ccc])''');
+
+ final multiLine =
+ methodA.getDisplayString(withNullability: true, multiline: true);
+ expect(multiLine, '''
+String? longMethodName(
+ String? aaa, [
+ String? Function(String?, String?, String?) bbb,
+ String? ccc,
+])''');
+ }
+
+ void test_shortMethod() {
+ final methodA = method(
+ 'm',
+ stringQuestion,
+ parameters: [
+ requiredParameter(name: 'a', type: stringQuestion),
+ positionalParameter(name: 'b', type: stringQuestion),
+ ],
+ );
+
+ final singleLine = methodA.getDisplayString(withNullability: true);
+ expect(singleLine, 'String? m(String? a, [String? b])');
+
+ final multiLine =
+ methodA.getDisplayString(withNullability: true, multiline: true);
+ // The signature is short enough that it remains on one line even for
+ // multiline: true.
+ expect(multiLine, 'String? m(String? a, [String? b])');
+ }
+}
diff --git a/pkg/analyzer/test/src/dart/element/test_all.dart b/pkg/analyzer/test/src/dart/element/test_all.dart
index f86065c..980299f 100644
--- a/pkg/analyzer/test/src/dart/element/test_all.dart
+++ b/pkg/analyzer/test/src/dart/element/test_all.dart
@@ -5,6 +5,7 @@
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'class_hierarchy_test.dart' as class_hierarchy;
+import 'display_string_test.dart' as display_string;
import 'element_test.dart' as element;
import 'factor_type_test.dart' as factor_type;
import 'flatten_type_test.dart' as flatten_type;
@@ -34,6 +35,7 @@
main() {
defineReflectiveSuite(() {
class_hierarchy.main();
+ display_string.main();
element.main();
factor_type.main();
flatten_type.main();
diff --git a/pkg/analyzer/test/src/dart/resolution/metadata_test.dart b/pkg/analyzer/test/src/dart/resolution/metadata_test.dart
index 39c6c92..07af5c1 100644
--- a/pkg/analyzer/test/src/dart/resolution/metadata_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/metadata_test.dart
@@ -50,6 +50,8 @@
IntegerLiteral
literal: 0
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
constructorName: ConstructorName
staticElement: self::@class::A::@constructor::•
type: TypeName
@@ -59,6 +61,9 @@
token: A
type: A
staticType: A
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 80
element: self::@class::A::@constructor::•
name: SimpleIdentifier
staticElement: self::@class::A
@@ -344,6 +349,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 53
element: self::@class::A::@constructor::named
name: PrefixedIdentifier
identifier: SimpleIdentifier
@@ -382,6 +390,7 @@
var annotation = findNode.annotation('@A');
_assertResolvedNodeText(annotation, r'''
Annotation
+ atSign.offset: 42
element: self::@class::A::@getter::foo
name: PrefixedIdentifier
identifier: SimpleIdentifier
@@ -420,6 +429,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 48
element: self::@class::A::@constructor::•
name: SimpleIdentifier
staticElement: self::@class::A
@@ -456,6 +468,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 54
element: ConstructorMember
base: self::@class::A::@constructor::named
substitution: {T: int}
@@ -506,6 +521,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 49
element: ConstructorMember
base: self::@class::A::@constructor::•
substitution: {T: int}
@@ -537,6 +555,7 @@
_assertResolvedNodeText(findNode.annotation('@A'), r'''
Annotation
+ atSign.offset: 31
element: self::@class::A::@getter::foo
name: PrefixedIdentifier
identifier: SimpleIdentifier
@@ -572,6 +591,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 56
element: ConstructorMember
base: self::@class::A::@constructor::named
substitution: {T: dynamic}
@@ -611,6 +633,7 @@
var annotation = findNode.annotation('@A');
_assertResolvedNodeText(annotation, r'''
Annotation
+ atSign.offset: 38
element: self::@class::A::@getter::foo
name: PrefixedIdentifier
identifier: SimpleIdentifier
@@ -649,6 +672,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 54
constructorName: SimpleIdentifier
staticElement: ConstructorMember
base: self::@class::A::@constructor::named
@@ -670,6 +696,8 @@
staticType: null
token: int
type: int
+ leftBracket: <
+ rightBracket: >
''');
_assertAnnotationValueText(annotation, '''
A<int>
@@ -701,6 +729,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 49
element: ConstructorMember
base: self::@class::A::@constructor::•
substitution: {T: int}
@@ -716,6 +747,8 @@
staticType: null
token: int
type: int
+ leftBracket: <
+ rightBracket: >
''');
_assertAnnotationValueText(annotation, r'''
A<int>
@@ -748,6 +781,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 48
element: ConstructorMember
base: self::@class::A::@constructor::•
substitution: {T: dynamic}
@@ -790,6 +826,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 88
element: ConstructorMember
base: self::@class::B::@constructor::•
substitution: {T: int}
@@ -828,6 +867,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 88
element: ConstructorMember
base: self::@class::B::@constructor::•
substitution: {T: int}
@@ -843,6 +885,8 @@
staticType: null
token: int
type: int
+ leftBracket: <
+ rightBracket: >
''');
_assertAnnotationValueText(annotation, r'''
B<int>
@@ -958,6 +1002,7 @@
var annotation = findNode.annotation('@prefix.B');
_assertResolvedNodeText(annotation, r'''
Annotation
+ atSign.offset: 28
constructorName: SimpleIdentifier
staticElement: package:test/a.dart::@class::A::@getter::foo
staticType: null
@@ -1005,6 +1050,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 28
constructorName: SimpleIdentifier
staticElement: ConstructorMember
base: package:test/a.dart::@class::A::@constructor::named
@@ -1063,6 +1111,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 28
element: ConstructorMember
base: package:test/a.dart::@class::A::@constructor::•
substitution: {T: int}
@@ -1115,6 +1166,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 28
constructorName: SimpleIdentifier
staticElement: ConstructorMember
base: package:test/a.dart::@class::A::@constructor::named
@@ -1144,6 +1198,8 @@
staticType: null
token: int
type: int
+ leftBracket: <
+ rightBracket: >
''');
_assertAnnotationValueText(annotation, r'''
A<int>
@@ -1181,6 +1237,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 28
element: ConstructorMember
base: package:test/a.dart::@class::A::@constructor::•
substitution: {T: int}
@@ -1204,6 +1263,8 @@
staticType: null
token: int
type: int
+ leftBracket: <
+ rightBracket: >
''');
_assertAnnotationValueText(annotation, r'''
A<int>
@@ -1232,6 +1293,7 @@
var annotation = findNode.annotation('@B');
_assertResolvedNodeText(annotation, r'''
Annotation
+ atSign.offset: 58
element: self::@class::A::@getter::foo
name: PrefixedIdentifier
identifier: SimpleIdentifier
@@ -1276,6 +1338,9 @@
DoubleLiteral
literal: 1.2
staticType: double
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 108
constructorName: SimpleIdentifier
staticElement: ConstructorMember
base: self::@class::A::@constructor::named
@@ -1297,6 +1362,8 @@
staticType: null
token: int
type: int
+ leftBracket: <
+ rightBracket: >
''');
_assertAnnotationValueText(annotation, r'''
A<int, double>
@@ -1342,6 +1409,9 @@
DoubleLiteral
literal: 1.2
staticType: double
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 102
element: ConstructorMember
base: self::@class::A::@constructor::•
substitution: {T: int, U: double}
@@ -1357,6 +1427,8 @@
staticType: null
token: int
type: int
+ leftBracket: <
+ rightBracket: >
''');
_assertAnnotationValueText(annotation, r'''
A<int, double>
@@ -1398,6 +1470,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 76
element: ConstructorMember
base: self::@class::A::@constructor::named
substitution: {T: int}
@@ -1451,6 +1526,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 70
element: ConstructorMember
base: self::@class::A::@constructor::•
substitution: {T: int}
@@ -1492,6 +1570,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 76
constructorName: SimpleIdentifier
staticElement: ConstructorMember
base: self::@class::A::@constructor::named
@@ -1513,6 +1594,8 @@
staticType: null
token: int
type: int
+ leftBracket: <
+ rightBracket: >
''');
_assertAnnotationValueText(annotation, r'''
A<int>
@@ -1547,6 +1630,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 70
element: ConstructorMember
base: self::@class::A::@constructor::•
substitution: {T: int}
@@ -1562,6 +1648,8 @@
staticType: null
token: int
type: int
+ leftBracket: <
+ rightBracket: >
''');
_assertAnnotationValueText(annotation, r'''
A<int>
@@ -1596,6 +1684,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 75
element: ConstructorMember
base: self::@class::A::@constructor::named
substitution: {T: int}
@@ -1649,6 +1740,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 69
element: ConstructorMember
base: self::@class::A::@constructor::•
substitution: {T: int}
@@ -1690,6 +1784,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 69
element: self::@class::A::@constructor::named
name: PrefixedIdentifier
identifier: SimpleIdentifier
@@ -1736,6 +1833,9 @@
IntegerLiteral
literal: 42
staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign.offset: 63
element: self::@class::A::@constructor::•
name: SimpleIdentifier
staticElement: self::@typeAlias::B
diff --git a/pkg/analyzer/test/src/diagnostics/analysis_options/analysis_options_test_support.dart b/pkg/analyzer/test/src/diagnostics/analysis_options/analysis_options_test_support.dart
index 900fd85..e0432e0 100644
--- a/pkg/analyzer/test/src/diagnostics/analysis_options/analysis_options_test_support.dart
+++ b/pkg/analyzer/test/src/diagnostics/analysis_options/analysis_options_test_support.dart
@@ -12,7 +12,7 @@
Future<void> assertErrorsInCode(
String code, List<ExpectedError> expectedErrors) async {
var diagnostics =
- analyzeAnalysisOptions(TestSource(), code, SourceFactory([]));
+ analyzeAnalysisOptions(TestSource(), code, SourceFactory([]), '/');
var errorListener = GatheringErrorListener();
errorListener.addAll(diagnostics);
errorListener.assertErrors(expectedErrors);
diff --git a/pkg/analyzer/test/src/diagnostics/analysis_options/include_file_not_found.dart b/pkg/analyzer/test/src/diagnostics/analysis_options/include_file_not_found_test.dart
similarity index 74%
rename from pkg/analyzer/test/src/diagnostics/analysis_options/include_file_not_found.dart
rename to pkg/analyzer/test/src/diagnostics/analysis_options/include_file_not_found_test.dart
index 976fc62..17df357 100644
--- a/pkg/analyzer/test/src/diagnostics/analysis_options/include_file_not_found.dart
+++ b/pkg/analyzer/test/src/diagnostics/analysis_options/include_file_not_found_test.dart
@@ -19,6 +19,14 @@
assertErrorsInCode('''
# We don't depend on pedantic, but we should consider adding it.
include: package:pedantic/analysis_options.yaml
-''', [error(AnalysisOptionsWarningCode.INCLUDE_FILE_NOT_FOUND, 74, 38)]);
+''', [
+ error(
+ AnalysisOptionsWarningCode.INCLUDE_FILE_NOT_FOUND,
+ 74,
+ 38,
+ text: "The include file 'package:pedantic/analysis_options.yaml'"
+ " in '/test.dart' can't be found when analyzing '/'.",
+ )
+ ]);
}
}
diff --git a/pkg/analyzer/test/src/diagnostics/analysis_options/test_all.dart b/pkg/analyzer/test/src/diagnostics/analysis_options/test_all.dart
new file mode 100644
index 0000000..4793f87
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/analysis_options/test_all.dart
@@ -0,0 +1,13 @@
+// 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.
+
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import 'include_file_not_found_test.dart' as include_file_not_found_test;
+
+main() {
+ defineReflectiveSuite(() {
+ include_file_not_found_test.main();
+ });
+}
diff --git a/pkg/analyzer/test/src/diagnostics/test_all.dart b/pkg/analyzer/test/src/diagnostics/test_all.dart
index ef8d0f6..ff961d3 100644
--- a/pkg/analyzer/test/src/diagnostics/test_all.dart
+++ b/pkg/analyzer/test/src/diagnostics/test_all.dart
@@ -15,6 +15,7 @@
as ambiguous_extension_member_access;
import 'ambiguous_import_test.dart' as ambiguous_import;
import 'ambiguous_set_or_map_literal_test.dart' as ambiguous_set_or_map_literal;
+import 'analysis_options/test_all.dart' as analysis_options;
import 'annotation_on_pointer_field_test.dart' as annotation_on_pointer_field;
import 'annotation_syntax_test.dart' as annotation_syntax;
import 'argument_must_be_a_constant_test.dart' as argument_must_be_a_constant;
@@ -712,6 +713,7 @@
ambiguous_extension_member_access.main();
ambiguous_import.main();
ambiguous_set_or_map_literal.main();
+ analysis_options.main();
annotation_on_pointer_field.main();
annotation_syntax.main();
argument_must_be_a_constant.main();
diff --git a/pkg/analyzer/test/src/services/available_declarations_test.dart b/pkg/analyzer/test/src/services/available_declarations_test.dart
index 9829096..a2e41c6 100644
--- a/pkg/analyzer/test/src/services/available_declarations_test.dart
+++ b/pkg/analyzer/test/src/services/available_declarations_test.dart
@@ -102,7 +102,7 @@
MockSdk(resourceProvider: resourceProvider);
newFolder('/home/test');
- newFile('/home/test/.packages', content: '''
+ newDotPackagesFile('/home/test', content: '''
test:${toUri('/home/test/lib')}
''');
diff --git a/pkg/analyzer/test/src/summary/element_text.dart b/pkg/analyzer/test/src/summary/element_text.dart
index 0f1dc1b..59a96d7 100644
--- a/pkg/analyzer/test/src/summary/element_text.dart
+++ b/pkg/analyzer/test/src/summary/element_text.dart
@@ -5,13 +5,10 @@
import 'dart:io';
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
-import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/generated/source.dart';
-import 'package:analyzer/src/summary2/reference.dart';
import 'package:analyzer/src/task/inference_error.dart';
import 'package:test/test.dart';
@@ -48,31 +45,13 @@
void checkElementText(
LibraryElement library,
String expected, {
- bool withAliasElementArguments = false,
bool withCodeRanges = false,
- bool withConstElements = true,
bool withExportScope = false,
- bool withOffsets = false,
- bool withResolvedAst = false,
- bool withResolvedAstOffsets = false,
- bool withSyntheticAccessors = false,
- bool withSyntheticFields = false,
- bool withTypes = false,
- bool withTypeParameterVariance = false,
}) {
var writer = _ElementWriter(
selfUriStr: '${library.source.uri}',
- withAliasElementArguments: withAliasElementArguments,
withCodeRanges: withCodeRanges,
- withConstElements: withConstElements,
withExportScope: withExportScope,
- withOffsets: withOffsets,
- withResolvedAst: withResolvedAst,
- withResolvedAstOffsets: withResolvedAstOffsets,
- withSyntheticAccessors: withSyntheticAccessors,
- withSyntheticFields: withSyntheticFields,
- withTypes: withTypes,
- withTypeParameterVariance: withTypeParameterVariance,
);
writer.writeLibraryElement(library);
@@ -134,1075 +113,59 @@
/// Writes the canonical text presentation of elements.
class _ElementWriter {
final String? selfUriStr;
- final bool withAliasElementArguments;
final bool withCodeRanges;
final bool withExportScope;
- final bool withOffsets;
- final bool withResolvedAst;
- final bool withResolvedAstOffsets;
- final bool withConstElements;
- final bool withSyntheticAccessors;
- final bool withSyntheticFields;
- final bool withTypes;
- final bool withTypeParameterVariance;
final StringBuffer buffer = StringBuffer();
String indent = '';
_ElementWriter({
this.selfUriStr,
- this.withAliasElementArguments = false,
this.withCodeRanges = false,
- this.withConstElements = true,
this.withExportScope = false,
- this.withOffsets = false,
- this.withResolvedAst = false,
- this.withResolvedAstOffsets = false,
- this.withSyntheticAccessors = false,
- this.withSyntheticFields = false,
- this.withTypes = false,
- this.withTypeParameterVariance = false,
});
- bool isDynamicType(DartType type) => type is DynamicTypeImpl;
-
- bool isEnumField(Element e) {
- var enclosing = e.enclosingElement;
- return enclosing is ClassElement && enclosing.isEnum;
- }
-
- void newLineIfNotEmpty() {
- if (buffer.isNotEmpty) {
- buffer.writeln();
- }
- }
-
- void writeBodyModifiers(ExecutableElement e) {
- if (e.isAsynchronous) {
- expect(e.isSynchronous, isFalse);
- buffer.write(' async');
- }
-
- if (e.isSynchronous && e.isGenerator) {
- expect(e.isAsynchronous, isFalse);
- buffer.write(' sync');
- }
-
- writeIf(e.isGenerator, '*');
- }
-
- void writeClassElement(ClassElement e) {
- writeDocumentation(e);
- writeMetadata(e, '', '\n');
-
- writeIf(e.isAbstract && !e.isMixin, 'abstract ');
- writeIf(!e.isSimplyBounded, 'notSimplyBounded ');
-
- if (e.isEnum) {
- buffer.write('enum ');
- } else if (e.isMixin) {
- buffer.write('mixin ');
- } else {
- buffer.write('class ');
- }
-
- writeIf(e.isMixinApplication, 'alias ');
-
- writeName(e);
- writeCodeRange(e);
- writeTypeParameterElements(e.typeParameters, withDefault: true);
-
- if (e.supertype != null && e.supertype!.element.name != 'Object' ||
- e.mixins.isNotEmpty) {
- buffer.write(' extends ');
- writeType(e.supertype!);
- }
-
- if (e.isMixin) {
- if (e.superclassConstraints.isEmpty) {
- throw StateError('At least Object is expected.');
- }
- writeList(' on ', '', e.superclassConstraints, ', ', writeType);
- }
-
- writeList(' with ', '', e.mixins, ', ', writeType);
- writeList(' implements ', '', e.interfaces, ', ', writeType);
-
- buffer.writeln(' {');
-
+ void writeLibraryElement(LibraryElement e) {
+ _writelnWithIndent('library');
_withIndent(() {
- e.fields.forEach(writePropertyInducingElement);
- e.accessors.forEach(writePropertyAccessorElement);
-
- if (e.isEnum) {
- expect(e.constructors, isEmpty);
- } else {
- expect(e.constructors, isNotEmpty);
+ var name = e.name;
+ if (name != null && name.isNotEmpty) {
+ _writelnWithIndent('name: $name');
}
- if (e.constructors.length == 1 &&
- e.constructors[0].isSynthetic &&
- e.mixins.isEmpty) {
- expect(e.constructors[0].parameters, isEmpty);
- } else {
- e.constructors.forEach(writeConstructorElement);
+ var nameOffset = e.nameOffset;
+ if (nameOffset != -1) {
+ _writelnWithIndent('nameOffset: $nameOffset');
}
- e.methods.forEach(writeMethodElement);
- });
+ _writeDocumentation(e);
+ _writeMetadata(e);
- buffer.writeln('}');
+ var imports = e.imports.where((import) => !import.isSynthetic).toList();
+ _writeElements('imports', imports, _writeImportElement);
- if (withResolvedAst) {
+ _writeElements('exports', e.exports, _writeExportElement);
+
+ _writelnWithIndent('definingUnit');
_withIndent(() {
- _writeResolvedMetadata(e.metadata);
- _writeResolvedTypeParameters(e.typeParameters);
+ _writeUnitElement(e.definingCompilationUnit);
});
- }
- }
- void writeCodeRange(Element e) {
- if (withCodeRanges) {
- var elementImpl = e as ElementImpl;
- buffer.write('/*codeOffset=');
- buffer.write(elementImpl.codeOffset);
- buffer.write(', codeLength=');
- buffer.write(elementImpl.codeLength);
- buffer.write('*/');
- }
- }
-
- void writeConstructorElement(ConstructorElement e) {
- writeDocumentation(e, ' ');
- writeMetadata(e, ' ', '\n');
-
- buffer.write(' ');
-
- writeIf(e.isSynthetic, 'synthetic ');
- writeIf(e.isExternal, 'external ');
- writeIf(e.isConst, 'const ');
- writeIf(e.isFactory, 'factory ');
- expect(e.isAbstract, isFalse);
-
- buffer.write(e.enclosingElement.name);
- if (e.name.isNotEmpty) {
- buffer.write('.');
- buffer.write(e.displayName);
- }
- if (!e.isSynthetic) {
- writeCodeRange(e);
- if (withOffsets) {
- var periodOffset = e.periodOffset;
- var nameEnd = e.nameEnd;
- if (periodOffset != null && nameEnd != null) {
- buffer.write('[periodOffset: $periodOffset]');
- buffer.write('[nameOffset: ${e.nameOffset}]');
- buffer.write('[nameEnd: $nameEnd]');
- } else {
- buffer.write('[nameOffset: ${e.nameOffset}]');
- }
- }
- }
-
- writeParameterElements(e.parameters);
-
- {
- var redirected = e.redirectedConstructor;
- if (redirected != null) {
- buffer.write(' = ');
- writeType(redirected.returnType);
- if (redirected.name.isNotEmpty) {
- buffer.write('.');
- buffer.write(redirected.name);
- }
- }
- }
-
- var initializers = (e as ConstructorElementImpl).constantInitializers;
- if (withResolvedAst) {
- buffer.writeln(';');
- _withIndent(() {
- _writeResolvedMetadata(e.metadata);
- if (initializers.isNotEmpty) {
- _writelnWithIndent('constantInitializers');
- _withIndent(() {
- for (var initializer in initializers) {
- _writeResolvedNode(initializer);
- }
- });
- }
- _writeParameterElementDefaultValues(e.parameters);
- });
- } else {
- writeList(' : ', '', initializers, ', ', writeNode);
- buffer.writeln(';');
- }
-
- expect(e.isAsynchronous, isFalse);
- expect(e.isGenerator, isFalse);
- }
-
- void writeDocumentation(Element e, [String prefix = '']) {
- var comment = e.documentationComment;
- if (comment != null) {
- if (comment.startsWith('///')) {
- comment = comment.split('\n').join('\n$prefix');
- }
- buffer.write(prefix);
- buffer.writeln(comment);
- }
- }
-
- void writeExportElement(ExportElement e) {
- writeMetadata(e, '', '\n');
- buffer.write('export ');
- writeUri(e.exportedLibrary?.source);
-
- e.combinators.forEach(writeNamespaceCombinator);
-
- buffer.writeln(';');
- }
-
- void writeExportScope(LibraryElement e) {
- if (!withExportScope) return;
-
- buffer.writeln();
- buffer.writeln('-' * 20);
- buffer.writeln('Exports:');
-
- var map = e.exportNamespace.definedNames;
- var names = map.keys.toList()..sort();
- for (var name in names) {
- var element = map[name];
- var elementLocationStr = _getElementLocationString(element);
- buffer.writeln(' $name: $elementLocationStr');
- }
- }
-
- void writeExtensionElement(ExtensionElement e) {
- writeDocumentation(e);
- writeMetadata(e, '', '\n');
-
- buffer.write('extension ');
- writeName(e);
- writeCodeRange(e);
- writeTypeParameterElements(e.typeParameters, withDefault: false);
- buffer.write(' on ');
- writeType(e.extendedType);
-
- buffer.writeln(' {');
-
- _withIndent(() {
- e.fields.forEach(writePropertyInducingElement);
- e.accessors.forEach(writePropertyAccessorElement);
- e.methods.forEach(writeMethodElement);
- });
-
- buffer.writeln('}');
-
- if (withResolvedAst) {
- _withIndent(() {
- _writeResolvedMetadata(e.metadata);
- _writeResolvedTypeParameters(e.typeParameters);
- });
- }
- }
-
- void writeFunctionElement(FunctionElement e) {
- writeDocumentation(e);
- writeMetadata(e, '', '\n');
-
- writeIf(e.isExternal, 'external ');
-
- writeType2(e.returnType);
-
- writeName(e);
- writeCodeRange(e);
-
- writeTypeParameterElements(e.typeParameters, withDefault: false);
- writeParameterElements(e.parameters);
-
- writeBodyModifiers(e);
-
- buffer.writeln(' {}');
-
- if (withResolvedAst) {
- _withIndent(() {
- _writeResolvedTypeParameters(e.typeParameters);
- _writeResolvedMetadata(e.metadata);
- _writeParameterElementDefaultValues(e.parameters);
- });
- }
- }
-
- void writeIf(bool flag, String str) {
- if (flag) {
- buffer.write(str);
- }
- }
-
- void writeImportElement(ImportElement e) {
- if (!e.isSynthetic) {
- writeMetadata(e, '', '\n');
- buffer.write('import ');
- writeUri(e.importedLibrary?.source);
-
- writeIf(e.isDeferred, ' deferred');
-
- var prefix = e.prefix;
- if (prefix != null) {
- buffer.write(' as ');
- writeName(prefix);
- if (withOffsets) {
- buffer.write('(${prefix.nameOffset})');
- }
- }
-
- e.combinators.forEach(writeNamespaceCombinator);
-
- buffer.writeln(';');
-
- if (withResolvedAst) {
+ _writeElements('parts', e.parts, (CompilationUnitElement e) {
+ _writelnWithIndent(e.uri!);
_withIndent(() {
- _writeResolvedMetadata(e.metadata);
+ _writeMetadata(e);
+ _writeUnitElement(e);
+ });
+ });
+
+ if (withExportScope) {
+ _writelnWithIndent('exportScope');
+ _withIndent(() {
+ _writeExportScope(e);
});
}
- }
- }
-
- void writeInterfaceTypeArgsComment(Expression e) {
- var typeArguments = (e.staticType as InterfaceType).typeArguments;
- writeList('/*typeArgs=', '*/', typeArguments, ',', writeType);
- }
-
- void writeLibraryElement(LibraryElement e) {
- if (e.documentationComment != null) {
- buffer.writeln(e.documentationComment);
- }
-
- if (e.displayName != '') {
- writeMetadata(e, '', '\n');
- buffer.write('library ');
- writeName(e);
- buffer.writeln(';');
- }
-
- e.imports.forEach(writeImportElement);
- e.exports.forEach(writeExportElement);
- e.parts.forEach(writePartElement);
-
- e.units.forEach(writeUnitElement);
-
- writeExportScope(e);
- }
-
- void writeList<T>(String open, String close, List<T> items, String separator,
- Function(T item) writeItem,
- {bool includeEmpty = false}) {
- if (!includeEmpty && items.isEmpty) {
- return;
- }
- buffer.write(open);
- bool first = true;
- for (T item in items) {
- if (!first) {
- buffer.write(separator);
- }
- writeItem(item);
- first = false;
- }
- buffer.write(close);
- }
-
- void writeMetadata(Element e, String prefix, String separator) {
- if (withResolvedAst) {
- return;
- }
-
- if (e.metadata.isNotEmpty) {
- writeList(prefix, '', e.metadata, '$separator$prefix', (a) {
- writeNode((a as ElementAnnotationImpl).annotationAst);
- });
- buffer.write(separator);
- }
- }
-
- void writeMethodElement(MethodElement e) {
- writeDocumentation(e, ' ');
- writeMetadata(e, ' ', '\n');
-
- buffer.write(' ');
-
- writeIf(e.isExternal, 'external ');
- writeIf(e.isStatic, 'static ');
-
- writeType2(e.returnType);
-
- writeName(e);
- writeCodeRange(e);
- writeTypeInferenceError(e);
-
- writeTypeParameterElements(e.typeParameters, withDefault: false);
- writeParameterElements(e.parameters);
-
- writeBodyModifiers(e);
-
- if (e.isAbstract) {
- buffer.writeln(';');
- } else {
- buffer.writeln(' {}');
- }
-
- if (withResolvedAst) {
- _withIndent(() {
- _writeResolvedTypeParameters(e.typeParameters);
- _writeResolvedMetadata(e.metadata);
- _writeParameterElementDefaultValues(e.parameters);
- });
- }
- }
-
- void writeName(Element e) {
- buffer.write(e.displayName);
- if (withOffsets) {
- buffer.write('@');
- buffer.write(e.nameOffset);
- }
- }
-
- void writeNamespaceCombinator(NamespaceCombinator e) {
- if (e is ShowElementCombinator) {
- buffer.write(' show ');
- buffer.write(e.shownNames.join(', '));
- } else if (e is HideElementCombinator) {
- buffer.write(' hide ');
- buffer.write(e.hiddenNames.join(', '));
- }
- }
-
- void writeNode(AstNode? e, {Expression? enclosing}) {
- bool needsParenthesis = e is Expression &&
- enclosing != null &&
- e.precedence < enclosing.precedence;
-
- if (needsParenthesis) {
- buffer.write('(');
- }
-
- if (e == null) {
- buffer.write('<null>');
- } else if (e is SimpleIdentifier && e.name == '#invalidConst') {
- buffer.write('#invalidConst');
- } else if (e is AdjacentStrings) {
- writeList("'", "'", e.strings, '',
- (StringLiteral s) => buffer.write(s.stringValue),
- includeEmpty: true);
- } else if (e is Annotation) {
- buffer.write('@');
- writeNode(e.name);
- if (e.constructorName != null) {
- buffer.write('.');
- writeNode(e.constructorName);
- }
- if (e.arguments != null) {
- writeList('(', ')', e.arguments!.arguments, ', ', writeNode,
- includeEmpty: true);
- }
- } else if (e is AsExpression) {
- writeNode(e.expression);
- buffer.write(' as ');
- writeNode(e.type);
- } else if (e is AssertInitializer) {
- buffer.write('assert(');
- writeNode(e.condition);
- if (e.message != null) {
- buffer.write(', ');
- writeNode(e.message);
- }
- buffer.write(')');
- } else if (e is BinaryExpression) {
- writeNode(e.leftOperand, enclosing: e);
- buffer.write(' ');
- buffer.write(e.operator.lexeme);
- buffer.write(' ');
- writeNode(e.rightOperand, enclosing: e);
- } else if (e is BooleanLiteral) {
- buffer.write(e.value);
- } else if (e is ConditionalExpression) {
- writeNode(e.condition);
- buffer.write(' ? ');
- writeNode(e.thenExpression);
- buffer.write(' : ');
- writeNode(e.elseExpression);
- } else if (e is ConstructorFieldInitializer) {
- writeNode(e.fieldName);
- buffer.write(' = ');
- writeNode(e.expression);
- } else if (e is ConstructorName) {
- writeNode(e.type);
- if (e.name != null) {
- buffer.write('.');
- writeNode(e.name);
- }
- } else if (e is DoubleLiteral) {
- buffer.write(e.value);
- } else if (e is GenericFunctionType) {
- if (e.returnType != null) {
- writeNode(e.returnType);
- buffer.write(' ');
- }
- buffer.write('Function');
- if (e.typeParameters != null) {
- writeList('<', '>', e.typeParameters!.typeParameters, ', ', writeNode);
- }
- writeList('(', ')', e.parameters.parameters, ', ', writeNode,
- includeEmpty: true);
- } else if (e is InstanceCreationExpression) {
- if (e.keyword != null) {
- buffer.write(e.keyword!.lexeme);
- buffer.write(' ');
- }
- if (withTypes && e.constructorName.type.typeArguments == null) {
- writeInterfaceTypeArgsComment(e);
- }
- writeNode(e.constructorName);
- writeList('(', ')', e.argumentList.arguments, ', ', writeNode,
- includeEmpty: true);
- } else if (e is IntegerLiteral) {
- buffer.write(e.value);
- } else if (e is InterpolationExpression) {
- buffer.write(r'${');
- writeNode(e.expression);
- buffer.write(r'}');
- } else if (e is InterpolationString) {
- buffer.write(e.value.replaceAll("'", r"\'"));
- } else if (e is IsExpression) {
- writeNode(e.expression);
- buffer.write(e.notOperator == null ? ' is ' : ' is! ');
- writeNode(e.type);
- } else if (e is ListLiteral) {
- if (e.constKeyword != null) {
- buffer.write('const ');
- }
- if (e.typeArguments != null) {
- writeList('<', '>', e.typeArguments!.arguments, ', ', writeNode);
- } else if (withTypes) {
- writeInterfaceTypeArgsComment(e);
- }
- writeList('[', ']', e.elements, ', ', writeNode, includeEmpty: true);
- } else if (e is Label) {
- writeNode(e.label);
- buffer.write(': ');
- } else if (e is SetOrMapLiteral) {
- if (e.constKeyword != null) {
- buffer.write('const ');
- }
- if (e.typeArguments != null) {
- writeList('<', '>', e.typeArguments!.arguments, ', ', writeNode);
- } else if (withTypes) {
- writeInterfaceTypeArgsComment(e);
- }
- writeList('{', '}', e.elements, ', ', writeNode, includeEmpty: true);
- if (e.isMap) {
- buffer.write('/*isMap*/');
- }
- if (e.isSet) {
- buffer.write('/*isSet*/');
- }
- } else if (e is MapLiteralEntry) {
- writeNode(e.key);
- buffer.write(': ');
- writeNode(e.value);
- } else if (e is MethodInvocation) {
- if (e.target != null) {
- writeNode(e.target);
- buffer.write(e.operator);
- }
- writeNode(e.methodName);
- if (e.typeArguments != null) {
- writeList('<', '>', e.typeArguments!.arguments, ', ', writeNode);
- }
- writeList('(', ')', e.argumentList.arguments, ', ', writeNode,
- includeEmpty: true);
- } else if (e is NamedExpression) {
- writeNode(e.name);
- buffer.write(e.expression);
- } else if (e is NullLiteral) {
- buffer.write('null');
- } else if (e is ParenthesizedExpression) {
- writeNode(e.expression, enclosing: e);
- } else if (e is PrefixExpression) {
- buffer.write(e.operator.lexeme);
- writeNode(e.operand, enclosing: e);
- } else if (e is PrefixedIdentifier) {
- writeNode(e.prefix);
- buffer.write('.');
- writeNode(e.identifier);
- } else if (e is PropertyAccess) {
- writeNode(e.target, enclosing: e);
- buffer.write('.');
- writeNode(e.propertyName);
- } else if (e is RedirectingConstructorInvocation) {
- buffer.write('this');
- if (e.constructorName != null) {
- buffer.write('.');
- writeNode(e.constructorName);
- }
- writeList('(', ')', e.argumentList.arguments, ', ', writeNode,
- includeEmpty: true);
- } else if (e is SimpleFormalParameter) {
- writeNode(e.type);
- if (e.identifier != null) {
- buffer.write(' ');
- buffer.write(e.identifier!.name);
- }
- } else if (e is SimpleIdentifier) {
- if (withConstElements) {
- buffer.writeln();
- buffer.write(' ' * 4);
- buffer.write(e.name);
- buffer.write('/*');
- buffer.write('location: ');
- buffer.write(_getElementLocationString(e.staticElement));
- buffer.write('*/');
- } else {
- buffer.write(e.name);
- }
- } else if (e is SimpleStringLiteral) {
- buffer.write("'");
- buffer.write(e.value.replaceAll("'", r"\'"));
- buffer.write("'");
- } else if (e is StringInterpolation) {
- buffer.write("'");
- e.elements.forEach(writeNode);
- buffer.write("'");
- } else if (e is SuperConstructorInvocation) {
- buffer.write('super');
- if (e.constructorName != null) {
- buffer.write('.');
- writeNode(e.constructorName);
- }
- writeList('(', ')', e.argumentList.arguments, ', ', writeNode,
- includeEmpty: true);
- } else if (e is SuperExpression) {
- buffer.write('super');
- } else if (e is SymbolLiteral) {
- buffer.write('#');
- writeList('', '', e.components, '.',
- (Token token) => buffer.write(token.lexeme));
- } else if (e is ThisExpression) {
- buffer.write('this');
- } else if (e is ThrowExpression) {
- buffer.write('throw ');
- writeNode(e.expression);
- } else if (e is TypeName) {
- writeNode(e.name);
- if (e.typeArguments != null) {
- writeList('<', '>', e.typeArguments!.arguments, ', ', writeNode);
- }
- } else if (e is SpreadElement) {
- buffer.write(e.spreadOperator.lexeme);
- writeNode(e.expression);
- } else if (e is IfElement) {
- buffer.write('if (');
- writeNode(e.condition);
- buffer.write(') ');
- writeNode(e.thenElement);
- var elseElement = e.elseElement;
- if (elseElement != null) {
- buffer.write(' else ');
- writeNode(elseElement);
- }
- } else {
- fail('Unsupported expression type: ${e.runtimeType}');
- }
-
- if (needsParenthesis) {
- buffer.write(')');
- }
- }
-
- void writeParameterElement(ParameterElement e) {
- String? defaultValueSeparator;
- Expression? defaultValue;
- String closeString;
- if (e.isRequiredPositional) {
- closeString = '';
- } else if (e.isOptionalPositional) {
- buffer.write('[');
- defaultValueSeparator = ' = ';
- defaultValue = (e as ConstVariableElement).constantInitializer;
- closeString = ']';
- } else if (e.isNamed) {
- buffer.write('{');
- defaultValueSeparator = ': ';
- defaultValue = (e as ConstVariableElement).constantInitializer;
- closeString = '}';
- } else {
- fail('Unknown parameter kind');
- }
-
- writeMetadata(e, '', ' ');
-
- writeIf(e.isCovariant, 'covariant ');
- writeIf(e.isFinal, 'final ');
-
- writeType2(e.type);
-
- if (e is FieldFormalParameterElement) {
- buffer.write('this.');
- }
-
- writeName(e);
- writeCodeRange(e);
-
- if (!withResolvedAst) {
- if (e.typeParameters.isNotEmpty) {
- buffer.write('/*');
- writeTypeParameterElements(e.typeParameters, withDefault: false);
- buffer.write('*/');
- }
-
- if (e.parameters.isNotEmpty) {
- buffer.write('/*');
- writeList('(', ')', e.parameters, ', ', writeParameterElement);
- buffer.write('*/');
- }
-
- if (defaultValue != null) {
- buffer.write(defaultValueSeparator);
- writeNode(defaultValue);
- }
- }
-
- buffer.write(closeString);
- }
-
- void writeParameterElements(List<ParameterElement> elements) {
- writeList('(', ')', elements, ', ', writeParameterElement,
- includeEmpty: true);
- }
-
- void writePartElement(CompilationUnitElement e) {
- writeMetadata(e, '', '\n');
- buffer.write('part ');
- writeUri(e.source);
- buffer.writeln(';');
- }
-
- void writePropertyAccessorElement(PropertyAccessorElement e) {
- if (e.isSynthetic && !withSyntheticAccessors) {
- return;
- }
-
- if (!e.isSynthetic) {
- PropertyInducingElement variable = e.variable;
- expect(variable, isNotNull);
-
- if (e.isGetter) {
- // Usually we have a synthetic property for a non-synthetic accessor.
- expect(variable.isSynthetic, isTrue);
- } else {
- // But it is possible to have a non-synthetic property.
- // class A {
- // final int foo;
- // set foo(int newValue) {}
- // }
- }
-
- var variableEnclosing = variable.enclosingElement;
- if (variableEnclosing is CompilationUnitElement) {
- expect(variableEnclosing.topLevelVariables, contains(variable));
- } else if (variableEnclosing is ClassElement) {
- expect(variableEnclosing.fields, contains(variable));
- }
-
- if (e.isGetter) {
- expect(variable.getter, same(e));
- if (variable.setter != null) {
- expect(variable.setter!.variable, same(variable));
- }
- } else {
- expect(variable.setter, same(e));
- if (variable.getter != null) {
- expect(variable.getter!.variable, same(variable));
- }
- }
- }
-
- if (e.enclosingElement is ClassElement ||
- e.enclosingElement is ExtensionElement) {
- writeDocumentation(e, ' ');
- writeMetadata(e, ' ', '\n');
-
- buffer.write(' ');
-
- writeIf(e.isSynthetic, 'synthetic ');
- writeIf(e.isStatic, 'static ');
- } else {
- writeDocumentation(e);
- writeMetadata(e, '', '\n');
- writeIf(e.isSynthetic, 'synthetic ');
- }
-
- writeIf(e.isExternal, 'external ');
-
- writeType2(e.returnType);
-
- if (e.isGetter) {
- buffer.write('get ');
- } else {
- buffer.write('set ');
- }
-
- writeName(e);
-
- expect(e.typeParameters, isEmpty);
-
- if (e.isSetter || e.parameters.isNotEmpty) {
- writeParameterElements(e.parameters);
- }
-
- writeBodyModifiers(e);
-
- if (e.isAbstract || e.isExternal) {
- buffer.writeln(';');
- } else {
- buffer.writeln(' {}');
- }
-
- if (withResolvedAst) {
- _withIndent(() {
- _writeResolvedMetadata(e.metadata);
- _writeParameterElementDefaultValues(e.parameters);
- });
- }
- }
-
- void writePropertyInducingElement(PropertyInducingElement e) {
- if (e.isSynthetic && !withSyntheticFields && !isEnumField(e)) {
- return;
- }
-
- DartType type = e.type;
- expect(type, isNotNull);
-
- if (!e.isSynthetic) {
- expect(e.getter, isNotNull);
- _assertSyntheticAccessorEnclosing(e, e.getter!);
-
- if (e.setter != null) {
- _assertSyntheticAccessorEnclosing(e, e.setter!);
- }
- }
-
- if (e.enclosingElement is ClassElement ||
- e.enclosingElement is ExtensionElement) {
- writeDocumentation(e, ' ');
- writeMetadata(e, ' ', '\n');
-
- buffer.write(' ');
-
- writeIf(e.isSynthetic, 'synthetic ');
- writeIf(e.isStatic, 'static ');
- writeIf(e is FieldElementImpl && e.isAbstract, 'abstract ');
- writeIf(e is FieldElementImpl && e.isCovariant, 'covariant ');
- writeIf(e is FieldElementImpl && e.isExternal, 'external ');
- } else {
- writeDocumentation(e);
- writeMetadata(e, '', '\n');
- writeIf(e.isSynthetic, 'synthetic ');
- writeIf(e is TopLevelVariableElementImpl && e.isExternal, 'external ');
- }
-
- writeIf(e.isLate, 'late ');
- writeIf(e.isFinal, 'final ');
- writeIf(e.isConst, 'const ');
- writeType2(type);
-
- writeName(e);
- writeCodeRange(e);
-
- writeTypeInferenceError(e);
-
- if (withResolvedAst) {
- buffer.writeln(';');
- _withIndent(() {
- _writeResolvedMetadata(e.metadata);
- if (e is ConstVariableElement) {
- var initializer = (e as ConstVariableElement).constantInitializer;
- if (initializer != null) {
- _writelnWithIndent('constantInitializer');
- _withIndent(() {
- _writeResolvedNode(initializer);
- });
- }
- }
- });
- } else {
- if (e is ConstVariableElement) {
- var initializer = (e as ConstVariableElement).constantInitializer;
- if (initializer != null) {
- buffer.write(' = ');
- writeNode(initializer);
- }
- }
- buffer.writeln(';');
- }
-
- // TODO(scheglov) Paul: One of the things that was hardest to get right
- // when resynthesizing the element model was the synthetic function for the
- // initializer. Can we write that out (along with its return type)?
- }
-
- void writeType(DartType type) {
- var typeStr = _typeStr(type);
- buffer.write(typeStr);
-
- if (withAliasElementArguments) {
- var aliasElement = type.aliasElement;
- if (aliasElement is TypeAliasElementImpl) {
- buffer.write('<aliasElement: ');
- buffer.write(_referenceToString(aliasElement.reference!));
- var typeArguments = type.aliasArguments!;
- writeList(', aliasArguments: [', ']', typeArguments, ', ', writeType);
- buffer.write('>');
- }
- }
- }
-
- void writeType2(DartType type) {
- writeType(type);
- buffer.write(' ');
- }
-
- void writeTypeAliasElement(TypeAliasElement e) {
- writeDocumentation(e);
- writeMetadata(e, '', '\n');
- writeIf(!e.isSimplyBounded, 'notSimplyBounded ');
-
- buffer.write('typedef ');
- writeName(e);
- writeCodeRange(e);
- writeTypeParameterElements(e.typeParameters, withDefault: true);
-
- buffer.write(' = ');
-
- var aliasedElement = e.aliasedElement;
- if (aliasedElement is GenericFunctionTypeElement) {
- writeType(aliasedElement.returnType);
- buffer.write(' Function');
- writeTypeParameterElements(aliasedElement.typeParameters,
- withDefault: false);
- writeParameterElements(aliasedElement.parameters);
- } else {
- writeType(e.aliasedType);
- }
-
- buffer.writeln(';');
-
- if (withResolvedAst) {
- _withIndent(() {
- _writeResolvedMetadata(e.metadata);
- _writeResolvedTypeParameters(e.typeParameters);
- var aliasedElement = e.aliasedElement;
- if (aliasedElement is GenericFunctionTypeElement) {
- _writelnWithIndent('aliasedElement');
- _withIndent(() {
- _writeResolvedTypeParameters(aliasedElement.typeParameters);
- _writeResolvedParameterElements(aliasedElement.parameters);
- });
- }
- });
- }
- }
-
- void writeTypeInferenceError(Element e) {
- TopLevelInferenceError? inferenceError;
- if (e is MethodElementImpl) {
- inferenceError = e.typeInferenceError;
- } else if (e is PropertyInducingElementImpl) {
- inferenceError = e.typeInferenceError;
- }
-
- if (inferenceError != null) {
- String kindName = inferenceError.kind.toString();
- if (kindName.startsWith('TopLevelInferenceErrorKind.')) {
- kindName = kindName.substring('TopLevelInferenceErrorKind.'.length);
- }
- buffer.write('/*error: $kindName*/');
- }
- }
-
- void writeTypeParameterElement(
- TypeParameterElement e, {
- required bool withDefault,
- }) {
- var impl = e as TypeParameterElementImpl;
-
- writeMetadata(e, '', '\n');
-
- // TODO (kallentu) : Clean up TypeParameterElementImpl casting once
- // variance is added to the interface.
- if (withTypeParameterVariance) {
- var variance = impl.variance;
- buffer.write(variance.toString() + ' ');
- }
-
- writeName(e);
- writeCodeRange(e);
- if (e.bound != null && !e.bound!.isDartCoreObject) {
- buffer.write(' extends ');
- writeType(e.bound!);
- }
-
- if (withDefault) {
- var defaultType = impl.defaultType!;
- if (defaultType is! DynamicTypeImpl) {
- buffer.write(' = ');
- writeType(defaultType);
- }
- }
- }
-
- void writeTypeParameterElements(
- List<TypeParameterElement> elements, {
- required bool withDefault,
- }) {
- if (!withResolvedAst) {
- writeList<TypeParameterElement>('<', '>', elements, ', ', (e) {
- writeTypeParameterElement(e, withDefault: withDefault);
- });
- }
- }
-
- void writeUnitElement(CompilationUnitElement e) {
- if (e.library.definingCompilationUnit != e) {
- buffer.writeln('-' * 20);
- buffer.writeln('unit: ${e.source.shortName}');
- buffer.writeln();
- }
- e.typeAliases.forEach(writeTypeAliasElement);
- e.enums.forEach(writeClassElement);
- e.classes.forEach(writeClassElement);
- e.mixins.forEach(writeClassElement);
- e.extensions.forEach(writeExtensionElement);
- e.topLevelVariables.forEach(writePropertyInducingElement);
- e.accessors.forEach(writePropertyAccessorElement);
- e.functions.forEach(writeFunctionElement);
- }
-
- void writeUri(Source? source) {
- if (source != null) {
- Uri uri = source.uri;
- String uriStr = uri.toString();
- if (uri.isScheme('file')) {
- uriStr = uri.pathSegments.last;
- }
- buffer.write('\'$uriStr\'');
- } else {
- buffer.write('\'<unresolved>\'');
- }
+ });
}
/// Assert that the [accessor] of the [property] is correctly linked to
@@ -1232,6 +195,16 @@
}
}
+ ResolvedAstPrinter _createAstPrinter() {
+ return ResolvedAstPrinter(
+ selfUriStr: selfUriStr,
+ sink: buffer,
+ indent: indent,
+ withNullability: true,
+ withOffsets: true,
+ );
+ }
+
String _getElementLocationString(Element? element) {
if (element == null || element is MultiplyDefinedElement) {
return 'null';
@@ -1258,25 +231,6 @@
return components.join(';');
}
- String _referenceToString(Reference reference) {
- var parent = reference.parent!;
- if (parent.parent == null) {
- var libraryUriStr = reference.name;
- if (libraryUriStr == selfUriStr) {
- return 'self';
- }
- return libraryUriStr;
- }
-
- // Ignore the unit, skip to the library.
- if (parent.name == '@unit') {
- return _referenceToString(parent.parent!);
- }
-
- var name = reference.name;
- return _referenceToString(parent) + '::$name';
- }
-
String? _typeStr(DartType? type) {
return type?.getDisplayString(
withNullability: true,
@@ -1290,10 +244,249 @@
indent = savedIndent;
}
- void _writelnTypeWithIndent(String name, DartType? type) {
+ void _writeBodyModifiers(ExecutableElement e) {
+ if (e.isAsynchronous) {
+ expect(e.isSynchronous, isFalse);
+ buffer.write(' async');
+ }
+
+ if (e.isSynchronous && e.isGenerator) {
+ expect(e.isAsynchronous, isFalse);
+ buffer.write(' sync');
+ }
+
+ _writeIf(e.isGenerator, '*');
+ }
+
+ void _writeClassElement(ClassElement e) {
+ _writeIndentedLine(() {
+ _writeIf(e.isAbstract && !e.isMixin, 'abstract ');
+ _writeIf(!e.isSimplyBounded, 'notSimplyBounded ');
+
+ if (e.isEnum) {
+ buffer.write('enum ');
+ } else if (e.isMixin) {
+ buffer.write('mixin ');
+ } else {
+ buffer.write('class ');
+ }
+ _writeIf(e.isMixinApplication, 'alias ');
+
+ _writeName(e);
+ });
+
+ _withIndent(() {
+ _writeDocumentation(e);
+ _writeMetadata(e);
+ _writeCodeRange(e);
+ _writeTypeParameterElements(e.typeParameters);
+
+ var supertype = e.supertype;
+ if (supertype != null &&
+ (supertype.element.name != 'Object' || e.mixins.isNotEmpty)) {
+ _writeType(supertype, name: 'supertype');
+ }
+
+ if (e.isMixin) {
+ var superclassConstraints = e.superclassConstraints;
+ if (superclassConstraints.isEmpty) {
+ throw StateError('At least Object is expected.');
+ }
+ _writeElements<DartType>(
+ 'superclassConstraints',
+ superclassConstraints,
+ _writeType,
+ );
+ }
+
+ _writeElements<DartType>('mixins', e.mixins, _writeType);
+ _writeElements<DartType>('interfaces', e.interfaces, _writeType);
+
+ _writeElements('fields', e.fields, _writePropertyInducingElement);
+
+ var constructors = e.constructors;
+ if (e.isEnum) {
+ expect(constructors, isEmpty);
+ } else {
+ expect(constructors, isNotEmpty);
+ }
+ _writeElements('constructors', constructors, _writeConstructorElement);
+
+ _writeElements('accessors', e.accessors, _writePropertyAccessorElement);
+ _writeElements('methods', e.methods, _writeMethodElement);
+ });
+ }
+
+ void _writeCodeRange(Element e) {
+ if (withCodeRanges && !e.isSynthetic) {
+ e as ElementImpl;
+ _writelnWithIndent('codeOffset: ${e.codeOffset}');
+ _writelnWithIndent('codeLength: ${e.codeLength}');
+ }
+ }
+
+ void _writeConstantInitializer(Element e) {
+ if (e is ConstVariableElement) {
+ var initializer = e.constantInitializer;
+ if (initializer != null) {
+ _writelnWithIndent('constantInitializer');
+ _withIndent(() {
+ _writeNode(initializer);
+ });
+ }
+ }
+ }
+
+ void _writeConstructorElement(ConstructorElement e) {
+ e as ConstructorElementImpl;
+
+ _writeIndentedLine(() {
+ _writeIf(e.isSynthetic, 'synthetic ');
+ _writeIf(e.isExternal, 'external ');
+ _writeIf(e.isConst, 'const ');
+ _writeIf(e.isFactory, 'factory ');
+ expect(e.isAbstract, isFalse);
+ _writeName(e);
+ });
+
+ _withIndent(() {
+ _writeDocumentation(e);
+ _writeMetadata(e);
+ _writeCodeRange(e);
+
+ var periodOffset = e.periodOffset;
+ var nameEnd = e.nameEnd;
+ if (periodOffset != null && nameEnd != null) {
+ _writelnWithIndent('periodOffset: $periodOffset');
+ _writelnWithIndent('nameEnd: $nameEnd');
+ }
+
+ _writeParameterElements(e.parameters);
+
+ _writeElements(
+ 'constantInitializers',
+ e.constantInitializers,
+ _writeNode,
+ );
+
+ var redirectedConstructor = e.redirectedConstructor;
+ if (redirectedConstructor != null) {
+ var printer = _createAstPrinter();
+ printer.writeElement('redirectedConstructor', redirectedConstructor);
+ }
+ });
+
+ expect(e.isAsynchronous, isFalse);
+ expect(e.isGenerator, isFalse);
+ }
+
+ void _writeDocumentation(Element element) {
+ var documentation = element.documentationComment;
+ if (documentation != null) {
+ var str = documentation;
+ str = str.replaceAll('\n', r'\n');
+ str = str.replaceAll('\r', r'\r');
+ _writelnWithIndent('documentationComment: $str');
+ }
+ }
+
+ void _writeElements<T>(String name, List<T> elements, void Function(T) f) {
+ if (elements.isNotEmpty) {
+ _writelnWithIndent(name);
+ _withIndent(() {
+ for (var element in elements) {
+ f(element);
+ }
+ });
+ }
+ }
+
+ void _writeExportElement(ExportElement e) {
+ _writeIndentedLine(() {
+ _writeUri(e.exportedLibrary?.source);
+ });
+
+ _withIndent(() {
+ _writeMetadata(e);
+ _writeNamespaceCombinators(e.combinators);
+ });
+ }
+
+ void _writeExportScope(LibraryElement e) {
+ var map = e.exportNamespace.definedNames;
+ var names = map.keys.toList()..sort();
+ for (var name in names) {
+ var element = map[name];
+ var elementLocationStr = _getElementLocationString(element);
+ _writelnWithIndent('$name: $elementLocationStr');
+ }
+ }
+
+ void _writeExtensionElement(ExtensionElement e) {
+ _writeIndentedLine(() {
+ _writeName(e);
+ });
+
+ _withIndent(() {
+ _writeDocumentation(e);
+ _writeMetadata(e);
+ _writeCodeRange(e);
+ _writeTypeParameterElements(e.typeParameters);
+ _writeType(e.extendedType, name: 'extendedType');
+ });
+
+ _withIndent(() {
+ _writeElements('fields', e.fields, _writePropertyInducingElement);
+ _writeElements('accessors', e.accessors, _writePropertyAccessorElement);
+ _writeElements('methods', e.methods, _writeMethodElement);
+ });
+ }
+
+ void _writeFunctionElement(FunctionElement e) {
+ _writeIndentedLine(() {
+ _writeIf(e.isExternal, 'external ');
+ _writeName(e);
+ _writeBodyModifiers(e);
+ });
+
+ _withIndent(() {
+ _writeDocumentation(e);
+ _writeMetadata(e);
+ _writeCodeRange(e);
+ _writeTypeParameterElements(e.typeParameters);
+ _writeParameterElements(e.parameters);
+ _writeType(e.returnType, name: 'returnType');
+ });
+ }
+
+ void _writeIf(bool flag, String str) {
+ if (flag) {
+ buffer.write(str);
+ }
+ }
+
+ void _writeImportElement(ImportElement e) {
+ _writeIndentedLine(() {
+ _writeUri(e.importedLibrary?.source);
+ _writeIf(e.isDeferred, ' deferred');
+
+ var prefix = e.prefix;
+ if (prefix != null) {
+ buffer.write(' as ');
+ _writeName(prefix);
+ }
+ });
+
+ _withIndent(() {
+ _writeMetadata(e);
+ _writeNamespaceCombinators(e.combinators);
+ });
+ }
+
+ void _writeIndentedLine(void Function() f) {
buffer.write(indent);
- buffer.write('$name: ');
- buffer.writeln(_typeStr(type));
+ f();
+ buffer.writeln();
}
void _writelnWithIndent(String line) {
@@ -1301,101 +494,320 @@
buffer.writeln(line);
}
- void _writeParameterElementDefaultValues(
- List<ParameterElement> parameters, {
- String enclosingNames = '',
- }) {
- for (var parameter in parameters) {
- if (parameter is ConstVariableElement) {
- var defaultParameter = parameter as ConstVariableElement;
- var defaultValue = defaultParameter.constantInitializer;
- if (defaultValue != null) {
- _writelnWithIndent(enclosingNames + parameter.name);
- _withIndent(() {
- _writeResolvedNode(defaultValue);
- });
- }
- }
- var subParameters = parameter.parameters;
+ void _writeMetadata(Element element) {
+ var annotations = element.metadata;
+ if (annotations.isNotEmpty) {
+ _writelnWithIndent('metadata');
_withIndent(() {
- _writeParameterElementDefaultValues(
- subParameters,
- enclosingNames: enclosingNames + parameter.name + '::',
+ for (var annotation in annotations) {
+ annotation as ElementAnnotationImpl;
+ _writeNode(annotation.annotationAst);
+ }
+ });
+ }
+ }
+
+ void _writeMethodElement(MethodElement e) {
+ _writeIndentedLine(() {
+ _writeIf(e.isStatic, 'static ');
+ _writeIf(e.isAbstract, 'abstract ');
+ _writeIf(e.isExternal, 'external ');
+
+ _writeName(e);
+ _writeBodyModifiers(e);
+ });
+
+ _withIndent(() {
+ _writeDocumentation(e);
+ _writeMetadata(e);
+ _writeCodeRange(e);
+ _writeTypeInferenceError(e);
+
+ _writeTypeParameterElements(e.typeParameters);
+ _writeParameterElements(e.parameters);
+ _writeType(e.returnType, name: 'returnType');
+ });
+ }
+
+ void _writeName(Element e) {
+ var name = e.displayName;
+ buffer.write(name);
+ buffer.write(name.isNotEmpty ? ' @' : '@');
+ buffer.write(e.nameOffset);
+ }
+
+ void _writeNamespaceCombinator(NamespaceCombinator e) {
+ _writeIndentedLine(() {
+ if (e is ShowElementCombinator) {
+ buffer.write('show: ');
+ buffer.write(e.shownNames.join(', '));
+ } else if (e is HideElementCombinator) {
+ buffer.write('hide: ');
+ buffer.write(e.hiddenNames.join(', '));
+ }
+ });
+ }
+
+ void _writeNamespaceCombinators(List<NamespaceCombinator> elements) {
+ _writeElements('combinators', elements, _writeNamespaceCombinator);
+ }
+
+ void _writeNode(AstNode node) {
+ buffer.write(indent);
+ node.accept(
+ _createAstPrinter(),
+ );
+ }
+
+ void _writeParameterElement(ParameterElement e) {
+ _writeIndentedLine(() {
+ if (e.isRequiredPositional) {
+ buffer.write('requiredPositional ');
+ } else if (e.isOptionalPositional) {
+ buffer.write('optionalPositional ');
+ } else if (e.isRequiredNamed) {
+ buffer.write('requiredName ');
+ } else if (e.isOptionalNamed) {
+ buffer.write('optionalNamed ');
+ }
+
+ _writeIf(e.isCovariant, 'covariant ');
+ _writeIf(e.isFinal, 'final ');
+
+ if (e is FieldFormalParameterElement) {
+ buffer.write('this.');
+ }
+
+ _writeName(e);
+ });
+
+ _withIndent(() {
+ _writeType(e.type, name: 'type');
+ _writeMetadata(e);
+ _writeCodeRange(e);
+ _writeTypeParameterElements(e.typeParameters);
+ _writeParameterElements(e.parameters);
+ _writeConstantInitializer(e);
+ });
+ }
+
+ void _writeParameterElements(List<ParameterElement> elements) {
+ _writeElements('parameters', elements, _writeParameterElement);
+ }
+
+ void _writePropertyAccessorElement(PropertyAccessorElement e) {
+ PropertyInducingElement variable = e.variable;
+ expect(variable, isNotNull);
+
+ var variableEnclosing = variable.enclosingElement;
+ if (variableEnclosing is CompilationUnitElement) {
+ expect(variableEnclosing.topLevelVariables, contains(variable));
+ } else if (variableEnclosing is ClassElement) {
+ expect(variableEnclosing.fields, contains(variable));
+ }
+
+ if (e.isGetter) {
+ expect(variable.getter, same(e));
+ if (variable.setter != null) {
+ expect(variable.setter!.variable, same(variable));
+ }
+ } else {
+ expect(variable.setter, same(e));
+ if (variable.getter != null) {
+ expect(variable.getter!.variable, same(variable));
+ }
+ }
+
+ _writeIndentedLine(() {
+ _writeIf(e.isSynthetic, 'synthetic ');
+ _writeIf(e.isStatic, 'static ');
+ _writeIf(e.isAbstract, 'abstract ');
+ _writeIf(e.isExternal, 'external ');
+
+ if (e.isGetter) {
+ buffer.write('get ');
+ } else {
+ buffer.write('set ');
+ }
+
+ _writeName(e);
+ _writeBodyModifiers(e);
+ });
+
+ _withIndent(() {
+ _writeDocumentation(e);
+ _writeMetadata(e);
+ _writeCodeRange(e);
+
+ expect(e.typeParameters, isEmpty);
+ _writeParameterElements(e.parameters);
+ _writeType(e.returnType, name: 'returnType');
+ });
+ }
+
+ void _writePropertyInducingElement(PropertyInducingElement e) {
+ DartType type = e.type;
+ expect(type, isNotNull);
+
+ if (!e.isSynthetic) {
+ expect(e.getter, isNotNull);
+ _assertSyntheticAccessorEnclosing(e, e.getter!);
+
+ if (e.setter != null) {
+ _assertSyntheticAccessorEnclosing(e, e.setter!);
+ }
+ }
+
+ _writeIndentedLine(() {
+ _writeIf(e.isSynthetic, 'synthetic ');
+ _writeIf(e.isStatic, 'static ');
+ _writeIf(e is FieldElementImpl && e.isAbstract, 'abstract ');
+ _writeIf(e is FieldElementImpl && e.isCovariant, 'covariant ');
+ _writeIf(e is FieldElementImpl && e.isExternal, 'external ');
+ _writeIf(e.isLate, 'late ');
+ _writeIf(e.isFinal, 'final ');
+ _writeIf(e.isConst, 'const ');
+
+ _writeName(e);
+ });
+
+ _withIndent(() {
+ _writeDocumentation(e);
+ _writeMetadata(e);
+ _writeCodeRange(e);
+ _writeTypeInferenceError(e);
+ _writeType(e.type, name: 'type');
+ _writeConstantInitializer(e);
+ });
+ }
+
+ void _writeType(DartType type, {String? name}) {
+ var typeStr = _typeStr(type);
+ if (name != null) {
+ _writelnWithIndent('$name: $typeStr');
+ } else {
+ _writelnWithIndent('$typeStr');
+ }
+
+ var aliasElement = type.aliasElement;
+ var aliasArguments = type.aliasArguments;
+ if (aliasElement is TypeAliasElementImpl && aliasArguments != null) {
+ _withIndent(() {
+ _createAstPrinter().writeElement('aliasElement', aliasElement);
+
+ _writeElements<DartType>(
+ 'aliasArguments',
+ aliasArguments,
+ _writeType,
);
});
}
}
- void _writeResolvedMetadata(List<ElementAnnotation> metadata) {
- if (metadata.isNotEmpty) {
- _writelnWithIndent('metadata');
- _withIndent(() {
- for (var annotation in metadata) {
- annotation as ElementAnnotationImpl;
- _writeResolvedNode(annotation.annotationAst);
- }
- });
+ void _writeTypeAliasElement(TypeAliasElement e) {
+ e as TypeAliasElementImpl;
+
+ _writeIndentedLine(() {
+ _writeIf(e.isFunctionTypeAliasBased, 'functionTypeAliasBased ');
+ _writeIf(!e.isSimplyBounded, 'notSimplyBounded ');
+ _writeName(e);
+ });
+
+ _withIndent(() {
+ _writeDocumentation(e);
+ _writeMetadata(e);
+ _writeCodeRange(e);
+ _writeTypeParameterElements(e.typeParameters);
+ _writelnWithIndent('aliasedType: ${e.aliasedType}');
+
+ var aliasedElement = e.aliasedElement;
+ if (aliasedElement is GenericFunctionTypeElement) {
+ final aliasedElement_ = aliasedElement as GenericFunctionTypeElement;
+ _writelnWithIndent('aliasedElement: GenericFunctionTypeElement');
+ _withIndent(() {
+ _writeTypeParameterElements(aliasedElement_.typeParameters);
+ _writeParameterElements(aliasedElement_.parameters);
+ _writeType(aliasedElement_.returnType, name: 'returnType');
+ });
+ }
+ });
+ }
+
+ void _writeTypeInferenceError(Element e) {
+ TopLevelInferenceError? inferenceError;
+ if (e is MethodElementImpl) {
+ inferenceError = e.typeInferenceError;
+ } else if (e is PropertyInducingElementImpl) {
+ inferenceError = e.typeInferenceError;
+ }
+
+ if (inferenceError != null) {
+ String kindName = inferenceError.kind.toString();
+ if (kindName.startsWith('TopLevelInferenceErrorKind.')) {
+ kindName = kindName.substring('TopLevelInferenceErrorKind.'.length);
+ }
+ _writelnWithIndent('typeInferenceError: $kindName');
}
}
- void _writeResolvedNode(AstNode node) {
- buffer.write(indent);
- node.accept(
- ResolvedAstPrinter(
- selfUriStr: selfUriStr,
- sink: buffer,
- indent: indent,
- withNullability: true,
- withOffsets: withResolvedAstOffsets,
- ),
+ void _writeTypeParameterElement(TypeParameterElement e) {
+ e as TypeParameterElementImpl;
+
+ _writeIndentedLine(() {
+ buffer.write('${e.variance} ');
+ _writeName(e);
+ });
+
+ _withIndent(() {
+ _writeCodeRange(e);
+
+ var bound = e.bound;
+ if (bound != null) {
+ _writeType(bound, name: 'bound');
+ }
+
+ var defaultType = e.defaultType;
+ if (defaultType != null) {
+ _writeType(defaultType, name: 'defaultType');
+ }
+
+ _writeMetadata(e);
+ });
+ }
+
+ void _writeTypeParameterElements(List<TypeParameterElement> elements) {
+ _writeElements('typeParameters', elements, _writeTypeParameterElement);
+ }
+
+ void _writeUnitElement(CompilationUnitElement e) {
+ _writeElements('classes', e.classes, _writeClassElement);
+ _writeElements('enums', e.enums, _writeClassElement);
+ _writeElements('extensions', e.extensions, _writeExtensionElement);
+ _writeElements('mixins', e.mixins, _writeClassElement);
+ _writeElements('typeAliases', e.typeAliases, _writeTypeAliasElement);
+ _writeElements(
+ 'topLevelVariables',
+ e.topLevelVariables,
+ _writePropertyInducingElement,
);
+ _writeElements(
+ 'accessors',
+ e.accessors,
+ _writePropertyAccessorElement,
+ );
+ _writeElements('functions', e.functions, _writeFunctionElement);
}
- void _writeResolvedParameterElements(
- List<ParameterElement> parameters, {
- String enclosingNames = '',
- }) {
- if (parameters.isNotEmpty) {
- _writelnWithIndent('parameters');
- _withIndent(() {
- var index = 0;
- for (var formalParameter in parameters) {
- var metadata = formalParameter.metadata;
- var name = formalParameter.name;
- if (name.isEmpty) {
- name = '$index';
- }
- _writelnWithIndent(name);
- _withIndent(() {
- _writeResolvedMetadata(metadata);
- var subParameters = formalParameter.parameters;
- _withIndent(() {
- _writeResolvedParameterElements(
- subParameters,
- enclosingNames: enclosingNames + name + '::',
- );
- });
- });
- index++;
- }
- });
- }
- }
-
- void _writeResolvedTypeParameters(List<TypeParameterElement> elements) {
- if (elements.isNotEmpty) {
- _writelnWithIndent('typeParameters');
- _withIndent(() {
- for (var e in elements) {
- e as TypeParameterElementImpl;
- _writelnWithIndent(e.name);
- _withIndent(() {
- _writelnTypeWithIndent('bound', e.bound);
- _writelnTypeWithIndent('defaultType', e.defaultType);
- _writeResolvedMetadata(e.metadata);
- });
- }
- });
+ void _writeUri(Source? source) {
+ if (source != null) {
+ Uri uri = source.uri;
+ String uriStr = uri.toString();
+ if (uri.isScheme('file')) {
+ uriStr = uri.pathSegments.last;
+ }
+ buffer.write('$uriStr');
+ } else {
+ buffer.write('<unresolved>');
}
}
}
diff --git a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
index 2c44b7f..a3a772a 100644
--- a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
+++ b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
@@ -86,7 +86,11 @@
_writeNextCodeLine(node);
_writeln('ArgumentList');
_withIndent(() {
- _writeNodeList('arguments', node.arguments);
+ var properties = _Properties();
+ properties.addToken('leftParenthesis', node.leftParenthesis);
+ properties.addNodeList('arguments', node.arguments);
+ properties.addToken('rightParenthesis', node.rightParenthesis);
+ _writeProperties(properties);
});
}
@@ -97,6 +101,7 @@
_withIndent(() {
var properties = _Properties();
properties.addNode('expression', node.expression);
+ properties.addToken('asOperator', node.asOperator);
properties.addNode('type', node.type);
_addExpression(properties, node);
_writeProperties(properties);
@@ -745,6 +750,19 @@
}
@override
+ void visitIfElement(IfElement node) {
+ _writeln('IfElement');
+ _withIndent(() {
+ var properties = _Properties();
+ properties.addNode('condition', node.condition);
+ properties.addNode('elseStatement', node.elseElement);
+ properties.addNode('thenStatement', node.thenElement);
+ _addAstNode(properties, node);
+ _writeProperties(properties);
+ });
+ }
+
+ @override
void visitIfStatement(IfStatement node) {
_writeNextCodeLine(node);
_writeln('IfStatement');
@@ -789,8 +807,10 @@
_writeln('IndexExpression');
_withIndent(() {
var properties = _Properties();
+ properties.addToken('leftBracket', node.leftBracket);
properties.addNode('index', node.index);
properties.addToken('period', node.period);
+ properties.addToken('rightBracket', node.rightBracket);
properties.addNode('target', node.target);
_addExpression(properties, node);
_addMethodReferenceExpression(properties, node);
@@ -855,6 +875,7 @@
_withIndent(() {
var properties = _Properties();
properties.addNode('expression', node.expression);
+ properties.addToken('isOperator', node.isOperator);
properties.addNode('type', node.type);
_addExpression(properties, node);
_writeProperties(properties);
@@ -900,7 +921,9 @@
_writeln('ListLiteral');
_withIndent(() {
var properties = _Properties();
+ properties.addToken('leftBracket', node.leftBracket);
properties.addNodeList('elements', node.elements);
+ properties.addToken('rightBracket', node.rightBracket);
_addTypedLiteral(properties, node);
_writeProperties(properties);
});
@@ -1009,7 +1032,9 @@
_writeln('ParenthesizedExpression');
_withIndent(() {
var properties = _Properties();
+ properties.addToken('leftParenthesis', node.leftParenthesis);
properties.addNode('expression', node.expression);
+ properties.addToken('rightParenthesis', node.rightParenthesis);
_addExpression(properties, node);
_writeProperties(properties);
});
@@ -1179,7 +1204,6 @@
_writeNextCodeLine(node);
_writeln('SimpleIdentifier');
_withIndent(() {
- _writeOffset('offset', node.offset);
_writeElement('staticElement', node.staticElement);
_writeType('staticType', node.staticType);
_writeToken('token', node.token);
@@ -1196,6 +1220,15 @@
}
@override
+ void visitSpreadElement(SpreadElement node) {
+ _writeln('SpreadElement');
+ _withIndent(() {
+ _writeNode('expressions', node.expression);
+ _writeToken('spreadOperator', node.spreadOperator);
+ });
+ }
+
+ @override
void visitStringInterpolation(StringInterpolation node) {
_writeNextCodeLine(node);
_writeln('StringInterpolation');
@@ -1267,6 +1300,18 @@
}
@override
+ void visitSymbolLiteral(SymbolLiteral node) {
+ _writeln('SymbolLiteral');
+ _withIndent(() {
+ var properties = _Properties();
+ properties.addToken('poundSign', node.poundSign);
+ properties.addTokenList('components', node.components);
+ _addAstNode(properties, node);
+ _writeProperties(properties);
+ });
+ }
+
+ @override
void visitThisExpression(ThisExpression node) {
_writeNextCodeLine(node);
_writeln('ThisExpression');
@@ -1324,7 +1369,9 @@
_writeln('TypeArgumentList');
_withIndent(() {
var properties = _Properties();
+ properties.addToken('leftBracket', node.leftBracket);
properties.addNodeList('arguments', node.arguments);
+ properties.addToken('rightBracket', node.rightBracket);
_addAstNode(properties, node);
_writeProperties(properties);
});
@@ -1365,7 +1412,9 @@
_writeln('TypeParameterList');
_withIndent(() {
var properties = _Properties();
+ properties.addToken('leftBracket', node.leftBracket);
properties.addNodeList('typeParameters', node.typeParameters);
+ properties.addToken('rightBracket', node.rightBracket);
_addAstNode(properties, node);
_writeProperties(properties);
});
@@ -1452,6 +1501,10 @@
});
}
+ void writeElement(String name, Element? element) {
+ _writeElement(name, element);
+ }
+
void _addAnnotatedNode(_Properties properties, AnnotatedNode node) {
properties.addNode('documentationComment', node.documentationComment);
properties.addNodeList('metadata', node.metadata);
@@ -1675,6 +1728,12 @@
if (libraryUriStr == _selfUriStr) {
return 'self';
}
+
+ // TODO(scheglov) Make it precise again, after Windows.
+ if (libraryUriStr.startsWith('file:')) {
+ return libraryUriStr.substring(libraryUriStr.lastIndexOf('/') + 1);
+ }
+
return libraryUriStr;
}
@@ -1796,9 +1855,7 @@
}
void _writeOffset(String name, int offset) {
- if (_withOffsets) {
- _writelnWithIndent('$name: $offset');
- }
+ _writelnWithIndent('$name: $offset');
}
void _writeParameterElements(List<ParameterElement> parameters) {
@@ -1846,9 +1903,24 @@
void _writeToken(String name, Token? token) {
if (token != null) {
- _writelnWithIndent('$name: $token');
+ if (_withOffsets) {
+ _writelnWithIndent('$name: $token @${token.offset}');
+ } else {
+ _writelnWithIndent('$name: $token');
+ }
+ }
+ }
+
+ void _writeTokenList(String name, List<Token> tokens) {
+ if (tokens.isNotEmpty) {
+ _writelnWithIndent(name);
_withIndent(() {
- _writeOffset('offset', token.offset);
+ for (var token in tokens) {
+ _writelnWithIndent('$name: $token');
+ _withIndent(() {
+ _writeOffset('offset', token.offset);
+ });
+ }
});
}
}
@@ -1966,6 +2038,12 @@
);
}
+ void addTokenList(String name, List<Token> tokens) {
+ properties.add(
+ _TokenListProperty(name, tokens),
+ );
+ }
+
void addType(String name, DartType? type) {
properties.add(
_TypeProperty(name, type),
@@ -2009,6 +2087,17 @@
}
}
+class _TokenListProperty extends _Property {
+ final List<Token> tokens;
+
+ _TokenListProperty(String name, this.tokens) : super(name);
+
+ @override
+ void write(ResolvedAstPrinter printer) {
+ printer._writeTokenList(name, tokens);
+ }
+}
+
class _TokenProperty extends _Property {
final Token? token;
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index c7addb5..3bd6477 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -108,8 +108,12 @@
test_class_abstract() async {
var library = await checkLibrary('abstract class C {}');
checkElementText(library, r'''
-abstract class C {
-}
+library
+ definingUnit
+ classes
+ abstract class C @15
+ constructors
+ synthetic @-1
''');
}
@@ -122,17 +126,35 @@
class G {}
''');
checkElementText(library, r'''
-class alias C extends D with E, F, G {
- synthetic C() : super();
-}
-class D {
-}
-class E {
-}
-class F {
-}
-class G {
-}
+library
+ definingUnit
+ classes
+ class alias C @6
+ supertype: D
+ mixins
+ E
+ F
+ G
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::D::@constructor::•
+ class D @32
+ constructors
+ synthetic @-1
+ class E @43
+ constructors
+ synthetic @-1
+ class F @54
+ constructors
+ synthetic @-1
+ class G @65
+ constructors
+ synthetic @-1
''');
}
@@ -143,13 +165,27 @@
class E {}
''');
checkElementText(library, r'''
-abstract class alias C extends D with E {
- synthetic C() : super();
-}
-class D {
-}
-class E {
-}
+library
+ definingUnit
+ classes
+ abstract class alias C @15
+ supertype: D
+ mixins
+ E
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::D::@constructor::•
+ class D @35
+ constructors
+ synthetic @-1
+ class E @46
+ constructors
+ synthetic @-1
''');
}
@@ -164,16 +200,28 @@
class E {}
''');
checkElementText(library, r'''
-/**
- * Docs
- */
-class alias C extends D with E {
- synthetic C() : super();
-}
-class D {
-}
-class E {
-}
+library
+ definingUnit
+ classes
+ class alias C @22
+ documentationComment: /**\n * Docs\n */
+ supertype: D
+ mixins
+ E
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::D::@constructor::•
+ class D @43
+ constructors
+ synthetic @-1
+ class E @54
+ constructors
+ synthetic @-1
''');
}
@@ -188,16 +236,28 @@
class E {}
''');
checkElementText(library, r'''
-/// aaa
-/// b
-/// cc
-class alias C extends D with E {
- synthetic C() : super();
-}
-class D {
-}
-class E {
-}
+library
+ definingUnit
+ classes
+ class alias C @27
+ documentationComment: /// aaa\n/// b\n/// cc
+ supertype: D
+ mixins
+ E
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::D::@constructor::•
+ class D @48
+ constructors
+ synthetic @-1
+ class E @59
+ constructors
+ synthetic @-1
''');
}
@@ -212,16 +272,28 @@
class D {}
class E {}''');
checkElementText(library, r'''
-/**
- * Docs
- */
-class alias C extends D with E {
- synthetic C() : super();
-}
-class D {
-}
-class E {
-}
+library
+ definingUnit
+ classes
+ class alias C @66
+ documentationComment: /**\n * Docs\n */
+ supertype: D
+ mixins
+ E
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::D::@constructor::•
+ class D @87
+ constructors
+ synthetic @-1
+ class E @98
+ constructors
+ synthetic @-1
''');
}
@@ -233,15 +305,37 @@
class C<C1> {}
''');
checkElementText(library, r'''
-class alias Z extends A with B<int>, C<double> {
- synthetic Z() : super();
-}
-class A {
-}
-class B<B1> {
-}
-class C<C1> {
-}
+library
+ definingUnit
+ classes
+ class alias Z @6
+ supertype: A
+ mixins
+ B<int>
+ C<double>
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::A::@constructor::•
+ class A @42
+ constructors
+ synthetic @-1
+ class B @53
+ typeParameters
+ covariant B1 @55
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class C @68
+ typeParameters
+ covariant C1 @70
+ defaultType: dynamic
+ constructors
+ synthetic @-1
''');
}
@@ -252,13 +346,31 @@
class E {}
''');
checkElementText(library, r'''
-notSimplyBounded class alias C<T extends C<dynamic>> extends D with E {
- synthetic C() : super();
-}
-class D {
-}
-class E {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class alias C @6
+ typeParameters
+ covariant T @8
+ bound: C<dynamic>
+ defaultType: dynamic
+ supertype: D
+ mixins
+ E
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::D::@constructor::•
+ class D @39
+ constructors
+ synthetic @-1
+ class E @50
+ constructors
+ synthetic @-1
''');
}
@@ -271,13 +383,30 @@
class E {}
''');
checkElementText(library, r'''
-class alias C<T> extends D with E {
- synthetic C() : super();
-}
-class D {
-}
-class E {
-}
+library
+ definingUnit
+ classes
+ class alias C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ supertype: D
+ mixins
+ E
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::D::@constructor::•
+ class D @29
+ constructors
+ synthetic @-1
+ class E @40
+ constructors
+ synthetic @-1
''');
}
@@ -290,13 +419,27 @@
class E {}
''');
checkElementText(library, r'''
-class alias C extends D with E {
- synthetic C() : super();
-}
-class D {
-}
-class E {
-}
+library
+ definingUnit
+ classes
+ class alias C @6
+ supertype: D
+ mixins
+ E
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::D::@constructor::•
+ class D @26
+ constructors
+ synthetic @-1
+ class E @37
+ constructors
+ synthetic @-1
''');
}
@@ -314,34 +457,44 @@
class M {}
class MixinApp = Base with M;
''');
- checkElementText(
- library,
- r'''
-import 'package:test/a.dart';
-class M {
-}
-class alias MixinApp extends Base with M {
- synthetic const MixinApp();
- constantInitializers
- SuperConstructorInvocation
- argumentList: ArgumentList
- staticElement: package:test/a.dart::@class::Base::@constructor::•
- synthetic const MixinApp.named();
- constantInitializers
- SuperConstructorInvocation
- argumentList: ArgumentList
- constructorName: SimpleIdentifier
- staticElement: package:test/a.dart::@class::Base::@constructor::named
- staticType: null
- token: named
- staticElement: package:test/a.dart::@class::Base::@constructor::named
-}
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ imports
+ package:test/a.dart
+ definingUnit
+ classes
+ class M @23
+ constructors
+ synthetic @-1
+ class alias MixinApp @34
+ supertype: Base
+ mixins
+ M
+ constructors
+ synthetic const @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: package:test/a.dart::@class::Base::@constructor::•
+ synthetic const named @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: SimpleIdentifier
+ staticElement: package:test/a.dart::@class::Base::@constructor::named
+ staticType: null
+ token: named @-1
+ staticElement: package:test/a.dart::@class::Base::@constructor::named
+''');
}
test_class_alias_with_forwarding_constructors() async {
- addLibrarySource('/a.dart', '''
+ testFile = convertPath('/home/test/lib/test.dart');
+ addLibrarySource('/home/test/lib/a.dart', r'''
class Base {
bool x = true;
Base._priv();
@@ -362,29 +515,148 @@
class MixinApp = Base with M;
''');
checkElementText(library, r'''
-import 'a.dart';
-class M {
-}
-class alias MixinApp extends Base with M {
- synthetic MixinApp() : super();
- synthetic MixinApp.noArgs() : super.
- noArgs/*location: a.dart;Base;noArgs*/();
- synthetic MixinApp.requiredArg(dynamic x) : super.
- requiredArg/*location: a.dart;Base;requiredArg*/(
- x/*location: test.dart;MixinApp;requiredArg;x*/);
- synthetic MixinApp.positionalArg([bool x = true]) : super.
- positionalArg/*location: a.dart;Base;positionalArg*/(
- x/*location: test.dart;MixinApp;positionalArg;x*/);
- synthetic MixinApp.positionalArg2([final bool x = true]) : super.
- positionalArg2/*location: a.dart;Base;positionalArg2*/(
- x/*location: test.dart;MixinApp;positionalArg2;x*/);
- synthetic MixinApp.namedArg({int x: 42}) : super.
- namedArg/*location: a.dart;Base;namedArg*/(
- x/*location: test.dart;MixinApp;namedArg;x*/);
- synthetic MixinApp.namedArg2({final bool x: true}) : super.
- namedArg2/*location: a.dart;Base;namedArg2*/(
- x/*location: test.dart;MixinApp;namedArg2;x*/);
-}
+library
+ imports
+ package:test/a.dart
+ definingUnit
+ classes
+ class M @23
+ constructors
+ synthetic @-1
+ class alias MixinApp @34
+ supertype: Base
+ mixins
+ M
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: package:test/a.dart::@class::Base::@constructor::•
+ synthetic noArgs @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: SimpleIdentifier
+ staticElement: package:test/a.dart::@class::Base::@constructor::noArgs
+ staticType: null
+ token: noArgs @-1
+ staticElement: package:test/a.dart::@class::Base::@constructor::noArgs
+ synthetic requiredArg @-1
+ parameters
+ requiredPositional x @-1
+ type: dynamic
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ arguments
+ SimpleIdentifier
+ staticElement: x@-1
+ staticType: dynamic
+ token: x @-1
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: SimpleIdentifier
+ staticElement: package:test/a.dart::@class::Base::@constructor::requiredArg
+ staticType: null
+ token: requiredArg @-1
+ staticElement: package:test/a.dart::@class::Base::@constructor::requiredArg
+ synthetic positionalArg @-1
+ parameters
+ optionalPositional x @-1
+ type: bool
+ constantInitializer
+ BooleanLiteral
+ literal: true @0
+ staticType: bool
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ arguments
+ SimpleIdentifier
+ staticElement: x@-1
+ staticType: bool
+ token: x @-1
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: SimpleIdentifier
+ staticElement: package:test/a.dart::@class::Base::@constructor::positionalArg
+ staticType: null
+ token: positionalArg @-1
+ staticElement: package:test/a.dart::@class::Base::@constructor::positionalArg
+ synthetic positionalArg2 @-1
+ parameters
+ optionalPositional final x @-1
+ type: bool
+ constantInitializer
+ BooleanLiteral
+ literal: true @0
+ staticType: bool
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ arguments
+ SimpleIdentifier
+ staticElement: x@-1
+ staticType: bool
+ token: x @-1
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: SimpleIdentifier
+ staticElement: package:test/a.dart::@class::Base::@constructor::positionalArg2
+ staticType: null
+ token: positionalArg2 @-1
+ staticElement: package:test/a.dart::@class::Base::@constructor::positionalArg2
+ synthetic namedArg @-1
+ parameters
+ optionalNamed x @-1
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 42 @0
+ staticType: int
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ arguments
+ SimpleIdentifier
+ staticElement: x@-1
+ staticType: int
+ token: x @-1
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: SimpleIdentifier
+ staticElement: package:test/a.dart::@class::Base::@constructor::namedArg
+ staticType: null
+ token: namedArg @-1
+ staticElement: package:test/a.dart::@class::Base::@constructor::namedArg
+ synthetic namedArg2 @-1
+ parameters
+ optionalNamed final x @-1
+ type: bool
+ constantInitializer
+ BooleanLiteral
+ literal: true @0
+ staticType: bool
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ arguments
+ SimpleIdentifier
+ staticElement: x@-1
+ staticType: bool
+ token: x @-1
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: SimpleIdentifier
+ staticElement: package:test/a.dart::@class::Base::@constructor::namedArg2
+ staticType: null
+ token: namedArg2 @-1
+ staticElement: package:test/a.dart::@class::Base::@constructor::namedArg2
''');
}
@@ -397,17 +669,55 @@
class MixinApp = Base with M;
''');
checkElementText(library, r'''
-class Base<T> {
- Base.ctor(T t, List<T> l);
-}
-class M {
-}
-class alias MixinApp extends Base<dynamic> with M {
- synthetic MixinApp.ctor(dynamic t, List<dynamic> l) : super.
- ctor/*location: test.dart;Base;ctor*/(
- t/*location: test.dart;MixinApp;ctor;t*/,
- l/*location: test.dart;MixinApp;ctor;l*/);
-}
+library
+ definingUnit
+ classes
+ class Base @6
+ typeParameters
+ covariant T @11
+ defaultType: dynamic
+ constructors
+ ctor @23
+ periodOffset: 22
+ nameEnd: 27
+ parameters
+ requiredPositional t @30
+ type: T
+ requiredPositional l @41
+ type: List<T>
+ class M @53
+ constructors
+ synthetic @-1
+ class alias MixinApp @64
+ supertype: Base<dynamic>
+ mixins
+ M
+ constructors
+ synthetic ctor @-1
+ parameters
+ requiredPositional t @-1
+ type: dynamic
+ requiredPositional l @-1
+ type: List<dynamic>
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ arguments
+ SimpleIdentifier
+ staticElement: t@-1
+ staticType: dynamic
+ token: t @-1
+ SimpleIdentifier
+ staticElement: l@-1
+ staticType: List<dynamic>
+ token: l @-1
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: SimpleIdentifier
+ staticElement: self::@class::Base::@constructor::ctor
+ staticType: null
+ token: ctor @-1
+ staticElement: self::@class::Base::@constructor::ctor
''');
}
@@ -420,17 +730,58 @@
class MixinApp<U> = Base<List<U>> with M;
''');
checkElementText(library, r'''
-class Base<T> {
- Base.ctor(T t, List<T> l);
-}
-class M {
-}
-class alias MixinApp<U> extends Base<List<U>> with M {
- synthetic MixinApp.ctor(List<U> t, List<List<U>> l) : super.
- ctor/*location: test.dart;Base;ctor*/(
- t/*location: test.dart;MixinApp;ctor;t*/,
- l/*location: test.dart;MixinApp;ctor;l*/);
-}
+library
+ definingUnit
+ classes
+ class Base @6
+ typeParameters
+ covariant T @11
+ defaultType: dynamic
+ constructors
+ ctor @23
+ periodOffset: 22
+ nameEnd: 27
+ parameters
+ requiredPositional t @30
+ type: T
+ requiredPositional l @41
+ type: List<T>
+ class M @53
+ constructors
+ synthetic @-1
+ class alias MixinApp @64
+ typeParameters
+ covariant U @73
+ defaultType: dynamic
+ supertype: Base<List<U>>
+ mixins
+ M
+ constructors
+ synthetic ctor @-1
+ parameters
+ requiredPositional t @-1
+ type: List<U>
+ requiredPositional l @-1
+ type: List<List<U>>
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ arguments
+ SimpleIdentifier
+ staticElement: t@-1
+ staticType: List<U>
+ token: t @-1
+ SimpleIdentifier
+ staticElement: l@-1
+ staticType: List<List<U>>
+ token: l @-1
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: SimpleIdentifier
+ staticElement: self::@class::Base::@constructor::ctor
+ staticType: null
+ token: ctor @-1
+ staticElement: self::@class::Base::@constructor::ctor
''');
}
@@ -445,80 +796,143 @@
int x;
}''');
checkElementText(library, r'''
-class alias C extends D with E {
- synthetic C() : super();
-}
-class D {
-}
-class E {
- int x;
- int get a {}
- void set b(int i) {}
- void f() {}
-}
+library
+ definingUnit
+ classes
+ class alias C @6
+ supertype: D
+ mixins
+ E
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::D::@constructor::•
+ class D @26
+ constructors
+ synthetic @-1
+ class E @37
+ fields
+ x @105
+ type: int
+ synthetic a @-1
+ type: int
+ synthetic b @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @105
+ returnType: int
+ synthetic set x @105
+ parameters
+ requiredPositional _x @105
+ type: int
+ returnType: void
+ get a @51
+ returnType: int
+ set b @73
+ parameters
+ requiredPositional i @79
+ type: int
+ returnType: void
+ methods
+ f @92
+ returnType: void
''');
}
test_class_constructor_const() async {
var library = await checkLibrary('class C { const C(); }');
checkElementText(library, r'''
-class C {
- const C();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ const @16
''');
}
test_class_constructor_const_external() async {
var library = await checkLibrary('class C { external const C(); }');
checkElementText(library, r'''
-class C {
- external const C();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ external const @25
''');
}
test_class_constructor_explicit_named() async {
var library = await checkLibrary('class C { C.foo(); }');
checkElementText(library, r'''
-class C {
- C.foo();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ foo @12
+ periodOffset: 11
+ nameEnd: 15
''');
}
test_class_constructor_explicit_type_params() async {
var library = await checkLibrary('class C<T, U> { C(); }');
checkElementText(library, r'''
-class C<T, U> {
- C();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ covariant U @11
+ defaultType: dynamic
+ constructors
+ @16
''');
}
test_class_constructor_explicit_unnamed() async {
var library = await checkLibrary('class C { C(); }');
checkElementText(library, r'''
-class C {
- C();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ @10
''');
}
test_class_constructor_external() async {
var library = await checkLibrary('class C { external C(); }');
checkElementText(library, r'''
-class C {
- external C();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ external @19
''');
}
test_class_constructor_factory() async {
var library = await checkLibrary('class C { factory C() => throw 0; }');
checkElementText(library, r'''
-class C {
- factory C();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ factory @18
''');
}
@@ -526,30 +940,78 @@
var library =
await checkLibrary('class C { dynamic x; C(dynamic this.x); }');
checkElementText(library, r'''
-class C {
- dynamic x;
- C(final dynamic this.x);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @18
+ type: dynamic
+ constructors
+ @21
+ parameters
+ requiredPositional final this.x @36
+ type: dynamic
+ accessors
+ synthetic get x @18
+ returnType: dynamic
+ synthetic set x @18
+ parameters
+ requiredPositional _x @18
+ type: dynamic
+ returnType: void
''');
}
test_class_constructor_field_formal_dynamic_typed() async {
var library = await checkLibrary('class C { dynamic x; C(int this.x); }');
checkElementText(library, r'''
-class C {
- dynamic x;
- C(final int this.x);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @18
+ type: dynamic
+ constructors
+ @21
+ parameters
+ requiredPositional final this.x @32
+ type: int
+ accessors
+ synthetic get x @18
+ returnType: dynamic
+ synthetic set x @18
+ parameters
+ requiredPositional _x @18
+ type: dynamic
+ returnType: void
''');
}
test_class_constructor_field_formal_dynamic_untyped() async {
var library = await checkLibrary('class C { dynamic x; C(this.x); }');
checkElementText(library, r'''
-class C {
- dynamic x;
- C(final dynamic this.x);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @18
+ type: dynamic
+ constructors
+ @21
+ parameters
+ requiredPositional final this.x @28
+ type: dynamic
+ accessors
+ synthetic get x @18
+ returnType: dynamic
+ synthetic set x @18
+ parameters
+ requiredPositional _x @18
+ type: dynamic
+ returnType: void
''');
}
@@ -561,10 +1023,29 @@
}
''');
checkElementText(library, r'''
-class C {
- dynamic x;
- C(final dynamic Function(double) this.x/*(double b)*/);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @16
+ type: dynamic
+ constructors
+ @21
+ parameters
+ requiredPositional final this.x @28
+ type: dynamic Function(double)
+ parameters
+ requiredPositional b @-1
+ type: double
+ accessors
+ synthetic get x @16
+ returnType: dynamic
+ synthetic set x @16
+ parameters
+ requiredPositional _x @16
+ type: dynamic
+ returnType: void
''');
}
@@ -576,10 +1057,29 @@
}
''');
checkElementText(library, r'''
-class C {
- dynamic x;
- C(final int Function(double) this.x/*(double b)*/);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @16
+ type: dynamic
+ constructors
+ @21
+ parameters
+ requiredPositional final this.x @32
+ type: int Function(double)
+ parameters
+ requiredPositional b @-1
+ type: double
+ accessors
+ synthetic get x @16
+ returnType: dynamic
+ synthetic set x @16
+ parameters
+ requiredPositional _x @16
+ type: dynamic
+ returnType: void
''');
}
@@ -591,10 +1091,32 @@
}
''');
checkElementText(library, r'''
-class C {
- dynamic Function() f;
- C(final List<U> Function<T, U>(T) this.f/*<T, U>*//*(T t)*/);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ f @23
+ type: dynamic Function()
+ constructors
+ @28
+ parameters
+ requiredPositional final this.f @43
+ type: List<U> Function<T, U>(T)
+ typeParameters
+ covariant T @-1
+ covariant U @-1
+ parameters
+ requiredPositional t @-1
+ type: T
+ accessors
+ synthetic get f @23
+ returnType: dynamic Function()
+ synthetic set f @23
+ parameters
+ requiredPositional _f @23
+ type: dynamic Function()
+ returnType: void
''');
}
@@ -603,11 +1125,35 @@
var library = await checkLibrary('class C { C(this.x); int x; String x; }',
allowErrors: true);
checkElementText(library, r'''
-class C {
- int x;
- String x;
- C(final int this.x);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @25
+ type: int
+ x @35
+ type: String
+ constructors
+ @10
+ parameters
+ requiredPositional final this.x @17
+ type: int
+ accessors
+ synthetic get x @25
+ returnType: int
+ synthetic set x @25
+ parameters
+ requiredPositional _x @25
+ type: int
+ returnType: void
+ synthetic get x @35
+ returnType: String
+ synthetic set x @35
+ parameters
+ requiredPositional _x @35
+ type: String
+ returnType: void
''');
}
@@ -616,9 +1162,15 @@
var library =
await checkLibrary('class C { C(this.x); }', allowErrors: true);
checkElementText(library, r'''
-class C {
- C(final dynamic this.x);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ @10
+ parameters
+ requiredPositional final this.x @17
+ type: dynamic
''');
}
@@ -626,135 +1178,331 @@
var library = await checkLibrary('class C { num x; C(dynamic this.x); }',
allowErrors: true);
checkElementText(library, r'''
-class C {
- num x;
- C(final dynamic this.x);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @14
+ type: num
+ constructors
+ @17
+ parameters
+ requiredPositional final this.x @32
+ type: dynamic
+ accessors
+ synthetic get x @14
+ returnType: num
+ synthetic set x @14
+ parameters
+ requiredPositional _x @14
+ type: num
+ returnType: void
''');
}
test_class_constructor_field_formal_typed_typed() async {
var library = await checkLibrary('class C { num x; C(int this.x); }');
checkElementText(library, r'''
-class C {
- num x;
- C(final int this.x);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @14
+ type: num
+ constructors
+ @17
+ parameters
+ requiredPositional final this.x @28
+ type: int
+ accessors
+ synthetic get x @14
+ returnType: num
+ synthetic set x @14
+ parameters
+ requiredPositional _x @14
+ type: num
+ returnType: void
''');
}
test_class_constructor_field_formal_typed_untyped() async {
var library = await checkLibrary('class C { num x; C(this.x); }');
checkElementText(library, r'''
-class C {
- num x;
- C(final num this.x);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @14
+ type: num
+ constructors
+ @17
+ parameters
+ requiredPositional final this.x @24
+ type: num
+ accessors
+ synthetic get x @14
+ returnType: num
+ synthetic set x @14
+ parameters
+ requiredPositional _x @14
+ type: num
+ returnType: void
''');
}
test_class_constructor_field_formal_untyped_dynamic() async {
var library = await checkLibrary('class C { var x; C(dynamic this.x); }');
checkElementText(library, r'''
-class C {
- dynamic x;
- C(final dynamic this.x);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @14
+ type: dynamic
+ constructors
+ @17
+ parameters
+ requiredPositional final this.x @32
+ type: dynamic
+ accessors
+ synthetic get x @14
+ returnType: dynamic
+ synthetic set x @14
+ parameters
+ requiredPositional _x @14
+ type: dynamic
+ returnType: void
''');
}
test_class_constructor_field_formal_untyped_typed() async {
var library = await checkLibrary('class C { var x; C(int this.x); }');
checkElementText(library, r'''
-class C {
- dynamic x;
- C(final int this.x);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @14
+ type: dynamic
+ constructors
+ @17
+ parameters
+ requiredPositional final this.x @28
+ type: int
+ accessors
+ synthetic get x @14
+ returnType: dynamic
+ synthetic set x @14
+ parameters
+ requiredPositional _x @14
+ type: dynamic
+ returnType: void
''');
}
test_class_constructor_field_formal_untyped_untyped() async {
var library = await checkLibrary('class C { var x; C(this.x); }');
checkElementText(library, r'''
-class C {
- dynamic x;
- C(final dynamic this.x);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @14
+ type: dynamic
+ constructors
+ @17
+ parameters
+ requiredPositional final this.x @24
+ type: dynamic
+ accessors
+ synthetic get x @14
+ returnType: dynamic
+ synthetic set x @14
+ parameters
+ requiredPositional _x @14
+ type: dynamic
+ returnType: void
''');
}
test_class_constructor_fieldFormal_named_noDefault() async {
var library = await checkLibrary('class C { int x; C({this.x}); }');
checkElementText(library, r'''
-class C {
- int x;
- C({final int this.x});
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @14
+ type: int
+ constructors
+ @17
+ parameters
+ optionalNamed final this.x @25
+ type: int
+ accessors
+ synthetic get x @14
+ returnType: int
+ synthetic set x @14
+ parameters
+ requiredPositional _x @14
+ type: int
+ returnType: void
''');
}
test_class_constructor_fieldFormal_named_withDefault() async {
var library = await checkLibrary('class C { int x; C({this.x: 42}); }');
checkElementText(library, r'''
-class C {
- int x;
- C({final int this.x: 42});
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @14
+ type: int
+ constructors
+ @17
+ parameters
+ optionalNamed final this.x @25
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 42 @0
+ staticType: int
+ accessors
+ synthetic get x @14
+ returnType: int
+ synthetic set x @14
+ parameters
+ requiredPositional _x @14
+ type: int
+ returnType: void
''');
}
test_class_constructor_fieldFormal_optional_noDefault() async {
var library = await checkLibrary('class C { int x; C([this.x]); }');
checkElementText(library, r'''
-class C {
- int x;
- C([final int this.x]);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @14
+ type: int
+ constructors
+ @17
+ parameters
+ optionalPositional final this.x @25
+ type: int
+ accessors
+ synthetic get x @14
+ returnType: int
+ synthetic set x @14
+ parameters
+ requiredPositional _x @14
+ type: int
+ returnType: void
''');
}
test_class_constructor_fieldFormal_optional_withDefault() async {
var library = await checkLibrary('class C { int x; C([this.x = 42]); }');
checkElementText(library, r'''
-class C {
- int x;
- C([final int this.x = 42]);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @14
+ type: int
+ constructors
+ @17
+ parameters
+ optionalPositional final this.x @25
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 42 @0
+ staticType: int
+ accessors
+ synthetic get x @14
+ returnType: int
+ synthetic set x @14
+ parameters
+ requiredPositional _x @14
+ type: int
+ returnType: void
''');
}
test_class_constructor_implicit() async {
var library = await checkLibrary('class C {}');
checkElementText(library, r'''
-class C {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
''');
}
test_class_constructor_implicit_type_params() async {
var library = await checkLibrary('class C<T, U> {}');
checkElementText(library, r'''
-class C<T, U> {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ covariant U @11
+ defaultType: dynamic
+ constructors
+ synthetic @-1
''');
}
test_class_constructor_params() async {
var library = await checkLibrary('class C { C(x, int y); }');
checkElementText(library, r'''
-class C {
- C(dynamic x, int y);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ @10
+ parameters
+ requiredPositional x @12
+ type: dynamic
+ requiredPositional y @19
+ type: int
''');
}
test_class_constructors() async {
var library = await checkLibrary('class C { C.foo(); C.bar(); }');
checkElementText(library, r'''
-class C {
- C.foo();
- C.bar();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ foo @12
+ periodOffset: 11
+ nameEnd: 15
+ bar @21
+ periodOffset: 20
+ nameEnd: 24
''');
}
@@ -765,11 +1513,13 @@
*/
class C {}''');
checkElementText(library, r'''
-/**
- * Docs
- */
-class C {
-}
+library
+ definingUnit
+ classes
+ class C @22
+ documentationComment: /**\n * Docs\n */
+ constructors
+ synthetic @-1
''');
}
@@ -812,43 +1562,46 @@
class E {}
''');
checkElementText(library, r'''
-/**
- * bbb
- */
-class A {
-}
-/// bbb
-/// ccc
-class B {
-}
-/**
- * ccc
- */
-class C {
-}
-/// ddd
-class D {
-}
-/**
- * aaa
- */
-class E {
-}
+library
+ definingUnit
+ classes
+ class A @36
+ documentationComment: /**\n * bbb\n */
+ constructors
+ synthetic @-1
+ class B @79
+ documentationComment: /// bbb\n/// ccc
+ constructors
+ synthetic @-1
+ class C @122
+ documentationComment: /**\n * ccc\n */
+ constructors
+ synthetic @-1
+ class D @173
+ documentationComment: /// ddd
+ constructors
+ synthetic @-1
+ class E @207
+ documentationComment: /**\n * aaa\n */
+ constructors
+ synthetic @-1
''');
}
test_class_documented_tripleSlash() async {
var library = await checkLibrary('''
-/// aaa
-/// bbbb
-/// cc
+/// first
+/// second
+/// third
class C {}''');
checkElementText(library, r'''
-/// aaa
-/// bbbb
-/// cc
-class C {
-}
+library
+ definingUnit
+ classes
+ class C @37
+ documentationComment: /// first\n/// second\n/// third
+ constructors
+ synthetic @-1
''');
}
@@ -862,26 +1615,32 @@
class D {}
class E {}''');
checkElementText(library, r'''
-/**
- * Docs referring to [D] and [E]
- */
-class C {
-}
-class D {
-}
-class E {
-}
+library
+ definingUnit
+ classes
+ class C @47
+ documentationComment: /**\n * Docs referring to [D] and [E]\n */
+ constructors
+ synthetic @-1
+ class D @59
+ constructors
+ synthetic @-1
+ class E @70
+ constructors
+ synthetic @-1
''');
}
test_class_documented_with_windows_line_endings() async {
var library = await checkLibrary('/**\r\n * Docs\r\n */\r\nclass C {}');
checkElementText(library, r'''
-/**
- * Docs
- */
-class C {
-}
+library
+ definingUnit
+ classes
+ class C @25
+ documentationComment: /**\n * Docs\n */
+ constructors
+ synthetic @-1
''');
}
@@ -893,11 +1652,13 @@
*/
class C {}''');
checkElementText(library, r'''
-/**
- * Docs
- */
-class C {
-}
+library
+ definingUnit
+ classes
+ class C @66
+ documentationComment: /**\n * Docs\n */
+ constructors
+ synthetic @-1
''');
}
@@ -933,46 +1694,121 @@
const Annotation.named();
}
''');
- checkElementText(
- library,
- r'''
-/// Comment 1
-/// Comment 2
-@Annotation()
-class BeforeMeta {
-}
-/// Comment 1
-/// Comment 2
-@Annotation.named()
-class BeforeMetaNamed {
-}
-/// Comment 1
-/// Comment 2
-@Annotation()
-class AfterMeta {
-}
-/// Comment 2
-@Annotation()
-class AroundMeta {
-}
-/// Doc comment.
-@Annotation()
-class DocBeforeMetaNotDocAfter {
-}
-class Annotation {
- const Annotation();
- const Annotation.named();
-}
-''',
- withConstElements: false);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class BeforeMeta @48
+ documentationComment: /// Comment 1\n/// Comment 2
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @39
+ rightParenthesis: ) @40
+ atSign.offset: 28
+ element: self::@class::Annotation::@constructor::•
+ name: SimpleIdentifier
+ staticElement: self::@class::Annotation
+ staticType: null
+ token: Annotation @29
+ constructors
+ synthetic @-1
+ class BeforeMetaNamed @117
+ documentationComment: /// Comment 1\n/// Comment 2
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @108
+ rightParenthesis: ) @109
+ atSign.offset: 91
+ element: self::@class::Annotation::@constructor::named
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: self::@class::Annotation::@constructor::named
+ staticType: null
+ token: named @103
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@class::Annotation
+ staticType: null
+ token: Annotation @92
+ staticElement: self::@class::Annotation::@constructor::named
+ staticType: null
+ constructors
+ synthetic @-1
+ class AfterMeta @185
+ documentationComment: /// Comment 1\n/// Comment 2
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @148
+ rightParenthesis: ) @149
+ atSign.offset: 137
+ element: self::@class::Annotation::@constructor::•
+ name: SimpleIdentifier
+ staticElement: self::@class::Annotation
+ staticType: null
+ token: Annotation @138
+ constructors
+ synthetic @-1
+ class AroundMeta @247
+ documentationComment: /// Comment 2
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @224
+ rightParenthesis: ) @225
+ atSign.offset: 213
+ element: self::@class::Annotation::@constructor::•
+ name: SimpleIdentifier
+ staticElement: self::@class::Annotation
+ staticType: null
+ token: Annotation @214
+ constructors
+ synthetic @-1
+ class DocBeforeMetaNotDocAfter @319
+ documentationComment: /// Doc comment.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @290
+ rightParenthesis: ) @291
+ atSign.offset: 279
+ element: self::@class::Annotation::@constructor::•
+ name: SimpleIdentifier
+ staticElement: self::@class::Annotation
+ staticType: null
+ token: Annotation @280
+ constructors
+ synthetic @-1
+ class Annotation @354
+ constructors
+ const @375
+ const named @408
+ periodOffset: 407
+ nameEnd: 413
+''');
}
test_class_field_const() async {
var library = await checkLibrary('class C { static const int i = 0; }');
checkElementText(library, r'''
-class C {
- static const int i = 0;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ static const i @27
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @31
+ staticType: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get i @27
+ returnType: int
''');
}
@@ -980,9 +1816,22 @@
var library =
await checkLibrary('class C { static late const int i = 0; }');
checkElementText(library, r'''
-class C {
- static late const int i = 0;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ static late const i @32
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @36
+ staticType: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get i @32
+ returnType: int
''');
}
@@ -994,35 +1843,73 @@
set foo(int newValue) {}
}
''');
- checkElementText(
- library,
- r'''
-class A {
- final int foo;
- synthetic int get foo {}
- void set foo(int newValue) {}
- A(final int this.foo);
-}
-''',
- withSyntheticFields: true,
- withSyntheticAccessors: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ final foo @22
+ type: int
+ constructors
+ @29
+ parameters
+ requiredPositional final this.foo @36
+ type: int
+ accessors
+ synthetic get foo @22
+ returnType: int
+ set foo @48
+ parameters
+ requiredPositional newValue @56
+ type: int
+ returnType: void
+''');
}
test_class_field_implicit_type() async {
var library = await checkLibrary('class C { var x; }');
checkElementText(library, r'''
-class C {
- dynamic x;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @14
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @14
+ returnType: dynamic
+ synthetic set x @14
+ parameters
+ requiredPositional _x @14
+ type: dynamic
+ returnType: void
''');
}
test_class_field_implicit_type_late() async {
var library = await checkLibrary('class C { late var x; }');
checkElementText(library, r'''
-class C {
- late dynamic x;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ late x @19
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @19
+ returnType: dynamic
+ synthetic set x @19
+ parameters
+ requiredPositional _x @19
+ type: dynamic
+ returnType: void
''');
}
@@ -1037,50 +1924,111 @@
final foo = 2;
}
''');
- checkElementText(
- library,
- r'''
-abstract class A {
- double get foo;
- const A();
-}
-class B extends A {
- final double foo;
- constantInitializer
- IntegerLiteral
- literal: 2
- staticType: double
- const B();
-}
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ synthetic foo @-1
+ type: double
+ constructors
+ const @27
+ accessors
+ abstract get foo @45
+ returnType: double
+ class B @58
+ supertype: A
+ fields
+ final foo @93
+ type: double
+ constantInitializer
+ IntegerLiteral
+ literal: 2 @99
+ staticType: double
+ constructors
+ const @80
+ accessors
+ synthetic get foo @93
+ returnType: double
+''');
}
test_class_field_static() async {
var library = await checkLibrary('class C { static int i; }');
checkElementText(library, r'''
-class C {
- static int i;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ static i @21
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get i @21
+ returnType: int
+ synthetic static set i @21
+ parameters
+ requiredPositional _i @21
+ type: int
+ returnType: void
''');
}
test_class_field_static_late() async {
var library = await checkLibrary('class C { static late int i; }');
checkElementText(library, r'''
-class C {
- static late int i;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ static late i @26
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get i @26
+ returnType: int
+ synthetic static set i @26
+ parameters
+ requiredPositional _i @26
+ type: int
+ returnType: void
''');
}
test_class_fields() async {
var library = await checkLibrary('class C { int i; int j; }');
checkElementText(library, r'''
-class C {
- int i;
- int j;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ i @14
+ type: int
+ j @21
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get i @14
+ returnType: int
+ synthetic set i @14
+ parameters
+ requiredPositional _i @14
+ type: int
+ returnType: void
+ synthetic get j @21
+ returnType: int
+ synthetic set j @21
+ parameters
+ requiredPositional _j @21
+ type: int
+ returnType: void
''');
}
@@ -1090,16 +2038,25 @@
late int foo;
}
''');
- checkElementText(
- library,
- r'''
-class C {
- late int foo;
- synthetic int get foo {}
- synthetic void set foo(int _foo) {}
-}
-''',
- withSyntheticAccessors: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ late foo @21
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get foo @21
+ returnType: int
+ synthetic set foo @21
+ parameters
+ requiredPositional _foo @21
+ type: int
+ returnType: void
+''');
}
test_class_fields_late_final() async {
@@ -1108,16 +2065,25 @@
late final int foo;
}
''');
- checkElementText(
- library,
- r'''
-class C {
- late final int foo;
- synthetic int get foo {}
- synthetic void set foo(int _foo) {}
-}
-''',
- withSyntheticAccessors: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ late final foo @27
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get foo @27
+ returnType: int
+ synthetic set foo @27
+ parameters
+ requiredPositional _foo @27
+ type: int
+ returnType: void
+''');
}
test_class_fields_late_final_initialized() async {
@@ -1126,41 +2092,73 @@
late final int foo = 0;
}
''');
- checkElementText(
- library,
- r'''
-class C {
- late final int foo;
- synthetic int get foo {}
-}
-''',
- withSyntheticAccessors: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ late final foo @27
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get foo @27
+ returnType: int
+''');
}
test_class_getter_abstract() async {
var library = await checkLibrary('abstract class C { int get x; }');
checkElementText(library, r'''
-abstract class C {
- int get x;
-}
+library
+ definingUnit
+ classes
+ abstract class C @15
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @27
+ returnType: int
''');
}
test_class_getter_external() async {
var library = await checkLibrary('class C { external int get x; }');
checkElementText(library, r'''
-class C {
- external int get x;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ external get x @27
+ returnType: int
''');
}
test_class_getter_implicit_return_type() async {
var library = await checkLibrary('class C { get x => null; }');
checkElementText(library, r'''
-class C {
- dynamic get x {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic x @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ get x @14
+ returnType: dynamic
''');
}
@@ -1171,33 +2169,59 @@
}
''');
checkElementText(library, r'''
-class C {
- external int get x;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ external get x @20
+ returnType: int
''');
}
test_class_getter_static() async {
var library = await checkLibrary('class C { static int get x => null; }');
- checkElementText(
- library,
- r'''
-class C {
- synthetic static int x;
- static int get x {}
-}
-''',
- withSyntheticFields: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic static x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ static get x @25
+ returnType: int
+''');
}
test_class_getters() async {
var library =
await checkLibrary('class C { int get x => null; get y => null; }');
checkElementText(library, r'''
-class C {
- int get x {}
- dynamic get y {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic x @-1
+ type: int
+ synthetic y @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ get x @18
+ returnType: int
+ get y @33
+ returnType: dynamic
''');
}
@@ -1208,16 +2232,25 @@
void set x(int value) {}
}
''');
- checkElementText(
- library,
- r'''
-class C {
- synthetic int x;
- int get x {}
- void set x(int value) {}
-}
-''',
- withSyntheticFields: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ get x @20
+ returnType: int
+ set x @39
+ parameters
+ requiredPositional value @45
+ type: int
+ returnType: void
+''');
}
test_class_implicitField_setterFirst() async {
@@ -1227,16 +2260,25 @@
int get x => 0;
}
''');
- checkElementText(
- library,
- r'''
-class C {
- synthetic int x;
- void set x(int value) {}
- int get x {}
-}
-''',
- withSyntheticFields: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ set x @21
+ parameters
+ requiredPositional value @27
+ type: int
+ returnType: void
+ get x @47
+ returnType: int
+''');
}
test_class_interfaces() async {
@@ -1246,12 +2288,21 @@
class E {}
''');
checkElementText(library, r'''
-class C implements D, E {
-}
-class D {
-}
-class E {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ interfaces
+ D
+ E
+ constructors
+ synthetic @-1
+ class D @33
+ constructors
+ synthetic @-1
+ class E @44
+ constructors
+ synthetic @-1
''');
}
@@ -1262,12 +2313,21 @@
class C implements A, Function, B {}
''');
checkElementText(library, r'''
-class A {
-}
-class B {
-}
-class C implements A, B {
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ class B @17
+ constructors
+ synthetic @-1
+ class C @28
+ interfaces
+ A
+ B
+ constructors
+ synthetic @-1
''');
}
@@ -1276,30 +2336,51 @@
'class C implements X, Y, Z {} class X {} class Z {}',
allowErrors: true);
checkElementText(library, r'''
-class C implements X, Z {
-}
-class X {
-}
-class Z {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ interfaces
+ X
+ Z
+ constructors
+ synthetic @-1
+ class X @36
+ constructors
+ synthetic @-1
+ class Z @47
+ constructors
+ synthetic @-1
''');
}
test_class_method_abstract() async {
var library = await checkLibrary('abstract class C { f(); }');
checkElementText(library, r'''
-abstract class C {
- dynamic f();
-}
+library
+ definingUnit
+ classes
+ abstract class C @15
+ constructors
+ synthetic @-1
+ methods
+ abstract f @19
+ returnType: dynamic
''');
}
test_class_method_external() async {
var library = await checkLibrary('class C { external f(); }');
checkElementText(library, r'''
-class C {
- external dynamic f() {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ external f @19
+ returnType: dynamic
''');
}
@@ -1311,11 +2392,19 @@
}
''');
checkElementText(library, r'''
-class A {
-}
-class B extends A {
- void A() {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ class B @17
+ supertype: A
+ constructors
+ synthetic @-1
+ methods
+ A @38
+ returnType: void
''');
}
@@ -1326,37 +2415,67 @@
}
''');
checkElementText(library, r'''
-class C {
- external int m() {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ external m @16
+ returnType: int
''');
}
test_class_method_params() async {
var library = await checkLibrary('class C { f(x, y) {} }');
checkElementText(library, r'''
-class C {
- dynamic f(dynamic x, dynamic y) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ f @10
+ parameters
+ requiredPositional x @12
+ type: dynamic
+ requiredPositional y @15
+ type: dynamic
+ returnType: dynamic
''');
}
test_class_method_static() async {
var library = await checkLibrary('class C { static f() {} }');
checkElementText(library, r'''
-class C {
- static dynamic f() {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ static f @17
+ returnType: dynamic
''');
}
test_class_methods() async {
var library = await checkLibrary('class C { f() {} g() {} }');
checkElementText(library, r'''
-class C {
- dynamic f() {}
- dynamic g() {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ f @10
+ returnType: dynamic
+ g @17
+ returnType: dynamic
''');
}
@@ -1369,17 +2488,29 @@
class G {}
''');
checkElementText(library, r'''
-class C extends D with E, F, G {
- synthetic C();
-}
-class D {
-}
-class E {
-}
-class F {
-}
-class G {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ supertype: D
+ mixins
+ E
+ F
+ G
+ constructors
+ synthetic @-1
+ class D @40
+ constructors
+ synthetic @-1
+ class E @51
+ constructors
+ synthetic @-1
+ class F @62
+ constructors
+ synthetic @-1
+ class G @73
+ constructors
+ synthetic @-1
''');
}
@@ -1391,15 +2522,31 @@
class C<C1> {}
''');
checkElementText(library, r'''
-class Z extends A with B<int>, C<double> {
- synthetic Z();
-}
-class A {
-}
-class B<B1> {
-}
-class C<C1> {
-}
+library
+ definingUnit
+ classes
+ class Z @6
+ supertype: A
+ mixins
+ B<int>
+ C<double>
+ constructors
+ synthetic @-1
+ class A @50
+ constructors
+ synthetic @-1
+ class B @61
+ typeParameters
+ covariant B1 @63
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class C @76
+ typeParameters
+ covariant C1 @78
+ defaultType: dynamic
+ constructors
+ synthetic @-1
''');
}
@@ -1408,13 +2555,22 @@
'class C extends Object with X, Y, Z {} class X {} class Z {}',
allowErrors: true);
checkElementText(library, r'''
-class C extends Object with X, Z {
- synthetic C();
-}
-class X {
-}
-class Z {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ supertype: Object
+ mixins
+ X
+ Z
+ constructors
+ synthetic @-1
+ class X @45
+ constructors
+ synthetic @-1
+ class Z @56
+ constructors
+ synthetic @-1
''');
}
@@ -1426,9 +2582,24 @@
typedef F(C value);
''');
checkElementText(library, r'''
-notSimplyBounded typedef F = dynamic Function(C<dynamic Function()> value);
-notSimplyBounded class C<T extends dynamic Function() = dynamic Function()> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant T @8
+ bound: dynamic Function()
+ defaultType: dynamic Function()
+ constructors
+ synthetic @-1
+ typeAliases
+ functionTypeAliasBased notSimplyBounded F @32
+ aliasedType: dynamic Function(C<dynamic Function()>)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional value @-1
+ type: C<dynamic Function()>
+ returnType: dynamic
''');
}
@@ -1439,8 +2610,16 @@
class C<T extends C<dynamic>> {}
''');
checkElementText(library, r'''
-class C<T extends C<dynamic> = C<dynamic>> {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ bound: C<dynamic>
+ defaultType: C<dynamic>
+ constructors
+ synthetic @-1
''');
}
@@ -1450,10 +2629,23 @@
class D<T extends C> {}
''');
checkElementText(library, r'''
-notSimplyBounded class C<T extends D<dynamic>> {
-}
-notSimplyBounded class D<T extends C<dynamic>> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant T @8
+ bound: D<dynamic>
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ notSimplyBounded class D @30
+ typeParameters
+ covariant T @32
+ bound: C<dynamic>
+ defaultType: dynamic
+ constructors
+ synthetic @-1
''');
}
@@ -1463,8 +2655,25 @@
typedef D<T extends C> = void Function();
''');
checkElementText(library, r'''
-notSimplyBounded typedef C<T extends dynamic Function()> = void Function();
-notSimplyBounded typedef D<T extends dynamic Function()> = void Function();
+library
+ definingUnit
+ typeAliases
+ notSimplyBounded C @8
+ typeParameters
+ unrelated T @10
+ bound: dynamic Function()
+ defaultType: dynamic
+ aliasedType: void Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void
+ notSimplyBounded D @50
+ typeParameters
+ unrelated T @52
+ bound: dynamic Function()
+ defaultType: dynamic
+ aliasedType: void Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void
''');
}
@@ -1475,8 +2684,21 @@
typedef D<T extends C> = List<T>;
''');
checkElementText(library, r'''
-notSimplyBounded typedef C<T extends dynamic> = List<T>;
-notSimplyBounded typedef D<T extends dynamic> = List<T>;
+library
+ definingUnit
+ typeAliases
+ notSimplyBounded C @8
+ typeParameters
+ covariant T @10
+ bound: dynamic
+ defaultType: dynamic
+ aliasedType: List<T>
+ notSimplyBounded D @42
+ typeParameters
+ covariant T @44
+ bound: dynamic
+ defaultType: dynamic
+ aliasedType: List<T>
''');
}
@@ -1486,10 +2708,23 @@
class D<T extends D> {}
''');
checkElementText(library, r'''
-notSimplyBounded class C<T extends D<dynamic> = D<dynamic>> {
-}
-notSimplyBounded class D<T extends D<dynamic>> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant T @8
+ bound: D<dynamic>
+ defaultType: D<dynamic>
+ constructors
+ synthetic @-1
+ notSimplyBounded class D @30
+ typeParameters
+ covariant T @32
+ bound: D<dynamic>
+ defaultType: dynamic
+ constructors
+ synthetic @-1
''');
}
@@ -1499,10 +2734,22 @@
class D<T> {}
''');
checkElementText(library, r'''
-notSimplyBounded class C<T extends D<T> = D<dynamic>> {
-}
-class D<T> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant T @8
+ bound: D<T>
+ defaultType: D<dynamic>
+ constructors
+ synthetic @-1
+ class D @33
+ typeParameters
+ covariant T @35
+ defaultType: dynamic
+ constructors
+ synthetic @-1
''');
}
@@ -1514,10 +2761,23 @@
class D<T extends D<T>> {}
''');
checkElementText(library, r'''
-class C<T extends D<dynamic> = D<dynamic>> {
-}
-notSimplyBounded class D<T extends D<T> = D<dynamic>> {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ bound: D<dynamic>
+ defaultType: D<dynamic>
+ constructors
+ synthetic @-1
+ notSimplyBounded class D @39
+ typeParameters
+ covariant T @41
+ bound: D<T>
+ defaultType: D<dynamic>
+ constructors
+ synthetic @-1
''');
}
@@ -1526,8 +2786,16 @@
class C<T extends void Function(T)> {}
''');
checkElementText(library, r'''
-notSimplyBounded class C<T extends void Function(T) = void Function(Never)> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant T @8
+ bound: void Function(T)
+ defaultType: void Function(Never)
+ constructors
+ synthetic @-1
''');
}
@@ -1537,8 +2805,16 @@
class C<T extends void Function(T)> {}
''');
checkElementText(library, r'''
-notSimplyBounded class C<T extends void Function(T*)* = void Function(Null*)*> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant T @8
+ bound: void Function(T*)*
+ defaultType: void Function(Null*)*
+ constructors
+ synthetic @-1
''');
}
@@ -1547,8 +2823,16 @@
class C<T extends T Function()> {}
''');
checkElementText(library, r'''
-notSimplyBounded class C<T extends T Function() = dynamic Function()> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant T @8
+ bound: T Function()
+ defaultType: dynamic Function()
+ constructors
+ synthetic @-1
''');
}
@@ -1557,8 +2841,16 @@
class C<T extends void Function()> {}
''');
checkElementText(library, r'''
-class C<T extends void Function() = void Function()> {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ bound: void Function()
+ defaultType: void Function()
+ constructors
+ synthetic @-1
''');
}
@@ -1572,10 +2864,31 @@
typedef G(F value);
''');
checkElementText(library, r'''
-notSimplyBounded typedef F = dynamic Function(dynamic Function() value);
-notSimplyBounded typedef G = dynamic Function(dynamic Function() value);
-notSimplyBounded class C<T extends dynamic Function() = dynamic Function()> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant T @8
+ bound: dynamic Function()
+ defaultType: dynamic Function()
+ constructors
+ synthetic @-1
+ typeAliases
+ functionTypeAliasBased notSimplyBounded F @32
+ aliasedType: dynamic Function(dynamic Function())
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional value @-1
+ type: dynamic Function()
+ returnType: dynamic
+ functionTypeAliasBased notSimplyBounded G @52
+ aliasedType: dynamic Function(dynamic Function())
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional value @-1
+ type: dynamic Function()
+ returnType: dynamic
''');
}
@@ -1584,8 +2897,16 @@
class C<T extends C> {}
''');
checkElementText(library, r'''
-notSimplyBounded class C<T extends C<dynamic>> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant T @8
+ bound: C<dynamic>
+ defaultType: dynamic
+ constructors
+ synthetic @-1
''');
}
@@ -1596,8 +2917,12 @@
class C {}
''');
checkElementText(library, r'''
-class C {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
''');
}
@@ -1607,10 +2932,22 @@
class D<T> {}
''');
checkElementText(library, r'''
-class C<T extends D<dynamic> = D<dynamic>> {
-}
-class D<T> {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ bound: D<dynamic>
+ defaultType: D<dynamic>
+ constructors
+ synthetic @-1
+ class D @30
+ typeParameters
+ covariant T @32
+ defaultType: dynamic
+ constructors
+ synthetic @-1
''');
}
@@ -1621,8 +2958,15 @@
class C<T> {}
''');
checkElementText(library, r'''
-class C<T> {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ synthetic @-1
''');
}
@@ -1631,10 +2975,24 @@
class C {}
C c;
''');
- checkElementText(library, '''
-class C {
-}
-C c;
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static c @13
+ type: C
+ accessors
+ synthetic static get c @13
+ returnType: C
+ synthetic static set c @13
+ parameters
+ requiredPositional _c @13
+ type: C
+ returnType: void
''');
}
@@ -1643,10 +3001,24 @@
class C {}
C? c;
''');
- checkElementText(library, '''
-class C {
-}
-C? c;
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static c @14
+ type: C?
+ accessors
+ synthetic static get c @14
+ returnType: C?
+ synthetic static set c @14
+ parameters
+ requiredPositional _c @14
+ type: C?
+ returnType: void
''');
}
@@ -1656,10 +3028,24 @@
class C {}
C c;
''');
- checkElementText(library, '''
-class C {
-}
-C* c;
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static c @13
+ type: C*
+ accessors
+ synthetic static get c @13
+ returnType: C*
+ synthetic static set c @13
+ parameters
+ requiredPositional _c @13
+ type: C*
+ returnType: void
''');
}
@@ -1667,9 +3053,21 @@
var library =
await checkLibrary('abstract class C { void set x(int value); }');
checkElementText(library, r'''
-abstract class C {
- void set x(int value);
-}
+library
+ definingUnit
+ classes
+ abstract class C @15
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract set x @28
+ parameters
+ requiredPositional value @34
+ type: int
+ returnType: void
''');
}
@@ -1677,63 +3075,146 @@
var library =
await checkLibrary('class C { external void set x(int value); }');
checkElementText(library, r'''
-class C {
- external void set x(int value);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ external set x @28
+ parameters
+ requiredPositional value @34
+ type: int
+ returnType: void
''');
}
test_class_setter_implicit_param_type() async {
var library = await checkLibrary('class C { void set x(value) {} }');
checkElementText(library, r'''
-class C {
- void set x(dynamic value) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic x @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ set x @19
+ parameters
+ requiredPositional value @21
+ type: dynamic
+ returnType: void
''');
}
test_class_setter_implicit_return_type() async {
var library = await checkLibrary('class C { set x(int value) {} }');
checkElementText(library, r'''
-class C {
- void set x(int value) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ set x @14
+ parameters
+ requiredPositional value @20
+ type: int
+ returnType: void
''');
}
test_class_setter_invalid_named_parameter() async {
var library = await checkLibrary('class C { void set x({a}) {} }');
checkElementText(library, r'''
-class C {
- void set x({dynamic a}) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic x @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ set x @19
+ parameters
+ optionalNamed a @22
+ type: dynamic
+ returnType: void
''');
}
test_class_setter_invalid_no_parameter() async {
var library = await checkLibrary('class C { void set x() {} }');
checkElementText(library, r'''
-class C {
- void set x() {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic x @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ set x @19
+ returnType: void
''');
}
test_class_setter_invalid_optional_parameter() async {
var library = await checkLibrary('class C { void set x([a]) {} }');
checkElementText(library, r'''
-class C {
- void set x([dynamic a]) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic x @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ set x @19
+ parameters
+ optionalPositional a @22
+ type: dynamic
+ returnType: void
''');
}
test_class_setter_invalid_too_many_parameters() async {
var library = await checkLibrary('class C { void set x(a, b) {} }');
checkElementText(library, r'''
-class C {
- void set x(dynamic a, dynamic b) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic x @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ set x @19
+ parameters
+ requiredPositional a @21
+ type: dynamic
+ requiredPositional b @24
+ type: dynamic
+ returnType: void
''');
}
@@ -1744,9 +3225,21 @@
}
''');
checkElementText(library, r'''
-class C {
- external void set x(int value);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ external set x @21
+ parameters
+ requiredPositional value @27
+ type: int
+ returnType: void
''');
}
@@ -1754,9 +3247,21 @@
var library =
await checkLibrary('class C { static void set x(int value) {} }');
checkElementText(library, r'''
-class C {
- static void set x(int value) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic static x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ static set x @26
+ parameters
+ requiredPositional value @32
+ type: int
+ returnType: void
''');
}
@@ -1768,10 +3273,28 @@
}
''');
checkElementText(library, r'''
-class C {
- void set x(int value) {}
- void set y(dynamic value) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic x @-1
+ type: int
+ synthetic y @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ set x @21
+ parameters
+ requiredPositional value @27
+ type: int
+ returnType: void
+ set y @43
+ parameters
+ requiredPositional value @45
+ type: dynamic
+ returnType: void
''');
}
@@ -1781,10 +3304,16 @@
class D {}
''');
checkElementText(library, r'''
-class C extends D {
-}
-class D {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ supertype: D
+ constructors
+ synthetic @-1
+ class D @27
+ constructors
+ synthetic @-1
''');
}
@@ -1794,10 +3323,21 @@
class D<T1, T2> {}
''');
checkElementText(library, r'''
-class C extends D<int, double> {
-}
-class D<T1, T2> {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ supertype: D<int, double>
+ constructors
+ synthetic @-1
+ class D @40
+ typeParameters
+ covariant T1 @42
+ defaultType: dynamic
+ covariant T2 @46
+ defaultType: dynamic
+ constructors
+ synthetic @-1
''');
}
@@ -1807,26 +3347,48 @@
class B extends A<B> {}
''');
checkElementText(library, r'''
-class A<T> {
-}
-class B extends A<B> {
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class B @20
+ supertype: A<B>
+ constructors
+ synthetic @-1
''');
}
test_class_supertype_unresolved() async {
var library = await checkLibrary('class C extends D {}', allowErrors: true);
checkElementText(library, r'''
-class C {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
''');
}
test_class_type_parameters() async {
var library = await checkLibrary('class C<T, U> {}');
checkElementText(library, r'''
-class C<T, U> {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ covariant U @11
+ defaultType: dynamic
+ constructors
+ synthetic @-1
''');
}
@@ -1836,50 +3398,97 @@
class D {}
''');
checkElementText(library, r'''
-class C<T = Object, U extends D = D> {
-}
-class D {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ bound: Object
+ defaultType: Object
+ covariant U @26
+ bound: D
+ defaultType: D
+ constructors
+ synthetic @-1
+ class D @48
+ constructors
+ synthetic @-1
''');
}
test_class_type_parameters_cycle_1of1() async {
var library = await checkLibrary('class C<T extends T> {}');
- checkElementText(
- library,
- r'''
-notSimplyBounded class C<T extends dynamic> {
-}
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant T @8
+ bound: dynamic
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+''');
}
test_class_type_parameters_cycle_2of3() async {
var library = await checkLibrary(r'''
class C<T extends V, U, V extends T> {}
''');
- checkElementText(
- library,
- r'''
-notSimplyBounded class C<T extends dynamic, U, V extends dynamic> {
-}
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant T @8
+ bound: dynamic
+ defaultType: dynamic
+ covariant U @21
+ defaultType: dynamic
+ covariant V @24
+ bound: dynamic
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+''');
}
test_class_type_parameters_f_bound_complex() async {
var library = await checkLibrary('class C<T extends List<U>, U> {}');
checkElementText(library, r'''
-notSimplyBounded class C<T extends List<U> = List<dynamic>, U> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant T @8
+ bound: List<U>
+ defaultType: List<dynamic>
+ covariant U @27
+ defaultType: dynamic
+ constructors
+ synthetic @-1
''');
}
test_class_type_parameters_f_bound_simple() async {
var library = await checkLibrary('class C<T extends U, U> {}');
checkElementText(library, r'''
-notSimplyBounded class C<T extends U, U> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant T @8
+ bound: U
+ defaultType: dynamic
+ covariant U @21
+ defaultType: dynamic
+ constructors
+ synthetic @-1
''');
}
@@ -1887,13 +3496,18 @@
var library = await checkLibrary(r'''
class A<T extends void Function(A)> {}
''');
- checkElementText(
- library,
- r'''
-notSimplyBounded class A<covariant T extends void Function(A<dynamic>)> {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ notSimplyBounded class A @6
+ typeParameters
+ covariant T @8
+ bound: void Function(A<dynamic>)
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+''');
}
test_class_typeParameters_defaultType_cycle_genericFunctionType2() async {
@@ -1901,13 +3515,18 @@
var library = await checkLibrary(r'''
class C<T extends void Function<U extends C>()> {}
''');
- checkElementText(
- library,
- r'''
-notSimplyBounded class C<covariant T extends void Function<U extends C<dynamic>>()> {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant T @8
+ bound: void Function<U extends C<dynamic>>()
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+''');
}
test_class_typeParameters_defaultType_functionTypeAlias_contravariant_legacy() async {
@@ -1917,14 +3536,35 @@
class A<X extends F<X>> {}
''');
- checkElementText(
- library,
- r'''
-typedef F<contravariant X> = void Function(X* );
-notSimplyBounded class A<covariant X extends void Function(X*)* = void Function(Null*)*> {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ notSimplyBounded class A @40
+ typeParameters
+ covariant X @42
+ bound: void Function(X*)*
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ X*
+ defaultType: void Function(Null*)*
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ Null*
+ constructors
+ synthetic @-1
+ typeAliases
+ F @8
+ typeParameters
+ contravariant X @10
+ defaultType: dynamic
+ aliasedType: void Function(X*)*
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional @-1
+ type: X*
+ returnType: void
+''');
}
test_class_typeParameters_defaultType_functionTypeAlias_contravariant_nullSafe() async {
@@ -1933,14 +3573,35 @@
class A<X extends F<X>> {}
''');
- checkElementText(
- library,
- r'''
-typedef F<contravariant X> = void Function(X );
-notSimplyBounded class A<covariant X extends void Function(X) = void Function(Never)> {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ notSimplyBounded class A @40
+ typeParameters
+ covariant X @42
+ bound: void Function(X)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ X
+ defaultType: void Function(Never)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ Never
+ constructors
+ synthetic @-1
+ typeAliases
+ F @8
+ typeParameters
+ contravariant X @10
+ defaultType: dynamic
+ aliasedType: void Function(X)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional @-1
+ type: X
+ returnType: void
+''');
}
test_class_typeParameters_defaultType_functionTypeAlias_covariant_nullSafe() async {
@@ -1949,14 +3610,32 @@
class A<X extends F<X>> {}
''');
- checkElementText(
- library,
- r'''
-typedef F<covariant X> = X Function();
-notSimplyBounded class A<covariant X extends X Function() = dynamic Function()> {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ notSimplyBounded class A @36
+ typeParameters
+ covariant X @38
+ bound: X Function()
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ X
+ defaultType: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ dynamic
+ constructors
+ synthetic @-1
+ typeAliases
+ F @8
+ typeParameters
+ covariant X @10
+ defaultType: dynamic
+ aliasedType: X Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: X
+''');
}
test_class_typeParameters_defaultType_functionTypeAlias_invariant_legacy() async {
@@ -1965,14 +3644,35 @@
class A<X extends F<X>> {}
''');
- checkElementText(
- library,
- r'''
-typedef F<invariant X> = X Function(X );
-notSimplyBounded class A<covariant X extends X Function(X) = dynamic Function(dynamic)> {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ notSimplyBounded class A @37
+ typeParameters
+ covariant X @39
+ bound: X Function(X)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ X
+ defaultType: dynamic Function(dynamic)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ dynamic
+ constructors
+ synthetic @-1
+ typeAliases
+ F @8
+ typeParameters
+ invariant X @10
+ defaultType: dynamic
+ aliasedType: X Function(X)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional @-1
+ type: X
+ returnType: X
+''');
}
test_class_typeParameters_defaultType_functionTypeAlias_invariant_nullSafe() async {
@@ -1981,14 +3681,35 @@
class A<X extends F<X>> {}
''');
- checkElementText(
- library,
- r'''
-typedef F<invariant X> = X Function(X );
-notSimplyBounded class A<covariant X extends X Function(X) = dynamic Function(dynamic)> {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ notSimplyBounded class A @37
+ typeParameters
+ covariant X @39
+ bound: X Function(X)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ X
+ defaultType: dynamic Function(dynamic)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ dynamic
+ constructors
+ synthetic @-1
+ typeAliases
+ F @8
+ typeParameters
+ invariant X @10
+ defaultType: dynamic
+ aliasedType: X Function(X)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional @-1
+ type: X
+ returnType: X
+''');
}
test_class_typeParameters_defaultType_genericFunctionType_both_legacy() async {
@@ -1997,8 +3718,16 @@
class A<X extends X Function(X)> {}
''');
checkElementText(library, r'''
-notSimplyBounded class A<X extends X* Function(X*)* = dynamic Function(Null*)*> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class A @6
+ typeParameters
+ covariant X @8
+ bound: X* Function(X*)*
+ defaultType: dynamic Function(Null*)*
+ constructors
+ synthetic @-1
''');
}
@@ -2007,8 +3736,16 @@
class A<X extends X Function(X)> {}
''');
checkElementText(library, r'''
-notSimplyBounded class A<X extends X Function(X) = dynamic Function(Never)> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class A @6
+ typeParameters
+ covariant X @8
+ bound: X Function(X)
+ defaultType: dynamic Function(Never)
+ constructors
+ synthetic @-1
''');
}
@@ -2018,8 +3755,16 @@
class A<X extends void Function(X)> {}
''');
checkElementText(library, r'''
-notSimplyBounded class A<X extends void Function(X*)* = void Function(Null*)*> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class A @6
+ typeParameters
+ covariant X @8
+ bound: void Function(X*)*
+ defaultType: void Function(Null*)*
+ constructors
+ synthetic @-1
''');
}
@@ -2028,8 +3773,16 @@
class A<X extends void Function(X)> {}
''');
checkElementText(library, r'''
-notSimplyBounded class A<X extends void Function(X) = void Function(Never)> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class A @6
+ typeParameters
+ covariant X @8
+ bound: void Function(X)
+ defaultType: void Function(Never)
+ constructors
+ synthetic @-1
''');
}
@@ -2038,8 +3791,16 @@
class A<X extends X Function()> {}
''');
checkElementText(library, r'''
-notSimplyBounded class A<X extends X Function() = dynamic Function()> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class A @6
+ typeParameters
+ covariant X @8
+ bound: X Function()
+ defaultType: dynamic Function()
+ constructors
+ synthetic @-1
''');
}
@@ -2048,8 +3809,16 @@
class A<X extends X Function()> {}
''');
checkElementText(library, r'''
-notSimplyBounded class A<X extends X Function() = dynamic Function()> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class A @6
+ typeParameters
+ covariant X @8
+ bound: X Function()
+ defaultType: dynamic Function()
+ constructors
+ synthetic @-1
''');
}
@@ -2060,14 +3829,30 @@
class B<X extends A<X>> {}
''');
- checkElementText(
- library,
- r'''
-typedef A<contravariant X> = List<void Function(X)>;
-notSimplyBounded class B<covariant X extends List<void Function(X)> = List<void Function(Never)>> {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ notSimplyBounded class B @46
+ typeParameters
+ covariant X @48
+ bound: List<void Function(X)>
+ aliasElement: self::@typeAlias::A
+ aliasArguments
+ X
+ defaultType: List<void Function(Never)>
+ aliasElement: self::@typeAlias::A
+ aliasArguments
+ Never
+ constructors
+ synthetic @-1
+ typeAliases
+ A @8
+ typeParameters
+ contravariant X @10
+ defaultType: dynamic
+ aliasedType: List<void Function(X)>
+''');
}
test_class_typeParameters_defaultType_typeAlias_interface_covariant() async {
@@ -2077,67 +3862,108 @@
class B<X extends A<X>> {}
''');
- checkElementText(
- library,
- r'''
-typedef A<covariant X> = Map<X, int>;
-notSimplyBounded class B<covariant X extends Map<X, int> = Map<dynamic, int>> {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ notSimplyBounded class B @35
+ typeParameters
+ covariant X @37
+ bound: Map<X, int>
+ aliasElement: self::@typeAlias::A
+ aliasArguments
+ X
+ defaultType: Map<dynamic, int>
+ aliasElement: self::@typeAlias::A
+ aliasArguments
+ dynamic
+ constructors
+ synthetic @-1
+ typeAliases
+ A @8
+ typeParameters
+ covariant X @10
+ defaultType: dynamic
+ aliasedType: Map<X, int>
+''');
}
test_class_typeParameters_variance_contravariant() async {
var library = await checkLibrary('class C<in T> {}');
- checkElementText(
- library,
- r'''
-class C<contravariant T> {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ contravariant T @11
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+''');
}
test_class_typeParameters_variance_covariant() async {
var library = await checkLibrary('class C<out T> {}');
- checkElementText(
- library,
- r'''
-class C<covariant T> {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @12
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+''');
}
test_class_typeParameters_variance_invariant() async {
var library = await checkLibrary('class C<inout T> {}');
- checkElementText(
- library,
- r'''
-class C<invariant T> {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ invariant T @14
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+''');
}
test_class_typeParameters_variance_multiple() async {
var library = await checkLibrary('class C<inout T, in U, out V> {}');
- checkElementText(
- library,
- r'''
-class C<invariant T, contravariant U, covariant V> {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ invariant T @14
+ defaultType: dynamic
+ contravariant U @20
+ defaultType: dynamic
+ covariant V @27
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+''');
}
test_classes() async {
var library = await checkLibrary('class C {} class D {}');
checkElementText(library, r'''
-class C {
-}
-class D {
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ class D @17
+ constructors
+ synthetic @-1
''');
}
@@ -2149,7 +3975,11 @@
}
''');
checkElementText(library, r'''
-dynamic f() {}
+library
+ definingUnit
+ functions
+ f @0
+ returnType: dynamic
''');
}
@@ -2158,7 +3988,14 @@
final f = <U, V>(U x, V y) => y;
''');
checkElementText(library, r'''
-final V Function<U, V>(U, V) f;
+library
+ definingUnit
+ topLevelVariables
+ static final f @6
+ type: V Function<U, V>(U, V)
+ accessors
+ synthetic static get f @6
+ returnType: V Function<U, V>(U, V)
''');
}
@@ -2169,12 +4006,18 @@
part "a.dart";
''');
checkElementText(library, r'''
-library lib;
-part 'a.dart';
---------------------
-unit: a.dart
-
-final double Function(int) f;
+library
+ name: lib
+ nameOffset: 8
+ definingUnit
+ parts
+ a.dart
+ topLevelVariables
+ static final f @19
+ type: double Function(int)
+ accessors
+ synthetic static get f @19
+ returnType: double Function(int)
''');
}
@@ -2207,32 +4050,89 @@
checkElementText(
library,
r'''
-class Raw/*codeOffset=0, codeLength=12*/ {
-}
-/// Comment 1.
-/// Comment 2.
-class HasDocComment/*codeOffset=14, codeLength=52*/ {
-}
-@Object()
-class HasAnnotation/*codeOffset=68, codeLength=32*/ {
-}
-/// Comment 1.
-/// Comment 2.
-@Object()
-class AnnotationThenComment/*codeOffset=102, codeLength=70*/ {
-}
-/// Comment 1.
-/// Comment 2.
-@Object()
-class CommentThenAnnotation/*codeOffset=174, codeLength=70*/ {
-}
-/// Comment 2.
-@Object()
-class CommentAroundAnnotation/*codeOffset=261, codeLength=57*/ {
-}
+library
+ definingUnit
+ classes
+ class Raw @6
+ codeOffset: 0
+ codeLength: 12
+ constructors
+ synthetic @-1
+ class HasDocComment @50
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ codeOffset: 14
+ codeLength: 52
+ constructors
+ synthetic @-1
+ class HasAnnotation @84
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @75
+ rightParenthesis: ) @76
+ atSign.offset: 68
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @69
+ codeOffset: 68
+ codeLength: 32
+ constructors
+ synthetic @-1
+ class AnnotationThenComment @148
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @109
+ rightParenthesis: ) @110
+ atSign.offset: 102
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @103
+ codeOffset: 102
+ codeLength: 70
+ constructors
+ synthetic @-1
+ class CommentThenAnnotation @220
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @211
+ rightParenthesis: ) @212
+ atSign.offset: 204
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @205
+ codeOffset: 174
+ codeLength: 70
+ constructors
+ synthetic @-1
+ class CommentAroundAnnotation @292
+ documentationComment: /// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @268
+ rightParenthesis: ) @269
+ atSign.offset: 261
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @262
+ codeOffset: 261
+ codeLength: 57
+ constructors
+ synthetic @-1
''',
- withCodeRanges: true,
- withConstElements: false);
+ withCodeRanges: true);
}
test_codeRange_class_namedMixin() async {
@@ -2268,42 +4168,159 @@
checkElementText(
library,
r'''
-class A/*codeOffset=0, codeLength=10*/ {
-}
-class B/*codeOffset=12, codeLength=10*/ {
-}
-class alias Raw/*codeOffset=24, codeLength=29*/ extends Object with A, B {
- synthetic const Raw() : super();
-}
-/// Comment 1.
-/// Comment 2.
-class alias HasDocComment/*codeOffset=55, codeLength=69*/ extends Object with A, B {
- synthetic const HasDocComment() : super();
-}
-@Object()
-class alias HasAnnotation/*codeOffset=126, codeLength=49*/ extends Object with A, B {
- synthetic const HasAnnotation() : super();
-}
-/// Comment 1.
-/// Comment 2.
-@Object()
-class alias AnnotationThenComment/*codeOffset=177, codeLength=87*/ extends Object with A, B {
- synthetic const AnnotationThenComment() : super();
-}
-/// Comment 1.
-/// Comment 2.
-@Object()
-class alias CommentThenAnnotation/*codeOffset=266, codeLength=87*/ extends Object with A, B {
- synthetic const CommentThenAnnotation() : super();
-}
-/// Comment 2.
-@Object()
-class alias CommentAroundAnnotation/*codeOffset=370, codeLength=74*/ extends Object with A, B {
- synthetic const CommentAroundAnnotation() : super();
-}
+library
+ definingUnit
+ classes
+ class A @6
+ codeOffset: 0
+ codeLength: 10
+ constructors
+ synthetic @-1
+ class B @18
+ codeOffset: 12
+ codeLength: 10
+ constructors
+ synthetic @-1
+ class alias Raw @30
+ codeOffset: 24
+ codeLength: 29
+ supertype: Object
+ mixins
+ A
+ B
+ constructors
+ synthetic const @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: dart:core::@class::Object::@constructor::•
+ class alias HasDocComment @91
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ codeOffset: 55
+ codeLength: 69
+ supertype: Object
+ mixins
+ A
+ B
+ constructors
+ synthetic const @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: dart:core::@class::Object::@constructor::•
+ class alias HasAnnotation @142
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @133
+ rightParenthesis: ) @134
+ atSign.offset: 126
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @127
+ codeOffset: 126
+ codeLength: 49
+ supertype: Object
+ mixins
+ A
+ B
+ constructors
+ synthetic const @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: dart:core::@class::Object::@constructor::•
+ class alias AnnotationThenComment @223
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @184
+ rightParenthesis: ) @185
+ atSign.offset: 177
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @178
+ codeOffset: 177
+ codeLength: 87
+ supertype: Object
+ mixins
+ A
+ B
+ constructors
+ synthetic const @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: dart:core::@class::Object::@constructor::•
+ class alias CommentThenAnnotation @312
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @303
+ rightParenthesis: ) @304
+ atSign.offset: 296
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @297
+ codeOffset: 266
+ codeLength: 87
+ supertype: Object
+ mixins
+ A
+ B
+ constructors
+ synthetic const @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: dart:core::@class::Object::@constructor::•
+ class alias CommentAroundAnnotation @401
+ documentationComment: /// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @377
+ rightParenthesis: ) @378
+ atSign.offset: 370
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @371
+ codeOffset: 370
+ codeLength: 74
+ supertype: Object
+ mixins
+ A
+ B
+ constructors
+ synthetic const @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: dart:core::@class::Object::@constructor::•
''',
- withCodeRanges: true,
- withConstElements: false);
+ withCodeRanges: true);
}
test_codeRange_constructor() async {
@@ -2339,29 +4356,96 @@
checkElementText(
library,
r'''
-class C/*codeOffset=0, codeLength=362*/ {
- C/*codeOffset=12, codeLength=4*/();
- C.raw/*codeOffset=20, codeLength=10*/();
- /// Comment 1.
- /// Comment 2.
- C.hasDocComment/*codeOffset=34, codeLength=54*/();
- @Object()
- C.hasAnnotation/*codeOffset=92, codeLength=32*/();
- /// Comment 1.
- /// Comment 2.
- @Object()
- C.annotationThenComment/*codeOffset=128, codeLength=74*/();
- /// Comment 1.
- /// Comment 2.
- @Object()
- C.commentThenAnnotation/*codeOffset=206, codeLength=74*/();
- /// Comment 2.
- @Object()
- C.commentAroundAnnotation/*codeOffset=301, codeLength=59*/();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ codeOffset: 0
+ codeLength: 362
+ constructors
+ @12
+ codeOffset: 12
+ codeLength: 4
+ raw @22
+ codeOffset: 20
+ codeLength: 10
+ periodOffset: 21
+ nameEnd: 25
+ hasDocComment @70
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ codeOffset: 34
+ codeLength: 54
+ periodOffset: 69
+ nameEnd: 83
+ hasAnnotation @106
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @99
+ rightParenthesis: ) @100
+ atSign.offset: 92
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @93
+ codeOffset: 92
+ codeLength: 32
+ periodOffset: 105
+ nameEnd: 119
+ annotationThenComment @176
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @135
+ rightParenthesis: ) @136
+ atSign.offset: 128
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @129
+ codeOffset: 128
+ codeLength: 74
+ periodOffset: 175
+ nameEnd: 197
+ commentThenAnnotation @254
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @247
+ rightParenthesis: ) @248
+ atSign.offset: 240
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @241
+ codeOffset: 206
+ codeLength: 74
+ periodOffset: 253
+ nameEnd: 275
+ commentAroundAnnotation @332
+ documentationComment: /// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @308
+ rightParenthesis: ) @309
+ atSign.offset: 301
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @302
+ codeOffset: 301
+ codeLength: 59
+ periodOffset: 331
+ nameEnd: 355
''',
- withCodeRanges: true,
- withConstElements: false);
+ withCodeRanges: true);
}
test_codeRange_constructor_factory() async {
@@ -2397,29 +4481,96 @@
checkElementText(
library,
r'''
-class C/*codeOffset=0, codeLength=483*/ {
- factory C/*codeOffset=12, codeLength=23*/();
- factory C.raw/*codeOffset=39, codeLength=27*/();
- /// Comment 1.
- /// Comment 2.
- factory C.hasDocComment/*codeOffset=70, codeLength=71*/();
- @Object()
- factory C.hasAnnotation/*codeOffset=145, codeLength=49*/();
- /// Comment 1.
- /// Comment 2.
- @Object()
- factory C.annotationThenComment/*codeOffset=198, codeLength=91*/();
- /// Comment 1.
- /// Comment 2.
- @Object()
- factory C.commentThenAnnotation/*codeOffset=293, codeLength=91*/();
- /// Comment 2.
- @Object()
- factory C.commentAroundAnnotation/*codeOffset=405, codeLength=76*/();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ codeOffset: 0
+ codeLength: 483
+ constructors
+ factory @20
+ codeOffset: 12
+ codeLength: 23
+ factory raw @49
+ codeOffset: 39
+ codeLength: 27
+ periodOffset: 48
+ nameEnd: 52
+ factory hasDocComment @114
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ codeOffset: 70
+ codeLength: 71
+ periodOffset: 113
+ nameEnd: 127
+ factory hasAnnotation @167
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @152
+ rightParenthesis: ) @153
+ atSign.offset: 145
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @146
+ codeOffset: 145
+ codeLength: 49
+ periodOffset: 166
+ nameEnd: 180
+ factory annotationThenComment @254
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @205
+ rightParenthesis: ) @206
+ atSign.offset: 198
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @199
+ codeOffset: 198
+ codeLength: 91
+ periodOffset: 253
+ nameEnd: 275
+ factory commentThenAnnotation @349
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @334
+ rightParenthesis: ) @335
+ atSign.offset: 327
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @328
+ codeOffset: 293
+ codeLength: 91
+ periodOffset: 348
+ nameEnd: 370
+ factory commentAroundAnnotation @444
+ documentationComment: /// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @412
+ rightParenthesis: ) @413
+ atSign.offset: 405
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @406
+ codeOffset: 405
+ codeLength: 76
+ periodOffset: 443
+ nameEnd: 467
''',
- withCodeRanges: true,
- withConstElements: false);
+ withCodeRanges: true);
}
test_codeRange_enum() async {
@@ -2431,17 +4582,45 @@
checkElementText(
library,
r'''
-enum E/*codeOffset=0, codeLength=26*/ {
- synthetic final int index/*codeOffset=null, codeLength=null*/;
- synthetic static const List<E> values/*codeOffset=null, codeLength=null*/;
- static const E aaa/*codeOffset=11, codeLength=3*/;
- static const E bbb/*codeOffset=16, codeLength=3*/;
- static const E ccc/*codeOffset=21, codeLength=3*/;
- String toString/*codeOffset=null, codeLength=null*/() {}
-}
+library
+ definingUnit
+ enums
+ enum E @5
+ codeOffset: 0
+ codeLength: 26
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const aaa @11
+ codeOffset: 11
+ codeLength: 3
+ type: E
+ static const bbb @16
+ codeOffset: 16
+ codeLength: 3
+ type: E
+ static const ccc @21
+ codeOffset: 21
+ codeLength: 3
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get aaa @-1
+ returnType: E
+ synthetic static get bbb @-1
+ returnType: E
+ synthetic static get ccc @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
''',
- withCodeRanges: true,
- withConstElements: false);
+ withCodeRanges: true);
}
test_codeRange_extensions() async {
@@ -2475,34 +4654,89 @@
checkElementText(
library,
r'''
-class A/*codeOffset=0, codeLength=10*/ {
-}
-extension Raw/*codeOffset=12, codeLength=21*/ on A {
-}
-/// Comment 1.
-/// Comment 2.
-extension HasDocComment/*codeOffset=35, codeLength=61*/ on A {
-}
-@Object()
-extension HasAnnotation/*codeOffset=98, codeLength=41*/ on A {
-}
-/// Comment 1.
-/// Comment 2.
-@Object()
-extension AnnotationThenComment/*codeOffset=141, codeLength=79*/ on A {
-}
-/// Comment 1.
-/// Comment 2.
-@Object()
-extension CommentThenAnnotation/*codeOffset=222, codeLength=79*/ on A {
-}
-/// Comment 2.
-@Object()
-extension CommentAroundAnnotation/*codeOffset=318, codeLength=66*/ on A {
-}
+library
+ definingUnit
+ classes
+ class A @6
+ codeOffset: 0
+ codeLength: 10
+ constructors
+ synthetic @-1
+ extensions
+ Raw @22
+ codeOffset: 12
+ codeLength: 21
+ extendedType: A
+ HasDocComment @75
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ codeOffset: 35
+ codeLength: 61
+ extendedType: A
+ HasAnnotation @118
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @105
+ rightParenthesis: ) @106
+ atSign.offset: 98
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @99
+ codeOffset: 98
+ codeLength: 41
+ extendedType: A
+ AnnotationThenComment @191
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @148
+ rightParenthesis: ) @149
+ atSign.offset: 141
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @142
+ codeOffset: 141
+ codeLength: 79
+ extendedType: A
+ CommentThenAnnotation @272
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @259
+ rightParenthesis: ) @260
+ atSign.offset: 252
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @253
+ codeOffset: 222
+ codeLength: 79
+ extendedType: A
+ CommentAroundAnnotation @353
+ documentationComment: /// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @325
+ rightParenthesis: ) @326
+ atSign.offset: 318
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @319
+ codeOffset: 318
+ codeLength: 66
+ extendedType: A
''',
- withCodeRanges: true,
- withConstElements: false);
+ withCodeRanges: true);
}
test_codeRange_field() async {
@@ -2518,16 +4752,73 @@
checkElementText(
library,
r'''
-class C/*codeOffset=0, codeLength=115*/ {
- int withInit/*codeOffset=12, codeLength=16*/;
- int withoutInit/*codeOffset=33, codeLength=15*/;
- int multiWithInit/*codeOffset=53, codeLength=21*/;
- int multiWithoutInit/*codeOffset=76, codeLength=16*/;
- int multiWithInit2/*codeOffset=94, codeLength=18*/;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ codeOffset: 0
+ codeLength: 115
+ fields
+ withInit @16
+ codeOffset: 12
+ codeLength: 16
+ type: int
+ withoutInit @37
+ codeOffset: 33
+ codeLength: 15
+ type: int
+ multiWithInit @57
+ codeOffset: 53
+ codeLength: 21
+ type: int
+ multiWithoutInit @76
+ codeOffset: 76
+ codeLength: 16
+ type: int
+ multiWithInit2 @94
+ codeOffset: 94
+ codeLength: 18
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get withInit @16
+ returnType: int
+ synthetic set withInit @16
+ parameters
+ requiredPositional _withInit @16
+ type: int
+ returnType: void
+ synthetic get withoutInit @37
+ returnType: int
+ synthetic set withoutInit @37
+ parameters
+ requiredPositional _withoutInit @37
+ type: int
+ returnType: void
+ synthetic get multiWithInit @57
+ returnType: int
+ synthetic set multiWithInit @57
+ parameters
+ requiredPositional _multiWithInit @57
+ type: int
+ returnType: void
+ synthetic get multiWithoutInit @76
+ returnType: int
+ synthetic set multiWithoutInit @76
+ parameters
+ requiredPositional _multiWithoutInit @76
+ type: int
+ returnType: void
+ synthetic get multiWithInit2 @94
+ returnType: int
+ synthetic set multiWithInit2 @94
+ parameters
+ requiredPositional _multiWithInit2 @94
+ type: int
+ returnType: void
''',
- withCodeRanges: true,
- withConstElements: false);
+ withCodeRanges: true);
}
test_codeRange_field_annotations() async {
@@ -2559,43 +4850,224 @@
checkElementText(
library,
r'''
-class C/*codeOffset=0, codeLength=436*/ {
- /// Comment 1.
- /// Comment 2.
- int hasDocComment/*codeOffset=12, codeLength=51*/;
- /// Comment 1.
- /// Comment 2.
- int hasDocComment2/*codeOffset=65, codeLength=14*/;
- @Object()
- int hasAnnotation/*codeOffset=84, codeLength=29*/;
- @Object()
- int hasAnnotation2/*codeOffset=115, codeLength=14*/;
- /// Comment 1.
- /// Comment 2.
- @Object()
- int annotationThenComment/*codeOffset=134, codeLength=71*/;
- /// Comment 1.
- /// Comment 2.
- @Object()
- int annotationThenComment2/*codeOffset=207, codeLength=22*/;
- /// Comment 1.
- /// Comment 2.
- @Object()
- int commentThenAnnotation/*codeOffset=234, codeLength=71*/;
- /// Comment 1.
- /// Comment 2.
- @Object()
- int commentThenAnnotation2/*codeOffset=307, codeLength=22*/;
- /// Comment 2.
- @Object()
- int commentAroundAnnotation/*codeOffset=351, codeLength=56*/;
- /// Comment 2.
- @Object()
- int commentAroundAnnotation2/*codeOffset=409, codeLength=24*/;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ codeOffset: 0
+ codeLength: 436
+ fields
+ hasDocComment @50
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ codeOffset: 12
+ codeLength: 51
+ type: int
+ hasDocComment2 @65
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ codeOffset: 65
+ codeLength: 14
+ type: int
+ hasAnnotation @100
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @91
+ rightParenthesis: ) @92
+ atSign.offset: 84
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @85
+ codeOffset: 84
+ codeLength: 29
+ type: int
+ hasAnnotation2 @115
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @91
+ rightParenthesis: ) @92
+ atSign.offset: 84
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @85
+ codeOffset: 115
+ codeLength: 14
+ type: int
+ annotationThenComment @184
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @141
+ rightParenthesis: ) @142
+ atSign.offset: 134
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @135
+ codeOffset: 134
+ codeLength: 71
+ type: int
+ annotationThenComment2 @207
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @141
+ rightParenthesis: ) @142
+ atSign.offset: 134
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @135
+ codeOffset: 207
+ codeLength: 22
+ type: int
+ commentThenAnnotation @284
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @275
+ rightParenthesis: ) @276
+ atSign.offset: 268
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @269
+ codeOffset: 234
+ codeLength: 71
+ type: int
+ commentThenAnnotation2 @307
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @275
+ rightParenthesis: ) @276
+ atSign.offset: 268
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @269
+ codeOffset: 307
+ codeLength: 22
+ type: int
+ commentAroundAnnotation @384
+ documentationComment: /// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @358
+ rightParenthesis: ) @359
+ atSign.offset: 351
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @352
+ codeOffset: 351
+ codeLength: 56
+ type: int
+ commentAroundAnnotation2 @409
+ documentationComment: /// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @358
+ rightParenthesis: ) @359
+ atSign.offset: 351
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @352
+ codeOffset: 409
+ codeLength: 24
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get hasDocComment @50
+ returnType: int
+ synthetic set hasDocComment @50
+ parameters
+ requiredPositional _hasDocComment @50
+ type: int
+ returnType: void
+ synthetic get hasDocComment2 @65
+ returnType: int
+ synthetic set hasDocComment2 @65
+ parameters
+ requiredPositional _hasDocComment2 @65
+ type: int
+ returnType: void
+ synthetic get hasAnnotation @100
+ returnType: int
+ synthetic set hasAnnotation @100
+ parameters
+ requiredPositional _hasAnnotation @100
+ type: int
+ returnType: void
+ synthetic get hasAnnotation2 @115
+ returnType: int
+ synthetic set hasAnnotation2 @115
+ parameters
+ requiredPositional _hasAnnotation2 @115
+ type: int
+ returnType: void
+ synthetic get annotationThenComment @184
+ returnType: int
+ synthetic set annotationThenComment @184
+ parameters
+ requiredPositional _annotationThenComment @184
+ type: int
+ returnType: void
+ synthetic get annotationThenComment2 @207
+ returnType: int
+ synthetic set annotationThenComment2 @207
+ parameters
+ requiredPositional _annotationThenComment2 @207
+ type: int
+ returnType: void
+ synthetic get commentThenAnnotation @284
+ returnType: int
+ synthetic set commentThenAnnotation @284
+ parameters
+ requiredPositional _commentThenAnnotation @284
+ type: int
+ returnType: void
+ synthetic get commentThenAnnotation2 @307
+ returnType: int
+ synthetic set commentThenAnnotation2 @307
+ parameters
+ requiredPositional _commentThenAnnotation2 @307
+ type: int
+ returnType: void
+ synthetic get commentAroundAnnotation @384
+ returnType: int
+ synthetic set commentAroundAnnotation @384
+ parameters
+ requiredPositional _commentAroundAnnotation @384
+ type: int
+ returnType: void
+ synthetic get commentAroundAnnotation2 @409
+ returnType: int
+ synthetic set commentAroundAnnotation2 @409
+ parameters
+ requiredPositional _commentAroundAnnotation2 @409
+ type: int
+ returnType: void
''',
- withCodeRanges: true,
- withConstElements: false);
+ withCodeRanges: true);
}
test_codeRange_function() async {
@@ -2627,26 +5099,83 @@
checkElementText(
library,
r'''
-void raw/*codeOffset=0, codeLength=13*/() {}
-/// Comment 1.
-/// Comment 2.
-void hasDocComment/*codeOffset=15, codeLength=53*/() {}
-@Object()
-void hasAnnotation/*codeOffset=70, codeLength=33*/() {}
-/// Comment 1.
-/// Comment 2.
-@Object()
-void annotationThenComment/*codeOffset=105, codeLength=71*/() {}
-/// Comment 1.
-/// Comment 2.
-@Object()
-void commentThenAnnotation/*codeOffset=178, codeLength=71*/() {}
-/// Comment 2.
-@Object()
-void commentAroundAnnotation/*codeOffset=266, codeLength=58*/() {}
+library
+ definingUnit
+ functions
+ raw @5
+ codeOffset: 0
+ codeLength: 13
+ returnType: void
+ hasDocComment @50
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ codeOffset: 15
+ codeLength: 53
+ returnType: void
+ hasAnnotation @85
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @77
+ rightParenthesis: ) @78
+ atSign.offset: 70
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @71
+ codeOffset: 70
+ codeLength: 33
+ returnType: void
+ annotationThenComment @150
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @112
+ rightParenthesis: ) @113
+ atSign.offset: 105
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @106
+ codeOffset: 105
+ codeLength: 71
+ returnType: void
+ commentThenAnnotation @223
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @215
+ rightParenthesis: ) @216
+ atSign.offset: 208
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @209
+ codeOffset: 178
+ codeLength: 71
+ returnType: void
+ commentAroundAnnotation @296
+ documentationComment: /// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @273
+ rightParenthesis: ) @274
+ atSign.offset: 266
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @267
+ codeOffset: 266
+ codeLength: 58
+ returnType: void
''',
- withCodeRanges: true,
- withConstElements: false);
+ withCodeRanges: true);
}
test_codeRange_functionTypeAlias() async {
@@ -2678,26 +5207,95 @@
checkElementText(
library,
r'''
-typedef Raw/*codeOffset=0, codeLength=14*/ = dynamic Function();
-/// Comment 1.
-/// Comment 2.
-typedef HasDocComment/*codeOffset=16, codeLength=54*/ = dynamic Function();
-@Object()
-typedef HasAnnotation/*codeOffset=72, codeLength=34*/ = dynamic Function();
-/// Comment 1.
-/// Comment 2.
-@Object()
-typedef AnnotationThenComment/*codeOffset=108, codeLength=72*/ = dynamic Function();
-/// Comment 1.
-/// Comment 2.
-@Object()
-typedef CommentThenAnnotation/*codeOffset=182, codeLength=72*/ = dynamic Function();
-/// Comment 2.
-@Object()
-typedef CommentAroundAnnotation/*codeOffset=271, codeLength=59*/ = dynamic Function();
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased Raw @8
+ codeOffset: 0
+ codeLength: 14
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
+ functionTypeAliasBased HasDocComment @54
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ codeOffset: 16
+ codeLength: 54
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
+ functionTypeAliasBased HasAnnotation @90
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ atSign.offset: 0
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @-1
+ codeOffset: 72
+ codeLength: 34
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
+ functionTypeAliasBased AnnotationThenComment @156
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ atSign.offset: 0
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @-1
+ codeOffset: 108
+ codeLength: 72
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
+ functionTypeAliasBased CommentThenAnnotation @230
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ atSign.offset: 0
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @-1
+ codeOffset: 182
+ codeLength: 72
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
+ functionTypeAliasBased CommentAroundAnnotation @304
+ documentationComment: /// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ atSign.offset: 0
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @-1
+ codeOffset: 271
+ codeLength: 59
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
''',
- withCodeRanges: true,
- withConstElements: false);
+ withCodeRanges: true);
}
test_codeRange_genericTypeAlias() async {
@@ -2729,26 +5327,95 @@
checkElementText(
library,
r'''
-typedef Raw/*codeOffset=0, codeLength=25*/ = dynamic Function();
-/// Comment 1.
-/// Comment 2.
-typedef HasDocComment/*codeOffset=27, codeLength=65*/ = dynamic Function();
-@Object()
-typedef HasAnnotation/*codeOffset=94, codeLength=45*/ = dynamic Function();
-/// Comment 1.
-/// Comment 2.
-@Object()
-typedef AnnotationThenComment/*codeOffset=141, codeLength=83*/ = dynamic Function();
-/// Comment 1.
-/// Comment 2.
-@Object()
-typedef CommentThenAnnotation/*codeOffset=226, codeLength=83*/ = dynamic Function();
-/// Comment 2.
-@Object()
-typedef CommentAroundAnnotation/*codeOffset=326, codeLength=70*/ = dynamic Function();
+library
+ definingUnit
+ typeAliases
+ Raw @8
+ codeOffset: 0
+ codeLength: 25
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
+ HasDocComment @65
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ codeOffset: 27
+ codeLength: 65
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
+ HasAnnotation @112
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ atSign.offset: 0
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @-1
+ codeOffset: 94
+ codeLength: 45
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
+ AnnotationThenComment @189
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ atSign.offset: 0
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @-1
+ codeOffset: 141
+ codeLength: 83
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
+ CommentThenAnnotation @274
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ atSign.offset: 0
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @-1
+ codeOffset: 226
+ codeLength: 83
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
+ CommentAroundAnnotation @359
+ documentationComment: /// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ atSign.offset: 0
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @-1
+ codeOffset: 326
+ codeLength: 70
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
''',
- withCodeRanges: true,
- withConstElements: false);
+ withCodeRanges: true);
}
test_codeRange_method() async {
@@ -2782,56 +5449,159 @@
checkElementText(
library,
r'''
-class C/*codeOffset=0, codeLength=372*/ {
- void raw/*codeOffset=12, codeLength=13*/() {}
- /// Comment 1.
- /// Comment 2.
- void hasDocComment/*codeOffset=29, codeLength=57*/() {}
- @Object()
- void hasAnnotation/*codeOffset=90, codeLength=35*/() {}
- /// Comment 1.
- /// Comment 2.
- @Object()
- void annotationThenComment/*codeOffset=129, codeLength=77*/() {}
- /// Comment 1.
- /// Comment 2.
- @Object()
- void commentThenAnnotation/*codeOffset=210, codeLength=77*/() {}
- /// Comment 2.
- @Object()
- void commentAroundAnnotation/*codeOffset=308, codeLength=62*/() {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ codeOffset: 0
+ codeLength: 372
+ constructors
+ synthetic @-1
+ methods
+ raw @17
+ codeOffset: 12
+ codeLength: 13
+ returnType: void
+ hasDocComment @68
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ codeOffset: 29
+ codeLength: 57
+ returnType: void
+ hasAnnotation @107
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @97
+ rightParenthesis: ) @98
+ atSign.offset: 90
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @91
+ codeOffset: 90
+ codeLength: 35
+ returnType: void
+ annotationThenComment @180
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @136
+ rightParenthesis: ) @137
+ atSign.offset: 129
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @130
+ codeOffset: 129
+ codeLength: 77
+ returnType: void
+ commentThenAnnotation @261
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @251
+ rightParenthesis: ) @252
+ atSign.offset: 244
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @245
+ codeOffset: 210
+ codeLength: 77
+ returnType: void
+ commentAroundAnnotation @342
+ documentationComment: /// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @315
+ rightParenthesis: ) @316
+ atSign.offset: 308
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @309
+ codeOffset: 308
+ codeLength: 62
+ returnType: void
''',
- withCodeRanges: true,
- withConstElements: false);
+ withCodeRanges: true);
}
test_codeRange_parameter() async {
var library = await checkLibrary('''
main({int a = 1, int b, int c = 2}) {}
''');
- checkElementText(
- library,
- 'dynamic main/*codeOffset=0, codeLength=38*/('
- '{int a/*codeOffset=6, codeLength=9*/: 1}, '
- '{int b/*codeOffset=17, codeLength=5*/}, '
- '{int c/*codeOffset=24, codeLength=9*/: 2}) {}\n',
- withCodeRanges: true,
- withConstElements: false);
+ checkElementText(library, r'''
+library
+ definingUnit
+ functions
+ main @0
+ parameters
+ optionalNamed a @10
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ optionalNamed b @21
+ type: int
+ optionalNamed c @28
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 2 @0
+ staticType: int
+ returnType: dynamic
+''');
}
test_codeRange_parameter_annotations() async {
var library = await checkLibrary('''
main(@Object() int a, int b, @Object() int c) {}
''');
- checkElementText(
- library,
- 'dynamic main/*codeOffset=0, codeLength=48*/('
- '@Object() int a/*codeOffset=5, codeLength=15*/, '
- 'int b/*codeOffset=22, codeLength=5*/, '
- '@Object() int c/*codeOffset=29, codeLength=15*/) {}\n',
- withCodeRanges: true,
- withConstElements: false);
+ checkElementText(library, r'''
+library
+ definingUnit
+ functions
+ main @0
+ parameters
+ requiredPositional a @19
+ type: int
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ atSign.offset: 0
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @-1
+ requiredPositional b @26
+ type: int
+ requiredPositional c @43
+ type: int
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ atSign.offset: 0
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @-1
+ returnType: dynamic
+''');
}
test_codeRange_topLevelVariable() async {
@@ -2845,14 +5615,67 @@
checkElementText(
library,
r'''
-int withInit/*codeOffset=0, codeLength=24*/;
-int withoutInit/*codeOffset=27, codeLength=15*/;
-int multiWithInit/*codeOffset=45, codeLength=21*/;
-int multiWithoutInit/*codeOffset=68, codeLength=16*/;
-int multiWithInit2/*codeOffset=86, codeLength=18*/;
+library
+ definingUnit
+ topLevelVariables
+ static withInit @4
+ codeOffset: 0
+ codeLength: 24
+ type: int
+ static withoutInit @31
+ codeOffset: 27
+ codeLength: 15
+ type: int
+ static multiWithInit @49
+ codeOffset: 45
+ codeLength: 21
+ type: int
+ static multiWithoutInit @68
+ codeOffset: 68
+ codeLength: 16
+ type: int
+ static multiWithInit2 @86
+ codeOffset: 86
+ codeLength: 18
+ type: int
+ accessors
+ synthetic static get withInit @4
+ returnType: int
+ synthetic static set withInit @4
+ parameters
+ requiredPositional _withInit @4
+ type: int
+ returnType: void
+ synthetic static get withoutInit @31
+ returnType: int
+ synthetic static set withoutInit @31
+ parameters
+ requiredPositional _withoutInit @31
+ type: int
+ returnType: void
+ synthetic static get multiWithInit @49
+ returnType: int
+ synthetic static set multiWithInit @49
+ parameters
+ requiredPositional _multiWithInit @49
+ type: int
+ returnType: void
+ synthetic static get multiWithoutInit @68
+ returnType: int
+ synthetic static set multiWithoutInit @68
+ parameters
+ requiredPositional _multiWithoutInit @68
+ type: int
+ returnType: void
+ synthetic static get multiWithInit2 @86
+ returnType: int
+ synthetic static set multiWithInit2 @86
+ parameters
+ requiredPositional _multiWithInit2 @86
+ type: int
+ returnType: void
''',
- withCodeRanges: true,
- withConstElements: false);
+ withCodeRanges: true);
}
test_codeRange_topLevelVariable_annotations() async {
@@ -2882,41 +5705,218 @@
checkElementText(
library,
r'''
-/// Comment 1.
-/// Comment 2.
-int hasDocComment/*codeOffset=0, codeLength=47*/;
-/// Comment 1.
-/// Comment 2.
-int hasDocComment2/*codeOffset=49, codeLength=14*/;
-@Object()
-int hasAnnotation/*codeOffset=66, codeLength=27*/;
-@Object()
-int hasAnnotation2/*codeOffset=95, codeLength=14*/;
-/// Comment 1.
-/// Comment 2.
-@Object()
-int annotationThenComment/*codeOffset=112, codeLength=65*/;
-/// Comment 1.
-/// Comment 2.
-@Object()
-int annotationThenComment2/*codeOffset=179, codeLength=22*/;
-/// Comment 1.
-/// Comment 2.
-@Object()
-int commentThenAnnotation/*codeOffset=204, codeLength=65*/;
-/// Comment 1.
-/// Comment 2.
-@Object()
-int commentThenAnnotation2/*codeOffset=271, codeLength=22*/;
-/// Comment 2.
-@Object()
-int commentAroundAnnotation/*codeOffset=311, codeLength=52*/;
-/// Comment 2.
-@Object()
-int commentAroundAnnotation2/*codeOffset=365, codeLength=24*/;
+library
+ definingUnit
+ topLevelVariables
+ static hasDocComment @34
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ codeOffset: 0
+ codeLength: 47
+ type: int
+ static hasDocComment2 @49
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ codeOffset: 49
+ codeLength: 14
+ type: int
+ static hasAnnotation @80
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @73
+ rightParenthesis: ) @74
+ atSign.offset: 66
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @67
+ codeOffset: 66
+ codeLength: 27
+ type: int
+ static hasAnnotation2 @95
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @73
+ rightParenthesis: ) @74
+ atSign.offset: 66
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @67
+ codeOffset: 95
+ codeLength: 14
+ type: int
+ static annotationThenComment @156
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @119
+ rightParenthesis: ) @120
+ atSign.offset: 112
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @113
+ codeOffset: 112
+ codeLength: 65
+ type: int
+ static annotationThenComment2 @179
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @119
+ rightParenthesis: ) @120
+ atSign.offset: 112
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @113
+ codeOffset: 179
+ codeLength: 22
+ type: int
+ static commentThenAnnotation @248
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @241
+ rightParenthesis: ) @242
+ atSign.offset: 234
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @235
+ codeOffset: 204
+ codeLength: 65
+ type: int
+ static commentThenAnnotation2 @271
+ documentationComment: /// Comment 1.\n/// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @241
+ rightParenthesis: ) @242
+ atSign.offset: 234
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @235
+ codeOffset: 271
+ codeLength: 22
+ type: int
+ static commentAroundAnnotation @340
+ documentationComment: /// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @318
+ rightParenthesis: ) @319
+ atSign.offset: 311
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @312
+ codeOffset: 311
+ codeLength: 52
+ type: int
+ static commentAroundAnnotation2 @365
+ documentationComment: /// Comment 2.
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @318
+ rightParenthesis: ) @319
+ atSign.offset: 311
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @312
+ codeOffset: 365
+ codeLength: 24
+ type: int
+ accessors
+ synthetic static get hasDocComment @34
+ returnType: int
+ synthetic static set hasDocComment @34
+ parameters
+ requiredPositional _hasDocComment @34
+ type: int
+ returnType: void
+ synthetic static get hasDocComment2 @49
+ returnType: int
+ synthetic static set hasDocComment2 @49
+ parameters
+ requiredPositional _hasDocComment2 @49
+ type: int
+ returnType: void
+ synthetic static get hasAnnotation @80
+ returnType: int
+ synthetic static set hasAnnotation @80
+ parameters
+ requiredPositional _hasAnnotation @80
+ type: int
+ returnType: void
+ synthetic static get hasAnnotation2 @95
+ returnType: int
+ synthetic static set hasAnnotation2 @95
+ parameters
+ requiredPositional _hasAnnotation2 @95
+ type: int
+ returnType: void
+ synthetic static get annotationThenComment @156
+ returnType: int
+ synthetic static set annotationThenComment @156
+ parameters
+ requiredPositional _annotationThenComment @156
+ type: int
+ returnType: void
+ synthetic static get annotationThenComment2 @179
+ returnType: int
+ synthetic static set annotationThenComment2 @179
+ parameters
+ requiredPositional _annotationThenComment2 @179
+ type: int
+ returnType: void
+ synthetic static get commentThenAnnotation @248
+ returnType: int
+ synthetic static set commentThenAnnotation @248
+ parameters
+ requiredPositional _commentThenAnnotation @248
+ type: int
+ returnType: void
+ synthetic static get commentThenAnnotation2 @271
+ returnType: int
+ synthetic static set commentThenAnnotation2 @271
+ parameters
+ requiredPositional _commentThenAnnotation2 @271
+ type: int
+ returnType: void
+ synthetic static get commentAroundAnnotation @340
+ returnType: int
+ synthetic static set commentAroundAnnotation @340
+ parameters
+ requiredPositional _commentAroundAnnotation @340
+ type: int
+ returnType: void
+ synthetic static get commentAroundAnnotation2 @365
+ returnType: int
+ synthetic static set commentAroundAnnotation2 @365
+ parameters
+ requiredPositional _commentAroundAnnotation2 @365
+ type: int
+ returnType: void
''',
- withCodeRanges: true,
- withConstElements: false);
+ withCodeRanges: true);
}
test_codeRange_type_parameter() async {
@@ -2927,12 +5927,31 @@
checkElementText(
library,
r'''
-class A/*codeOffset=0, codeLength=13*/<T/*codeOffset=8, codeLength=1*/> {
-}
-void f/*codeOffset=14, codeLength=24*/<U/*codeOffset=21, codeLength=13*/ extends num>() {}
+library
+ definingUnit
+ classes
+ class A @6
+ codeOffset: 0
+ codeLength: 13
+ typeParameters
+ covariant T @8
+ codeOffset: 8
+ codeLength: 1
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ functions
+ f @19
+ codeOffset: 14
+ codeLength: 24
+ typeParameters
+ covariant U @21
+ codeOffset: 21
+ codeLength: 13
+ bound: num
+ returnType: void
''',
- withCodeRanges: true,
- withConstElements: false);
+ withCodeRanges: true);
}
test_compilationUnit_nnbd_disabled_via_dart_directive() async {
@@ -2958,11 +5977,37 @@
const num a = 0;
const b = a as int;
''');
- checkElementText(library, '''
-const num a = 0;
-const int b =
- a/*location: test.dart;a?*/ as
- int/*location: dart:core;int*/;
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const a @10
+ type: num
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @14
+ staticType: int
+ static const b @23
+ type: int
+ constantInitializer
+ AsExpression
+ asOperator: as @0
+ expression: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: num
+ token: a @27
+ staticType: int
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @32
+ type: int
+ accessors
+ synthetic static get a @10
+ returnType: num
+ synthetic static get b @23
+ returnType: int
''');
}
@@ -2971,72 +6016,85 @@
const a = 0;
const b = (a += 1);
''');
- checkElementText(
- library,
- r'''
-const int a;
- constantInitializer
- IntegerLiteral
- literal: 0
- staticType: int
-const int b;
- constantInitializer
- ParenthesizedExpression
- expression: AssignmentExpression
- leftHandSide: SimpleIdentifier
- staticElement: <null>
- staticType: null
- token: a
- operator: +=
- readElement: self::@getter::a
- readType: int
- rightHandSide: IntegerLiteral
- literal: 1
- staticType: int
- staticElement: dart:core::@class::num::@method::+
- staticType: int
- writeElement: self::@getter::a
- writeType: dynamic
- staticType: int
-''',
- withResolvedAst: true,
- );
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @10
+ staticType: int
+ static const b @19
+ type: int
+ constantInitializer
+ ParenthesizedExpression
+ expression: AssignmentExpression
+ leftHandSide: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: a @24
+ operator: += @0
+ readElement: self::@getter::a
+ readType: int
+ rightHandSide: IntegerLiteral
+ literal: 1 @29
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticType: int
+ writeElement: self::@getter::a
+ writeType: dynamic
+ leftParenthesis: ( @23
+ rightParenthesis: ) @30
+ staticType: int
+ accessors
+ synthetic static get a @6
+ returnType: int
+ synthetic static get b @19
+ returnType: int
+''');
}
test_const_cascadeExpression() async {
var library = await checkLibrary(r'''
const a = 0..isEven..abs();
''');
- checkElementText(
- library,
- r'''
-const int a;
- constantInitializer
- CascadeExpression
- cascadeSections
- PropertyAccess
- operator: ..
- propertyName: SimpleIdentifier
- staticElement: dart:core::@class::int::@getter::isEven
- staticType: bool
- token: isEven
- staticType: bool
- MethodInvocation
- argumentList: ArgumentList
- methodName: SimpleIdentifier
- staticElement: dart:core::@class::int::@method::abs
- staticType: int Function()
- token: abs
- operator: ..
- staticInvokeType: int Function()
- staticType: int
- staticType: int
- target: IntegerLiteral
- literal: 0
- staticType: int
-''',
- withResolvedAst: true,
- );
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: int
+ constantInitializer
+ CascadeExpression
+ cascadeSections
+ PropertyAccess
+ operator: .. @0
+ propertyName: SimpleIdentifier
+ staticElement: dart:core::@class::int::@getter::isEven
+ staticType: bool
+ token: isEven @13
+ staticType: bool
+ MethodInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @24
+ rightParenthesis: ) @25
+ methodName: SimpleIdentifier
+ staticElement: dart:core::@class::int::@method::abs
+ staticType: int Function()
+ token: abs @21
+ operator: .. @0
+ staticInvokeType: int Function()
+ staticType: int
+ staticType: int
+ target: IntegerLiteral
+ literal: 0 @10
+ staticType: int
+ accessors
+ synthetic static get a @6
+ returnType: int
+''');
}
test_const_classField() async {
@@ -3047,15 +6105,56 @@
}
''');
checkElementText(library, r'''
-class C {
- static const int f1 = 1;
- static const int f2 =
- C/*location: test.dart;C*/.
- f1/*location: test.dart;C;f1?*/;
- static const int f3 =
- C/*location: test.dart;C*/.
- f2/*location: test.dart;C;f2?*/;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ static const f1 @29
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 1 @34
+ staticType: int
+ static const f2 @56
+ type: int
+ constantInitializer
+ PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: self::@class::C::@getter::f1
+ staticType: int
+ token: f1 @63
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @61
+ staticElement: self::@class::C::@getter::f1
+ staticType: int
+ static const f3 @67
+ type: int
+ constantInitializer
+ PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: self::@class::C::@getter::f2
+ staticType: int
+ token: f2 @74
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @72
+ staticElement: self::@class::C::@getter::f2
+ staticType: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get f1 @29
+ returnType: int
+ synthetic static get f2 @56
+ returnType: int
+ synthetic static get f3 @67
+ returnType: int
''');
}
@@ -3069,17 +6168,89 @@
const Object x = const C(0);
const Object y = const C.named(0);
''');
- checkElementText(library, '''
-class C<T> {
- final T t;
- const C(final T this.t);
- const C.named(final T this.t);
-}
-const Object x = const
- C/*location: test.dart;C*/(0);
-const Object y = const
- C/*location: test.dart;C*/.
- named/*location: test.dart;C;named*/(0);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ fields
+ final t @23
+ type: T
+ constructors
+ const @34
+ parameters
+ requiredPositional final this.t @41
+ type: T
+ const named @55
+ periodOffset: 54
+ nameEnd: 60
+ parameters
+ requiredPositional final this.t @66
+ type: T
+ accessors
+ synthetic get t @23
+ returnType: T
+ topLevelVariables
+ static const x @85
+ type: Object
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @97
+ staticType: int
+ leftParenthesis: ( @96
+ rightParenthesis: ) @98
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::C::@constructor::•
+ substitution: {T: int}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @95
+ type: C<int>
+ keyword: const @89
+ staticType: C<int>
+ static const y @114
+ type: Object
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @132
+ staticType: int
+ leftParenthesis: ( @131
+ rightParenthesis: ) @133
+ constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: ConstructorMember
+ base: self::@class::C::@constructor::named
+ substitution: {T: dynamic}
+ staticType: null
+ token: named @126
+ staticElement: ConstructorMember
+ base: self::@class::C::@constructor::named
+ substitution: {T: int}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @124
+ type: C<int>
+ keyword: const @118
+ staticType: C<int>
+ accessors
+ synthetic static get x @85
+ returnType: Object
+ synthetic static get y @114
+ returnType: Object
''');
var x = library.definingCompilationUnit.topLevelVariables[0]
as TopLevelVariableElementImpl;
@@ -3104,10 +6275,22 @@
}
''');
checkElementText(library, r'''
-class C {
- final int f = 42;
- const C();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ final f @22
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 42 @26
+ staticType: int
+ constructors
+ const @38
+ accessors
+ synthetic get f @22
+ returnType: int
''');
}
@@ -3117,40 +6300,53 @@
const b = 0;
const c = a[b];
''');
- checkElementText(
- library,
- r'''
-const List<int> a;
- constantInitializer
- ListLiteral
- elements
- IntegerLiteral
- literal: 0
- staticType: int
- staticType: List<int>
-const int b;
- constantInitializer
- IntegerLiteral
- literal: 0
- staticType: int
-const int c;
- constantInitializer
- IndexExpression
- index: SimpleIdentifier
- staticElement: self::@getter::b
- staticType: int
- token: b
- staticElement: MethodMember
- base: dart:core::@class::List::@method::[]
- substitution: {E: int}
- staticType: int
- target: SimpleIdentifier
- staticElement: self::@getter::a
- staticType: List<int>
- token: a
-''',
- withResolvedAst: true,
- );
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: List<int>
+ constantInitializer
+ ListLiteral
+ elements
+ IntegerLiteral
+ literal: 0 @11
+ staticType: int
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<int>
+ static const b @21
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @25
+ staticType: int
+ static const c @34
+ type: int
+ constantInitializer
+ IndexExpression
+ index: SimpleIdentifier
+ staticElement: self::@getter::b
+ staticType: int
+ token: b @40
+ leftBracket: [ @39
+ rightBracket: ] @41
+ staticElement: MethodMember
+ base: dart:core::@class::List::@method::[]
+ substitution: {E: int}
+ staticType: int
+ target: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: List<int>
+ token: a @38
+ accessors
+ synthetic static get a @6
+ returnType: List<int>
+ synthetic static get b @21
+ returnType: int
+ synthetic static get c @34
+ returnType: int
+''');
}
test_const_inference_downward_list() async {
@@ -3172,24 +6368,83 @@
P2<int>(),
];
''');
- checkElementText(
- library,
- '''
-class P<T> {
- const P();
-}
-class P1<T> extends P<T> {
- const P1();
-}
-class P2<T> extends P<T> {
- const P2();
-}
-const List<P<dynamic>> values = /*typeArgs=P<dynamic>*/[/*typeArgs=dynamic*/
- P1/*location: test.dart;P1*/(),
- P2/*location: test.dart;P2*/<
- int/*location: dart:core;int*/>()];
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class P @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ class P1 @35
+ typeParameters
+ covariant T @38
+ defaultType: dynamic
+ supertype: P<T>
+ constructors
+ const @64
+ class P2 @79
+ typeParameters
+ covariant T @82
+ defaultType: dynamic
+ supertype: P<T>
+ constructors
+ const @108
+ topLevelVariables
+ static const values @131
+ type: List<P<dynamic>>
+ constantInitializer
+ ListLiteral
+ elements
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @146
+ rightParenthesis: ) @147
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::P1::@constructor::•
+ substitution: {T: dynamic}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::P1
+ staticType: null
+ token: P1 @144
+ type: P1<dynamic>
+ staticType: P1<dynamic>
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @159
+ rightParenthesis: ) @160
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::P2::@constructor::•
+ substitution: {T: int}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::P2
+ staticType: null
+ token: P2 @152
+ type: P2<int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @155
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ staticType: P2<int>
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<P<dynamic>>
+ accessors
+ synthetic static get values @131
+ returnType: List<P<dynamic>>
+''');
}
test_const_invalid_field_const() async {
@@ -3200,11 +6455,40 @@
int foo() => 42;
''', allowErrors: true);
checkElementText(library, r'''
-class C {
- static const int f = 1 +
- foo/*location: test.dart;foo*/();
-}
-int foo() {}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ static const f @25
+ type: int
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @29
+ staticType: int
+ operator: + @0
+ rightOperand: MethodInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @36
+ rightParenthesis: ) @37
+ methodName: SimpleIdentifier
+ staticElement: self::@function::foo
+ staticType: int Function()
+ token: foo @33
+ staticInvokeType: int Function()
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: null
+ staticType: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get f @25
+ returnType: int
+ functions
+ foo @46
+ returnType: int
''');
}
@@ -3216,10 +6500,21 @@
int foo() => 42;
''', allowErrors: true);
checkElementText(library, r'''
-class C {
- final int f;
-}
-int foo() {}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ final f @18
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get f @18
+ returnType: int
+ functions
+ foo @39
+ returnType: int
''');
}
@@ -3239,9 +6534,36 @@
int foo() => 42;
''', allowErrors: true);
checkElementText(library, r'''
-const int v = 1 +
- foo/*location: test.dart;foo*/();
-int foo() {}
+library
+ definingUnit
+ topLevelVariables
+ static const v @6
+ type: int
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @10
+ staticType: int
+ operator: + @0
+ rightOperand: MethodInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @17
+ rightParenthesis: ) @18
+ methodName: SimpleIdentifier
+ staticElement: self::@function::foo
+ staticType: int Function()
+ token: foo @14
+ staticInvokeType: int Function()
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: null
+ staticType: int
+ accessors
+ synthetic static get v @6
+ returnType: int
+ functions
+ foo @25
+ returnType: int
''');
}
@@ -3251,9 +6573,35 @@
const bool b = a + 5;
''', allowErrors: true);
checkElementText(library, r'''
-const int a = 0;
-const bool b =
- a/*location: test.dart;a?*/ + 5;
+library
+ definingUnit
+ topLevelVariables
+ static const a @10
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @14
+ staticType: int
+ static const b @28
+ type: bool
+ constantInitializer
+ BinaryExpression
+ leftOperand: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: int
+ token: a @32
+ operator: + @0
+ rightOperand: IntegerLiteral
+ literal: 5 @36
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: null
+ staticType: int
+ accessors
+ synthetic static get a @10
+ returnType: int
+ synthetic static get b @28
+ returnType: bool
''');
}
@@ -3265,14 +6613,75 @@
const V = const C<int, String>.named(1, '222');
''');
checkElementText(library, r'''
-class C<K, V> {
- const C.named(K k, V v);
-}
-const C<int, String> V = const
- C/*location: test.dart;C*/<
- int/*location: dart:core;int*/,
- String/*location: dart:core;String*/>.
- named/*location: test.dart;C;named*/(1, '222');
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant K @8
+ defaultType: dynamic
+ covariant V @11
+ defaultType: dynamic
+ constructors
+ const named @26
+ periodOffset: 25
+ nameEnd: 31
+ parameters
+ requiredPositional k @34
+ type: K
+ requiredPositional v @39
+ type: V
+ topLevelVariables
+ static const V @51
+ type: C<int, String>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @82
+ staticType: int
+ SimpleStringLiteral
+ literal: '222' @85
+ leftParenthesis: ( @81
+ rightParenthesis: ) @90
+ constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: ConstructorMember
+ base: self::@class::C::@constructor::named
+ substitution: {K: int, V: String}
+ staticType: null
+ token: named @76
+ staticElement: ConstructorMember
+ base: self::@class::C::@constructor::named
+ substitution: {K: int, V: String}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @61
+ type: C<int, String>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @63
+ type: int
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::String
+ staticType: null
+ token: String @68
+ type: String
+ leftBracket: < @0
+ rightBracket: > @0
+ keyword: const @55
+ staticType: C<int, String>
+ accessors
+ synthetic static get V @51
+ returnType: C<int, String>
''');
}
@@ -3287,12 +6696,61 @@
const V = const C<int, String>.named(1, '222');
''');
checkElementText(library, r'''
-import 'a.dart';
-const C<int, String> V = const
- C/*location: a.dart;C*/<
- int/*location: dart:core;int*/,
- String/*location: dart:core;String*/>.
- named/*location: a.dart;C;named*/(1, '222');
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static const V @23
+ type: C<int, String>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @54
+ staticType: int
+ SimpleStringLiteral
+ literal: '222' @57
+ leftParenthesis: ( @53
+ rightParenthesis: ) @62
+ constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: ConstructorMember
+ base: a.dart::@class::C::@constructor::named
+ substitution: {K: int, V: String}
+ staticType: null
+ token: named @48
+ staticElement: ConstructorMember
+ base: a.dart::@class::C::@constructor::named
+ substitution: {K: int, V: String}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: null
+ token: C @33
+ type: C<int, String>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @35
+ type: int
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::String
+ staticType: null
+ token: String @40
+ type: String
+ leftBracket: < @0
+ rightBracket: > @0
+ keyword: const @27
+ staticType: C<int, String>
+ accessors
+ synthetic static get V @23
+ returnType: C<int, String>
''');
}
@@ -3307,13 +6765,69 @@
const V = const p.C<int, String>.named(1, '222');
''');
checkElementText(library, r'''
-import 'a.dart' as p;
-const C<int, String> V = const
- p/*location: test.dart;p*/.
- C/*location: a.dart;C*/<
- int/*location: dart:core;int*/,
- String/*location: dart:core;String*/>.
- named/*location: a.dart;C;named*/(1, '222');
+library
+ imports
+ a.dart as p @19
+ definingUnit
+ topLevelVariables
+ static const V @28
+ type: C<int, String>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @61
+ staticType: int
+ SimpleStringLiteral
+ literal: '222' @64
+ leftParenthesis: ( @60
+ rightParenthesis: ) @69
+ constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: ConstructorMember
+ base: a.dart::@class::C::@constructor::named
+ substitution: {K: int, V: String}
+ staticType: null
+ token: named @55
+ staticElement: ConstructorMember
+ base: a.dart::@class::C::@constructor::named
+ substitution: {K: int, V: String}
+ type: TypeName
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: null
+ token: C @40
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @38
+ staticElement: a.dart::@class::C
+ staticType: null
+ type: C<int, String>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @42
+ type: int
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::String
+ staticType: null
+ token: String @47
+ type: String
+ leftBracket: < @0
+ rightBracket: > @0
+ keyword: const @32
+ staticType: C<int, String>
+ accessors
+ synthetic static get V @28
+ returnType: C<int, String>
''');
}
@@ -3325,11 +6839,40 @@
const V = const C();
''');
checkElementText(library, r'''
-class C<K, V> {
- const C();
-}
-const C<dynamic, dynamic> V = const
- C/*location: test.dart;C*/();
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant K @8
+ defaultType: dynamic
+ covariant V @11
+ defaultType: dynamic
+ constructors
+ const @24
+ topLevelVariables
+ static const V @37
+ type: C<dynamic, dynamic>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @48
+ rightParenthesis: ) @49
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::C::@constructor::•
+ substitution: {K: dynamic, V: dynamic}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @47
+ type: C<dynamic, dynamic>
+ keyword: const @41
+ staticType: C<dynamic, dynamic>
+ accessors
+ synthetic static get V @37
+ returnType: C<dynamic, dynamic>
''');
}
@@ -3341,13 +6884,56 @@
const V = const C<int, String>();
''');
checkElementText(library, r'''
-class C<K, V> {
- const C();
-}
-const C<int, String> V = const
- C/*location: test.dart;C*/<
- int/*location: dart:core;int*/,
- String/*location: dart:core;String*/>();
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant K @8
+ defaultType: dynamic
+ covariant V @11
+ defaultType: dynamic
+ constructors
+ const @24
+ topLevelVariables
+ static const V @37
+ type: C<int, String>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @61
+ rightParenthesis: ) @62
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::C::@constructor::•
+ substitution: {K: int, V: String}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @47
+ type: C<int, String>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @49
+ type: int
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::String
+ staticType: null
+ token: String @54
+ type: String
+ leftBracket: < @0
+ rightBracket: > @0
+ keyword: const @41
+ staticType: C<int, String>
+ accessors
+ synthetic static get V @37
+ returnType: C<int, String>
''');
}
@@ -3362,11 +6948,49 @@
const V = const C<int, String>();
''');
checkElementText(library, r'''
-import 'a.dart';
-const C<int, String> V = const
- C/*location: a.dart;C*/<
- int/*location: dart:core;int*/,
- String/*location: dart:core;String*/>();
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static const V @23
+ type: C<int, String>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @47
+ rightParenthesis: ) @48
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: a.dart::@class::C::@constructor::•
+ substitution: {K: int, V: String}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: null
+ token: C @33
+ type: C<int, String>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @35
+ type: int
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::String
+ staticType: null
+ token: String @40
+ type: String
+ leftBracket: < @0
+ rightBracket: > @0
+ keyword: const @27
+ staticType: C<int, String>
+ accessors
+ synthetic static get V @23
+ returnType: C<int, String>
''');
}
@@ -3381,12 +7005,57 @@
const V = const p.C<int, String>();
''');
checkElementText(library, r'''
-import 'a.dart' as p;
-const C<int, String> V = const
- p/*location: test.dart;p*/.
- C/*location: a.dart;C*/<
- int/*location: dart:core;int*/,
- String/*location: dart:core;String*/>();
+library
+ imports
+ a.dart as p @19
+ definingUnit
+ topLevelVariables
+ static const V @28
+ type: C<int, String>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @54
+ rightParenthesis: ) @55
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: a.dart::@class::C::@constructor::•
+ substitution: {K: int, V: String}
+ type: TypeName
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: null
+ token: C @40
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @38
+ staticElement: a.dart::@class::C
+ staticType: null
+ type: C<int, String>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @42
+ type: int
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::String
+ staticType: null
+ token: String @47
+ type: String
+ leftBracket: < @0
+ rightBracket: > @0
+ keyword: const @32
+ staticType: C<int, String>
+ accessors
+ synthetic static get V @28
+ returnType: C<int, String>
''');
}
@@ -3398,14 +7067,77 @@
const V = const C.named(true, 1, 2, d: 'ccc', e: 3.4);
''');
checkElementText(library, r'''
-class C {
- const C.named(bool a, int b, int c, {String d}, {double e});
-}
-const C V = const
- C/*location: test.dart;C*/.
- named/*location: test.dart;C;named*/(true, 1, 2,
- d/*location: test.dart;C;named;d*/: 'ccc',
- e/*location: test.dart;C;named;e*/: 3.4);
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ const named @20
+ periodOffset: 19
+ nameEnd: 25
+ parameters
+ requiredPositional a @31
+ type: bool
+ requiredPositional b @38
+ type: int
+ requiredPositional c @45
+ type: int
+ optionalNamed d @56
+ type: String
+ optionalNamed e @66
+ type: double
+ topLevelVariables
+ static const V @79
+ type: C
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ BooleanLiteral
+ literal: true @97
+ staticType: bool
+ IntegerLiteral
+ literal: 1 @103
+ staticType: int
+ IntegerLiteral
+ literal: 2 @106
+ staticType: int
+ NamedExpression
+ name: Label
+ label: SimpleIdentifier
+ staticElement: self::@class::C::@constructor::named::@parameter::d
+ staticType: null
+ token: d @109
+ expression: SimpleStringLiteral
+ literal: 'ccc' @112
+ NamedExpression
+ name: Label
+ label: SimpleIdentifier
+ staticElement: self::@class::C::@constructor::named::@parameter::e
+ staticType: null
+ token: e @119
+ expression: DoubleLiteral
+ literal: 3.4 @122
+ staticType: double
+ leftParenthesis: ( @96
+ rightParenthesis: ) @125
+ constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@class::C::@constructor::named
+ staticType: null
+ token: named @91
+ staticElement: self::@class::C::@constructor::named
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @89
+ type: C
+ keyword: const @83
+ staticType: C
+ accessors
+ synthetic static get V @79
+ returnType: C
''');
}
@@ -3420,10 +7152,35 @@
const V = const C.named();
''');
checkElementText(library, r'''
-import 'a.dart';
-const C V = const
- C/*location: a.dart;C*/.
- named/*location: a.dart;C;named*/();
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static const V @23
+ type: C
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @40
+ rightParenthesis: ) @41
+ constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: a.dart::@class::C::@constructor::named
+ staticType: null
+ token: named @35
+ staticElement: a.dart::@class::C::@constructor::named
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: null
+ token: C @33
+ type: C
+ keyword: const @27
+ staticType: C
+ accessors
+ synthetic static get V @23
+ returnType: C
''');
}
@@ -3438,11 +7195,43 @@
const V = const p.C.named();
''');
checkElementText(library, r'''
-import 'a.dart' as p;
-const C V = const
- p/*location: test.dart;p*/.
- C/*location: a.dart;C*/.
- named/*location: a.dart;C;named*/();
+library
+ imports
+ a.dart as p @19
+ definingUnit
+ topLevelVariables
+ static const V @28
+ type: C
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @47
+ rightParenthesis: ) @48
+ constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: a.dart::@class::C::@constructor::named
+ staticType: null
+ token: named @42
+ staticElement: a.dart::@class::C::@constructor::named
+ type: TypeName
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: null
+ token: C @40
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @38
+ staticElement: a.dart::@class::C
+ staticType: null
+ type: C
+ keyword: const @32
+ staticType: C
+ accessors
+ synthetic static get V @28
+ returnType: C
''');
}
@@ -3452,11 +7241,37 @@
const V = const C.named();
''', allowErrors: true);
checkElementText(library, r'''
-class C {
-}
-const C V = const
- C/*location: test.dart;C*/.
- named/*location: null*/();
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static const V @17
+ type: C
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @34
+ rightParenthesis: ) @35
+ constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: named @29
+ staticElement: <null>
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @27
+ type: C
+ keyword: const @21
+ staticType: C
+ accessors
+ synthetic static get V @17
+ returnType: C
''');
}
@@ -3465,9 +7280,37 @@
const V = const C.named();
''', allowErrors: true);
checkElementText(library, r'''
-const dynamic V = const
- C/*location: null*/.
- named/*location: null*/();
+library
+ definingUnit
+ topLevelVariables
+ static const V @6
+ type: dynamic
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @23
+ rightParenthesis: ) @24
+ constructorName: ConstructorName
+ staticElement: <null>
+ type: TypeName
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: named @18
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: C @16
+ staticElement: <null>
+ staticType: null
+ type: dynamic
+ keyword: const @10
+ staticType: dynamic
+ accessors
+ synthetic static get V @6
+ returnType: dynamic
''');
}
@@ -3481,11 +7324,43 @@
const V = const p.C.named();
''', allowErrors: true);
checkElementText(library, r'''
-import 'a.dart' as p;
-const C V = const
- p/*location: test.dart;p*/.
- C/*location: a.dart;C*/.
- named/*location: null*/();
+library
+ imports
+ a.dart as p @19
+ definingUnit
+ topLevelVariables
+ static const V @28
+ type: C
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @47
+ rightParenthesis: ) @48
+ constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: named @42
+ staticElement: <null>
+ type: TypeName
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: null
+ token: C @40
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @38
+ staticElement: a.dart::@class::C
+ staticType: null
+ type: C
+ keyword: const @32
+ staticType: C
+ accessors
+ synthetic static get V @28
+ returnType: C
''');
}
@@ -3496,11 +7371,43 @@
const V = const p.C.named();
''', allowErrors: true);
checkElementText(library, r'''
-import 'a.dart' as p;
-const dynamic V = const
- p/*location: test.dart;p*/.
- C/*location: null*/.
- named/*location: null*/();
+library
+ imports
+ a.dart as p @19
+ definingUnit
+ topLevelVariables
+ static const V @28
+ type: dynamic
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @47
+ rightParenthesis: ) @48
+ constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: named @42
+ staticElement: <null>
+ type: TypeName
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: C @40
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @38
+ staticElement: <null>
+ staticType: null
+ type: dynamic
+ keyword: const @32
+ staticType: dynamic
+ accessors
+ synthetic static get V @28
+ returnType: dynamic
''');
}
@@ -3509,10 +7416,41 @@
const V = const p.C.named();
''', allowErrors: true);
checkElementText(library, r'''
-const dynamic V = const
- p/*location: null*/.
- C/*location: null*/.
- named/*location: null*/();
+library
+ definingUnit
+ topLevelVariables
+ static const V @6
+ type: dynamic
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @25
+ rightParenthesis: ) @26
+ constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: named @20
+ staticElement: <null>
+ type: TypeName
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: C @18
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: p @16
+ staticElement: <null>
+ staticType: null
+ type: dynamic
+ keyword: const @10
+ staticType: dynamic
+ accessors
+ synthetic static get V @6
+ returnType: dynamic
''');
}
@@ -3522,11 +7460,40 @@
const V = const C.named();
''', allowErrors: true);
checkElementText(library, r'''
-class C<T> {
-}
-const C<dynamic> V = const
- C/*location: test.dart;C*/.
- named/*location: null*/();
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static const V @20
+ type: C<dynamic>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @37
+ rightParenthesis: ) @38
+ constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: named @32
+ staticElement: <null>
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @30
+ type: C<dynamic>
+ keyword: const @24
+ staticType: C<dynamic>
+ accessors
+ synthetic static get V @20
+ returnType: C<dynamic>
''');
}
@@ -3538,11 +7505,33 @@
const V = const C();
''');
checkElementText(library, r'''
-class C {
- const C();
-}
-const C V = const
- C/*location: test.dart;C*/();
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ const @18
+ topLevelVariables
+ static const V @31
+ type: C
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @42
+ rightParenthesis: ) @43
+ constructorName: ConstructorName
+ staticElement: self::@class::C::@constructor::•
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @41
+ type: C
+ keyword: const @35
+ staticType: C
+ accessors
+ synthetic static get V @31
+ returnType: C
''');
}
@@ -3557,9 +7546,31 @@
const V = const C();
''');
checkElementText(library, r'''
-import 'a.dart';
-const C V = const
- C/*location: a.dart;C*/();
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static const V @23
+ type: C
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @34
+ rightParenthesis: ) @35
+ constructorName: ConstructorName
+ staticElement: a.dart::@class::C::@constructor::•
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: null
+ token: C @33
+ type: C
+ keyword: const @27
+ staticType: C
+ accessors
+ synthetic static get V @23
+ returnType: C
''');
}
@@ -3574,10 +7585,39 @@
const V = const p.C();
''');
checkElementText(library, r'''
-import 'a.dart' as p;
-const C V = const
- p/*location: test.dart;p*/.
- C/*location: a.dart;C*/();
+library
+ imports
+ a.dart as p @19
+ definingUnit
+ topLevelVariables
+ static const V @28
+ type: C
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @41
+ rightParenthesis: ) @42
+ constructorName: ConstructorName
+ staticElement: a.dart::@class::C::@constructor::•
+ type: TypeName
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: null
+ token: C @40
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @38
+ staticElement: a.dart::@class::C
+ staticType: null
+ type: C
+ keyword: const @32
+ staticType: C
+ accessors
+ synthetic static get V @28
+ returnType: C
''');
}
@@ -3586,8 +7626,29 @@
const V = const C();
''', allowErrors: true);
checkElementText(library, r'''
-const dynamic V = const
- C/*location: null*/();
+library
+ definingUnit
+ topLevelVariables
+ static const V @6
+ type: dynamic
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @17
+ rightParenthesis: ) @18
+ constructorName: ConstructorName
+ staticElement: <null>
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: C @16
+ type: dynamic
+ keyword: const @10
+ staticType: dynamic
+ accessors
+ synthetic static get V @6
+ returnType: dynamic
''');
}
@@ -3598,10 +7659,39 @@
const V = const p.C();
''', allowErrors: true);
checkElementText(library, r'''
-import 'a.dart' as p;
-const dynamic V = const
- p/*location: test.dart;p*/.
- C/*location: null*/();
+library
+ imports
+ a.dart as p @19
+ definingUnit
+ topLevelVariables
+ static const V @28
+ type: dynamic
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @41
+ rightParenthesis: ) @42
+ constructorName: ConstructorName
+ staticElement: <null>
+ type: TypeName
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: C @40
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @38
+ staticElement: <null>
+ staticType: null
+ type: dynamic
+ keyword: const @32
+ staticType: dynamic
+ accessors
+ synthetic static get V @28
+ returnType: dynamic
''');
}
@@ -3610,9 +7700,37 @@
const V = const p.C();
''', allowErrors: true);
checkElementText(library, r'''
-const dynamic V = const
- p/*location: null*/.
- C/*location: null*/();
+library
+ definingUnit
+ topLevelVariables
+ static const V @6
+ type: dynamic
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @19
+ rightParenthesis: ) @20
+ constructorName: ConstructorName
+ staticElement: <null>
+ type: TypeName
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: C @18
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: p @16
+ staticElement: <null>
+ staticType: null
+ type: dynamic
+ keyword: const @10
+ staticType: dynamic
+ accessors
+ synthetic static get V @6
+ returnType: dynamic
''');
}
@@ -3621,11 +7739,37 @@
const a = 0;
const b = a is int;
''');
- checkElementText(library, '''
-const int a = 0;
-const bool b =
- a/*location: test.dart;a?*/ is
- int/*location: dart:core;int*/;
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @10
+ staticType: int
+ static const b @19
+ type: bool
+ constantInitializer
+ IsExpression
+ expression: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: int
+ token: a @23
+ isOperator: is @0
+ staticType: bool
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @28
+ type: int
+ accessors
+ synthetic static get a @6
+ returnType: int
+ synthetic static get b @19
+ returnType: bool
''');
}
@@ -3637,13 +7781,47 @@
const int v = C.F.length;
''');
checkElementText(library, r'''
-class C {
- static const String F = '';
-}
-const int v =
- C/*location: test.dart;C*/.
- F/*location: test.dart;C;F?*/.
- length/*location: dart:core;String;length?*/;
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ static const F @32
+ type: String
+ constantInitializer
+ SimpleStringLiteral
+ literal: '' @36
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get F @32
+ returnType: String
+ topLevelVariables
+ static const v @52
+ type: int
+ constantInitializer
+ PropertyAccess
+ operator: . @0
+ propertyName: SimpleIdentifier
+ staticElement: dart:core::@class::String::@getter::length
+ staticType: int
+ token: length @60
+ staticType: int
+ target: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: self::@class::C::@getter::F
+ staticType: String
+ token: F @58
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @56
+ staticElement: self::@class::C::@getter::F
+ staticType: String
+ accessors
+ synthetic static get v @52
+ returnType: int
''');
}
@@ -3658,11 +7836,36 @@
const int v = C.F.length;
''');
checkElementText(library, r'''
-import 'a.dart';
-const int v =
- C/*location: a.dart;C*/.
- F/*location: a.dart;C;F?*/.
- length/*location: dart:core;String;length?*/;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static const v @27
+ type: int
+ constantInitializer
+ PropertyAccess
+ operator: . @0
+ propertyName: SimpleIdentifier
+ staticElement: dart:core::@class::String::@getter::length
+ staticType: int
+ token: length @35
+ staticType: int
+ target: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@class::C::@getter::F
+ staticType: String
+ token: F @33
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: null
+ token: C @31
+ staticElement: a.dart::@class::C::@getter::F
+ staticType: String
+ accessors
+ synthetic static get v @27
+ returnType: int
''');
}
@@ -3677,12 +7880,43 @@
const int v = p.C.F.length;
''');
checkElementText(library, r'''
-import 'a.dart' as p;
-const int v =
- p/*location: test.dart;p*/.
- C/*location: a.dart;C*/.
- F/*location: a.dart;C;F?*/.
- length/*location: dart:core;String;length?*/;
+library
+ imports
+ a.dart as p @19
+ definingUnit
+ topLevelVariables
+ static const v @32
+ type: int
+ constantInitializer
+ PropertyAccess
+ operator: . @0
+ propertyName: SimpleIdentifier
+ staticElement: dart:core::@class::String::@getter::length
+ staticType: int
+ token: length @42
+ staticType: int
+ target: PropertyAccess
+ operator: . @0
+ propertyName: SimpleIdentifier
+ staticElement: a.dart::@class::C::@getter::F
+ staticType: String
+ token: F @40
+ staticType: String
+ target: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: null
+ token: C @38
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @36
+ staticElement: a.dart::@class::C
+ staticType: null
+ accessors
+ synthetic static get v @32
+ returnType: int
''');
}
@@ -3691,8 +7925,24 @@
const v = 'abc'.length;
''');
checkElementText(library, r'''
-const int v = 'abc'.
- length/*location: dart:core;String;length?*/;
+library
+ definingUnit
+ topLevelVariables
+ static const v @6
+ type: int
+ constantInitializer
+ PropertyAccess
+ operator: . @0
+ propertyName: SimpleIdentifier
+ staticElement: dart:core::@class::String::@getter::length
+ staticType: int
+ token: length @16
+ staticType: int
+ target: SimpleStringLiteral
+ literal: 'abc' @10
+ accessors
+ synthetic static get v @6
+ returnType: int
''');
}
@@ -3702,10 +7952,34 @@
const v = S.length;
''');
checkElementText(library, r'''
-const String S = 'abc';
-const int v =
- S/*location: test.dart;S?*/.
- length/*location: dart:core;String;length?*/;
+library
+ definingUnit
+ topLevelVariables
+ static const S @13
+ type: String
+ constantInitializer
+ SimpleStringLiteral
+ literal: 'abc' @17
+ static const v @30
+ type: int
+ constantInitializer
+ PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: dart:core::@class::String::@getter::length
+ staticType: int
+ token: length @36
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@getter::S
+ staticType: String
+ token: S @34
+ staticElement: dart:core::@class::String::@getter::length
+ staticType: int
+ accessors
+ synthetic static get S @13
+ returnType: String
+ synthetic static get v @30
+ returnType: int
''');
}
@@ -3718,10 +7992,29 @@
const v = S.length;
''');
checkElementText(library, r'''
-import 'a.dart';
-const int v =
- S/*location: a.dart;S?*/.
- length/*location: dart:core;String;length?*/;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static const v @23
+ type: int
+ constantInitializer
+ PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: dart:core::@class::String::@getter::length
+ staticType: int
+ token: length @29
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: a.dart::@getter::S
+ staticType: String
+ token: S @27
+ staticElement: dart:core::@class::String::@getter::length
+ staticType: int
+ accessors
+ synthetic static get v @23
+ returnType: int
''');
}
@@ -3734,11 +8027,36 @@
const v = p.S.length;
''');
checkElementText(library, r'''
-import 'a.dart' as p;
-const int v =
- p/*location: test.dart;p*/.
- S/*location: a.dart;S?*/.
- length/*location: dart:core;String;length?*/;
+library
+ imports
+ a.dart as p @19
+ definingUnit
+ topLevelVariables
+ static const v @28
+ type: int
+ constantInitializer
+ PropertyAccess
+ operator: . @0
+ propertyName: SimpleIdentifier
+ staticElement: dart:core::@class::String::@getter::length
+ staticType: int
+ token: length @36
+ staticType: int
+ target: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@getter::S
+ staticType: String
+ token: S @34
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @32
+ staticElement: a.dart::@getter::S
+ staticType: String
+ accessors
+ synthetic static get v @28
+ returnType: int
''');
}
@@ -3750,12 +8068,34 @@
const v = C.length;
''');
checkElementText(library, r'''
-class C {
- static int length() {}
-}
-const int Function() v =
- C/*location: test.dart;C*/.
- length/*location: test.dart;C;length*/;
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ static length @23
+ returnType: int
+ topLevelVariables
+ static const v @47
+ type: int Function()
+ constantInitializer
+ PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: self::@class::C::@method::length
+ staticType: int Function()
+ token: length @53
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @51
+ staticElement: self::@class::C::@method::length
+ staticType: int Function()
+ accessors
+ synthetic static get v @47
+ returnType: int Function()
''');
}
@@ -3763,26 +8103,83 @@
var library = await checkLibrary('''
const Object x = const <int>[if (true) 1];
''');
- checkElementText(
- library,
- '''
-const Object x = const <
- int/*location: dart:core;int*/>[if (true) 1];
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const x @13
+ type: Object
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ elements
+ IfElement
+ condition: BooleanLiteral
+ literal: true @33
+ staticType: bool
+ thenStatement: IntegerLiteral
+ literal: 1 @39
+ staticType: int
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @24
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ accessors
+ synthetic static get x @13
+ returnType: Object
+''');
}
test_const_list_if_else() async {
var library = await checkLibrary('''
const Object x = const <int>[if (true) 1 else 2];
''');
- checkElementText(
- library,
- '''
-const Object x = const <
- int/*location: dart:core;int*/>[if (true) 1 else 2];
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const x @13
+ type: Object
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ elements
+ IfElement
+ condition: BooleanLiteral
+ literal: true @33
+ staticType: bool
+ elseStatement: IntegerLiteral
+ literal: 2 @46
+ staticType: int
+ thenStatement: IntegerLiteral
+ literal: 1 @39
+ staticType: int
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @24
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ accessors
+ synthetic static get x @13
+ returnType: Object
+''');
}
test_const_list_inferredType() async {
@@ -3792,54 +8189,181 @@
var library = await checkLibrary('''
const Object x = const [1];
''');
- checkElementText(
- library,
- '''
-const Object x = const /*typeArgs=int*/[1];
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const x @13
+ type: Object
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ elements
+ IntegerLiteral
+ literal: 1 @24
+ staticType: int
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<int>
+ accessors
+ synthetic static get x @13
+ returnType: Object
+''');
}
test_const_list_spread() async {
var library = await checkLibrary('''
const Object x = const <int>[...<int>[1]];
''');
- checkElementText(
- library,
- '''
-const Object x = const <
- int/*location: dart:core;int*/>[...<
- int/*location: dart:core;int*/>[1]];
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const x @13
+ type: Object
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ elements
+ SpreadElement
+ expressions: ListLiteral
+ elements
+ IntegerLiteral
+ literal: 1 @38
+ staticType: int
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @33
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ spreadOperator: ... @0
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @24
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ accessors
+ synthetic static get x @13
+ returnType: Object
+''');
}
test_const_list_spread_null_aware() async {
var library = await checkLibrary('''
const Object x = const <int>[...?<int>[1]];
''');
- checkElementText(
- library,
- '''
-const Object x = const <
- int/*location: dart:core;int*/>[...?<
- int/*location: dart:core;int*/>[1]];
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const x @13
+ type: Object
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ elements
+ SpreadElement
+ expressions: ListLiteral
+ elements
+ IntegerLiteral
+ literal: 1 @39
+ staticType: int
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @34
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ spreadOperator: ...? @0
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @24
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ accessors
+ synthetic static get x @13
+ returnType: Object
+''');
}
test_const_map_if() async {
var library = await checkLibrary('''
const Object x = const <int, int>{if (true) 1: 2};
''');
- checkElementText(
- library,
- '''
-const Object x = const <
- int/*location: dart:core;int*/,
- int/*location: dart:core;int*/>{if (true) 1: 2}/*isMap*/;
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const x @13
+ type: Object
+ constantInitializer
+ SetOrMapLiteral
+ constKeyword: const @0
+ elements
+ IfElement
+ condition: BooleanLiteral
+ literal: true @38
+ staticType: bool
+ thenStatement: SetOrMapLiteral
+ key: IntegerLiteral
+ literal: 1 @44
+ staticType: int
+ value: IntegerLiteral
+ literal: 2 @47
+ staticType: int
+ isMap: true
+ staticType: Map<int, int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @24
+ type: int
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @29
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ accessors
+ synthetic static get x @13
+ returnType: Object
+''');
}
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/44522')
@@ -3847,14 +8371,11 @@
var library = await checkLibrary('''
const Object x = const <int, int>{if (true) 1: 2 else 3: 4];
''');
- checkElementText(
- library,
- '''
+ checkElementText(library, r'''
const Object x = const <
int/*location: dart:core;int*/,
int/*location: dart:core;int*/>{if (true) 1: 2 else 3: 4}/*isMap*/;
-''',
- withTypes: true);
+''');
}
test_const_map_inferredType() async {
@@ -3864,86 +8385,216 @@
var library = await checkLibrary('''
const Object x = const {1: 1.0};
''');
- checkElementText(
- library,
- '''
-const Object x = const /*typeArgs=int,double*/{1: 1.0}/*isMap*/;
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const x @13
+ type: Object
+ constantInitializer
+ SetOrMapLiteral
+ constKeyword: const @0
+ elements
+ SetOrMapLiteral
+ key: IntegerLiteral
+ literal: 1 @24
+ staticType: int
+ value: DoubleLiteral
+ literal: 1.0 @27
+ staticType: double
+ isMap: true
+ staticType: Map<int, double>
+ accessors
+ synthetic static get x @13
+ returnType: Object
+''');
}
test_const_map_spread() async {
var library = await checkLibrary('''
const Object x = const <int, int>{...<int, int>{1: 2}};
''');
- checkElementText(
- library,
- '''
-const Object x = const <
- int/*location: dart:core;int*/,
- int/*location: dart:core;int*/>{...<
- int/*location: dart:core;int*/,
- int/*location: dart:core;int*/>{1: 2}/*isMap*/}/*isMap*/;
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const x @13
+ type: Object
+ constantInitializer
+ SetOrMapLiteral
+ constKeyword: const @0
+ elements
+ SpreadElement
+ expressions: SetOrMapLiteral
+ elements
+ SetOrMapLiteral
+ key: IntegerLiteral
+ literal: 1 @48
+ staticType: int
+ value: IntegerLiteral
+ literal: 2 @51
+ staticType: int
+ isMap: true
+ staticType: Map<int, int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @38
+ type: int
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @43
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ spreadOperator: ... @0
+ isMap: true
+ staticType: Map<int, int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @24
+ type: int
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @29
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ accessors
+ synthetic static get x @13
+ returnType: Object
+''');
}
test_const_map_spread_null_aware() async {
var library = await checkLibrary('''
const Object x = const <int, int>{...?<int, int>{1: 2}};
''');
- checkElementText(
- library,
- '''
-const Object x = const <
- int/*location: dart:core;int*/,
- int/*location: dart:core;int*/>{...?<
- int/*location: dart:core;int*/,
- int/*location: dart:core;int*/>{1: 2}/*isMap*/}/*isMap*/;
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const x @13
+ type: Object
+ constantInitializer
+ SetOrMapLiteral
+ constKeyword: const @0
+ elements
+ SpreadElement
+ expressions: SetOrMapLiteral
+ elements
+ SetOrMapLiteral
+ key: IntegerLiteral
+ literal: 1 @49
+ staticType: int
+ value: IntegerLiteral
+ literal: 2 @52
+ staticType: int
+ isMap: true
+ staticType: Map<int, int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @39
+ type: int
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @44
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ spreadOperator: ...? @0
+ isMap: true
+ staticType: Map<int, int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @24
+ type: int
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @29
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ accessors
+ synthetic static get x @13
+ returnType: Object
+''');
}
+ /// TODO(scheglov) review location
test_const_methodInvocation() async {
var library = await checkLibrary(r'''
T f<T>(T a) => a;
const b = f<int>(0);
''');
- checkElementText(
- library,
- r'''
-const int b;
- constantInitializer
- MethodInvocation
- argumentList: ArgumentList
- arguments
- IntegerLiteral
- literal: 0
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const b @24
+ type: int
+ constantInitializer
+ MethodInvocation
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @35
+ staticType: int
+ leftParenthesis: ( @34
+ rightParenthesis: ) @36
+ methodName: SimpleIdentifier
+ staticElement: self::@function::f
+ staticType: T Function<T>(T)
+ token: f @28
+ staticInvokeType: int Function(int)
staticType: int
- methodName: SimpleIdentifier
- staticElement: self::@function::f
- staticType: T Function<T>(T)
- token: f
- staticInvokeType: int Function(int)
- staticType: int
- typeArgumentTypes
- int
- typeArguments: TypeArgumentList
- arguments
- TypeName
- name: SimpleIdentifier
- staticElement: dart:core::@class::int
- staticType: null
- token: int
- type: int
-T f(T a) {}
- typeParameters
- T
- bound: null
- defaultType: null
-''',
- withResolvedAst: true,
- );
+ typeArgumentTypes
+ int
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @30
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ accessors
+ synthetic static get b @24
+ returnType: int
+ functions
+ f @2
+ typeParameters
+ covariant T @4
+ parameters
+ requiredPositional a @9
+ type: T
+ returnType: T
+''');
}
test_const_parameterDefaultValue_initializingFormal_functionTyped() async {
@@ -3955,12 +8606,29 @@
int foo() => 42;
''');
checkElementText(library, r'''
-class C {
- final dynamic x;
- const C({final dynamic this.x:
- foo/*location: test.dart;foo*/});
-}
-int foo() {}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ final x @18
+ type: dynamic
+ constructors
+ const @29
+ parameters
+ optionalNamed final this.x @37
+ type: dynamic
+ constantInitializer
+ SimpleIdentifier
+ staticElement: self::@function::foo
+ staticType: int Function()
+ token: foo @-1
+ accessors
+ synthetic get x @18
+ returnType: dynamic
+ functions
+ foo @53
+ returnType: int
''');
}
@@ -3972,10 +8640,33 @@
}
''');
checkElementText(library, r'''
-class C {
- final dynamic x;
- const C({final dynamic this.x: 1 + 2});
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ final x @18
+ type: dynamic
+ constructors
+ const @29
+ parameters
+ optionalNamed final this.x @37
+ type: dynamic
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ operator: + @0
+ rightOperand: IntegerLiteral
+ literal: 2 @0
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: null
+ staticType: int
+ accessors
+ synthetic get x @18
+ returnType: dynamic
''');
}
@@ -3987,10 +8678,33 @@
}
''');
checkElementText(library, r'''
-class C {
- final dynamic x;
- const C([final dynamic this.x = 1 + 2]);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ final x @18
+ type: dynamic
+ constructors
+ const @29
+ parameters
+ optionalPositional final this.x @37
+ type: dynamic
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ operator: + @0
+ rightOperand: IntegerLiteral
+ literal: 2 @0
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: null
+ staticType: int
+ accessors
+ synthetic get x @18
+ returnType: dynamic
''');
}
@@ -4006,14 +8720,92 @@
}
''');
checkElementText(library, r'''
-class C {
- const C.positional([dynamic p = 1 + 2]);
- const C.named({dynamic p: 1 + 2});
- void methodPositional([dynamic p = 1 + 2]) {}
- void methodPositionalWithoutDefault([dynamic p]) {}
- void methodNamed({dynamic p: 1 + 2}) {}
- void methodNamedWithoutDefault({dynamic p}) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ const positional @20
+ periodOffset: 19
+ nameEnd: 30
+ parameters
+ optionalPositional p @32
+ type: dynamic
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ operator: + @0
+ rightOperand: IntegerLiteral
+ literal: 2 @0
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: null
+ staticType: int
+ const named @55
+ periodOffset: 54
+ nameEnd: 60
+ parameters
+ optionalNamed p @62
+ type: dynamic
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ operator: + @0
+ rightOperand: IntegerLiteral
+ literal: 2 @0
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: null
+ staticType: int
+ methods
+ methodPositional @81
+ parameters
+ optionalPositional p @99
+ type: dynamic
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ operator: + @0
+ rightOperand: IntegerLiteral
+ literal: 2 @0
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: null
+ staticType: int
+ returnType: void
+ methodPositionalWithoutDefault @121
+ parameters
+ optionalPositional p @153
+ type: dynamic
+ returnType: void
+ methodNamed @167
+ parameters
+ optionalNamed p @180
+ type: dynamic
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ operator: + @0
+ rightOperand: IntegerLiteral
+ literal: 2 @0
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: null
+ staticType: int
+ returnType: void
+ methodNamedWithoutDefault @201
+ parameters
+ optionalNamed p @228
+ type: dynamic
+ returnType: void
''');
}
@@ -4022,31 +8814,37 @@
const a = 0;
const b = a++;
''');
- checkElementText(
- library,
- r'''
-const int a;
- constantInitializer
- IntegerLiteral
- literal: 0
- staticType: int
-const int b;
- constantInitializer
- PostfixExpression
- operand: SimpleIdentifier
- staticElement: <null>
- staticType: null
- token: a
- operator: ++
- readElement: self::@getter::a
- readType: int
- staticElement: dart:core::@class::num::@method::+
- staticType: int
- writeElement: self::@getter::a
- writeType: dynamic
-''',
- withResolvedAst: true,
- );
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @10
+ staticType: int
+ static const b @19
+ type: int
+ constantInitializer
+ PostfixExpression
+ operand: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: a @23
+ operator: ++ @0
+ readElement: self::@getter::a
+ readType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticType: int
+ writeElement: self::@getter::a
+ writeType: dynamic
+ accessors
+ synthetic static get a @6
+ returnType: int
+ synthetic static get b @19
+ returnType: int
+''');
}
test_const_postfixExpression_nullCheck() async {
@@ -4054,27 +8852,33 @@
const int? a = 0;
const b = a!;
''');
- checkElementText(
- library,
- r'''
-const int? a;
- constantInitializer
- IntegerLiteral
- literal: 0
- staticType: int
-const int b;
- constantInitializer
- PostfixExpression
- operand: SimpleIdentifier
- staticElement: self::@getter::a
- staticType: int?
- token: a
- operator: !
- staticElement: <null>
- staticType: int
-''',
- withResolvedAst: true,
- );
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const a @11
+ type: int?
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @15
+ staticType: int
+ static const b @24
+ type: int
+ constantInitializer
+ PostfixExpression
+ operand: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: int?
+ token: a @28
+ operator: ! @0
+ staticElement: <null>
+ staticType: int
+ accessors
+ synthetic static get a @11
+ returnType: int?
+ synthetic static get b @24
+ returnType: int
+''');
}
test_const_prefixExpression_class_unaryMinus() async {
@@ -4082,27 +8886,33 @@
const a = 0;
const b = -a;
''');
- checkElementText(
- library,
- r'''
-const int a;
- constantInitializer
- IntegerLiteral
- literal: 0
- staticType: int
-const int b;
- constantInitializer
- PrefixExpression
- operand: SimpleIdentifier
- staticElement: self::@getter::a
- staticType: int
- token: a
- operator: -
- staticElement: dart:core::@class::int::@method::unary-
- staticType: int
-''',
- withResolvedAst: true,
- );
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @10
+ staticType: int
+ static const b @19
+ type: int
+ constantInitializer
+ PrefixExpression
+ operand: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: int
+ token: a @24
+ operator: - @23
+ staticElement: dart:core::@class::int::@method::unary-
+ staticType: int
+ accessors
+ synthetic static get a @6
+ returnType: int
+ synthetic static get b @19
+ returnType: int
+''');
}
test_const_prefixExpression_extension_unaryMinus() async {
@@ -4117,23 +8927,27 @@
import 'a.dart';
const b = -a;
''');
- checkElementText(
- library,
- r'''
-import 'package:test/a.dart';
-const int b;
- constantInitializer
- PrefixExpression
- operand: SimpleIdentifier
- staticElement: package:test/a.dart::@getter::a
- staticType: Object
- token: a
- operator: -
- staticElement: package:test/a.dart::@extension::E::@method::unary-
- staticType: int
-''',
- withResolvedAst: true,
- );
+ checkElementText(library, r'''
+library
+ imports
+ package:test/a.dart
+ definingUnit
+ topLevelVariables
+ static const b @23
+ type: int
+ constantInitializer
+ PrefixExpression
+ operand: SimpleIdentifier
+ staticElement: package:test/a.dart::@getter::a
+ staticType: Object
+ token: a @28
+ operator: - @27
+ staticElement: package:test/a.dart::@extension::E::@method::unary-
+ staticType: int
+ accessors
+ synthetic static get b @23
+ returnType: int
+''');
}
test_const_prefixExpression_increment() async {
@@ -4141,31 +8955,37 @@
const a = 0;
const b = ++a;
''');
- checkElementText(
- library,
- r'''
-const int a;
- constantInitializer
- IntegerLiteral
- literal: 0
- staticType: int
-const int b;
- constantInitializer
- PrefixExpression
- operand: SimpleIdentifier
- staticElement: <null>
- staticType: null
- token: a
- operator: ++
- readElement: self::@getter::a
- readType: int
- staticElement: dart:core::@class::num::@method::+
- staticType: int
- writeElement: self::@getter::a
- writeType: dynamic
-''',
- withResolvedAst: true,
- );
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @10
+ staticType: int
+ static const b @19
+ type: int
+ constantInitializer
+ PrefixExpression
+ operand: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: a @25
+ operator: ++ @23
+ readElement: self::@getter::a
+ readType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticType: int
+ writeElement: self::@getter::a
+ writeType: dynamic
+ accessors
+ synthetic static get a @6
+ returnType: int
+ synthetic static get b @19
+ returnType: int
+''');
}
test_const_reference_staticField() async {
@@ -4176,12 +8996,41 @@
const V = C.F;
''');
checkElementText(library, r'''
-class C {
- static const int F = 42;
-}
-const int V =
- C/*location: test.dart;C*/.
- F/*location: test.dart;C;F?*/;
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ static const F @29
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 42 @33
+ staticType: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get F @29
+ returnType: int
+ topLevelVariables
+ static const V @45
+ type: int
+ constantInitializer
+ PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: self::@class::C::@getter::F
+ staticType: int
+ token: F @51
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @49
+ staticElement: self::@class::C::@getter::F
+ staticType: int
+ accessors
+ synthetic static get V @45
+ returnType: int
''');
}
@@ -4196,10 +9045,29 @@
const V = C.F;
''');
checkElementText(library, r'''
-import 'a.dart';
-const int V =
- C/*location: a.dart;C*/.
- F/*location: a.dart;C;F?*/;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static const V @23
+ type: int
+ constantInitializer
+ PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@class::C::@getter::F
+ staticType: int
+ token: F @29
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: null
+ token: C @27
+ staticElement: a.dart::@class::C::@getter::F
+ staticType: int
+ accessors
+ synthetic static get V @23
+ returnType: int
''');
}
@@ -4214,11 +9082,36 @@
const V = p.C.F;
''');
checkElementText(library, r'''
-import 'a.dart' as p;
-const int V =
- p/*location: test.dart;p*/.
- C/*location: a.dart;C*/.
- F/*location: a.dart;C;F?*/;
+library
+ imports
+ a.dart as p @19
+ definingUnit
+ topLevelVariables
+ static const V @28
+ type: int
+ constantInitializer
+ PropertyAccess
+ operator: . @0
+ propertyName: SimpleIdentifier
+ staticElement: a.dart::@class::C::@getter::F
+ staticType: int
+ token: F @36
+ staticType: int
+ target: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: null
+ token: C @34
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @32
+ staticElement: a.dart::@class::C
+ staticType: null
+ accessors
+ synthetic static get V @28
+ returnType: int
''');
}
@@ -4230,12 +9123,39 @@
const V = C.m;
''');
checkElementText(library, r'''
-class C {
- static int m(int a, String b) {}
-}
-const int Function(int, String) V =
- C/*location: test.dart;C*/.
- m/*location: test.dart;C;m*/;
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ static m @23
+ parameters
+ requiredPositional a @29
+ type: int
+ requiredPositional b @39
+ type: String
+ returnType: int
+ topLevelVariables
+ static const V @57
+ type: int Function(int, String)
+ constantInitializer
+ PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: self::@class::C::@method::m
+ staticType: int Function(int, String)
+ token: m @63
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @61
+ staticElement: self::@class::C::@method::m
+ staticType: int Function(int, String)
+ accessors
+ synthetic static get V @57
+ returnType: int Function(int, String)
''');
}
@@ -4250,10 +9170,29 @@
const V = C.m;
''');
checkElementText(library, r'''
-import 'a.dart';
-const int Function(int, String) V =
- C/*location: a.dart;C*/.
- m/*location: a.dart;C;m*/;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static const V @23
+ type: int Function(int, String)
+ constantInitializer
+ PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@class::C::@method::m
+ staticType: int Function(int, String)
+ token: m @29
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: null
+ token: C @27
+ staticElement: a.dart::@class::C::@method::m
+ staticType: int Function(int, String)
+ accessors
+ synthetic static get V @23
+ returnType: int Function(int, String)
''');
}
@@ -4268,11 +9207,36 @@
const V = p.C.m;
''');
checkElementText(library, r'''
-import 'a.dart' as p;
-const int Function(int, String) V =
- p/*location: test.dart;p*/.
- C/*location: a.dart;C*/.
- m/*location: a.dart;C;m*/;
+library
+ imports
+ a.dart as p @19
+ definingUnit
+ topLevelVariables
+ static const V @28
+ type: int Function(int, String)
+ constantInitializer
+ PropertyAccess
+ operator: . @0
+ propertyName: SimpleIdentifier
+ staticElement: a.dart::@class::C::@method::m
+ staticType: int Function(int, String)
+ token: m @36
+ staticType: int Function(int, String)
+ target: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: null
+ token: C @34
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @32
+ staticElement: a.dart::@class::C
+ staticType: null
+ accessors
+ synthetic static get V @28
+ returnType: int Function(int, String)
''');
}
@@ -4285,14 +9249,37 @@
const x = E.f;
''');
checkElementText(library, r'''
-class A {
-}
-extension E on A {
- static void f() {}
-}
-const void Function() x =
- E/*location: test.dart;E*/.
- f/*location: test.dart;E;f*/;
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ extensions
+ E @21
+ extendedType: A
+ methods
+ static f @44
+ returnType: void
+ topLevelVariables
+ static const x @59
+ type: void Function()
+ constantInitializer
+ PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: self::@extension::E::@method::f
+ staticType: void Function()
+ token: f @65
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@extension::E
+ staticType: null
+ token: E @63
+ staticElement: self::@extension::E::@method::f
+ staticType: void Function()
+ accessors
+ synthetic static get x @59
+ returnType: void Function()
''');
}
@@ -4302,9 +9289,22 @@
const V = foo;
''');
checkElementText(library, r'''
-const dynamic Function() V =
- foo/*location: test.dart;foo*/;
-dynamic foo() {}
+library
+ definingUnit
+ topLevelVariables
+ static const V @15
+ type: dynamic Function()
+ constantInitializer
+ SimpleIdentifier
+ staticElement: self::@function::foo
+ staticType: dynamic Function()
+ token: foo @19
+ accessors
+ synthetic static get V @15
+ returnType: dynamic Function()
+ functions
+ foo @0
+ returnType: dynamic
''');
}
@@ -4314,9 +9314,28 @@
const V = foo;
''');
checkElementText(library, r'''
-const R Function<P, R>(P) V =
- foo/*location: test.dart;foo*/;
-R foo<P, R>(P p) {}
+library
+ definingUnit
+ topLevelVariables
+ static const V @26
+ type: R Function<P, R>(P)
+ constantInitializer
+ SimpleIdentifier
+ staticElement: self::@function::foo
+ staticType: R Function<P, R>(P)
+ token: foo @30
+ accessors
+ synthetic static get V @26
+ returnType: R Function<P, R>(P)
+ functions
+ foo @2
+ typeParameters
+ covariant P @6
+ covariant R @9
+ parameters
+ requiredPositional p @14
+ type: P
+ returnType: R
''');
}
@@ -4329,9 +9348,21 @@
const V = foo;
''');
checkElementText(library, r'''
-import 'a.dart';
-const dynamic Function() V =
- foo/*location: a.dart;foo*/;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static const V @23
+ type: dynamic Function()
+ constantInitializer
+ SimpleIdentifier
+ staticElement: a.dart::@function::foo
+ staticType: dynamic Function()
+ token: foo @27
+ accessors
+ synthetic static get V @23
+ returnType: dynamic Function()
''');
}
@@ -4344,10 +9375,29 @@
const V = p.foo;
''');
checkElementText(library, r'''
-import 'a.dart' as p;
-const dynamic Function() V =
- p/*location: test.dart;p*/.
- foo/*location: a.dart;foo*/;
+library
+ imports
+ a.dart as p @19
+ definingUnit
+ topLevelVariables
+ static const V @28
+ type: dynamic Function()
+ constantInitializer
+ PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@function::foo
+ staticType: dynamic Function()
+ token: foo @34
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @32
+ staticElement: a.dart::@function::foo
+ staticType: dynamic Function()
+ accessors
+ synthetic static get V @28
+ returnType: dynamic Function()
''');
}
@@ -4357,9 +9407,35 @@
const B = A + 2;
''');
checkElementText(library, r'''
-const int A = 1;
-const int B =
- A/*location: test.dart;A?*/ + 2;
+library
+ definingUnit
+ topLevelVariables
+ static const A @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 1 @10
+ staticType: int
+ static const B @19
+ type: int
+ constantInitializer
+ BinaryExpression
+ leftOperand: SimpleIdentifier
+ staticElement: self::@getter::A
+ staticType: int
+ token: A @23
+ operator: + @0
+ rightOperand: IntegerLiteral
+ literal: 2 @27
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: null
+ staticType: int
+ accessors
+ synthetic static get A @6
+ returnType: int
+ synthetic static get B @19
+ returnType: int
''');
}
@@ -4372,9 +9448,29 @@
const B = A + 2;
''');
checkElementText(library, r'''
-import 'a.dart';
-const int B =
- A/*location: a.dart;A?*/ + 2;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static const B @23
+ type: int
+ constantInitializer
+ BinaryExpression
+ leftOperand: SimpleIdentifier
+ staticElement: a.dart::@getter::A
+ staticType: int
+ token: A @27
+ operator: + @0
+ rightOperand: IntegerLiteral
+ literal: 2 @31
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: null
+ staticType: int
+ accessors
+ synthetic static get B @23
+ returnType: int
''');
}
@@ -4387,10 +9483,37 @@
const B = p.A + 2;
''');
checkElementText(library, r'''
-import 'a.dart' as p;
-const int B =
- p/*location: test.dart;p*/.
- A/*location: a.dart;A?*/ + 2;
+library
+ imports
+ a.dart as p @19
+ definingUnit
+ topLevelVariables
+ static const B @28
+ type: int
+ constantInitializer
+ BinaryExpression
+ leftOperand: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@getter::A
+ staticType: int
+ token: A @34
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @32
+ staticElement: a.dart::@getter::A
+ staticType: int
+ operator: + @0
+ rightOperand: IntegerLiteral
+ literal: 2 @38
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: null
+ staticType: int
+ accessors
+ synthetic static get B @28
+ returnType: int
''');
}
@@ -4409,33 +9532,120 @@
const vFunctionTypeAlias = F;
''');
checkElementText(library, r'''
-typedef F = dynamic Function(int a, String b);
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E a;
- static const E b;
- static const E c;
- String toString() {}
-}
-class C {
-}
-class D<T> {
-}
-const Type vDynamic =
- dynamic/*location: dynamic*/;
-const Type vNull =
- Null/*location: dart:core;Null*/;
-const Type vObject =
- Object/*location: dart:core;Object*/;
-const Type vClass =
- C/*location: test.dart;C*/;
-const Type vGenericClass =
- D/*location: test.dart;D*/;
-const Type vEnum =
- E/*location: test.dart;E*/;
-const Type vFunctionTypeAlias =
- F/*location: test.dart;F*/;
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ class D @17
+ typeParameters
+ covariant T @19
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ enums
+ enum E @30
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const a @33
+ type: E
+ static const b @36
+ type: E
+ static const c @39
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get a @-1
+ returnType: E
+ synthetic static get b @-1
+ returnType: E
+ synthetic static get c @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
+ typeAliases
+ functionTypeAliasBased F @50
+ aliasedType: dynamic Function(int, String)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional a @-1
+ type: int
+ requiredPositional b @-1
+ type: String
+ returnType: dynamic
+ topLevelVariables
+ static const vDynamic @76
+ type: Type
+ constantInitializer
+ SimpleIdentifier
+ staticElement: dynamic@-1
+ staticType: Type
+ token: dynamic @87
+ static const vNull @102
+ type: Type
+ constantInitializer
+ SimpleIdentifier
+ staticElement: dart:core::@class::Null
+ staticType: Type
+ token: Null @110
+ static const vObject @122
+ type: Type
+ constantInitializer
+ SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: Type
+ token: Object @132
+ static const vClass @146
+ type: Type
+ constantInitializer
+ SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: Type
+ token: C @155
+ static const vGenericClass @164
+ type: Type
+ constantInitializer
+ SimpleIdentifier
+ staticElement: self::@class::D
+ staticType: Type
+ token: D @180
+ static const vEnum @189
+ type: Type
+ constantInitializer
+ SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: Type
+ token: E @197
+ static const vFunctionTypeAlias @206
+ type: Type
+ constantInitializer
+ SimpleIdentifier
+ staticElement: self::@typeAlias::F
+ staticType: Type
+ token: F @227
+ accessors
+ synthetic static get vDynamic @76
+ returnType: Type
+ synthetic static get vNull @102
+ returnType: Type
+ synthetic static get vObject @122
+ returnType: Type
+ synthetic static get vClass @146
+ returnType: Type
+ synthetic static get vGenericClass @164
+ returnType: Type
+ synthetic static get vEnum @189
+ returnType: Type
+ synthetic static get vFunctionTypeAlias @206
+ returnType: Type
''');
}
@@ -4447,10 +9657,23 @@
}
''');
checkElementText(library, r'''
-typedef F = dynamic Function();
-class C {
- final List<dynamic Function()> f;
-}
+library
+ definingUnit
+ classes
+ class C @19
+ fields
+ final f @31
+ type: List<dynamic Function()>
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get f @31
+ returnType: List<dynamic Function()>
+ typeAliases
+ functionTypeAliasBased F @8
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
''');
}
@@ -4467,13 +9690,39 @@
const vFunctionTypeAlias = F;
''');
checkElementText(library, r'''
-import 'a.dart';
-const Type vClass =
- C/*location: a.dart;C*/;
-const Type vEnum =
- E/*location: a.dart;E*/;
-const Type vFunctionTypeAlias =
- F/*location: a.dart;F*/;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static const vClass @23
+ type: Type
+ constantInitializer
+ SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: Type
+ token: C @32
+ static const vEnum @41
+ type: Type
+ constantInitializer
+ SimpleIdentifier
+ staticElement: a.dart::@enum::E
+ staticType: Type
+ token: E @49
+ static const vFunctionTypeAlias @58
+ type: Type
+ constantInitializer
+ SimpleIdentifier
+ staticElement: a.dart::@typeAlias::F
+ staticType: Type
+ token: F @79
+ accessors
+ synthetic static get vClass @23
+ returnType: Type
+ synthetic static get vEnum @41
+ returnType: Type
+ synthetic static get vFunctionTypeAlias @58
+ returnType: Type
''');
}
@@ -4490,16 +9739,63 @@
const vFunctionTypeAlias = p.F;
''');
checkElementText(library, r'''
-import 'a.dart' as p;
-const Type vClass =
- p/*location: test.dart;p*/.
- C/*location: a.dart;C*/;
-const Type vEnum =
- p/*location: test.dart;p*/.
- E/*location: a.dart;E*/;
-const Type vFunctionTypeAlias =
- p/*location: test.dart;p*/.
- F/*location: a.dart;F*/;
+library
+ imports
+ a.dart as p @19
+ definingUnit
+ topLevelVariables
+ static const vClass @28
+ type: Type
+ constantInitializer
+ PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: Type
+ token: C @39
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @37
+ staticElement: a.dart::@class::C
+ staticType: Type
+ static const vEnum @48
+ type: Type
+ constantInitializer
+ PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@enum::E
+ staticType: Type
+ token: E @58
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @56
+ staticElement: a.dart::@enum::E
+ staticType: Type
+ static const vFunctionTypeAlias @67
+ type: Type
+ constantInitializer
+ PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@typeAlias::F
+ staticType: Type
+ token: F @90
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @88
+ staticElement: a.dart::@typeAlias::F
+ staticType: Type
+ accessors
+ synthetic static get vClass @28
+ returnType: Type
+ synthetic static get vEnum @48
+ returnType: Type
+ synthetic static get vFunctionTypeAlias @67
+ returnType: Type
''');
}
@@ -4510,9 +9806,21 @@
}
''');
checkElementText(library, r'''
-class C<T> {
- final List<T> f;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ fields
+ final f @21
+ type: List<T>
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get f @21
+ returnType: List<T>
''');
}
@@ -4521,8 +9829,19 @@
const V = foo;
''', allowErrors: true);
checkElementText(library, r'''
-const dynamic V =
- foo/*location: null*/;
+library
+ definingUnit
+ topLevelVariables
+ static const V @6
+ type: dynamic
+ constantInitializer
+ SimpleIdentifier
+ staticElement: <null>
+ staticType: dynamic
+ token: foo @10
+ accessors
+ synthetic static get V @6
+ returnType: dynamic
''');
}
@@ -4532,11 +9851,31 @@
const V = C.foo;
''', allowErrors: true);
checkElementText(library, r'''
-class C {
-}
-const dynamic V =
- C/*location: test.dart;C*/.
- foo/*location: null*/;
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static const V @17
+ type: dynamic
+ constantInitializer
+ PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: dynamic
+ token: foo @23
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @21
+ staticElement: <null>
+ staticType: dynamic
+ accessors
+ synthetic static get V @17
+ returnType: dynamic
''');
}
@@ -4549,11 +9888,36 @@
const V = p.C.foo;
''', allowErrors: true);
checkElementText(library, r'''
-import 'foo.dart' as p;
-const dynamic V =
- p/*location: test.dart;p*/.
- C/*location: foo.dart;C*/.
- foo/*location: null*/;
+library
+ imports
+ foo.dart as p @21
+ definingUnit
+ topLevelVariables
+ static const V @30
+ type: dynamic
+ constantInitializer
+ PropertyAccess
+ operator: . @0
+ propertyName: SimpleIdentifier
+ staticElement: <null>
+ staticType: dynamic
+ token: foo @38
+ staticType: dynamic
+ target: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: foo.dart::@class::C
+ staticType: null
+ token: C @36
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @34
+ staticElement: foo.dart::@class::C
+ staticType: null
+ accessors
+ synthetic static get V @30
+ returnType: dynamic
''');
}
@@ -4561,13 +9925,39 @@
var library = await checkLibrary('''
const Object x = const <int>{if (true) 1};
''');
- checkElementText(
- library,
- '''
-const Object x = const <
- int/*location: dart:core;int*/>{if (true) 1}/*isSet*/;
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const x @13
+ type: Object
+ constantInitializer
+ SetOrMapLiteral
+ constKeyword: const @0
+ elements
+ IfElement
+ condition: BooleanLiteral
+ literal: true @33
+ staticType: bool
+ thenStatement: IntegerLiteral
+ literal: 1 @39
+ staticType: int
+ isMap: false
+ staticType: Set<int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @24
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ accessors
+ synthetic static get x @13
+ returnType: Object
+''');
}
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/44522')
@@ -4575,13 +9965,10 @@
var library = await checkLibrary('''
const Object x = const <int>{if (true) 1 else 2];
''');
- checkElementText(
- library,
- '''
+ checkElementText(library, r'''
const Object x = const <
int/*location: dart:core;int*/>{if (true) 1 else 2}/*isSet*/;
-''',
- withTypes: true);
+''');
}
test_const_set_inferredType() async {
@@ -4591,40 +9978,127 @@
var library = await checkLibrary('''
const Object x = const {1};
''');
- checkElementText(
- library,
- '''
-const Object x = const /*typeArgs=int*/{1}/*isSet*/;
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const x @13
+ type: Object
+ constantInitializer
+ SetOrMapLiteral
+ constKeyword: const @0
+ elements
+ IntegerLiteral
+ literal: 1 @24
+ staticType: int
+ isMap: false
+ staticType: Set<int>
+ accessors
+ synthetic static get x @13
+ returnType: Object
+''');
}
test_const_set_spread() async {
var library = await checkLibrary('''
const Object x = const <int>{...<int>{1}};
''');
- checkElementText(
- library,
- '''
-const Object x = const <
- int/*location: dart:core;int*/>{...<
- int/*location: dart:core;int*/>{1}/*isSet*/}/*isSet*/;
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const x @13
+ type: Object
+ constantInitializer
+ SetOrMapLiteral
+ constKeyword: const @0
+ elements
+ SpreadElement
+ expressions: SetOrMapLiteral
+ elements
+ IntegerLiteral
+ literal: 1 @38
+ staticType: int
+ isMap: false
+ staticType: Set<int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @33
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ spreadOperator: ... @0
+ isMap: false
+ staticType: Set<int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @24
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ accessors
+ synthetic static get x @13
+ returnType: Object
+''');
}
test_const_set_spread_null_aware() async {
var library = await checkLibrary('''
const Object x = const <int>{...?<int>{1}};
''');
- checkElementText(
- library,
- '''
-const Object x = const <
- int/*location: dart:core;int*/>{...?<
- int/*location: dart:core;int*/>{1}/*isSet*/}/*isSet*/;
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const x @13
+ type: Object
+ constantInitializer
+ SetOrMapLiteral
+ constKeyword: const @0
+ elements
+ SpreadElement
+ expressions: SetOrMapLiteral
+ elements
+ IntegerLiteral
+ literal: 1 @39
+ staticType: int
+ isMap: false
+ staticType: Set<int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @34
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ spreadOperator: ...? @0
+ isMap: false
+ staticType: Set<int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @24
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ accessors
+ synthetic static get x @13
+ returnType: Object
+''');
}
test_const_topLevel_binary() async {
@@ -4649,24 +10123,298 @@
const vLessEqual = 1 <= 2;
''');
checkElementText(library, r'''
-const bool vEqual = 1 == 2;
-const bool vAnd = true && false;
-const bool vOr = false || true;
-const int vBitXor = 1 ^ 2;
-const int vBitAnd = 1 & 2;
-const int vBitOr = 1 | 2;
-const int vBitShiftLeft = 1 << 2;
-const int vBitShiftRight = 1 >> 2;
-const int vAdd = 1 + 2;
-const int vSubtract = 1 - 2;
-const int vMiltiply = 1 * 2;
-const double vDivide = 1 / 2;
-const int vFloorDivide = 1 ~/ 2;
-const int vModulo = 1 % 2;
-const bool vGreater = 1 > 2;
-const bool vGreaterEqual = 1 >= 2;
-const bool vLess = 1 < 2;
-const bool vLessEqual = 1 <= 2;
+library
+ definingUnit
+ topLevelVariables
+ static const vEqual @6
+ type: bool
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @15
+ staticType: int
+ operator: == @0
+ rightOperand: IntegerLiteral
+ literal: 2 @20
+ staticType: int
+ staticElement: dart:core::@class::num::@method::==
+ staticInvokeType: null
+ staticType: bool
+ static const vAnd @29
+ type: bool
+ constantInitializer
+ BinaryExpression
+ leftOperand: BooleanLiteral
+ literal: true @36
+ staticType: bool
+ operator: && @0
+ rightOperand: BooleanLiteral
+ literal: false @44
+ staticType: bool
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: bool
+ static const vOr @57
+ type: bool
+ constantInitializer
+ BinaryExpression
+ leftOperand: BooleanLiteral
+ literal: false @63
+ staticType: bool
+ operator: || @0
+ rightOperand: BooleanLiteral
+ literal: true @72
+ staticType: bool
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: bool
+ static const vBitXor @84
+ type: int
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @94
+ staticType: int
+ operator: ^ @0
+ rightOperand: IntegerLiteral
+ literal: 2 @98
+ staticType: int
+ staticElement: dart:core::@class::int::@method::^
+ staticInvokeType: null
+ staticType: int
+ static const vBitAnd @107
+ type: int
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @117
+ staticType: int
+ operator: & @0
+ rightOperand: IntegerLiteral
+ literal: 2 @121
+ staticType: int
+ staticElement: dart:core::@class::int::@method::&
+ staticInvokeType: null
+ staticType: int
+ static const vBitOr @130
+ type: int
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @139
+ staticType: int
+ operator: | @0
+ rightOperand: IntegerLiteral
+ literal: 2 @143
+ staticType: int
+ staticElement: dart:core::@class::int::@method::|
+ staticInvokeType: null
+ staticType: int
+ static const vBitShiftLeft @152
+ type: int
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @168
+ staticType: int
+ operator: << @0
+ rightOperand: IntegerLiteral
+ literal: 2 @173
+ staticType: int
+ staticElement: dart:core::@class::int::@method::<<
+ staticInvokeType: null
+ staticType: int
+ static const vBitShiftRight @182
+ type: int
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @199
+ staticType: int
+ operator: >> @0
+ rightOperand: IntegerLiteral
+ literal: 2 @204
+ staticType: int
+ staticElement: dart:core::@class::int::@method::>>
+ staticInvokeType: null
+ staticType: int
+ static const vAdd @213
+ type: int
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @220
+ staticType: int
+ operator: + @0
+ rightOperand: IntegerLiteral
+ literal: 2 @224
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: null
+ staticType: int
+ static const vSubtract @233
+ type: int
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @245
+ staticType: int
+ operator: - @0
+ rightOperand: IntegerLiteral
+ literal: 2 @249
+ staticType: int
+ staticElement: dart:core::@class::num::@method::-
+ staticInvokeType: null
+ staticType: int
+ static const vMiltiply @258
+ type: int
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @270
+ staticType: int
+ operator: * @0
+ rightOperand: IntegerLiteral
+ literal: 2 @274
+ staticType: int
+ staticElement: dart:core::@class::num::@method::*
+ staticInvokeType: null
+ staticType: int
+ static const vDivide @283
+ type: double
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @293
+ staticType: int
+ operator: / @0
+ rightOperand: IntegerLiteral
+ literal: 2 @297
+ staticType: int
+ staticElement: dart:core::@class::num::@method::/
+ staticInvokeType: null
+ staticType: double
+ static const vFloorDivide @306
+ type: int
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @321
+ staticType: int
+ operator: ~/ @0
+ rightOperand: IntegerLiteral
+ literal: 2 @326
+ staticType: int
+ staticElement: dart:core::@class::num::@method::~/
+ staticInvokeType: null
+ staticType: int
+ static const vModulo @335
+ type: int
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @345
+ staticType: int
+ operator: % @0
+ rightOperand: IntegerLiteral
+ literal: 2 @349
+ staticType: int
+ staticElement: dart:core::@class::num::@method::%
+ staticInvokeType: null
+ staticType: int
+ static const vGreater @358
+ type: bool
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @369
+ staticType: int
+ operator: > @0
+ rightOperand: IntegerLiteral
+ literal: 2 @373
+ staticType: int
+ staticElement: dart:core::@class::num::@method::>
+ staticInvokeType: null
+ staticType: bool
+ static const vGreaterEqual @382
+ type: bool
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @398
+ staticType: int
+ operator: >= @0
+ rightOperand: IntegerLiteral
+ literal: 2 @403
+ staticType: int
+ staticElement: dart:core::@class::num::@method::>=
+ staticInvokeType: null
+ staticType: bool
+ static const vLess @412
+ type: bool
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @420
+ staticType: int
+ operator: < @0
+ rightOperand: IntegerLiteral
+ literal: 2 @424
+ staticType: int
+ staticElement: dart:core::@class::num::@method::<
+ staticInvokeType: null
+ staticType: bool
+ static const vLessEqual @433
+ type: bool
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @446
+ staticType: int
+ operator: <= @0
+ rightOperand: IntegerLiteral
+ literal: 2 @451
+ staticType: int
+ staticElement: dart:core::@class::num::@method::<=
+ staticInvokeType: null
+ staticType: bool
+ accessors
+ synthetic static get vEqual @6
+ returnType: bool
+ synthetic static get vAnd @29
+ returnType: bool
+ synthetic static get vOr @57
+ returnType: bool
+ synthetic static get vBitXor @84
+ returnType: int
+ synthetic static get vBitAnd @107
+ returnType: int
+ synthetic static get vBitOr @130
+ returnType: int
+ synthetic static get vBitShiftLeft @152
+ returnType: int
+ synthetic static get vBitShiftRight @182
+ returnType: int
+ synthetic static get vAdd @213
+ returnType: int
+ synthetic static get vSubtract @233
+ returnType: int
+ synthetic static get vMiltiply @258
+ returnType: int
+ synthetic static get vDivide @283
+ returnType: double
+ synthetic static get vFloorDivide @306
+ returnType: int
+ synthetic static get vModulo @335
+ returnType: int
+ synthetic static get vGreater @358
+ returnType: bool
+ synthetic static get vGreaterEqual @382
+ returnType: bool
+ synthetic static get vLess @412
+ returnType: bool
+ synthetic static get vLessEqual @433
+ returnType: bool
''');
}
@@ -4675,7 +10423,40 @@
const vConditional = (1 == 2) ? 11 : 22;
''');
checkElementText(library, r'''
-const int vConditional = (1 == 2) ? 11 : 22;
+library
+ definingUnit
+ topLevelVariables
+ static const vConditional @6
+ type: int
+ constantInitializer
+ ConditionalExpression
+ colon: : @0
+ condition: ParenthesizedExpression
+ expression: BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @22
+ staticType: int
+ operator: == @0
+ rightOperand: IntegerLiteral
+ literal: 2 @27
+ staticType: int
+ staticElement: dart:core::@class::num::@method::==
+ staticInvokeType: null
+ staticType: bool
+ leftParenthesis: ( @21
+ rightParenthesis: ) @28
+ staticType: bool
+ elseExpression: IntegerLiteral
+ literal: 22 @37
+ staticType: int
+ question: ? @0
+ staticType: int
+ thenExpression: IntegerLiteral
+ literal: 11 @32
+ staticType: int
+ accessors
+ synthetic static get vConditional @6
+ returnType: int
''');
}
@@ -4684,7 +10465,40 @@
const vIdentical = (1 == 2) ? 11 : 22;
''');
checkElementText(library, r'''
-const int vIdentical = (1 == 2) ? 11 : 22;
+library
+ definingUnit
+ topLevelVariables
+ static const vIdentical @6
+ type: int
+ constantInitializer
+ ConditionalExpression
+ colon: : @0
+ condition: ParenthesizedExpression
+ expression: BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @20
+ staticType: int
+ operator: == @0
+ rightOperand: IntegerLiteral
+ literal: 2 @25
+ staticType: int
+ staticElement: dart:core::@class::num::@method::==
+ staticInvokeType: null
+ staticType: bool
+ leftParenthesis: ( @19
+ rightParenthesis: ) @26
+ staticType: bool
+ elseExpression: IntegerLiteral
+ literal: 22 @35
+ staticType: int
+ question: ? @0
+ staticType: int
+ thenExpression: IntegerLiteral
+ literal: 11 @30
+ staticType: int
+ accessors
+ synthetic static get vIdentical @6
+ returnType: int
''');
}
@@ -4693,7 +10507,26 @@
const vIfNull = 1 ?? 2.0;
''');
checkElementText(library, r'''
-const num vIfNull = 1 ?? 2.0;
+library
+ definingUnit
+ topLevelVariables
+ static const vIfNull @6
+ type: num
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @16
+ staticType: int
+ operator: ?? @0
+ rightOperand: DoubleLiteral
+ literal: 2.0 @21
+ staticType: double
+ staticElement: <null>
+ staticInvokeType: null
+ staticType: num
+ accessors
+ synthetic static get vIfNull @6
+ returnType: num
''');
}
@@ -4714,19 +10547,143 @@
const vSymbol = #aaa.bbb.ccc;
''');
checkElementText(library, r'''
-const dynamic vNull = null;
-const bool vBoolFalse = false;
-const bool vBoolTrue = true;
-const int vIntPositive = 1;
-const int vIntNegative = -2;
-const int vIntLong1 = 9223372036854775807;
-const int vIntLong2 = -1;
-const int vIntLong3 = -9223372036854775808;
-const double vDouble = 2.3;
-const String vString = 'abc';
-const String vStringConcat = 'aaabbb';
-const String vStringInterpolation = 'aaa ${true} ${42} bbb';
-const Symbol vSymbol = #aaa.bbb.ccc;
+library
+ definingUnit
+ topLevelVariables
+ static const vNull @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ static const vBoolFalse @26
+ type: bool
+ constantInitializer
+ BooleanLiteral
+ literal: false @39
+ staticType: bool
+ static const vBoolTrue @52
+ type: bool
+ constantInitializer
+ BooleanLiteral
+ literal: true @64
+ staticType: bool
+ static const vIntPositive @76
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 1 @91
+ staticType: int
+ static const vIntNegative @100
+ type: int
+ constantInitializer
+ PrefixExpression
+ operand: IntegerLiteral
+ literal: 2 @116
+ staticType: int
+ operator: - @115
+ staticElement: dart:core::@class::int::@method::unary-
+ staticType: int
+ static const vIntLong1 @125
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 9223372036854775807 @137
+ staticType: int
+ static const vIntLong2 @163
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: -1 @175
+ staticType: int
+ static const vIntLong3 @201
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: -9223372036854775808 @213
+ staticType: int
+ static const vDouble @239
+ type: double
+ constantInitializer
+ DoubleLiteral
+ literal: 2.3 @249
+ staticType: double
+ static const vString @260
+ type: String
+ constantInitializer
+ SimpleStringLiteral
+ literal: 'abc' @270
+ static const vStringConcat @283
+ type: String
+ constantInitializer
+ AdjacentStrings
+ staticType: null
+ stringValue: aaabbb
+ strings
+ SimpleStringLiteral
+ literal: 'aaa' @299
+ SimpleStringLiteral
+ literal: 'bbb' @305
+ static const vStringInterpolation @318
+ type: String
+ constantInitializer
+ StringInterpolation
+ elements
+ InterpolationString
+ contents: aaa @0
+ InterpolationExpression
+ expression: BooleanLiteral
+ literal: true @348
+ staticType: bool
+ InterpolationString
+ contents: @0
+ InterpolationExpression
+ expression: IntegerLiteral
+ literal: 42 @356
+ staticType: int
+ InterpolationString
+ contents: bbb @0
+ staticType: null
+ stringValue: null
+ static const vSymbol @372
+ type: Symbol
+ constantInitializer
+ SymbolLiteral
+ components
+ components: aaa
+ offset: 0
+ components: bbb
+ offset: 0
+ components: ccc
+ offset: 0
+ poundSign: # @0
+ accessors
+ synthetic static get vNull @6
+ returnType: dynamic
+ synthetic static get vBoolFalse @26
+ returnType: bool
+ synthetic static get vBoolTrue @52
+ returnType: bool
+ synthetic static get vIntPositive @76
+ returnType: int
+ synthetic static get vIntNegative @100
+ returnType: int
+ synthetic static get vIntLong1 @125
+ returnType: int
+ synthetic static get vIntLong2 @163
+ returnType: int
+ synthetic static get vIntLong3 @201
+ returnType: int
+ synthetic static get vDouble @239
+ returnType: double
+ synthetic static get vString @260
+ returnType: String
+ synthetic static get vStringConcat @283
+ returnType: String
+ synthetic static get vStringInterpolation @318
+ returnType: String
+ synthetic static get vSymbol @372
+ returnType: Symbol
''');
}
@@ -4738,31 +10695,40 @@
a?.length,
];
''');
- checkElementText(
- library,
- r'''
-const String? a;
- constantInitializer
- SimpleStringLiteral
- literal: ''
-const List<int?> b;
- constantInitializer
- ListLiteral
- elements
- PropertyAccess
- operator: ?.
- propertyName: SimpleIdentifier
- staticElement: dart:core::@class::String::@getter::length
- staticType: int
- token: length
- staticType: int?
- target: SimpleIdentifier
- staticElement: self::@getter::a
- staticType: String?
- token: a
- staticType: List<int?>
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const a @14
+ type: String?
+ constantInitializer
+ SimpleStringLiteral
+ literal: '' @18
+ static const b @40
+ type: List<int?>
+ constantInitializer
+ ListLiteral
+ elements
+ PropertyAccess
+ operator: ?. @0
+ propertyName: SimpleIdentifier
+ staticElement: dart:core::@class::String::@getter::length
+ staticType: int
+ token: length @51
+ staticType: int?
+ target: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: String?
+ token: a @48
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<int?>
+ accessors
+ synthetic static get a @14
+ returnType: String?
+ synthetic static get b @40
+ returnType: List<int?>
+''');
}
test_const_topLevel_parenthesis() async {
@@ -4772,10 +10738,87 @@
const int v3 = ('aaa' + 'bbb').length;
''');
checkElementText(library, r'''
-const int v1 = (1 + 2) * 3;
-const int v2 = -(1 + 2);
-const int v3 = ('aaa' + 'bbb').
- length/*location: dart:core;String;length?*/;
+library
+ definingUnit
+ topLevelVariables
+ static const v1 @10
+ type: int
+ constantInitializer
+ BinaryExpression
+ leftOperand: ParenthesizedExpression
+ expression: BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @16
+ staticType: int
+ operator: + @0
+ rightOperand: IntegerLiteral
+ literal: 2 @20
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: null
+ staticType: int
+ leftParenthesis: ( @15
+ rightParenthesis: ) @21
+ staticType: int
+ operator: * @0
+ rightOperand: IntegerLiteral
+ literal: 3 @25
+ staticType: int
+ staticElement: dart:core::@class::num::@method::*
+ staticInvokeType: null
+ staticType: int
+ static const v2 @38
+ type: int
+ constantInitializer
+ PrefixExpression
+ operand: ParenthesizedExpression
+ expression: BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @45
+ staticType: int
+ operator: + @0
+ rightOperand: IntegerLiteral
+ literal: 2 @49
+ staticType: int
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: null
+ staticType: int
+ leftParenthesis: ( @44
+ rightParenthesis: ) @50
+ staticType: int
+ operator: - @43
+ staticElement: dart:core::@class::int::@method::unary-
+ staticType: int
+ static const v3 @63
+ type: int
+ constantInitializer
+ PropertyAccess
+ operator: . @0
+ propertyName: SimpleIdentifier
+ staticElement: dart:core::@class::String::@getter::length
+ staticType: int
+ token: length @84
+ staticType: int
+ target: ParenthesizedExpression
+ expression: BinaryExpression
+ leftOperand: SimpleStringLiteral
+ literal: 'aaa' @69
+ operator: + @0
+ rightOperand: SimpleStringLiteral
+ literal: 'bbb' @77
+ staticElement: dart:core::@class::String::@method::+
+ staticInvokeType: null
+ staticType: String
+ leftParenthesis: ( @68
+ rightParenthesis: ) @82
+ staticType: String
+ accessors
+ synthetic static get v1 @10
+ returnType: int
+ synthetic static get v2 @38
+ returnType: int
+ synthetic static get v3 @63
+ returnType: int
''');
}
@@ -4787,10 +10830,62 @@
const vComplement = ~1;
''');
checkElementText(library, r'''
-const bool vNotEqual = 1 != 2;
-const bool vNot = !true;
-const int vNegate = -1;
-const int vComplement = ~1;
+library
+ definingUnit
+ topLevelVariables
+ static const vNotEqual @6
+ type: bool
+ constantInitializer
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @18
+ staticType: int
+ operator: != @0
+ rightOperand: IntegerLiteral
+ literal: 2 @23
+ staticType: int
+ staticElement: dart:core::@class::num::@method::==
+ staticInvokeType: null
+ staticType: bool
+ static const vNot @32
+ type: bool
+ constantInitializer
+ PrefixExpression
+ operand: BooleanLiteral
+ literal: true @40
+ staticType: bool
+ operator: ! @39
+ staticElement: <null>
+ staticType: bool
+ static const vNegate @52
+ type: int
+ constantInitializer
+ PrefixExpression
+ operand: IntegerLiteral
+ literal: 1 @63
+ staticType: int
+ operator: - @62
+ staticElement: dart:core::@class::int::@method::unary-
+ staticType: int
+ static const vComplement @72
+ type: int
+ constantInitializer
+ PrefixExpression
+ operand: IntegerLiteral
+ literal: 1 @87
+ staticType: int
+ operator: ~ @86
+ staticElement: dart:core::@class::int::@method::~
+ staticType: int
+ accessors
+ synthetic static get vNotEqual @6
+ returnType: bool
+ synthetic static get vNot @32
+ returnType: bool
+ synthetic static get vNegate @52
+ returnType: int
+ synthetic static get vComplement @72
+ returnType: int
''');
}
@@ -4799,7 +10894,18 @@
const vSuper = super;
''');
checkElementText(library, r'''
-const dynamic vSuper = super;
+library
+ definingUnit
+ topLevelVariables
+ static const vSuper @6
+ type: dynamic
+ constantInitializer
+ SuperExpression
+ staticType: dynamic
+ superKeyword: super @0
+ accessors
+ synthetic static get vSuper @6
+ returnType: dynamic
''');
}
@@ -4808,7 +10914,18 @@
const vThis = this;
''');
checkElementText(library, r'''
-const dynamic vThis = this;
+library
+ definingUnit
+ topLevelVariables
+ static const vThis @6
+ type: dynamic
+ constantInitializer
+ ThisExpression
+ staticType: dynamic
+ thisKeyword: this @0
+ accessors
+ synthetic static get vThis @6
+ returnType: dynamic
''');
}
@@ -4817,7 +10934,20 @@
const c = throw 42;
''');
checkElementText(library, r'''
-const Never c = throw 42;
+library
+ definingUnit
+ topLevelVariables
+ static const c @6
+ type: Never
+ constantInitializer
+ ThrowExpression
+ expression: IntegerLiteral
+ literal: 42 @16
+ staticType: int
+ staticType: Never
+ accessors
+ synthetic static get c @6
+ returnType: Never
''');
}
@@ -4827,7 +10957,20 @@
const c = throw 42;
''');
checkElementText(library, r'''
-const dynamic c = throw 42;
+library
+ definingUnit
+ topLevelVariables
+ static const c @6
+ type: dynamic
+ constantInitializer
+ ThrowExpression
+ expression: IntegerLiteral
+ literal: 42 @16
+ staticType: int*
+ staticType: Never*
+ accessors
+ synthetic static get c @6
+ returnType: dynamic
''');
}
@@ -4841,22 +10984,186 @@
const vInterfaceWithTypeArguments2 = const <Map<int, List<String>>>[];
''');
checkElementText(library, r'''
-const List<Null> vNull = const <
- Null/*location: dart:core;Null*/>[];
-const List<dynamic> vDynamic = const <
- dynamic/*location: dynamic*/>[1, 2, 3];
-const List<int> vInterfaceNoTypeParameters = const <
- int/*location: dart:core;int*/>[1, 2, 3];
-const List<List<dynamic>> vInterfaceNoTypeArguments = const <
- List/*location: dart:core;List*/>[];
-const List<List<String>> vInterfaceWithTypeArguments = const <
- List/*location: dart:core;List*/<
- String/*location: dart:core;String*/>>[];
-const List<Map<int, List<String>>> vInterfaceWithTypeArguments2 = const <
- Map/*location: dart:core;Map*/<
- int/*location: dart:core;int*/,
- List/*location: dart:core;List*/<
- String/*location: dart:core;String*/>>>[];
+library
+ definingUnit
+ topLevelVariables
+ static const vNull @6
+ type: List<Null>
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<Null>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Null
+ staticType: null
+ token: Null @21
+ type: Null
+ leftBracket: < @0
+ rightBracket: > @0
+ static const vDynamic @36
+ type: List<dynamic>
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ elements
+ IntegerLiteral
+ literal: 1 @63
+ staticType: int
+ IntegerLiteral
+ literal: 2 @66
+ staticType: int
+ IntegerLiteral
+ literal: 3 @69
+ staticType: int
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<dynamic>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dynamic@-1
+ staticType: null
+ token: dynamic @54
+ type: dynamic
+ leftBracket: < @0
+ rightBracket: > @0
+ static const vInterfaceNoTypeParameters @79
+ type: List<int>
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ elements
+ IntegerLiteral
+ literal: 1 @120
+ staticType: int
+ IntegerLiteral
+ literal: 2 @123
+ staticType: int
+ IntegerLiteral
+ literal: 3 @126
+ staticType: int
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @115
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ static const vInterfaceNoTypeArguments @136
+ type: List<List<dynamic>>
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<List<dynamic>>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::List
+ staticType: null
+ token: List @171
+ type: List<dynamic>
+ leftBracket: < @0
+ rightBracket: > @0
+ static const vInterfaceWithTypeArguments @186
+ type: List<List<String>>
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<List<String>>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::List
+ staticType: null
+ token: List @223
+ type: List<String>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::String
+ staticType: null
+ token: String @228
+ type: String
+ leftBracket: < @0
+ rightBracket: > @0
+ leftBracket: < @0
+ rightBracket: > @0
+ static const vInterfaceWithTypeArguments2 @246
+ type: List<Map<int, List<String>>>
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<Map<int, List<String>>>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Map
+ staticType: null
+ token: Map @284
+ type: Map<int, List<String>>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @288
+ type: int
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::List
+ staticType: null
+ token: List @293
+ type: List<String>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::String
+ staticType: null
+ token: String @298
+ type: String
+ leftBracket: < @0
+ rightBracket: > @0
+ leftBracket: < @0
+ rightBracket: > @0
+ leftBracket: < @0
+ rightBracket: > @0
+ accessors
+ synthetic static get vNull @6
+ returnType: List<Null>
+ synthetic static get vDynamic @36
+ returnType: List<dynamic>
+ synthetic static get vInterfaceNoTypeParameters @79
+ returnType: List<int>
+ synthetic static get vInterfaceNoTypeArguments @136
+ returnType: List<List<dynamic>>
+ synthetic static get vInterfaceWithTypeArguments @186
+ returnType: List<List<String>>
+ synthetic static get vInterfaceWithTypeArguments2 @246
+ returnType: List<Map<int, List<String>>>
''');
}
@@ -4867,9 +11174,32 @@
const v = const <C>[];
''');
checkElementText(library, r'''
-import 'a.dart';
-const List<C> v = const <
- C/*location: a.dart;C*/>[];
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static const v @23
+ type: List<C>
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<C>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: null
+ token: C @34
+ type: C
+ leftBracket: < @0
+ rightBracket: > @0
+ accessors
+ synthetic static get v @23
+ returnType: List<C>
''');
}
@@ -4880,10 +11210,40 @@
const v = const <p.C>[];
''');
checkElementText(library, r'''
-import 'a.dart' as p;
-const List<C> v = const <
- p/*location: test.dart;p*/.
- C/*location: a.dart;C*/>[];
+library
+ imports
+ a.dart as p @19
+ definingUnit
+ topLevelVariables
+ static const v @28
+ type: List<C>
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<C>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@class::C
+ staticType: null
+ token: C @41
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::p
+ staticType: null
+ token: p @39
+ staticElement: a.dart::@class::C
+ staticType: null
+ type: C
+ leftBracket: < @0
+ rightBracket: > @0
+ accessors
+ synthetic static get v @28
+ returnType: List<C>
''');
}
@@ -4893,9 +11253,38 @@
const v = const <F>[];
''');
checkElementText(library, r'''
-typedef F = int Function(String id);
-const List<int Function(String)> v = const <
- F/*location: test.dart;F*/>[];
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @12
+ aliasedType: int Function(String)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional id @-1
+ type: String
+ returnType: int
+ topLevelVariables
+ static const v @32
+ type: List<int Function(String)>
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<int Function(String)>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: self::@typeAlias::F
+ staticType: null
+ token: F @43
+ type: int Function(String)
+ leftBracket: < @0
+ rightBracket: > @0
+ accessors
+ synthetic static get v @32
+ returnType: List<int Function(String)>
''');
}
@@ -4907,19 +11296,120 @@
const vInterfaceWithTypeArguments = const <int, List<String>>{};
''');
checkElementText(library, r'''
-const Map<dynamic, int> vDynamic1 = const <
- dynamic/*location: dynamic*/,
- int/*location: dart:core;int*/>{}/*isMap*/;
-const Map<int, dynamic> vDynamic2 = const <
- int/*location: dart:core;int*/,
- dynamic/*location: dynamic*/>{}/*isMap*/;
-const Map<int, String> vInterface = const <
- int/*location: dart:core;int*/,
- String/*location: dart:core;String*/>{}/*isMap*/;
-const Map<int, List<String>> vInterfaceWithTypeArguments = const <
- int/*location: dart:core;int*/,
- List/*location: dart:core;List*/<
- String/*location: dart:core;String*/>>{}/*isMap*/;
+library
+ definingUnit
+ topLevelVariables
+ static const vDynamic1 @6
+ type: Map<dynamic, int>
+ constantInitializer
+ SetOrMapLiteral
+ constKeyword: const @0
+ isMap: true
+ staticType: Map<dynamic, int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dynamic@-1
+ staticType: null
+ token: dynamic @25
+ type: dynamic
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @34
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ static const vDynamic2 @48
+ type: Map<int, dynamic>
+ constantInitializer
+ SetOrMapLiteral
+ constKeyword: const @0
+ isMap: true
+ staticType: Map<int, dynamic>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @67
+ type: int
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dynamic@-1
+ staticType: null
+ token: dynamic @72
+ type: dynamic
+ leftBracket: < @0
+ rightBracket: > @0
+ static const vInterface @90
+ type: Map<int, String>
+ constantInitializer
+ SetOrMapLiteral
+ constKeyword: const @0
+ isMap: true
+ staticType: Map<int, String>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @110
+ type: int
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::String
+ staticType: null
+ token: String @115
+ type: String
+ leftBracket: < @0
+ rightBracket: > @0
+ static const vInterfaceWithTypeArguments @132
+ type: Map<int, List<String>>
+ constantInitializer
+ SetOrMapLiteral
+ constKeyword: const @0
+ isMap: true
+ staticType: Map<int, List<String>>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @169
+ type: int
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::List
+ staticType: null
+ token: List @174
+ type: List<String>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::String
+ staticType: null
+ token: String @179
+ type: String
+ leftBracket: < @0
+ rightBracket: > @0
+ leftBracket: < @0
+ rightBracket: > @0
+ accessors
+ synthetic static get vDynamic1 @6
+ returnType: Map<dynamic, int>
+ synthetic static get vDynamic2 @48
+ returnType: Map<int, dynamic>
+ synthetic static get vInterface @90
+ returnType: Map<int, String>
+ synthetic static get vInterfaceWithTypeArguments @132
+ returnType: Map<int, List<String>>
''');
}
@@ -4930,13 +11420,77 @@
const vInterfaceWithTypeArguments = const <List<String>>{};
''');
checkElementText(library, r'''
-const Set<dynamic> vDynamic1 = const <
- dynamic/*location: dynamic*/>{}/*isSet*/;
-const Set<int> vInterface = const <
- int/*location: dart:core;int*/>{}/*isSet*/;
-const Set<List<String>> vInterfaceWithTypeArguments = const <
- List/*location: dart:core;List*/<
- String/*location: dart:core;String*/>>{}/*isSet*/;
+library
+ definingUnit
+ topLevelVariables
+ static const vDynamic1 @6
+ type: Set<dynamic>
+ constantInitializer
+ SetOrMapLiteral
+ constKeyword: const @0
+ isMap: false
+ staticType: Set<dynamic>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dynamic@-1
+ staticType: null
+ token: dynamic @25
+ type: dynamic
+ leftBracket: < @0
+ rightBracket: > @0
+ static const vInterface @43
+ type: Set<int>
+ constantInitializer
+ SetOrMapLiteral
+ constKeyword: const @0
+ isMap: false
+ staticType: Set<int>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @63
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ static const vInterfaceWithTypeArguments @77
+ type: Set<List<String>>
+ constantInitializer
+ SetOrMapLiteral
+ constKeyword: const @0
+ isMap: false
+ staticType: Set<List<String>>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::List
+ staticType: null
+ token: List @114
+ type: List<String>
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::String
+ staticType: null
+ token: String @119
+ type: String
+ leftBracket: < @0
+ rightBracket: > @0
+ leftBracket: < @0
+ rightBracket: > @0
+ accessors
+ synthetic static get vDynamic1 @6
+ returnType: Set<dynamic>
+ synthetic static get vInterface @43
+ returnType: Set<int>
+ synthetic static get vInterfaceWithTypeArguments @77
+ returnType: Set<List<String>>
''');
}
@@ -4945,7 +11499,30 @@
const v = const [1, 2, 3];
''');
checkElementText(library, r'''
-const List<int> v = const [1, 2, 3];
+library
+ definingUnit
+ topLevelVariables
+ static const v @6
+ type: List<int>
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ elements
+ IntegerLiteral
+ literal: 1 @17
+ staticType: int
+ IntegerLiteral
+ literal: 2 @20
+ staticType: int
+ IntegerLiteral
+ literal: 3 @23
+ staticType: int
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<int>
+ accessors
+ synthetic static get v @6
+ returnType: List<int>
''');
}
@@ -4954,7 +11531,38 @@
const v = const {0: 'aaa', 1: 'bbb', 2: 'ccc'};
''');
checkElementText(library, r'''
-const Map<int, String> v = const {0: 'aaa', 1: 'bbb', 2: 'ccc'}/*isMap*/;
+library
+ definingUnit
+ topLevelVariables
+ static const v @6
+ type: Map<int, String>
+ constantInitializer
+ SetOrMapLiteral
+ constKeyword: const @0
+ elements
+ SetOrMapLiteral
+ key: IntegerLiteral
+ literal: 0 @17
+ staticType: int
+ value: SimpleStringLiteral
+ literal: 'aaa' @20
+ SetOrMapLiteral
+ key: IntegerLiteral
+ literal: 1 @27
+ staticType: int
+ value: SimpleStringLiteral
+ literal: 'bbb' @30
+ SetOrMapLiteral
+ key: IntegerLiteral
+ literal: 2 @37
+ staticType: int
+ value: SimpleStringLiteral
+ literal: 'ccc' @40
+ isMap: true
+ staticType: Map<int, String>
+ accessors
+ synthetic static get v @6
+ returnType: Map<int, String>
''');
}
@@ -4963,7 +11571,29 @@
const v = const {0, 1, 2};
''');
checkElementText(library, r'''
-const Set<int> v = const {0, 1, 2}/*isSet*/;
+library
+ definingUnit
+ topLevelVariables
+ static const v @6
+ type: Set<int>
+ constantInitializer
+ SetOrMapLiteral
+ constKeyword: const @0
+ elements
+ IntegerLiteral
+ literal: 0 @17
+ staticType: int
+ IntegerLiteral
+ literal: 1 @20
+ staticType: int
+ IntegerLiteral
+ literal: 2 @23
+ staticType: int
+ isMap: false
+ staticType: Set<int>
+ accessors
+ synthetic static get v @6
+ returnType: Set<int>
''');
}
@@ -4975,17 +11605,49 @@
final vIndex = E.a.index;
''');
checkElementText(library, r'''
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E a;
- static const E b;
- static const E c;
- String toString() {}
-}
-final E vValue;
-final List<E> vValues;
-final int vIndex;
+library
+ definingUnit
+ enums
+ enum E @5
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const a @8
+ type: E
+ static const b @11
+ type: E
+ static const c @14
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get a @-1
+ returnType: E
+ synthetic static get b @-1
+ returnType: E
+ synthetic static get c @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
+ topLevelVariables
+ static final vValue @23
+ type: E
+ static final vValues @43
+ type: List<E>
+ static final vIndex @69
+ type: int
+ accessors
+ synthetic static get vValue @23
+ returnType: E
+ synthetic static get vValues @43
+ returnType: List<E>
+ synthetic static get vIndex @69
+ returnType: int
''');
}
@@ -4995,13 +11657,33 @@
final vToString = E.a.toString();
''');
checkElementText(library, r'''
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E a;
- String toString() {}
-}
-final String vToString;
+library
+ definingUnit
+ enums
+ enum E @5
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const a @8
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get a @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
+ topLevelVariables
+ static final vToString @17
+ type: String
+ accessors
+ synthetic static get vToString @17
+ returnType: String
''');
}
@@ -5013,11 +11695,31 @@
}
''');
checkElementText(library, r'''
-class C {
- static const dynamic a =
- b/*location: test.dart;C;b?*/;
- static const dynamic b = null;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ static const a @25
+ type: dynamic
+ constantInitializer
+ SimpleIdentifier
+ staticElement: self::@class::C::@getter::b
+ staticType: dynamic
+ token: b @29
+ static const b @47
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get a @25
+ returnType: dynamic
+ synthetic static get b @47
+ returnType: dynamic
''');
}
@@ -5029,11 +11731,26 @@
}
''');
checkElementText(library, r'''
-class C {
- static const dynamic Function() a =
- m/*location: test.dart;C;m*/;
- static dynamic m() {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ static const a @25
+ type: dynamic Function()
+ constantInitializer
+ SimpleIdentifier
+ staticElement: self::@class::C::@method::m
+ staticType: dynamic Function()
+ token: m @29
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get a @25
+ returnType: dynamic Function()
+ methods
+ static m @41
+ returnType: dynamic
''');
}
@@ -5046,12 +11763,13 @@
C();
}''');
checkElementText(library, r'''
-class C {
- /**
- * Docs
- */
- C();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ @34
+ documentationComment: /**\n * Docs\n */
''');
}
@@ -5062,10 +11780,29 @@
}
''');
checkElementText(library, r'''
-class C {
- const C(int x) : assert(
- x/*location: test.dart;C;;x*/ >= 42);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ const @18
+ parameters
+ requiredPositional x @24
+ type: int
+ constantInitializers
+ AssertInitializer
+ condition: BinaryExpression
+ leftOperand: SimpleIdentifier
+ staticElement: x@24
+ staticType: int
+ token: x @-1
+ operator: >= @0
+ rightOperand: IntegerLiteral
+ literal: 42 @0
+ staticType: int
+ staticElement: dart:core::@class::num::@method::>=
+ staticInvokeType: null
+ staticType: bool
''');
}
@@ -5076,10 +11813,31 @@
}
''');
checkElementText(library, r'''
-class C {
- const C(int x) : assert(
- x/*location: test.dart;C;;x*/ >= 42, 'foo');
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ const @18
+ parameters
+ requiredPositional x @24
+ type: int
+ constantInitializers
+ AssertInitializer
+ condition: BinaryExpression
+ leftOperand: SimpleIdentifier
+ staticElement: x@24
+ staticType: int
+ token: x @-1
+ operator: >= @0
+ rightOperand: IntegerLiteral
+ literal: 42 @0
+ staticType: int
+ staticElement: dart:core::@class::num::@method::>=
+ staticInvokeType: null
+ staticType: bool
+ message: SimpleStringLiteral
+ literal: 'foo' @0
''');
}
@@ -5091,11 +11849,28 @@
}
''');
checkElementText(library, r'''
-class C {
- final dynamic x;
- const C() :
- x/*location: test.dart;C;x*/ = 42;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ final x @18
+ type: dynamic
+ constructors
+ const @29
+ constantInitializers
+ ConstructorFieldInitializer
+ equals: = @0
+ expression: IntegerLiteral
+ literal: 42 @0
+ staticType: int
+ fieldName: SimpleIdentifier
+ staticElement: self::@class::C::@field::x
+ staticType: null
+ token: x @-1
+ accessors
+ synthetic get x @18
+ returnType: dynamic
''');
}
@@ -5109,13 +11884,38 @@
''', allowErrors: true);
// It is OK to keep non-constant initializers.
checkElementText(library, r'''
-class C {
- final dynamic x;
- const C() :
- x/*location: test.dart;C;x*/ =
- foo/*location: test.dart;foo*/();
-}
-int foo() {}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ final x @18
+ type: dynamic
+ constructors
+ const @29
+ constantInitializers
+ ConstructorFieldInitializer
+ equals: = @0
+ expression: MethodInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ methodName: SimpleIdentifier
+ staticElement: self::@function::foo
+ staticType: int Function()
+ token: foo @-1
+ staticInvokeType: int Function()
+ staticType: int
+ fieldName: SimpleIdentifier
+ staticElement: self::@class::C::@field::x
+ staticType: null
+ token: x @-1
+ accessors
+ synthetic get x @18
+ returnType: dynamic
+ functions
+ foo @52
+ returnType: int
''');
}
@@ -5126,30 +11926,38 @@
const A([int f = 0]) : _f = f;
}
''');
- checkElementText(
- library,
- r'''
-class A {
- final int _f;
- const A([int f]);
- constantInitializers
- ConstructorFieldInitializer
- equals: =
- expression: SimpleIdentifier
- staticElement: self::@class::A::@constructor::•::@parameter::f
- staticType: int
- token: f
- fieldName: SimpleIdentifier
- staticElement: self::@class::A::@field::_f
- staticType: null
- token: _f
- f
- IntegerLiteral
- literal: 0
- staticType: int
-}
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ final _f @22
+ type: int
+ constructors
+ const @34
+ parameters
+ optionalPositional f @41
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ constantInitializers
+ ConstructorFieldInitializer
+ equals: = @0
+ expression: SimpleIdentifier
+ staticElement: self::@class::A::@constructor::•::@parameter::f
+ staticType: int
+ token: f @-1
+ fieldName: SimpleIdentifier
+ staticElement: self::@class::A::@field::_f
+ staticType: null
+ token: _f @-1
+ accessors
+ synthetic get _f @22
+ returnType: int
+''');
}
test_constructor_initializers_field_withParameter() async {
@@ -5160,12 +11968,40 @@
}
''');
checkElementText(library, r'''
-class C {
- final dynamic x;
- const C(int p) :
- x/*location: test.dart;C;x*/ = 1 +
- p/*location: test.dart;C;;p*/;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ final x @18
+ type: dynamic
+ constructors
+ const @29
+ parameters
+ requiredPositional p @35
+ type: int
+ constantInitializers
+ ConstructorFieldInitializer
+ equals: = @0
+ expression: BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ operator: + @0
+ rightOperand: SimpleIdentifier
+ staticElement: p@35
+ staticType: int
+ token: p @-1
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: null
+ staticType: int
+ fieldName: SimpleIdentifier
+ staticElement: self::@class::C::@field::x
+ staticType: null
+ token: x @-1
+ accessors
+ synthetic get x @18
+ returnType: dynamic
''');
}
@@ -5181,14 +12017,59 @@
}
''');
checkElementText(library, r'''
-class A<T> {
- const A();
-}
-class B {
- const B(dynamic x);
- const B.f() = B : this(
- A/*location: test.dart;A*/<Function()>());
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ class B @34
+ constructors
+ const @46
+ parameters
+ requiredPositional x @56
+ type: dynamic
+ const f @70
+ periodOffset: 69
+ nameEnd: 71
+ constantInitializers
+ RedirectingConstructorInvocation
+ argumentList: ArgumentList
+ arguments
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::A::@constructor::•
+ substitution: {T: dynamic Function()}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @-1
+ type: A<dynamic Function()>
+ typeArguments: TypeArgumentList
+ arguments
+ GenericFunctionType
+ declaredElement: GenericFunctionTypeElement
+ parameters
+ returnType: dynamic
+ type: dynamic Function()
+ functionKeyword: Function @0
+ parameters: FormalParameterList
+ type: dynamic Function()
+ leftBracket: < @0
+ rightBracket: > @0
+ staticType: A<dynamic Function()>
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::B::@constructor::•
+ redirectedConstructor: self::@class::B::@constructor::•
''');
}
@@ -5201,25 +12082,33 @@
const B() : super(const []);
}
''');
- checkElementText(
- library,
- r'''
-class A {
- const A(List<String> values);
-}
-class B extends A {
- const B();
- constantInitializers
- SuperConstructorInvocation
- argumentList: ArgumentList
- arguments
- ListLiteral
- constKeyword: const
- staticType: List<String>
- staticElement: self::@class::A::@constructor::•
-}
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ const @18
+ parameters
+ requiredPositional values @33
+ type: List<String>
+ class B @50
+ supertype: A
+ constructors
+ const @72
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ arguments
+ ListLiteral
+ constKeyword: const @0
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<String>
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::A::@constructor::•
+''');
}
test_constructor_initializers_superInvocation_named() async {
@@ -5232,13 +12121,35 @@
}
''');
checkElementText(library, r'''
-class A {
- const A.aaa(int p);
-}
-class C extends A {
- const C() : super.
- aaa/*location: test.dart;A;aaa*/(42);
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ const aaa @20
+ periodOffset: 19
+ nameEnd: 23
+ parameters
+ requiredPositional p @28
+ type: int
+ class C @40
+ supertype: A
+ constructors
+ const @62
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 42 @0
+ staticType: int
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: SimpleIdentifier
+ staticElement: self::@class::A::@constructor::aaa
+ staticType: null
+ token: aaa @-1
+ staticElement: self::@class::A::@constructor::aaa
''');
}
@@ -5252,13 +12163,28 @@
}
''');
checkElementText(library, r'''
-class A {
- const A._();
-}
-class B extends A {
- const B() : super.
- _/*location: test.dart;A;_*/();
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ const _ @20
+ periodOffset: 19
+ nameEnd: 21
+ class B @33
+ supertype: A
+ constructors
+ const @55
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: SimpleIdentifier
+ staticElement: self::@class::A::@constructor::_
+ staticType: null
+ token: _ @-1
+ staticElement: self::@class::A::@constructor::_
''');
}
@@ -5272,14 +12198,46 @@
}
''');
checkElementText(library, r'''
-class A {
- const A.aaa(dynamic a, {int b});
-}
-class C extends A {
- const C() : super.
- aaa/*location: test.dart;A;aaa*/(1,
- b/*location: test.dart;A;aaa;b*/: 2);
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ const aaa @20
+ periodOffset: 19
+ nameEnd: 23
+ parameters
+ requiredPositional a @24
+ type: dynamic
+ optionalNamed b @32
+ type: int
+ class C @45
+ supertype: A
+ constructors
+ const @67
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ NamedExpression
+ name: Label
+ label: SimpleIdentifier
+ staticElement: self::@class::A::@constructor::aaa::@parameter::b
+ staticType: null
+ token: b @-1
+ expression: IntegerLiteral
+ literal: 2 @0
+ staticType: int
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: SimpleIdentifier
+ staticElement: self::@class::A::@constructor::aaa
+ staticType: null
+ token: aaa @-1
+ staticElement: self::@class::A::@constructor::aaa
''');
}
@@ -5293,12 +12251,31 @@
}
''');
checkElementText(library, r'''
-class A {
- const A(int p);
-}
-class C extends A {
- const C.ccc() : super(42);
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ const @18
+ parameters
+ requiredPositional p @24
+ type: int
+ class C @36
+ supertype: A
+ constructors
+ const ccc @60
+ periodOffset: 59
+ nameEnd: 63
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 42 @0
+ staticType: int
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::A::@constructor::•
''');
}
@@ -5309,23 +12286,33 @@
const A.empty() : this(const []);
}
''');
- checkElementText(
- library,
- r'''
-class A {
- const A(List<String> values);
- const A.empty() = A;
- constantInitializers
- RedirectingConstructorInvocation
- argumentList: ArgumentList
- arguments
- ListLiteral
- constKeyword: const
- staticType: List<String>
- staticElement: self::@class::A::@constructor::•
-}
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ const @18
+ parameters
+ requiredPositional values @33
+ type: List<String>
+ const empty @52
+ periodOffset: 51
+ nameEnd: 57
+ constantInitializers
+ RedirectingConstructorInvocation
+ argumentList: ArgumentList
+ arguments
+ ListLiteral
+ constKeyword: const @0
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<String>
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::A::@constructor::•
+ redirectedConstructor: self::@class::A::@constructor::•
+''');
}
test_constructor_initializers_thisInvocation_named() async {
@@ -5336,11 +12323,37 @@
}
''');
checkElementText(library, r'''
-class C {
- const C() = C.named : this.
- named/*location: test.dart;C;named*/(1, 'bbb');
- const C.named(int a, String b);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ const @18
+ constantInitializers
+ RedirectingConstructorInvocation
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'bbb' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: SimpleIdentifier
+ staticElement: self::@class::C::@constructor::named
+ staticType: null
+ token: named @-1
+ staticElement: self::@class::C::@constructor::named
+ redirectedConstructor: self::@class::C::@constructor::named
+ const named @56
+ periodOffset: 55
+ nameEnd: 61
+ parameters
+ requiredPositional a @66
+ type: int
+ requiredPositional b @76
+ type: String
''');
}
@@ -5352,12 +12365,44 @@
}
''');
checkElementText(library, r'''
-class C {
- const C() = C.named : this.
- named/*location: test.dart;C;named*/(1,
- b/*location: test.dart;C;named;b*/: 2);
- const C.named(dynamic a, {int b});
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ const @18
+ constantInitializers
+ RedirectingConstructorInvocation
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ NamedExpression
+ name: Label
+ label: SimpleIdentifier
+ staticElement: self::@class::C::@constructor::named::@parameter::b
+ staticType: null
+ token: b @-1
+ expression: IntegerLiteral
+ literal: 2 @0
+ staticType: int
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: SimpleIdentifier
+ staticElement: self::@class::C::@constructor::named
+ staticType: null
+ token: named @-1
+ staticElement: self::@class::C::@constructor::named
+ redirectedConstructor: self::@class::C::@constructor::named
+ const named @55
+ periodOffset: 54
+ nameEnd: 60
+ parameters
+ requiredPositional a @61
+ type: dynamic
+ optionalNamed b @69
+ type: int
''');
}
@@ -5369,10 +12414,33 @@
}
''');
checkElementText(library, r'''
-class C {
- const C.named() = C : this(1, 'bbb');
- const C(int a, String b);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ const named @20
+ periodOffset: 19
+ nameEnd: 25
+ constantInitializers
+ RedirectingConstructorInvocation
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'bbb' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::C::@constructor::•
+ redirectedConstructor: self::@class::C::@constructor::•
+ const @54
+ parameters
+ requiredPositional a @60
+ type: int
+ requiredPositional b @70
+ type: String
''');
}
@@ -5387,13 +12455,22 @@
}
''');
checkElementText(library, r'''
-class C {
- factory C() = D.named;
- C._();
-}
-class D extends C {
- D.named();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ factory @20
+ redirectedConstructor: self::@class::D::@constructor::named
+ _ @39
+ periodOffset: 38
+ nameEnd: 40
+ class D @52
+ supertype: C
+ constructors
+ named @70
+ periodOffset: 69
+ nameEnd: 75
''');
}
@@ -5408,13 +12485,34 @@
}
''');
checkElementText(library, r'''
-class C<T, U> {
- factory C() = D<U, T>.named;
- C._();
-}
-class D<T, U> extends C<U, T> {
- D.named();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ covariant U @11
+ defaultType: dynamic
+ constructors
+ factory @26
+ redirectedConstructor: ConstructorMember
+ base: self::@class::D::@constructor::named
+ substitution: {T: U, U: T}
+ _ @51
+ periodOffset: 50
+ nameEnd: 52
+ class D @64
+ typeParameters
+ covariant T @66
+ defaultType: dynamic
+ covariant U @69
+ defaultType: dynamic
+ supertype: C<U, T>
+ constructors
+ named @94
+ periodOffset: 93
+ nameEnd: 99
''');
}
@@ -5431,14 +12529,42 @@
}
''');
checkElementText(library, r'''
-typedef A<T, U> = C<T, U>;
-class B<T, U> {
- factory B() = C<U, T>.named;
- B._();
-}
-class C<T, U> extends C<U, T> {
- C.named();
-}
+library
+ definingUnit
+ classes
+ class B @33
+ typeParameters
+ covariant T @35
+ defaultType: dynamic
+ covariant U @38
+ defaultType: dynamic
+ constructors
+ factory @53
+ redirectedConstructor: ConstructorMember
+ base: self::@class::C::@constructor::named
+ substitution: {T: U, U: T}
+ _ @78
+ periodOffset: 77
+ nameEnd: 79
+ class C @91
+ typeParameters
+ covariant T @93
+ defaultType: dynamic
+ covariant U @96
+ defaultType: dynamic
+ supertype: C<U, T>
+ constructors
+ named @121
+ periodOffset: 120
+ nameEnd: 126
+ typeAliases
+ A @8
+ typeParameters
+ covariant T @10
+ defaultType: dynamic
+ covariant U @13
+ defaultType: dynamic
+ aliasedType: C<T, U>
''');
}
@@ -5457,11 +12583,18 @@
}
''');
checkElementText(library, r'''
-import 'foo.dart';
-class C {
- factory C() = D.named;
- C._();
-}
+library
+ imports
+ foo.dart
+ definingUnit
+ classes
+ class C @25
+ constructors
+ factory @39
+ redirectedConstructor: foo.dart::@class::D::@constructor::named
+ _ @58
+ periodOffset: 57
+ nameEnd: 59
''');
}
@@ -5480,11 +12613,25 @@
}
''');
checkElementText(library, r'''
-import 'foo.dart';
-class C<T, U> {
- factory C() = D<U, T>.named;
- C._();
-}
+library
+ imports
+ foo.dart
+ definingUnit
+ classes
+ class C @25
+ typeParameters
+ covariant T @27
+ defaultType: dynamic
+ covariant U @30
+ defaultType: dynamic
+ constructors
+ factory @45
+ redirectedConstructor: ConstructorMember
+ base: foo.dart::@class::D::@constructor::named
+ substitution: {T: U, U: T}
+ _ @70
+ periodOffset: 69
+ nameEnd: 71
''');
}
@@ -5503,11 +12650,18 @@
}
''');
checkElementText(library, r'''
-import 'foo.dart' as foo;
-class C {
- factory C() = D.named;
- C._();
-}
+library
+ imports
+ foo.dart as foo @21
+ definingUnit
+ classes
+ class C @32
+ constructors
+ factory @46
+ redirectedConstructor: foo.dart::@class::D::@constructor::named
+ _ @69
+ periodOffset: 68
+ nameEnd: 70
''');
}
@@ -5526,11 +12680,25 @@
}
''');
checkElementText(library, r'''
-import 'foo.dart' as foo;
-class C<T, U> {
- factory C() = D<U, T>.named;
- C._();
-}
+library
+ imports
+ foo.dart as foo @21
+ definingUnit
+ classes
+ class C @32
+ typeParameters
+ covariant T @34
+ defaultType: dynamic
+ covariant U @37
+ defaultType: dynamic
+ constructors
+ factory @52
+ redirectedConstructor: ConstructorMember
+ base: foo.dart::@class::D::@constructor::named
+ substitution: {T: U, U: T}
+ _ @81
+ periodOffset: 80
+ nameEnd: 82
''');
}
@@ -5541,9 +12709,15 @@
}
''', allowErrors: true);
checkElementText(library, r'''
-class C<E> {
- factory C();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant E @8
+ defaultType: dynamic
+ constructors
+ factory @23
''');
}
@@ -5555,11 +12729,18 @@
}
''', allowErrors: true);
checkElementText(library, r'''
-class D {
-}
-class C<E> {
- factory C();
-}
+library
+ definingUnit
+ classes
+ class D @6
+ constructors
+ synthetic @-1
+ class C @17
+ typeParameters
+ covariant E @19
+ defaultType: dynamic
+ constructors
+ factory @34
''');
}
@@ -5574,13 +12755,20 @@
}
''');
checkElementText(library, r'''
-class C {
- factory C() = D;
- C._();
-}
-class D extends C {
- D();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ factory @20
+ redirectedConstructor: self::@class::D::@constructor::•
+ _ @33
+ periodOffset: 32
+ nameEnd: 34
+ class D @46
+ supertype: C
+ constructors
+ @62
''');
}
@@ -5595,13 +12783,32 @@
}
''');
checkElementText(library, r'''
-class C<T, U> {
- factory C() = D<U, T>;
- C._();
-}
-class D<T, U> extends C<U, T> {
- D();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ covariant U @11
+ defaultType: dynamic
+ constructors
+ factory @26
+ redirectedConstructor: ConstructorMember
+ base: self::@class::D::@constructor::•
+ substitution: {T: U, U: T}
+ _ @45
+ periodOffset: 44
+ nameEnd: 46
+ class D @58
+ typeParameters
+ covariant T @60
+ defaultType: dynamic
+ covariant U @63
+ defaultType: dynamic
+ supertype: C<U, T>
+ constructors
+ @86
''');
}
@@ -5618,14 +12825,40 @@
}
''');
checkElementText(library, r'''
-typedef A<T, U> = C<T, U>;
-class B<T, U> {
- factory B() = C<U, T>;
- dynamic B_();
-}
-class C<T, U> extends B<U, T> {
- C();
-}
+library
+ definingUnit
+ classes
+ class B @33
+ typeParameters
+ covariant T @35
+ defaultType: dynamic
+ covariant U @38
+ defaultType: dynamic
+ constructors
+ factory @53
+ redirectedConstructor: ConstructorMember
+ base: self::@class::C::@constructor::•
+ substitution: {T: U, U: T}
+ methods
+ abstract B_ @70
+ returnType: dynamic
+ class C @84
+ typeParameters
+ covariant T @86
+ defaultType: dynamic
+ covariant U @89
+ defaultType: dynamic
+ supertype: B<U, T>
+ constructors
+ @112
+ typeAliases
+ A @8
+ typeParameters
+ covariant T @10
+ defaultType: dynamic
+ covariant U @13
+ defaultType: dynamic
+ aliasedType: C<T, U>
''');
}
@@ -5644,11 +12877,18 @@
}
''');
checkElementText(library, r'''
-import 'foo.dart';
-class C {
- factory C() = D;
- C._();
-}
+library
+ imports
+ foo.dart
+ definingUnit
+ classes
+ class C @25
+ constructors
+ factory @39
+ redirectedConstructor: foo.dart::@class::D::@constructor::•
+ _ @52
+ periodOffset: 51
+ nameEnd: 53
''');
}
@@ -5667,11 +12907,25 @@
}
''');
checkElementText(library, r'''
-import 'foo.dart';
-class C<T, U> {
- factory C() = D<U, T>;
- C._();
-}
+library
+ imports
+ foo.dart
+ definingUnit
+ classes
+ class C @25
+ typeParameters
+ covariant T @27
+ defaultType: dynamic
+ covariant U @30
+ defaultType: dynamic
+ constructors
+ factory @45
+ redirectedConstructor: ConstructorMember
+ base: foo.dart::@class::D::@constructor::•
+ substitution: {T: U, U: T}
+ _ @64
+ periodOffset: 63
+ nameEnd: 65
''');
}
@@ -5692,11 +12946,18 @@
}
''');
checkElementText(library, r'''
-import 'foo.dart';
-class C {
- factory C() = B;
- C._();
-}
+library
+ imports
+ foo.dart
+ definingUnit
+ classes
+ class C @25
+ constructors
+ factory @39
+ redirectedConstructor: foo.dart::@class::B::@constructor::•
+ _ @52
+ periodOffset: 51
+ nameEnd: 53
''');
}
@@ -5715,11 +12976,18 @@
}
''');
checkElementText(library, r'''
-import 'foo.dart' as foo;
-class C {
- factory C() = D;
- C._();
-}
+library
+ imports
+ foo.dart as foo @21
+ definingUnit
+ classes
+ class C @32
+ constructors
+ factory @46
+ redirectedConstructor: foo.dart::@class::D::@constructor::•
+ _ @63
+ periodOffset: 62
+ nameEnd: 64
''');
}
@@ -5738,11 +13006,25 @@
}
''');
checkElementText(library, r'''
-import 'foo.dart' as foo;
-class C<T, U> {
- factory C() = D<U, T>;
- C._();
-}
+library
+ imports
+ foo.dart as foo @21
+ definingUnit
+ classes
+ class C @32
+ typeParameters
+ covariant T @34
+ defaultType: dynamic
+ covariant U @37
+ defaultType: dynamic
+ constructors
+ factory @52
+ redirectedConstructor: ConstructorMember
+ base: foo.dart::@class::D::@constructor::•
+ substitution: {T: U, U: T}
+ _ @75
+ periodOffset: 74
+ nameEnd: 76
''');
}
@@ -5763,11 +13045,18 @@
}
''');
checkElementText(library, r'''
-import 'foo.dart' as foo;
-class C {
- factory C() = B;
- C._();
-}
+library
+ imports
+ foo.dart as foo @21
+ definingUnit
+ classes
+ class C @32
+ constructors
+ factory @46
+ redirectedConstructor: foo.dart::@class::B::@constructor::•
+ _ @63
+ periodOffset: 62
+ nameEnd: 64
''');
}
@@ -5778,9 +13067,15 @@
}
''', allowErrors: true);
checkElementText(library, r'''
-class C<E> {
- factory C();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant E @8
+ defaultType: dynamic
+ constructors
+ factory @23
''');
}
@@ -5797,14 +13092,23 @@
}
''');
checkElementText(library, r'''
-typedef A = C;
-class B {
- factory B() = C;
- B._();
-}
-class C extends B {
- C();
-}
+library
+ definingUnit
+ classes
+ class B @21
+ constructors
+ factory @35
+ redirectedConstructor: self::@class::C::@constructor::•
+ _ @48
+ periodOffset: 47
+ nameEnd: 49
+ class C @61
+ supertype: B
+ constructors
+ @77
+ typeAliases
+ A @8
+ aliasedType: C
''');
}
@@ -5816,11 +13120,26 @@
}
''');
checkElementText(library, r'''
-class C {
- const C.named();
- const C() = C.named : this.
- named/*location: test.dart;C;named*/();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ const named @20
+ periodOffset: 19
+ nameEnd: 25
+ const @37
+ constantInitializers
+ RedirectingConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: SimpleIdentifier
+ staticElement: self::@class::C::@constructor::named
+ staticType: null
+ token: named @-1
+ staticElement: self::@class::C::@constructor::named
+ redirectedConstructor: self::@class::C::@constructor::named
''');
}
@@ -5832,11 +13151,29 @@
}
''');
checkElementText(library, r'''
-class C<T> {
- const C.named();
- const C() = C<T>.named : this.
- named/*location: test.dart;C;named*/();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const named @23
+ periodOffset: 22
+ nameEnd: 28
+ const @40
+ constantInitializers
+ RedirectingConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: SimpleIdentifier
+ staticElement: self::@class::C::@constructor::named
+ staticType: null
+ token: named @-1
+ staticElement: self::@class::C::@constructor::named
+ redirectedConstructor: self::@class::C::@constructor::named
''');
}
@@ -5848,10 +13185,15 @@
}
''');
checkElementText(library, r'''
-class C {
- C.named();
- C();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ named @14
+ periodOffset: 13
+ nameEnd: 19
+ @25
''');
}
@@ -5863,10 +13205,22 @@
}
''');
checkElementText(library, r'''
-class C {
- const C();
- const C.named() = C : this();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ const @18
+ const named @33
+ periodOffset: 32
+ nameEnd: 38
+ constantInitializers
+ RedirectingConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::C::@constructor::•
+ redirectedConstructor: self::@class::C::@constructor::•
''');
}
@@ -5878,10 +13232,25 @@
}
''');
checkElementText(library, r'''
-class C<T> {
- const C();
- const C.named() = C<T> : this();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ const named @36
+ periodOffset: 35
+ nameEnd: 41
+ constantInitializers
+ RedirectingConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::C::@constructor::•
+ redirectedConstructor: self::@class::C::@constructor::•
''');
}
@@ -5893,10 +13262,15 @@
}
''');
checkElementText(library, r'''
-class C {
- C();
- C.named();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ @12
+ named @21
+ periodOffset: 20
+ nameEnd: 26
''');
}
@@ -5912,18 +13286,69 @@
}
''');
checkElementText(library, r'''
-class C {
- final dynamic x;
- const C() :
- x/*location: test.dart;C;x*/ = const
- D/*location: test.dart;D*/();
-}
-class D {
- final dynamic x;
- const D() :
- x/*location: test.dart;D;x*/ = const
- C/*location: test.dart;C*/();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ final x @18
+ type: dynamic
+ constructors
+ const @29
+ constantInitializers
+ ConstructorFieldInitializer
+ equals: = @0
+ expression: InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@class::D::@constructor::•
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::D
+ staticType: null
+ token: D @-1
+ type: D
+ keyword: const @0
+ staticType: D
+ fieldName: SimpleIdentifier
+ staticElement: self::@class::C::@field::x
+ staticType: null
+ token: x @-1
+ accessors
+ synthetic get x @18
+ returnType: dynamic
+ class D @58
+ fields
+ final x @70
+ type: dynamic
+ constructors
+ const @81
+ constantInitializers
+ ConstructorFieldInitializer
+ equals: = @0
+ expression: InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@class::C::@constructor::•
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @-1
+ type: C
+ keyword: const @0
+ staticType: C
+ fieldName: SimpleIdentifier
+ staticElement: self::@class::D::@field::x
+ staticType: null
+ token: x @-1
+ accessors
+ synthetic get x @70
+ returnType: dynamic
''');
}
@@ -5939,14 +13364,27 @@
}
''');
checkElementText(library, r'''
-class C {
- final dynamic x;
- C();
-}
-class D {
- final dynamic x;
- D();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ final x @18
+ type: dynamic
+ constructors
+ @23
+ accessors
+ synthetic get x @18
+ returnType: dynamic
+ class D @50
+ fields
+ final x @62
+ type: dynamic
+ constructors
+ @67
+ accessors
+ synthetic get x @62
+ returnType: dynamic
''');
}
@@ -5956,14 +13394,29 @@
const X({List<T> a = const []});
}
''');
- checkElementText(
- library,
- r'''
-class A<T> {
- dynamic X({List<T> a: const /*typeArgs=Never*/[]});
-}
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ abstract X @21
+ parameters
+ optionalNamed a @32
+ type: List<T>
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<Never>
+ returnType: dynamic
+''');
}
test_defaultValue_eliminateTypeParameters_legacy() async {
@@ -5973,14 +13426,29 @@
const X({List<T> a = const []});
}
''');
- checkElementText(
- library,
- r'''
-class A<T> {
- dynamic X({List<T*>* a: const /*typeArgs=Null**/[]});
-}
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ abstract X @21
+ parameters
+ optionalNamed a @32
+ type: List<T*>*
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<Null*>*
+ returnType: dynamic
+''');
}
test_defaultValue_genericFunction() async {
@@ -5995,13 +13463,54 @@
}
''');
checkElementText(library, r'''
-typedef F<T> = void Function(T v);
-class X {
- final void Function(dynamic) f;
- const X({final void Function(dynamic) this.f:
- defaultF/*location: test.dart;defaultF*/});
-}
-void defaultF<T>(T v) {}
+library
+ definingUnit
+ classes
+ class X @57
+ fields
+ final f @71
+ type: void Function(dynamic)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ dynamic
+ constructors
+ const @82
+ parameters
+ optionalNamed final this.f @90
+ type: void Function(dynamic)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ dynamic
+ constantInitializer
+ SimpleIdentifier
+ staticElement: self::@function::defaultF
+ staticType: void Function(dynamic)
+ token: defaultF @-1
+ accessors
+ synthetic get f @71
+ returnType: void Function(dynamic)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ dynamic
+ typeAliases
+ functionTypeAliasBased F @13
+ typeParameters
+ contravariant T @15
+ defaultType: dynamic
+ aliasedType: void Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional v @-1
+ type: T
+ returnType: void
+ functions
+ defaultF @30
+ typeParameters
+ covariant T @39
+ parameters
+ requiredPositional v @44
+ type: T
+ returnType: void
''');
}
@@ -6015,13 +13524,53 @@
}
''');
checkElementText(library, r'''
-class A<T> {
- const A();
-}
-class B {
- void foo({dynamic a: const
- A/*location: test.dart;A*/<Function()>()}) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ class B @34
+ constructors
+ synthetic @-1
+ methods
+ foo @45
+ parameters
+ optionalNamed a @50
+ type: dynamic
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::A::@constructor::•
+ substitution: {T: dynamic Function()}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @-1
+ type: A<dynamic Function()>
+ typeArguments: TypeArgumentList
+ arguments
+ GenericFunctionType
+ declaredElement: GenericFunctionTypeElement
+ parameters
+ returnType: dynamic
+ type: dynamic Function()
+ functionKeyword: Function @0
+ parameters: FormalParameterList
+ type: dynamic Function()
+ leftBracket: < @0
+ rightBracket: > @0
+ keyword: const @0
+ staticType: A<dynamic Function()>
+ returnType: void
''');
}
@@ -6029,24 +13578,32 @@
var library = await checkLibrary('''
void f( g({a: 0 is int}) ) {}
''');
- checkElementText(
- library,
- r'''
-void f(dynamic Function({dynamic a}) g) {}
- g::a
- IsExpression
- expression: IntegerLiteral
- literal: 0
- staticType: int
- staticType: bool
- type: TypeName
- name: SimpleIdentifier
- staticElement: dart:core::@class::int
- staticType: null
- token: int
- type: int
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ functions
+ f @5
+ parameters
+ requiredPositional g @8
+ type: dynamic Function({dynamic a})
+ parameters
+ optionalNamed a @11
+ type: dynamic
+ constantInitializer
+ IsExpression
+ expression: IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ isOperator: is @0
+ staticType: bool
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @-1
+ type: int
+ returnType: void
+''');
}
test_defaultValue_methodMember_legacy() async {
@@ -6054,29 +13611,36 @@
var library = await checkLibrary('''
void f([Comparator<T> compare = Comparable.compare]) {}
''');
- checkElementText(
- library,
- r'''
-void f([int* Function(dynamic, dynamic)* compare]) {}
- compare
- PrefixedIdentifier
- identifier: SimpleIdentifier
- staticElement: MethodMember
- base: dart:core::@class::Comparable::@method::compare
- substitution: {}
- staticType: int* Function(Comparable<dynamic>*, Comparable<dynamic>*)*
- token: compare
- period: .
- prefix: SimpleIdentifier
- staticElement: dart:core::@class::Comparable
- staticType: null
- token: Comparable
- staticElement: MethodMember
- base: dart:core::@class::Comparable::@method::compare
- substitution: {}
- staticType: int* Function(Comparable<dynamic>*, Comparable<dynamic>*)*
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ functions
+ f @5
+ parameters
+ optionalPositional compare @22
+ type: int* Function(dynamic, dynamic)*
+ aliasElement: dart:core::@typeAlias::Comparator
+ aliasArguments
+ dynamic
+ constantInitializer
+ PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: MethodMember
+ base: dart:core::@class::Comparable::@method::compare
+ substitution: {}
+ staticType: int* Function(Comparable<dynamic>*, Comparable<dynamic>*)*
+ token: compare @-1
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: dart:core::@class::Comparable
+ staticType: null
+ token: Comparable @-1
+ staticElement: MethodMember
+ base: dart:core::@class::Comparable::@method::compare
+ substitution: {}
+ staticType: int* Function(Comparable<dynamic>*, Comparable<dynamic>*)*
+ returnType: void
+''');
}
test_defaultValue_refersToExtension_method_inside() async {
@@ -6088,13 +13652,28 @@
}
''');
checkElementText(library, r'''
-class A {
-}
-extension E on A {
- static void f() {}
- static void g([Object p =
- f/*location: test.dart;E;f*/]) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ extensions
+ E @21
+ extendedType: A
+ methods
+ static f @44
+ returnType: void
+ static g @65
+ parameters
+ optionalPositional p @75
+ type: Object
+ constantInitializer
+ SimpleIdentifier
+ staticElement: self::@extension::E::@method::f
+ staticType: void Function()
+ token: f @-1
+ returnType: void
''');
}
@@ -6107,18 +13686,45 @@
void foo([B<int, double> b = const B()]) {}
}
''');
- checkElementText(
- library,
- r'''
-class B<T1, T2> {
- const B();
-}
-class C {
- void foo([B<int, double> b = const /*typeArgs=int,double*/
- B/*location: test.dart;B*/()]) {}
-}
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class B @6
+ typeParameters
+ covariant T1 @8
+ defaultType: dynamic
+ covariant T2 @12
+ defaultType: dynamic
+ constructors
+ const @26
+ class C @39
+ constructors
+ synthetic @-1
+ methods
+ foo @50
+ parameters
+ optionalPositional b @70
+ type: B<int, double>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::B::@constructor::•
+ substitution: {T1: int, T2: double}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::B
+ staticType: null
+ token: B @-1
+ type: B<int, double>
+ keyword: const @0
+ staticType: B<int, double>
+ returnType: void
+''');
}
test_defaultValue_refersToGenericClass_constructor() async {
@@ -6130,18 +13736,43 @@
const C([B<T> b = const B()]);
}
''');
- checkElementText(
- library,
- r'''
-class B<T> {
- const B();
-}
-class C<T> {
- const C([B<T> b = const /*typeArgs=Never*/
- B/*location: test.dart;B*/()]);
-}
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class B @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ class C @34
+ typeParameters
+ covariant T @36
+ defaultType: dynamic
+ constructors
+ const @49
+ parameters
+ optionalPositional b @57
+ type: B<T>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::B::@constructor::•
+ substitution: {T: Never}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::B
+ staticType: null
+ token: B @-1
+ type: B<Never>
+ keyword: const @0
+ staticType: B<Never>
+''');
}
test_defaultValue_refersToGenericClass_constructor2() async {
@@ -6154,20 +13785,53 @@
const C([A<T> a = const B()]);
}
''');
- checkElementText(
- library,
- r'''
-abstract class A<T> {
-}
-class B<T> implements A<T> {
- const B();
-}
-class C<T> implements A<Iterable<T>> {
- const C([A<T> a = const /*typeArgs=Never*/
- B/*location: test.dart;B*/()]);
-}
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ abstract class A @15
+ typeParameters
+ covariant T @17
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class B @29
+ typeParameters
+ covariant T @31
+ defaultType: dynamic
+ interfaces
+ A<T>
+ constructors
+ const @60
+ class C @73
+ typeParameters
+ covariant T @75
+ defaultType: dynamic
+ interfaces
+ A<Iterable<T>>
+ constructors
+ const @114
+ parameters
+ optionalPositional a @122
+ type: A<T>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::B::@constructor::•
+ substitution: {T: Never}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::B
+ staticType: null
+ token: B @-1
+ type: B<Never>
+ keyword: const @0
+ staticType: B<Never>
+''');
}
test_defaultValue_refersToGenericClass_constructor2_legacy() async {
@@ -6181,20 +13845,53 @@
const C([A<T> a = const B()]);
}
''');
- checkElementText(
- library,
- r'''
-abstract class A<T> {
-}
-class B<T> implements A<T*>* {
- const B();
-}
-class C<T> implements A<Iterable<T*>*>* {
- const C([A<T*>* a = const /*typeArgs=Null**/
- B/*location: test.dart;B*/()]);
-}
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ abstract class A @15
+ typeParameters
+ covariant T @17
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class B @29
+ typeParameters
+ covariant T @31
+ defaultType: dynamic
+ interfaces
+ A<T*>*
+ constructors
+ const @60
+ class C @73
+ typeParameters
+ covariant T @75
+ defaultType: dynamic
+ interfaces
+ A<Iterable<T*>*>*
+ constructors
+ const @114
+ parameters
+ optionalPositional a @122
+ type: A<T*>*
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::B::@constructor::•
+ substitution: {T: Null*}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::B
+ staticType: null
+ token: B @-1
+ type: B<Null*>*
+ keyword: const @0
+ staticType: B<Null*>*
+''');
}
test_defaultValue_refersToGenericClass_constructor_legacy() async {
@@ -6207,18 +13904,43 @@
const C([B<T> b = const B()]);
}
''');
- checkElementText(
- library,
- r'''
-class B<T> {
- const B();
-}
-class C<T> {
- const C([B<T*>* b = const /*typeArgs=Null**/
- B/*location: test.dart;B*/()]);
-}
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class B @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ class C @34
+ typeParameters
+ covariant T @36
+ defaultType: dynamic
+ constructors
+ const @49
+ parameters
+ optionalPositional b @57
+ type: B<T*>*
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::B::@constructor::•
+ substitution: {T: Null*}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::B
+ staticType: null
+ token: B @-1
+ type: B<Null*>*
+ keyword: const @0
+ staticType: B<Null*>*
+''');
}
test_defaultValue_refersToGenericClass_functionG() async {
@@ -6228,16 +13950,42 @@
}
void foo<T>([B<T> b = const B()]) {}
''');
- checkElementText(
- library,
- r'''
-class B<T> {
- const B();
-}
-void foo<T>([B<T> b = const /*typeArgs=Never*/
- B/*location: test.dart;B*/()]) {}
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class B @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ functions
+ foo @33
+ typeParameters
+ covariant T @37
+ parameters
+ optionalPositional b @46
+ type: B<T>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::B::@constructor::•
+ substitution: {T: Never}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::B
+ staticType: null
+ token: B @-1
+ type: B<Never>
+ keyword: const @0
+ staticType: B<Never>
+ returnType: void
+''');
}
test_defaultValue_refersToGenericClass_methodG() async {
@@ -6249,18 +13997,45 @@
void foo<T>([B<T> b = const B()]) {}
}
''');
- checkElementText(
- library,
- r'''
-class B<T> {
- const B();
-}
-class C {
- void foo<T>([B<T> b = const /*typeArgs=Never*/
- B/*location: test.dart;B*/()]) {}
-}
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class B @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ class C @34
+ constructors
+ synthetic @-1
+ methods
+ foo @45
+ typeParameters
+ covariant T @49
+ parameters
+ optionalPositional b @58
+ type: B<T>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::B::@constructor::•
+ substitution: {T: Never}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::B
+ staticType: null
+ token: B @-1
+ type: B<Never>
+ keyword: const @0
+ staticType: B<Never>
+ returnType: void
+''');
}
test_defaultValue_refersToGenericClass_methodG_classG() async {
@@ -6272,18 +14047,50 @@
void foo<E2>([B<E1, E2> b = const B()]) {}
}
''');
- checkElementText(
- library,
- r'''
-class B<T1, T2> {
- const B();
-}
-class C<E1> {
- void foo<E2>([B<E1, E2> b = const /*typeArgs=Never,Never*/
- B/*location: test.dart;B*/()]) {}
-}
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class B @6
+ typeParameters
+ covariant T1 @8
+ defaultType: dynamic
+ covariant T2 @12
+ defaultType: dynamic
+ constructors
+ const @26
+ class C @39
+ typeParameters
+ covariant E1 @41
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ foo @54
+ typeParameters
+ covariant E2 @58
+ parameters
+ optionalPositional b @73
+ type: B<E1, E2>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::B::@constructor::•
+ substitution: {T1: Never, T2: Never}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::B
+ staticType: null
+ token: B @-1
+ type: B<Never, Never>
+ keyword: const @0
+ staticType: B<Never, Never>
+ returnType: void
+''');
}
test_defaultValue_refersToGenericClass_methodNG() async {
@@ -6295,18 +14102,46 @@
void foo([B<T> b = const B()]) {}
}
''');
- checkElementText(
- library,
- r'''
-class B<T> {
- const B();
-}
-class C<T> {
- void foo([B<T> b = const /*typeArgs=Never*/
- B/*location: test.dart;B*/()]) {}
-}
-''',
- withTypes: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class B @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ class C @34
+ typeParameters
+ covariant T @36
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ foo @48
+ parameters
+ optionalPositional b @58
+ type: B<T>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::B::@constructor::•
+ substitution: {T: Never}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::B
+ staticType: null
+ token: B @-1
+ type: B<Never>
+ keyword: const @0
+ staticType: B<Never>
+ returnType: void
+''');
}
test_duplicateDeclaration_class() async {
@@ -6320,14 +14155,40 @@
}
''');
checkElementText(library, r'''
-class A {
-}
-class A {
- dynamic x;
-}
-class A {
- int y;
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ class A @17
+ fields
+ x @27
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @27
+ returnType: dynamic
+ synthetic set x @27
+ parameters
+ requiredPositional _x @27
+ type: dynamic
+ returnType: void
+ class A @38
+ fields
+ y @48
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get y @48
+ returnType: int
+ synthetic set y @48
+ parameters
+ requiredPositional _y @48
+ type: int
+ returnType: void
''');
}
@@ -6340,18 +14201,45 @@
mixin M {}
''');
checkElementText(library, r'''
-class A {
-}
-class B {
-}
-class alias X extends A with M {
- synthetic X() : super();
-}
-class alias X extends B with M {
- synthetic X() : super();
-}
-mixin M on Object {
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ class B @17
+ constructors
+ synthetic @-1
+ class alias X @28
+ supertype: A
+ mixins
+ M
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::A::@constructor::•
+ class alias X @48
+ supertype: B
+ mixins
+ M
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::B::@constructor::•
+ mixins
+ mixin M @68
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
''');
}
@@ -6361,21 +14249,57 @@
enum E {c, d, e}
''');
checkElementText(library, r'''
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E a;
- static const E b;
- String toString() {}
-}
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E c;
- static const E d;
- static const E e;
- String toString() {}
-}
+library
+ definingUnit
+ enums
+ enum E @5
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const a @8
+ type: E
+ static const b @11
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get a @-1
+ returnType: E
+ synthetic static get b @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
+ enum E @19
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const c @22
+ type: E
+ static const d @25
+ type: E
+ static const e @28
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get c @-1
+ returnType: E
+ synthetic static get d @-1
+ returnType: E
+ synthetic static get e @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
''');
}
@@ -6391,16 +14315,41 @@
}
''');
checkElementText(library, r'''
-class A {
-}
-extension E on A {
-}
-extension E on A {
- static dynamic x;
-}
-extension E on A {
- static int y;
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ extensions
+ E @21
+ extendedType: A
+ E @41
+ extendedType: A
+ fields
+ static x @63
+ type: dynamic
+ accessors
+ synthetic static get x @63
+ returnType: dynamic
+ synthetic static set x @63
+ parameters
+ requiredPositional _x @63
+ type: dynamic
+ returnType: void
+ E @78
+ extendedType: A
+ fields
+ static y @100
+ type: int
+ accessors
+ synthetic static get y @100
+ returnType: int
+ synthetic static set y @100
+ parameters
+ requiredPositional _y @100
+ type: int
+ returnType: void
''');
}
@@ -6411,9 +14360,23 @@
void f([int b, double c]) {}
''');
checkElementText(library, r'''
-void f() {}
-void f(int a) {}
-void f([int b], [double c]) {}
+library
+ definingUnit
+ functions
+ f @5
+ returnType: void
+ f @17
+ parameters
+ requiredPositional a @23
+ type: int
+ returnType: void
+ f @34
+ parameters
+ optionalPositional b @41
+ type: int
+ optionalPositional c @51
+ type: double
+ returnType: void
''');
}
@@ -6424,9 +14387,29 @@
typedef void F([int b, double c]);
''');
checkElementText(library, r'''
-typedef F = void Function();
-typedef F = void Function(int a);
-typedef F = void Function([int b], [double c]);
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @13
+ aliasedType: void Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void
+ functionTypeAliasBased F @31
+ aliasedType: void Function(int)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional a @-1
+ type: int
+ returnType: void
+ functionTypeAliasBased F @54
+ aliasedType: void Function([int, double])
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ optionalPositional b @-1
+ type: int
+ optionalPositional c @-1
+ type: double
+ returnType: void
''');
}
@@ -6441,14 +14424,46 @@
}
''');
checkElementText(library, r'''
-mixin A on Object {
-}
-mixin A on Object {
- dynamic x;
-}
-mixin A on Object {
- int y;
-}
+library
+ definingUnit
+ mixins
+ mixin A @6
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
+ mixin A @17
+ superclassConstraints
+ Object
+ fields
+ x @27
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @27
+ returnType: dynamic
+ synthetic set x @27
+ parameters
+ requiredPositional _x @27
+ type: dynamic
+ returnType: void
+ mixin A @38
+ superclassConstraints
+ Object
+ fields
+ y @48
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get y @48
+ returnType: int
+ synthetic set y @48
+ parameters
+ requiredPositional _y @48
+ type: int
+ returnType: void
''');
}
@@ -6460,10 +14475,46 @@
var x = 2.3;
''');
checkElementText(library, r'''
-bool x;
-dynamic x;
-int x;
-double x;
+library
+ definingUnit
+ topLevelVariables
+ static x @5
+ type: bool
+ static x @12
+ type: dynamic
+ static x @19
+ type: int
+ static x @30
+ type: double
+ accessors
+ synthetic static get x @5
+ returnType: bool
+ synthetic static set x @5
+ parameters
+ requiredPositional _x @5
+ type: bool
+ returnType: void
+ synthetic static get x @12
+ returnType: dynamic
+ synthetic static set x @12
+ parameters
+ requiredPositional _x @12
+ type: dynamic
+ returnType: void
+ synthetic static get x @19
+ returnType: int
+ synthetic static set x @19
+ parameters
+ requiredPositional _x @19
+ type: int
+ returnType: void
+ synthetic static get x @30
+ returnType: double
+ synthetic static set x @30
+ parameters
+ requiredPositional _x @30
+ type: double
+ returnType: void
''');
}
@@ -6475,15 +14526,28 @@
*/
enum E { v }''');
checkElementText(library, r'''
-/**
- * Docs
- */
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E v;
- String toString() {}
-}
+library
+ definingUnit
+ enums
+ enum E @65
+ documentationComment: /**\n * Docs\n */
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const v @69
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get v @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
''');
}
@@ -6498,17 +14562,33 @@
b
}''');
checkElementText(library, r'''
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- /**
- * aaa
- */
- static const E a;
- /// bbb
- static const E b;
- String toString() {}
-}
+library
+ definingUnit
+ enums
+ enum E @5
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const a @32
+ documentationComment: /**\n * aaa\n */
+ type: E
+ static const b @47
+ documentationComment: /// bbb
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get a @-1
+ returnType: E
+ synthetic static get b @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
''');
}
@@ -6527,55 +14607,136 @@
const int annotation = 0;
''');
- checkElementText(
- library,
- r'''
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- /**
- * aaa
- */
- @annotation
- static const E a;
- /// bbb
- @annotation
- static const E b;
- String toString() {}
-}
-const int annotation = 0;
-''',
- withConstElements: false);
+ checkElementText(library, r'''
+library
+ definingUnit
+ enums
+ enum E @5
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const a @46
+ documentationComment: /**\n * aaa\n */
+ metadata
+ Annotation
+ atSign.offset: 32
+ element: self::@getter::annotation
+ name: SimpleIdentifier
+ staticElement: self::@getter::annotation
+ staticType: null
+ token: annotation @33
+ type: E
+ static const b @75
+ documentationComment: /// bbb
+ metadata
+ Annotation
+ atSign.offset: 61
+ element: self::@getter::annotation
+ name: SimpleIdentifier
+ staticElement: self::@getter::annotation
+ staticType: null
+ token: annotation @62
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get a @-1
+ returnType: E
+ synthetic static get b @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
+ topLevelVariables
+ static const annotation @91
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @104
+ staticType: int
+ accessors
+ synthetic static get annotation @91
+ returnType: int
+''');
}
test_enum_values() async {
var library = await checkLibrary('enum E { v1, v2 }');
checkElementText(library, r'''
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E v1;
- static const E v2;
- String toString() {}
-}
+library
+ definingUnit
+ enums
+ enum E @5
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const v1 @9
+ type: E
+ static const v2 @13
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get v1 @-1
+ returnType: E
+ synthetic static get v2 @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
''');
}
test_enums() async {
var library = await checkLibrary('enum E1 { v1 } enum E2 { v2 }');
checkElementText(library, r'''
-enum E1 {
- synthetic final int index;
- synthetic static const List<E1> values;
- static const E1 v1;
- String toString() {}
-}
-enum E2 {
- synthetic final int index;
- synthetic static const List<E2> values;
- static const E2 v2;
- String toString() {}
-}
+library
+ definingUnit
+ enums
+ enum E1 @5
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E1>
+ static const v1 @10
+ type: E1
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E1>
+ synthetic static get v1 @-1
+ returnType: E1
+ methods
+ toString @-1
+ returnType: String
+ enum E2 @20
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E2>
+ static const v2 @25
+ type: E2
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E2>
+ synthetic static get v2 @-1
+ returnType: E2
+ methods
+ toString @-1
+ returnType: String
''');
}
@@ -6600,29 +14761,74 @@
class D = Object with M, E;
''');
checkElementText(library, r'''
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E a;
- static const E b;
- static const E c;
- String toString() {}
-}
-class M {
-}
-class A {
- dynamic foo() {}
-}
-class B implements M {
- dynamic foo() {}
-}
-class C extends Object with M {
- synthetic C();
- dynamic foo() {}
-}
-class alias D extends Object with M {
- synthetic const D() : super();
-}
+library
+ definingUnit
+ classes
+ class M @24
+ constructors
+ synthetic @-1
+ class A @36
+ constructors
+ synthetic @-1
+ methods
+ foo @52
+ returnType: dynamic
+ class B @70
+ interfaces
+ M
+ constructors
+ synthetic @-1
+ methods
+ foo @92
+ returnType: dynamic
+ class C @110
+ supertype: Object
+ mixins
+ M
+ constructors
+ synthetic @-1
+ methods
+ foo @141
+ returnType: dynamic
+ class alias D @159
+ supertype: Object
+ mixins
+ M
+ constructors
+ synthetic const @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: dart:core::@class::Object::@constructor::•
+ enums
+ enum E @5
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const a @8
+ type: E
+ static const b @11
+ type: E
+ static const c @14
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get a @-1
+ returnType: E
+ synthetic static get b @-1
+ returnType: E
+ synthetic static get c @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
''');
}
@@ -6632,8 +14838,23 @@
main(F f) {}
''');
checkElementText(library, r'''
-typedef F = dynamic Function(int p);
-dynamic main(dynamic Function(int) f) {}
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @8
+ aliasedType: dynamic Function(int)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional p @-1
+ type: int
+ returnType: dynamic
+ functions
+ main @18
+ parameters
+ requiredPositional f @25
+ type: dynamic Function(int)
+ aliasElement: self::@typeAlias::F
+ returnType: dynamic
''');
}
@@ -6643,11 +14864,12 @@
checkElementText(
library,
r'''
-export 'a.dart';
-
---------------------
-Exports:
- C: a.dart;C
+library
+ exports
+ a.dart
+ definingUnit
+ exportScope
+ C: a.dart;C
''',
withExportScope: true);
}
@@ -6662,11 +14884,12 @@
checkElementText(
library,
r'''
-export 'a.dart';
-
---------------------
-Exports:
- C: a.dart;C
+library
+ exports
+ a.dart
+ definingUnit
+ exportScope
+ C: a.dart;C
''',
withExportScope: true);
}
@@ -6686,11 +14909,12 @@
checkElementText(
library,
r'''
-export 'foo.dart';
-
---------------------
-Exports:
- A: foo.dart;A
+library
+ exports
+ foo.dart
+ definingUnit
+ exportScope
+ A: foo.dart;A
''',
withExportScope: true);
expect(library.exports[0].exportedLibrary!.source.shortName, 'foo.dart');
@@ -6712,11 +14936,12 @@
checkElementText(
library,
r'''
-export 'foo_io.dart';
-
---------------------
-Exports:
- A: foo_io.dart;A
+library
+ exports
+ foo_io.dart
+ definingUnit
+ exportScope
+ A: foo_io.dart;A
''',
withExportScope: true);
expect(library.exports[0].exportedLibrary!.source.shortName, 'foo_io.dart');
@@ -6738,11 +14963,12 @@
checkElementText(
library,
r'''
-export 'foo_html.dart';
-
---------------------
-Exports:
- A: foo_html.dart;A
+library
+ exports
+ foo_html.dart
+ definingUnit
+ exportScope
+ A: foo_html.dart;A
''',
withExportScope: true);
ExportElement export = library.exports[0];
@@ -6755,11 +14981,12 @@
checkElementText(
library,
r'''
-export 'a.dart';
-
---------------------
-Exports:
- f: a.dart;f
+library
+ exports
+ a.dart
+ definingUnit
+ exportScope
+ f: a.dart;f
''',
withExportScope: true);
}
@@ -6768,7 +14995,10 @@
addLibrarySource('/a.dart', 'get f() => null;');
var library = await checkLibrary('export "a.dart";');
checkElementText(library, r'''
-export 'a.dart';
+library
+ exports
+ a.dart
+ definingUnit
''');
}
@@ -6779,16 +15009,19 @@
checkElementText(
library,
r'''
-export 'dart:async' hide Stream, Future;
-
---------------------
-Exports:
- Completer: dart:async;Completer
- FutureOr: dart:async;FutureOr
- StreamIterator: dart:async;dart:async/stream.dart;StreamIterator
- StreamSubscription: dart:async;dart:async/stream.dart;StreamSubscription
- StreamTransformer: dart:async;dart:async/stream.dart;StreamTransformer
- Timer: dart:async;Timer
+library
+ exports
+ dart:async
+ combinators
+ hide: Stream, Future
+ definingUnit
+ exportScope
+ Completer: dart:async;Completer
+ FutureOr: dart:async;FutureOr
+ StreamIterator: dart:async;dart:async/stream.dart;StreamIterator
+ StreamSubscription: dart:async;dart:async/stream.dart;StreamSubscription
+ StreamTransformer: dart:async;dart:async/stream.dart;StreamTransformer
+ Timer: dart:async;Timer
''',
withExportScope: true);
}
@@ -6800,11 +15033,15 @@
checkElementText(
library,
r'''
-export 'dart:async' hide Stream show Future;
-
---------------------
-Exports:
- Future: dart:async;Future
+library
+ exports
+ dart:async
+ combinators
+ hide: Stream
+ show: Future
+ definingUnit
+ exportScope
+ Future: dart:async;Future
''',
withExportScope: true);
}
@@ -6815,11 +15052,12 @@
checkElementText(
library,
r'''
-export 'a.dart';
-
---------------------
-Exports:
- f=: a.dart;f=
+library
+ exports
+ a.dart
+ definingUnit
+ exportScope
+ f=: a.dart;f=
''',
withExportScope: true);
}
@@ -6831,12 +15069,15 @@
checkElementText(
library,
r'''
-export 'dart:async' show Future, Stream;
-
---------------------
-Exports:
- Future: dart:async;Future
- Stream: dart:async;dart:async/stream.dart;Stream
+library
+ exports
+ dart:async
+ combinators
+ show: Future, Stream
+ definingUnit
+ exportScope
+ Future: dart:async;Future
+ Stream: dart:async;dart:async/stream.dart;Stream
''',
withExportScope: true);
}
@@ -6850,12 +15091,15 @@
checkElementText(
library,
r'''
-export 'a.dart' show f;
-
---------------------
-Exports:
- f: a.dart;f?
- f=: a.dart;f=
+library
+ exports
+ a.dart
+ combinators
+ show: f
+ definingUnit
+ exportScope
+ f: a.dart;f?
+ f=: a.dart;f=
''',
withExportScope: true);
}
@@ -6866,11 +15110,12 @@
checkElementText(
library,
r'''
-export 'a.dart';
-
---------------------
-Exports:
- F: a.dart;F
+library
+ exports
+ a.dart
+ definingUnit
+ exportScope
+ F: a.dart;F
''',
withExportScope: true);
}
@@ -6888,12 +15133,13 @@
checkElementText(
library,
r'''
-export 'a.dart';
-
---------------------
-Exports:
- x: a.dart;x?
- x=: a.dart;x=
+library
+ exports
+ a.dart
+ definingUnit
+ exportScope
+ x: a.dart;x?
+ x=: a.dart;x=
''',
withExportScope: true);
}
@@ -6904,11 +15150,12 @@
checkElementText(
library,
r'''
-export 'a.dart';
-
---------------------
-Exports:
- x: a.dart;x?
+library
+ exports
+ a.dart
+ definingUnit
+ exportScope
+ x: a.dart;x?
''',
withExportScope: true);
}
@@ -6919,11 +15166,12 @@
checkElementText(
library,
r'''
-export 'a.dart';
-
---------------------
-Exports:
- x: a.dart;x?
+library
+ exports
+ a.dart
+ definingUnit
+ exportScope
+ x: a.dart;x?
''',
withExportScope: true);
}
@@ -6945,9 +15193,15 @@
class B extends A {}
''');
checkElementText(library, r'''
-import 'bar.dart';
-class B extends A {
-}
+library
+ imports
+ bar.dart
+ definingUnit
+ classes
+ class B @25
+ supertype: A
+ constructors
+ synthetic @-1
''');
var typeA = library.definingCompilationUnit.getType('B')!.supertype!;
expect(typeA.element.source.shortName, 'foo.dart');
@@ -6971,9 +15225,15 @@
class B extends A {}
''');
checkElementText(library, r'''
-import 'bar.dart';
-class B extends A {
-}
+library
+ imports
+ bar.dart
+ definingUnit
+ classes
+ class B @25
+ supertype: A
+ constructors
+ synthetic @-1
''');
var typeA = library.definingCompilationUnit.getType('B')!.supertype!;
expect(typeA.element.source.shortName, 'foo_io.dart');
@@ -6997,9 +15257,15 @@
class B extends A {}
''');
checkElementText(library, r'''
-import 'bar.dart';
-class B extends A {
-}
+library
+ imports
+ bar.dart
+ definingUnit
+ classes
+ class B @25
+ supertype: A
+ constructors
+ synthetic @-1
''');
var typeA = library.definingCompilationUnit.getType('B')!.supertype!;
expect(typeA.element.source.shortName, 'foo_html.dart');
@@ -7012,11 +15278,12 @@
checkElementText(
library,
r'''
-export 'a.dart';
-export 'b.dart';
-
---------------------
-Exports:
+library
+ exports
+ a.dart
+ b.dart
+ definingUnit
+ exportScope
''',
withExportScope: true);
}
@@ -7028,9 +15295,21 @@
}
''');
checkElementText(library, r'''
-class C<T> {
- final dynamic f;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ fields
+ final f @21
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get f @21
+ returnType: dynamic
''');
}
@@ -7041,11 +15320,12 @@
/// cc
extension E on int {}''');
checkElementText(library, r'''
-/// aaa
-/// bbbb
-/// cc
-extension E on int {
-}
+library
+ definingUnit
+ extensions
+ E @34
+ documentationComment: /// aaa\n/// bbbb\n/// cc
+ extendedType: int
''');
}
@@ -7055,9 +15335,21 @@
static const x = 0;
}''');
checkElementText(library, r'''
-extension E on int {
- static const int x = 0;
-}
+library
+ definingUnit
+ extensions
+ E @10
+ extendedType: int
+ fields
+ static const x @36
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @40
+ staticType: int
+ accessors
+ synthetic static get x @36
+ returnType: int
''');
}
@@ -7067,10 +15359,24 @@
abstract int i;
}
''');
- checkElementText(library, '''
-abstract class C {
- abstract int i;
-}
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ abstract class C @15
+ fields
+ abstract i @34
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic abstract get i @34
+ returnType: int
+ synthetic abstract set i @34
+ parameters
+ requiredPositional _i @34
+ type: int
+ returnType: void
''');
}
@@ -7080,9 +15386,23 @@
covariant int x;
}''');
checkElementText(library, r'''
-class C {
- covariant int x;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ covariant x @26
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @26
+ returnType: int
+ synthetic set x @26
+ parameters
+ requiredPositional covariant _x @26
+ type: int
+ returnType: void
''');
}
@@ -7095,12 +15415,24 @@
var x;
}''');
checkElementText(library, r'''
-class C {
- /**
- * Docs
- */
- dynamic x;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @38
+ documentationComment: /**\n * Docs\n */
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @38
+ returnType: dynamic
+ synthetic set x @38
+ parameters
+ requiredPositional _x @38
+ type: dynamic
+ returnType: void
''');
}
@@ -7110,10 +15442,24 @@
external int i;
}
''');
- checkElementText(library, '''
-abstract class C {
- external int i;
-}
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ abstract class C @15
+ fields
+ external i @34
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get i @34
+ returnType: int
+ synthetic set i @34
+ parameters
+ requiredPositional _i @34
+ type: int
+ returnType: void
''');
}
@@ -7125,10 +15471,22 @@
}
''');
checkElementText(library, r'''
-class C {
- final int x = 42;
- const C();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ final x @18
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 42 @22
+ staticType: int
+ constructors
+ const @34
+ accessors
+ synthetic get x @18
+ returnType: int
''');
}
@@ -7143,16 +15501,76 @@
}
''');
checkElementText(library, r'''
-class A<T> {
- const A();
-}
-class B {
- final A<int Function(double)> f = const
- A/*location: test.dart;A*/<
- int/*location: dart:core;int*/ Function(
- double/*location: dart:core;double*/ a)>();
- const B();
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ class B @34
+ fields
+ final f @46
+ type: A<int Function(double)>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @81
+ rightParenthesis: ) @82
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::A::@constructor::•
+ substitution: {T: int Function(double)}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @56
+ type: A<int Function(double)>
+ typeArguments: TypeArgumentList
+ arguments
+ GenericFunctionType
+ declaredElement: GenericFunctionTypeElement
+ parameters
+ a
+ kind: required positional
+ type: double
+ returnType: int
+ type: int Function(double)
+ functionKeyword: Function @0
+ parameters: FormalParameterList
+ parameters
+ SimpleFormalParameter
+ declaredElement: a@-1
+ declaredElementType: double
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: a @78
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::double
+ staticType: null
+ token: double @71
+ type: double
+ returnType: TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @58
+ type: int
+ type: int Function(double)
+ leftBracket: < @0
+ rightBracket: > @0
+ keyword: const @50
+ staticType: A<int Function(double)>
+ constructors
+ const @93
+ accessors
+ synthetic get f @46
+ returnType: A<int Function(double)>
''');
}
@@ -7163,9 +15581,18 @@
}
''');
checkElementText(library, r'''
-class C {
- final int x;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ final x @18
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @18
+ returnType: int
''');
}
@@ -7173,31 +15600,82 @@
var library = await checkLibrary('class C extends D { var v; C(this.v); }'
' abstract class D { int get v; }');
checkElementText(library, r'''
-class C extends D {
- int v;
- C(final int this.v);
-}
-abstract class D {
- int get v;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ supertype: D
+ fields
+ v @24
+ type: int
+ constructors
+ @27
+ parameters
+ requiredPositional final this.v @34
+ type: int
+ accessors
+ synthetic get v @24
+ returnType: int
+ synthetic set v @24
+ parameters
+ requiredPositional _v @24
+ type: int
+ returnType: void
+ abstract class D @55
+ fields
+ synthetic v @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract get v @67
+ returnType: int
''');
}
test_field_inferred_type_nonStatic_explicit_initialized() async {
var library = await checkLibrary('class C { num v = 0; }');
checkElementText(library, r'''
-class C {
- num v;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ v @14
+ type: num
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get v @14
+ returnType: num
+ synthetic set v @14
+ parameters
+ requiredPositional _v @14
+ type: num
+ returnType: void
''');
}
test_field_inferred_type_nonStatic_implicit_initialized() async {
var library = await checkLibrary('class C { var v = 0; }');
checkElementText(library, r'''
-class C {
- int v;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ v @14
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get v @14
+ returnType: int
+ synthetic set v @14
+ parameters
+ requiredPositional _v @14
+ type: int
+ returnType: void
''');
}
@@ -7205,12 +15683,33 @@
var library = await checkLibrary(
'class C extends D { var v; } abstract class D { int get v; }');
checkElementText(library, r'''
-class C extends D {
- int v;
-}
-abstract class D {
- int get v;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ supertype: D
+ fields
+ v @24
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get v @24
+ returnType: int
+ synthetic set v @24
+ parameters
+ requiredPositional _v @24
+ type: int
+ returnType: void
+ abstract class D @44
+ fields
+ synthetic v @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract get v @56
+ returnType: int
''');
}
@@ -7226,40 +15725,72 @@
final f = [a];
}
''');
- checkElementText(
- library,
- r'''
-abstract class A {
- List<int> get f;
- const A();
-}
-class B extends A {
- final List<int> f;
- constantInitializer
- ListLiteral
- elements
- SimpleIdentifier
- staticElement: self::@getter::a
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ abstract class A @28
+ fields
+ synthetic f @-1
+ type: List<int>
+ constructors
+ const @40
+ accessors
+ abstract get f @61
+ returnType: List<int>
+ class B @72
+ supertype: A
+ fields
+ final f @107
+ type: List<int>
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: int
+ token: a @112
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<int>
+ constructors
+ const @94
+ accessors
+ synthetic get f @107
+ returnType: List<int>
+ topLevelVariables
+ static const a @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @10
staticType: int
- token: a
- staticType: List<int>
- const B();
-}
-const int a;
- constantInitializer
- IntegerLiteral
- literal: 0
- staticType: int
-''',
- withResolvedAst: true);
+ accessors
+ synthetic static get a @6
+ returnType: int
+''');
}
test_field_inferred_type_static_implicit_initialized() async {
var library = await checkLibrary('class C { static var v = 0; }');
checkElementText(library, r'''
-class C {
- static int v;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ static v @21
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get v @21
+ returnType: int
+ synthetic static set v @21
+ parameters
+ requiredPositional _v @21
+ type: int
+ returnType: void
''');
}
@@ -7269,9 +15800,22 @@
static const x = 0;
}''');
checkElementText(library, r'''
-class C {
- static const int x = 0;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ static const x @25
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @29
+ staticType: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get x @25
+ returnType: int
''');
}
@@ -7283,10 +15827,20 @@
final b = a / 2;
}''');
checkElementText(library, r'''
-import 'a.dart';
-class C {
- final double b;
-}
+library
+ imports
+ a.dart
+ definingUnit
+ classes
+ class C @23
+ fields
+ final b @35
+ type: double
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get b @35
+ returnType: double
''');
}
@@ -7299,15 +15853,28 @@
final b = a / 2;
}''');
checkElementText(library, r'''
-library lib;
-part 'a.dart';
-class C {
- final double b;
-}
---------------------
-unit: a.dart
-
-final int a;
+library
+ name: lib
+ nameOffset: 8
+ definingUnit
+ classes
+ class C @34
+ fields
+ final b @46
+ type: double
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get b @46
+ returnType: double
+ parts
+ a.dart
+ topLevelVariables
+ static final a @19
+ type: int
+ accessors
+ synthetic static get a @19
+ returnType: int
''');
}
@@ -7317,9 +15884,18 @@
final x = 0;
}''');
checkElementText(library, r'''
-class C {
- final int x;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ final x @18
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @18
+ returnType: int
''');
}
@@ -7329,18 +15905,36 @@
static final x = 0;
}''');
checkElementText(library, r'''
-class C {
- static final int x;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ static final x @25
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get x @25
+ returnType: int
''');
}
test_field_static_final_untyped() async {
var library = await checkLibrary('class C { static final x = 0; }');
checkElementText(library, r'''
-class C {
- static final int x;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ static final x @23
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get x @23
+ returnType: int
''');
}
@@ -7352,9 +15946,23 @@
''');
checkElementText(library, r'''
-class C {
- Never a;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ a @16
+ type: Never
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get a @16
+ returnType: Never
+ synthetic set a @16
+ parameters
+ requiredPositional _a @16
+ type: Never
+ returnType: void
''');
}
@@ -7372,28 +15980,71 @@
''');
checkElementText(library, r'''
-import 'a.dart';
-class C {
- int b;
-}
+library
+ imports
+ a.dart
+ definingUnit
+ classes
+ class C @23
+ fields
+ b @33
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get b @33
+ returnType: int
+ synthetic set b @33
+ parameters
+ requiredPositional _b @33
+ type: int
+ returnType: void
''');
}
test_field_typed() async {
var library = await checkLibrary('class C { int x = 0; }');
checkElementText(library, r'''
-class C {
- int x;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @14
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @14
+ returnType: int
+ synthetic set x @14
+ parameters
+ requiredPositional _x @14
+ type: int
+ returnType: void
''');
}
test_field_untyped() async {
var library = await checkLibrary('class C { var x = 0; }');
checkElementText(library, r'''
-class C {
- int x;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @14
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @14
+ returnType: int
+ synthetic set x @14
+ parameters
+ requiredPositional _x @14
+ type: int
+ returnType: void
''');
}
@@ -7408,23 +16059,35 @@
C2();
}
''');
- checkElementText(
- library,
- r'''
-class C1 {
- final List<int> f1;
- constantInitializer
- ListLiteral
- constKeyword: const
- staticType: List<int>
- const C1();
-}
-class C2 {
- final List<int> f2;
- C2();
-}
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C1 @6
+ fields
+ final f1 @30
+ type: List<int>
+ constantInitializer
+ ListLiteral
+ constKeyword: const @0
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<int>
+ constructors
+ const @53
+ accessors
+ synthetic get f1 @30
+ returnType: List<int>
+ class C2 @67
+ fields
+ final f2 @91
+ type: List<int>
+ constructors
+ @108
+ accessors
+ synthetic get f2 @91
+ returnType: List<int>
+''');
}
test_function_async() async {
@@ -7433,8 +16096,13 @@
Future f() async {}
''');
checkElementText(library, r'''
-import 'dart:async';
-Future<dynamic> f() async {}
+library
+ imports
+ dart:async
+ definingUnit
+ functions
+ f @28 async
+ returnType: Future<dynamic>
''');
}
@@ -7444,8 +16112,13 @@
Stream f() async* {}
''');
checkElementText(library, r'''
-import 'dart:async';
-Stream<dynamic> f() async* {}
+library
+ imports
+ dart:async
+ definingUnit
+ functions
+ f @28 async*
+ returnType: Stream<dynamic>
''');
}
@@ -7457,17 +16130,23 @@
*/
f() {}''');
checkElementText(library, r'''
-/**
- * Docs
- */
-dynamic f() {}
+library
+ definingUnit
+ functions
+ f @60
+ documentationComment: /**\n * Docs\n */
+ returnType: dynamic
''');
}
test_function_entry_point() async {
var library = await checkLibrary('main() {}');
checkElementText(library, r'''
-dynamic main() {}
+library
+ definingUnit
+ functions
+ main @0
+ returnType: dynamic
''');
}
@@ -7475,7 +16154,10 @@
addLibrarySource('/a.dart', 'library a; main() {}');
var library = await checkLibrary('export "a.dart";');
checkElementText(library, r'''
-export 'a.dart';
+library
+ exports
+ a.dart
+ definingUnit
''');
}
@@ -7483,7 +16165,12 @@
addLibrarySource('/a.dart', 'library a; main() {}');
var library = await checkLibrary('export "a.dart" hide main;');
checkElementText(library, r'''
-export 'a.dart' hide main;
+library
+ exports
+ a.dart
+ combinators
+ hide: main
+ definingUnit
''');
}
@@ -7491,19 +16178,26 @@
addSource('/a.dart', 'part of my.lib; main() {}');
var library = await checkLibrary('library my.lib; part "a.dart";');
checkElementText(library, r'''
-library my.lib;
-part 'a.dart';
---------------------
-unit: a.dart
-
-dynamic main() {}
+library
+ name: my.lib
+ nameOffset: 8
+ definingUnit
+ parts
+ a.dart
+ functions
+ main @16
+ returnType: dynamic
''');
}
test_function_external() async {
var library = await checkLibrary('external f();');
checkElementText(library, r'''
-external dynamic f() {}
+library
+ definingUnit
+ functions
+ external f @9
+ returnType: dynamic
''');
}
@@ -7528,7 +16222,14 @@
void f(int this.a) {}
''');
checkElementText(library, r'''
-void f(final int this.a) {}
+library
+ definingUnit
+ functions
+ f @5
+ parameters
+ requiredPositional final this.a @16
+ type: int
+ returnType: void
''');
}
@@ -7536,16 +16237,20 @@
var library = await checkLibrary('''
void f({int this.a: 42}) {}
''');
- checkElementText(
- library,
- r'''
-void f({final int this.a}) {}
- a
- IntegerLiteral
- literal: 42
- staticType: int
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ functions
+ f @5
+ parameters
+ optionalNamed final this.a @17
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 42 @0
+ staticType: int
+ returnType: void
+''');
}
test_function_parameter_fieldFormal_functionTyped() async {
@@ -7553,105 +16258,220 @@
void f(int this.a(int b)) {}
''');
checkElementText(library, r'''
-void f(final int Function(int) this.a/*(int b)*/) {}
+library
+ definingUnit
+ functions
+ f @5
+ parameters
+ requiredPositional final this.a @16
+ type: int Function(int)
+ parameters
+ requiredPositional b @-1
+ type: int
+ returnType: void
''');
}
test_function_parameter_final() async {
var library = await checkLibrary('f(final x) {}');
checkElementText(library, r'''
-dynamic f(final dynamic x) {}
+library
+ definingUnit
+ functions
+ f @0
+ parameters
+ requiredPositional final x @8
+ type: dynamic
+ returnType: dynamic
''');
}
test_function_parameter_kind_named() async {
var library = await checkLibrary('f({x}) {}');
checkElementText(library, r'''
-dynamic f({dynamic x}) {}
+library
+ definingUnit
+ functions
+ f @0
+ parameters
+ optionalNamed x @3
+ type: dynamic
+ returnType: dynamic
''');
}
test_function_parameter_kind_positional() async {
var library = await checkLibrary('f([x]) {}');
checkElementText(library, r'''
-dynamic f([dynamic x]) {}
+library
+ definingUnit
+ functions
+ f @0
+ parameters
+ optionalPositional x @3
+ type: dynamic
+ returnType: dynamic
''');
}
test_function_parameter_kind_required() async {
var library = await checkLibrary('f(x) {}');
checkElementText(library, r'''
-dynamic f(dynamic x) {}
+library
+ definingUnit
+ functions
+ f @0
+ parameters
+ requiredPositional x @2
+ type: dynamic
+ returnType: dynamic
''');
}
test_function_parameter_parameters() async {
var library = await checkLibrary('f(g(x, y)) {}');
checkElementText(library, r'''
-dynamic f(dynamic Function(dynamic, dynamic) g/*(dynamic x, dynamic y)*/) {}
+library
+ definingUnit
+ functions
+ f @0
+ parameters
+ requiredPositional g @2
+ type: dynamic Function(dynamic, dynamic)
+ parameters
+ requiredPositional x @4
+ type: dynamic
+ requiredPositional y @7
+ type: dynamic
+ returnType: dynamic
''');
}
test_function_parameter_return_type() async {
var library = await checkLibrary('f(int g()) {}');
checkElementText(library, r'''
-dynamic f(int Function() g) {}
+library
+ definingUnit
+ functions
+ f @0
+ parameters
+ requiredPositional g @6
+ type: int Function()
+ returnType: dynamic
''');
}
test_function_parameter_return_type_void() async {
var library = await checkLibrary('f(void g()) {}');
checkElementText(library, r'''
-dynamic f(void Function() g) {}
+library
+ definingUnit
+ functions
+ f @0
+ parameters
+ requiredPositional g @7
+ type: void Function()
+ returnType: dynamic
''');
}
test_function_parameter_type() async {
var library = await checkLibrary('f(int i) {}');
checkElementText(library, r'''
-dynamic f(int i) {}
+library
+ definingUnit
+ functions
+ f @0
+ parameters
+ requiredPositional i @6
+ type: int
+ returnType: dynamic
''');
}
test_function_parameters() async {
var library = await checkLibrary('f(x, y) {}');
checkElementText(library, r'''
-dynamic f(dynamic x, dynamic y) {}
+library
+ definingUnit
+ functions
+ f @0
+ parameters
+ requiredPositional x @2
+ type: dynamic
+ requiredPositional y @5
+ type: dynamic
+ returnType: dynamic
''');
}
test_function_return_type() async {
var library = await checkLibrary('int f() => null;');
checkElementText(library, r'''
-int f() {}
+library
+ definingUnit
+ functions
+ f @4
+ returnType: int
''');
}
test_function_return_type_implicit() async {
var library = await checkLibrary('f() => null;');
checkElementText(library, r'''
-dynamic f() {}
+library
+ definingUnit
+ functions
+ f @0
+ returnType: dynamic
''');
}
test_function_return_type_void() async {
var library = await checkLibrary('void f() {}');
checkElementText(library, r'''
-void f() {}
+library
+ definingUnit
+ functions
+ f @5
+ returnType: void
''');
}
test_function_type_parameter() async {
var library = await checkLibrary('T f<T, U>(U u) => null;');
checkElementText(library, r'''
-T f<T, U>(U u) {}
+library
+ definingUnit
+ functions
+ f @2
+ typeParameters
+ covariant T @4
+ covariant U @7
+ parameters
+ requiredPositional u @12
+ type: U
+ returnType: T
''');
}
test_function_type_parameter_with_function_typed_parameter() async {
var library = await checkLibrary('void f<T, U>(T x(U u)) {}');
checkElementText(library, r'''
-void f<T, U>(T Function(U) x/*(U u)*/) {}
+library
+ definingUnit
+ functions
+ f @5
+ typeParameters
+ covariant T @7
+ covariant U @10
+ parameters
+ requiredPositional x @15
+ type: T Function(U)
+ parameters
+ requiredPositional u @19
+ type: U
+ returnType: void
''');
}
@@ -7666,8 +16486,13 @@
test_functions() async {
var library = await checkLibrary('f() {} g() {}');
checkElementText(library, r'''
-dynamic f() {}
-dynamic g() {}
+library
+ definingUnit
+ functions
+ f @0
+ returnType: dynamic
+ g @7
+ returnType: dynamic
''');
}
@@ -7708,12 +16533,21 @@
var library = await checkLibrary(r'''
typedef void F<T>(T a);
''');
- checkElementText(
- library,
- r'''
-typedef F<contravariant T> = void Function(T a);
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @13
+ typeParameters
+ contravariant T @15
+ defaultType: dynamic
+ aliasedType: void Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional a @-1
+ type: T
+ returnType: void
+''');
}
test_functionTypeAlias_typeParameters_variance_contravariant2() async {
@@ -7721,13 +16555,31 @@
typedef void F1<T>(T a);
typedef F1<T> F2<T>();
''');
- checkElementText(
- library,
- r'''
-typedef F1<contravariant T> = void Function(T a);
-typedef F2<contravariant T> = void Function(T) Function();
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F1 @13
+ typeParameters
+ contravariant T @16
+ defaultType: dynamic
+ aliasedType: void Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional a @-1
+ type: T
+ returnType: void
+ functionTypeAliasBased F2 @39
+ typeParameters
+ contravariant T @42
+ defaultType: dynamic
+ aliasedType: void Function(T) Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void Function(T)
+ aliasElement: self::@typeAlias::F1
+ aliasArguments
+ T
+''');
}
test_functionTypeAlias_typeParameters_variance_contravariant3() async {
@@ -7735,37 +16587,67 @@
typedef F1<T> F2<T>();
typedef void F1<T>(T a);
''');
- checkElementText(
- library,
- r'''
-typedef F2<contravariant T> = void Function(T) Function();
-typedef F1<contravariant T> = void Function(T a);
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F2 @14
+ typeParameters
+ contravariant T @17
+ defaultType: dynamic
+ aliasedType: void Function(T) Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void Function(T)
+ aliasElement: self::@typeAlias::F1
+ aliasArguments
+ T
+ functionTypeAliasBased F1 @36
+ typeParameters
+ contravariant T @39
+ defaultType: dynamic
+ aliasedType: void Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional a @-1
+ type: T
+ returnType: void
+''');
}
test_functionTypeAlias_typeParameters_variance_covariant() async {
var library = await checkLibrary(r'''
typedef T F<T>();
''');
- checkElementText(
- library,
- r'''
-typedef F<covariant T> = T Function();
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @10
+ typeParameters
+ covariant T @12
+ defaultType: dynamic
+ aliasedType: T Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: T
+''');
}
test_functionTypeAlias_typeParameters_variance_covariant2() async {
var library = await checkLibrary(r'''
typedef List<T> F<T>();
''');
- checkElementText(
- library,
- r'''
-typedef F<covariant T> = List<T> Function();
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @16
+ typeParameters
+ covariant T @18
+ defaultType: dynamic
+ aliasedType: List<T> Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: List<T>
+''');
}
test_functionTypeAlias_typeParameters_variance_covariant3() async {
@@ -7773,13 +16655,28 @@
typedef T F1<T>();
typedef F1<T> F2<T>();
''');
- checkElementText(
- library,
- r'''
-typedef F1<covariant T> = T Function();
-typedef F2<covariant T> = T Function() Function();
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F1 @10
+ typeParameters
+ covariant T @13
+ defaultType: dynamic
+ aliasedType: T Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: T
+ functionTypeAliasBased F2 @33
+ typeParameters
+ covariant T @36
+ defaultType: dynamic
+ aliasedType: T Function() Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: T Function()
+ aliasElement: self::@typeAlias::F1
+ aliasArguments
+ T
+''');
}
test_functionTypeAlias_typeParameters_variance_covariant4() async {
@@ -7787,25 +16684,55 @@
typedef void F1<T>(T a);
typedef void F2<T>(F1<T> a);
''');
- checkElementText(
- library,
- r'''
-typedef F1<contravariant T> = void Function(T a);
-typedef F2<covariant T> = void Function(void Function(T) a);
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F1 @13
+ typeParameters
+ contravariant T @16
+ defaultType: dynamic
+ aliasedType: void Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional a @-1
+ type: T
+ returnType: void
+ functionTypeAliasBased F2 @38
+ typeParameters
+ covariant T @41
+ defaultType: dynamic
+ aliasedType: void Function(void Function(T))
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional a @-1
+ type: void Function(T)
+ aliasElement: self::@typeAlias::F1
+ aliasArguments
+ T
+ returnType: void
+''');
}
test_functionTypeAlias_typeParameters_variance_invariant() async {
var library = await checkLibrary(r'''
typedef T F<T>(T a);
''');
- checkElementText(
- library,
- r'''
-typedef F<invariant T> = T Function(T a);
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @10
+ typeParameters
+ invariant T @12
+ defaultType: dynamic
+ aliasedType: T Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional a @-1
+ type: T
+ returnType: T
+''');
}
test_functionTypeAlias_typeParameters_variance_invariant2() async {
@@ -7813,32 +16740,72 @@
typedef T F1<T>();
typedef F1<T> F2<T>(T a);
''');
- checkElementText(
- library,
- r'''
-typedef F1<covariant T> = T Function();
-typedef F2<invariant T> = T Function() Function(T a);
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F1 @10
+ typeParameters
+ covariant T @13
+ defaultType: dynamic
+ aliasedType: T Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: T
+ functionTypeAliasBased F2 @33
+ typeParameters
+ invariant T @36
+ defaultType: dynamic
+ aliasedType: T Function() Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional a @-1
+ type: T
+ returnType: T Function()
+ aliasElement: self::@typeAlias::F1
+ aliasArguments
+ T
+''');
}
test_functionTypeAlias_typeParameters_variance_unrelated() async {
var library = await checkLibrary(r'''
typedef void F<T>(int a);
''');
- checkElementText(
- library,
- r'''
-typedef F<unrelated T> = void Function(int a);
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @13
+ typeParameters
+ unrelated T @15
+ defaultType: dynamic
+ aliasedType: void Function(int)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional a @-1
+ type: int
+ returnType: void
+''');
}
test_futureOr() async {
var library = await checkLibrary('import "dart:async"; FutureOr<int> x;');
checkElementText(library, r'''
-import 'dart:async';
-FutureOr<int> x;
+library
+ imports
+ dart:async
+ definingUnit
+ topLevelVariables
+ static x @35
+ type: FutureOr<int>
+ accessors
+ synthetic static get x @35
+ returnType: FutureOr<int>
+ synthetic static set x @35
+ parameters
+ requiredPositional _x @35
+ type: FutureOr<int>
+ returnType: void
''');
var variables = library.definingCompilationUnit.topLevelVariables;
expect(variables, hasLength(1));
@@ -7849,9 +16816,21 @@
var library =
await checkLibrary('import "dart:async"; const x = FutureOr;');
checkElementText(library, r'''
-import 'dart:async';
-const Type x =
- FutureOr/*location: dart:async;FutureOr*/;
+library
+ imports
+ dart:async
+ definingUnit
+ topLevelVariables
+ static const x @27
+ type: Type
+ constantInitializer
+ SimpleIdentifier
+ staticElement: dart:async::@class::FutureOr
+ staticType: Type
+ token: FutureOr @31
+ accessors
+ synthetic static get x @27
+ returnType: Type
''');
var variables = library.definingCompilationUnit.topLevelVariables;
expect(variables, hasLength(1));
@@ -7868,10 +16847,33 @@
var y = x.then((z) => z.asDouble());
''');
checkElementText(library, r'''
-import 'dart:async';
-FutureOr<int> x;
-dynamic y;
-FutureOr<int> f() {}
+library
+ imports
+ dart:async
+ definingUnit
+ topLevelVariables
+ static x @52
+ type: FutureOr<int>
+ static y @65
+ type: dynamic
+ accessors
+ synthetic static get x @52
+ returnType: FutureOr<int>
+ synthetic static set x @52
+ parameters
+ requiredPositional _x @52
+ type: FutureOr<int>
+ returnType: void
+ synthetic static get y @65
+ returnType: dynamic
+ synthetic static set y @65
+ parameters
+ requiredPositional _y @65
+ type: dynamic
+ returnType: void
+ functions
+ f @35
+ returnType: FutureOr<int>
''');
var variables = library.definingCompilationUnit.topLevelVariables;
expect(variables, hasLength(2));
@@ -7887,8 +16889,20 @@
var library = await checkLibrary('''
void Function() f;
''');
- checkElementText(library, '''
-void Function() f;
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static f @16
+ type: void Function()
+ accessors
+ synthetic static get f @16
+ returnType: void Function()
+ synthetic static set f @16
+ parameters
+ requiredPositional _f @16
+ type: void Function()
+ returnType: void
''');
}
@@ -7896,8 +16910,20 @@
var library = await checkLibrary('''
void Function()? f;
''');
- checkElementText(library, '''
-void Function()? f;
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static f @17
+ type: void Function()?
+ accessors
+ synthetic static get f @17
+ returnType: void Function()?
+ synthetic static set f @17
+ parameters
+ requiredPositional _f @17
+ type: void Function()?
+ returnType: void
''');
}
@@ -7906,8 +16932,20 @@
var library = await checkLibrary('''
void Function() f;
''');
- checkElementText(library, '''
-void Function()* f;
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static f @16
+ type: void Function()*
+ accessors
+ synthetic static get f @16
+ returnType: void Function()*
+ synthetic static set f @16
+ parameters
+ requiredPositional _f @16
+ type: void Function()*
+ returnType: void
''');
}
@@ -7921,9 +16959,28 @@
}
''');
checkElementText(library, r'''
-class C<T, U> {
- static void m<V, W>(V v, W w) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ covariant U @11
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ static m @30
+ typeParameters
+ covariant V @32
+ covariant W @35
+ parameters
+ requiredPositional v @40
+ type: V
+ requiredPositional w @45
+ type: W
+ returnType: void
''');
}
@@ -7932,7 +16989,11 @@
int Function(int a, String b) f() => null;
''');
checkElementText(library, r'''
-int Function(int, String) f() {}
+library
+ definingUnit
+ functions
+ f @30
+ returnType: int Function(int, String)
''');
}
@@ -7941,7 +17002,17 @@
void f(int Function(int a, String b) p(num c)) => null;
''');
checkElementText(library, r'''
-void f(int Function(int, String) Function(num) p/*(num c)*/) {}
+library
+ definingUnit
+ functions
+ f @5
+ parameters
+ requiredPositional p @37
+ type: int Function(int, String) Function(num)
+ parameters
+ requiredPositional c @43
+ type: num
+ returnType: void
''');
}
@@ -7950,7 +17021,16 @@
typedef F = void Function(String a) Function(int b);
''');
checkElementText(library, r'''
-typedef F = void Function(String) Function(int b);
+library
+ definingUnit
+ typeAliases
+ F @8
+ aliasedType: void Function(String) Function(int)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional b @-1
+ type: int
+ returnType: void Function(String)
''');
}
@@ -7961,9 +17041,15 @@
}
''');
checkElementText(library, r'''
-class C {
- int Function(int, String) m() {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ m @42
+ returnType: int Function(int, String)
''');
}
@@ -7972,7 +17058,14 @@
void f(int Function(int a, String b) p) => null;
''');
checkElementText(library, r'''
-void f(int Function(int, String) p) {}
+library
+ definingUnit
+ functions
+ f @5
+ parameters
+ requiredPositional p @37
+ type: int Function(int, String)
+ returnType: void
''');
}
@@ -7981,7 +17074,19 @@
int Function(int a, String b) v;
''');
checkElementText(library, r'''
-int Function(int, String) v;
+library
+ definingUnit
+ topLevelVariables
+ static v @30
+ type: int Function(int, String)
+ accessors
+ synthetic static get v @30
+ returnType: int Function(int, String)
+ synthetic static set v @30
+ parameters
+ requiredPositional _v @30
+ type: int Function(int, String)
+ returnType: void
''');
}
@@ -7994,63 +17099,68 @@
@A<int Function(String a)>()
class B {}
''');
- checkElementText(
- library,
- r'''
-class A {
- const A();
-}
- typeParameters
- T
- bound: null
- defaultType: dynamic
-class B {
-}
- metadata
- Annotation
- arguments: ArgumentList
- element: ConstructorMember
- base: self::@class::A::@constructor::•
- substitution: {T: dynamic}
- name: SimpleIdentifier
- staticElement: self::@class::A
- staticType: null
- token: A
- typeArguments: TypeArgumentList
- arguments
- GenericFunctionType
- declaredElement: GenericFunctionTypeElement
- parameters
- a
- kind: required positional
- type: String
- returnType: int
- type: int Function(String)
- functionKeyword: Function
- parameters: FormalParameterList
- parameters
- SimpleFormalParameter
- declaredElement: a@-1
- declaredElementType: String
- identifier: SimpleIdentifier
- staticElement: <null>
- staticType: null
- token: a
- type: TypeName
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ class B @64
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @55
+ rightParenthesis: ) @56
+ atSign.offset: 29
+ element: ConstructorMember
+ base: self::@class::A::@constructor::•
+ substitution: {T: dynamic}
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @30
+ typeArguments: TypeArgumentList
+ arguments
+ GenericFunctionType
+ declaredElement: GenericFunctionTypeElement
+ parameters
+ a
+ kind: required positional
+ type: String
+ returnType: int
+ type: int Function(String)
+ functionKeyword: Function @0
+ parameters: FormalParameterList
+ parameters
+ SimpleFormalParameter
+ declaredElement: a@-1
+ declaredElementType: String
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: a @52
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::String
+ staticType: null
+ token: String @45
+ type: String
+ returnType: TypeName
name: SimpleIdentifier
- staticElement: dart:core::@class::String
+ staticElement: dart:core::@class::int
staticType: null
- token: String
- type: String
- returnType: TypeName
- name: SimpleIdentifier
- staticElement: dart:core::@class::int
- staticType: null
- token: int
- type: int
- type: int Function(String)
-''',
- withResolvedAst: true);
+ token: int @32
+ type: int
+ type: int Function(String)
+ leftBracket: < @0
+ rightBracket: > @0
+ constructors
+ synthetic @-1
+''');
}
test_genericFunction_asTypeArgument_ofAnnotation_topLevelVariable() async {
@@ -8062,62 +17172,76 @@
@A<int Function(String a)>()
var v = 0;
''');
- checkElementText(
- library,
- r'''
-class A {
- const A();
-}
- typeParameters
- T
- bound: null
- defaultType: dynamic
-int v;
- metadata
- Annotation
- arguments: ArgumentList
- element: ConstructorMember
- base: self::@class::A::@constructor::•
- substitution: {T: dynamic}
- name: SimpleIdentifier
- staticElement: self::@class::A
- staticType: null
- token: A
- typeArguments: TypeArgumentList
- arguments
- GenericFunctionType
- declaredElement: GenericFunctionTypeElement
- parameters
- a
- kind: required positional
- type: String
- returnType: int
- type: int Function(String)
- functionKeyword: Function
- parameters: FormalParameterList
- parameters
- SimpleFormalParameter
- declaredElement: a@-1
- declaredElementType: String
- identifier: SimpleIdentifier
- staticElement: <null>
- staticType: null
- token: a
- type: TypeName
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ topLevelVariables
+ static v @62
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @55
+ rightParenthesis: ) @56
+ atSign.offset: 29
+ element: ConstructorMember
+ base: self::@class::A::@constructor::•
+ substitution: {T: dynamic}
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @30
+ typeArguments: TypeArgumentList
+ arguments
+ GenericFunctionType
+ declaredElement: GenericFunctionTypeElement
+ parameters
+ a
+ kind: required positional
+ type: String
+ returnType: int
+ type: int Function(String)
+ functionKeyword: Function @0
+ parameters: FormalParameterList
+ parameters
+ SimpleFormalParameter
+ declaredElement: a@-1
+ declaredElementType: String
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: a @52
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::String
+ staticType: null
+ token: String @45
+ type: String
+ returnType: TypeName
name: SimpleIdentifier
- staticElement: dart:core::@class::String
+ staticElement: dart:core::@class::int
staticType: null
- token: String
- type: String
- returnType: TypeName
- name: SimpleIdentifier
- staticElement: dart:core::@class::int
- staticType: null
- token: int
- type: int
- type: int Function(String)
-''',
- withResolvedAst: true);
+ token: int @32
+ type: int
+ type: int Function(String)
+ leftBracket: < @0
+ rightBracket: > @0
+ type: int
+ accessors
+ synthetic static get v @62
+ returnType: int
+ synthetic static set v @62
+ parameters
+ requiredPositional _v @62
+ type: int
+ returnType: void
+''');
}
test_genericFunction_asTypeArgument_parameters_optionalNamed() async {
@@ -8128,73 +17252,81 @@
const v = A<String Function({int? a})>();
''');
- checkElementText(
- library,
- r'''
-class A {
- const A();
-}
- typeParameters
- T
- bound: null
- defaultType: dynamic
-const A<String Function({int? a})> v;
- constantInitializer
- InstanceCreationExpression
- argumentList: ArgumentList
- constructorName: ConstructorName
- staticElement: ConstructorMember
- base: self::@class::A::@constructor::•
- substitution: {T: String Function({int? a})}
- type: TypeName
- name: SimpleIdentifier
- staticElement: self::@class::A
- staticType: null
- token: A
- type: A<String Function({int? a})>
- typeArguments: TypeArgumentList
- arguments
- GenericFunctionType
- declaredElement: GenericFunctionTypeElement
- parameters
- a
- kind: optional named
- type: int?
- returnType: String
- type: String Function({int? a})
- functionKeyword: Function
- parameters: FormalParameterList
- parameters
- DefaultFormalParameter
- declaredElement: a@-1
- declaredElementType: int?
- identifier: SimpleIdentifier
- staticElement: <null>
- staticType: null
- token: a
- parameter: SimpleFormalParameter
- declaredElement: a@-1
- declaredElementType: int?
- identifier: SimpleIdentifier
- staticElement: <null>
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ topLevelVariables
+ static const v @35
+ type: A<String Function({int? a})>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @67
+ rightParenthesis: ) @68
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::A::@constructor::•
+ substitution: {T: String Function({int? a})}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @39
+ type: A<String Function({int? a})>
+ typeArguments: TypeArgumentList
+ arguments
+ GenericFunctionType
+ declaredElement: GenericFunctionTypeElement
+ parameters
+ a
+ kind: optional named
+ type: int?
+ returnType: String
+ type: String Function({int? a})
+ functionKeyword: Function @0
+ parameters: FormalParameterList
+ parameters
+ DefaultFormalParameter
+ declaredElement: a@-1
+ declaredElementType: int?
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: a @63
+ parameter: SimpleFormalParameter
+ declaredElement: a@-1
+ declaredElementType: int?
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: a @63
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @58
+ type: int?
+ returnType: TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::String
staticType: null
- token: a
- type: TypeName
- name: SimpleIdentifier
- staticElement: dart:core::@class::int
- staticType: null
- token: int
- type: int?
- returnType: TypeName
- name: SimpleIdentifier
- staticElement: dart:core::@class::String
- staticType: null
- token: String
- type: String
- type: String Function({int? a})
- staticType: A<String Function({int? a})>
-''',
- withResolvedAst: true);
+ token: String @41
+ type: String
+ type: String Function({int? a})
+ leftBracket: < @0
+ rightBracket: > @0
+ staticType: A<String Function({int? a})>
+ accessors
+ synthetic static get v @35
+ returnType: A<String Function({int? a})>
+''');
}
test_genericFunction_asTypeArgument_parameters_optionalPositional() async {
@@ -8205,73 +17337,81 @@
const v = A<String Function([int? a])>();
''');
- checkElementText(
- library,
- r'''
-class A {
- const A();
-}
- typeParameters
- T
- bound: null
- defaultType: dynamic
-const A<String Function([int?])> v;
- constantInitializer
- InstanceCreationExpression
- argumentList: ArgumentList
- constructorName: ConstructorName
- staticElement: ConstructorMember
- base: self::@class::A::@constructor::•
- substitution: {T: String Function([int?])}
- type: TypeName
- name: SimpleIdentifier
- staticElement: self::@class::A
- staticType: null
- token: A
- type: A<String Function([int?])>
- typeArguments: TypeArgumentList
- arguments
- GenericFunctionType
- declaredElement: GenericFunctionTypeElement
- parameters
- a
- kind: optional positional
- type: int?
- returnType: String
- type: String Function([int?])
- functionKeyword: Function
- parameters: FormalParameterList
- parameters
- DefaultFormalParameter
- declaredElement: a@-1
- declaredElementType: int?
- identifier: SimpleIdentifier
- staticElement: <null>
- staticType: null
- token: a
- parameter: SimpleFormalParameter
- declaredElement: a@-1
- declaredElementType: int?
- identifier: SimpleIdentifier
- staticElement: <null>
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ topLevelVariables
+ static const v @35
+ type: A<String Function([int?])>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @67
+ rightParenthesis: ) @68
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::A::@constructor::•
+ substitution: {T: String Function([int?])}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @39
+ type: A<String Function([int?])>
+ typeArguments: TypeArgumentList
+ arguments
+ GenericFunctionType
+ declaredElement: GenericFunctionTypeElement
+ parameters
+ a
+ kind: optional positional
+ type: int?
+ returnType: String
+ type: String Function([int?])
+ functionKeyword: Function @0
+ parameters: FormalParameterList
+ parameters
+ DefaultFormalParameter
+ declaredElement: a@-1
+ declaredElementType: int?
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: a @63
+ parameter: SimpleFormalParameter
+ declaredElement: a@-1
+ declaredElementType: int?
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: a @63
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @58
+ type: int?
+ returnType: TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::String
staticType: null
- token: a
- type: TypeName
- name: SimpleIdentifier
- staticElement: dart:core::@class::int
- staticType: null
- token: int
- type: int?
- returnType: TypeName
- name: SimpleIdentifier
- staticElement: dart:core::@class::String
- staticType: null
- token: String
- type: String
- type: String Function([int?])
- staticType: A<String Function([int?])>
-''',
- withResolvedAst: true);
+ token: String @41
+ type: String
+ type: String Function([int?])
+ leftBracket: < @0
+ rightBracket: > @0
+ staticType: A<String Function([int?])>
+ accessors
+ synthetic static get v @35
+ returnType: A<String Function([int?])>
+''');
}
test_genericFunction_asTypeArgument_parameters_requiredNamed() async {
@@ -8282,74 +17422,82 @@
const v = A<String Function({required int a})>();
''');
- checkElementText(
- library,
- r'''
-class A {
- const A();
-}
- typeParameters
- T
- bound: null
- defaultType: dynamic
-const A<String Function({required int a})> v;
- constantInitializer
- InstanceCreationExpression
- argumentList: ArgumentList
- constructorName: ConstructorName
- staticElement: ConstructorMember
- base: self::@class::A::@constructor::•
- substitution: {T: String Function({required int a})}
- type: TypeName
- name: SimpleIdentifier
- staticElement: self::@class::A
- staticType: null
- token: A
- type: A<String Function({required int a})>
- typeArguments: TypeArgumentList
- arguments
- GenericFunctionType
- declaredElement: GenericFunctionTypeElement
- parameters
- a
- kind: required named
- type: int
- returnType: String
- type: String Function({required int a})
- functionKeyword: Function
- parameters: FormalParameterList
- parameters
- DefaultFormalParameter
- declaredElement: a@-1
- declaredElementType: int
- identifier: SimpleIdentifier
- staticElement: <null>
- staticType: null
- token: a
- parameter: SimpleFormalParameter
- declaredElement: a@-1
- declaredElementType: int
- identifier: SimpleIdentifier
- staticElement: <null>
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ topLevelVariables
+ static const v @35
+ type: A<String Function({required int a})>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @75
+ rightParenthesis: ) @76
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::A::@constructor::•
+ substitution: {T: String Function({required int a})}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @39
+ type: A<String Function({required int a})>
+ typeArguments: TypeArgumentList
+ arguments
+ GenericFunctionType
+ declaredElement: GenericFunctionTypeElement
+ parameters
+ a
+ kind: required named
+ type: int
+ returnType: String
+ type: String Function({required int a})
+ functionKeyword: Function @0
+ parameters: FormalParameterList
+ parameters
+ DefaultFormalParameter
+ declaredElement: a@-1
+ declaredElementType: int
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: a @71
+ parameter: SimpleFormalParameter
+ declaredElement: a@-1
+ declaredElementType: int
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: a @71
+ requiredKeyword: required @0
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @67
+ type: int
+ returnType: TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::String
staticType: null
- token: a
- requiredKeyword: required
- type: TypeName
- name: SimpleIdentifier
- staticElement: dart:core::@class::int
- staticType: null
- token: int
- type: int
- returnType: TypeName
- name: SimpleIdentifier
- staticElement: dart:core::@class::String
- staticType: null
- token: String
- type: String
- type: String Function({required int a})
- staticType: A<String Function({required int a})>
-''',
- withResolvedAst: true);
+ token: String @41
+ type: String
+ type: String Function({required int a})
+ leftBracket: < @0
+ rightBracket: > @0
+ staticType: A<String Function({required int a})>
+ accessors
+ synthetic static get v @35
+ returnType: A<String Function({required int a})>
+''');
}
test_genericFunction_asTypeArgument_parameters_requiredPositional() async {
@@ -8360,66 +17508,74 @@
const v = A<String Function(int a)>();
''');
- checkElementText(
- library,
- r'''
-class A {
- const A();
-}
- typeParameters
- T
- bound: null
- defaultType: dynamic
-const A<String Function(int)> v;
- constantInitializer
- InstanceCreationExpression
- argumentList: ArgumentList
- constructorName: ConstructorName
- staticElement: ConstructorMember
- base: self::@class::A::@constructor::•
- substitution: {T: String Function(int)}
- type: TypeName
- name: SimpleIdentifier
- staticElement: self::@class::A
- staticType: null
- token: A
- type: A<String Function(int)>
- typeArguments: TypeArgumentList
- arguments
- GenericFunctionType
- declaredElement: GenericFunctionTypeElement
- parameters
- a
- kind: required positional
- type: int
- returnType: String
- type: String Function(int)
- functionKeyword: Function
- parameters: FormalParameterList
- parameters
- SimpleFormalParameter
- declaredElement: a@-1
- declaredElementType: int
- identifier: SimpleIdentifier
- staticElement: <null>
- staticType: null
- token: a
- type: TypeName
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ topLevelVariables
+ static const v @35
+ type: A<String Function(int)>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @64
+ rightParenthesis: ) @65
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::A::@constructor::•
+ substitution: {T: String Function(int)}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @39
+ type: A<String Function(int)>
+ typeArguments: TypeArgumentList
+ arguments
+ GenericFunctionType
+ declaredElement: GenericFunctionTypeElement
+ parameters
+ a
+ kind: required positional
+ type: int
+ returnType: String
+ type: String Function(int)
+ functionKeyword: Function @0
+ parameters: FormalParameterList
+ parameters
+ SimpleFormalParameter
+ declaredElement: a@-1
+ declaredElementType: int
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: a @61
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @57
+ type: int
+ returnType: TypeName
name: SimpleIdentifier
- staticElement: dart:core::@class::int
+ staticElement: dart:core::@class::String
staticType: null
- token: int
- type: int
- returnType: TypeName
- name: SimpleIdentifier
- staticElement: dart:core::@class::String
- staticType: null
- token: String
- type: String
- type: String Function(int)
- staticType: A<String Function(int)>
-''',
- withResolvedAst: true);
+ token: String @41
+ type: String
+ type: String Function(int)
+ leftBracket: < @0
+ rightBracket: > @0
+ staticType: A<String Function(int)>
+ accessors
+ synthetic static get v @35
+ returnType: A<String Function(int)>
+''');
}
test_genericFunction_boundOf_typeParameter_ofMixin() async {
@@ -8427,8 +17583,18 @@
mixin B<X extends void Function()> {}
''');
checkElementText(library, r'''
-mixin B<X extends void Function() = void Function()> on Object {
-}
+library
+ definingUnit
+ mixins
+ mixin B @6
+ typeParameters
+ covariant X @8
+ bound: void Function()
+ defaultType: void Function()
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
''');
}
@@ -8439,13 +17605,33 @@
class B = A<void Function()> with M;
''');
checkElementText(library, r'''
-class A<T> {
-}
-class alias B extends A<void Function()> with M {
- synthetic B() : super();
-}
-mixin M on Object {
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class alias B @31
+ supertype: A<void Function()>
+ mixins
+ M
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::A::@constructor::•
+ mixins
+ mixin M @20
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
''');
}
@@ -8455,8 +17641,28 @@
typedef F2<V2> = V2 Function();
''');
checkElementText(library, r'''
-typedef F1 = dynamic Function<V1>(V1 Function() );
-typedef F2<V2> = V2 Function();
+library
+ definingUnit
+ typeAliases
+ F1 @8
+ aliasedType: dynamic Function<V1>(V1 Function())
+ aliasedElement: GenericFunctionTypeElement
+ typeParameters
+ covariant V1 @-1
+ parameters
+ requiredPositional @-1
+ type: V1 Function()
+ aliasElement: self::@typeAlias::F2
+ aliasArguments
+ V1
+ returnType: dynamic
+ F2 @43
+ typeParameters
+ covariant V2 @46
+ defaultType: dynamic
+ aliasedType: V2 Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: V2
''');
}
@@ -8490,7 +17696,20 @@
typedef F<X extends F> = Function(F);
''');
checkElementText(library, r'''
-notSimplyBounded typedef F<X extends dynamic Function()> = dynamic Function(dynamic Function() );
+library
+ definingUnit
+ typeAliases
+ notSimplyBounded F @8
+ typeParameters
+ unrelated X @10
+ bound: dynamic Function()
+ defaultType: dynamic
+ aliasedType: dynamic Function(dynamic Function())
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional @-1
+ type: dynamic Function()
+ returnType: dynamic
''');
}
@@ -8499,7 +17718,14 @@
Future<int> get foo async => 0;
''');
checkElementText(library, r'''
-Future<int> get foo async {}
+library
+ definingUnit
+ topLevelVariables
+ synthetic static foo @-1
+ type: Future<int>
+ accessors
+ get foo @16 async
+ returnType: Future<int>
''');
}
@@ -8509,8 +17735,16 @@
Stream<int> get foo async* {}
''');
checkElementText(library, r'''
-import 'dart:async';
-Stream<int> get foo async* {}
+library
+ imports
+ dart:async
+ definingUnit
+ topLevelVariables
+ synthetic static foo @-1
+ type: Stream<int>
+ accessors
+ get foo @37 async*
+ returnType: Stream<int>
''');
}
@@ -8522,17 +17756,29 @@
*/
get x => null;''');
checkElementText(library, r'''
-/**
- * Docs
- */
-dynamic get x {}
+library
+ definingUnit
+ topLevelVariables
+ synthetic static x @-1
+ type: dynamic
+ accessors
+ get x @64
+ documentationComment: /**\n * Docs\n */
+ returnType: dynamic
''');
}
test_getter_external() async {
var library = await checkLibrary('external int get x;');
checkElementText(library, r'''
-external int get x;
+library
+ definingUnit
+ topLevelVariables
+ synthetic static x @-1
+ type: int
+ accessors
+ external get x @17
+ returnType: int
''');
}
@@ -8540,12 +17786,28 @@
var library = await checkLibrary(
'class C extends D { get f => null; } abstract class D { int get f; }');
checkElementText(library, r'''
-class C extends D {
- int get f {}
-}
-abstract class D {
- int get f;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ supertype: D
+ fields
+ synthetic f @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ get f @24
+ returnType: int
+ abstract class D @52
+ fields
+ synthetic f @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract get f @64
+ returnType: int
''');
}
@@ -8554,15 +17816,32 @@
Iterator<int> get foo sync* {}
''');
checkElementText(library, r'''
-Iterator<int> get foo sync* {}
+library
+ definingUnit
+ topLevelVariables
+ synthetic static foo @-1
+ type: Iterator<int>
+ accessors
+ get foo @18 sync*
+ returnType: Iterator<int>
''');
}
test_getters() async {
var library = await checkLibrary('int get x => null; get y => null;');
checkElementText(library, r'''
-int get x {}
-dynamic get y {}
+library
+ definingUnit
+ topLevelVariables
+ synthetic static x @-1
+ type: int
+ synthetic static y @-1
+ type: dynamic
+ accessors
+ get x @8
+ returnType: int
+ get y @23
+ returnType: dynamic
''');
}
@@ -8575,13 +17854,51 @@
const x = C.named(42);
''');
checkElementText(library, r'''
-class C {
- final Object x;
- const C.named(final Object this.x);
-}
-const C x =
- C/*location: test.dart;C*/.
- named/*location: test.dart;C;named*/(42);
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ final x @25
+ type: Object
+ constructors
+ const named @38
+ periodOffset: 37
+ nameEnd: 43
+ parameters
+ requiredPositional final this.x @49
+ type: Object
+ accessors
+ synthetic get x @25
+ returnType: Object
+ topLevelVariables
+ static const x @61
+ type: C
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 42 @73
+ staticType: int
+ leftParenthesis: ( @72
+ rightParenthesis: ) @75
+ constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@class::C::@constructor::named
+ staticType: null
+ token: named @67
+ staticElement: self::@class::C::@constructor::named
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @65
+ type: C
+ staticType: C
+ accessors
+ synthetic static get x @61
+ returnType: C
''');
}
@@ -8589,8 +17906,19 @@
var library =
await checkLibrary('int get x => 0; void set x(int value) {}');
checkElementText(library, r'''
-int get x {}
-void set x(int value) {}
+library
+ definingUnit
+ topLevelVariables
+ synthetic static x @-1
+ type: int
+ accessors
+ get x @8
+ returnType: int
+ set x @25
+ parameters
+ requiredPositional value @31
+ type: int
+ returnType: void
''');
}
@@ -8598,8 +17926,19 @@
var library =
await checkLibrary('void set x(int value) {} int get x => 0;');
checkElementText(library, r'''
-void set x(int value) {}
-int get x {}
+library
+ definingUnit
+ topLevelVariables
+ synthetic static x @-1
+ type: int
+ accessors
+ set x @9
+ parameters
+ requiredPositional value @15
+ type: int
+ returnType: void
+ get x @33
+ returnType: int
''');
}
@@ -8618,9 +17957,15 @@
class B extends A {}
''');
checkElementText(library, r'''
-import 'foo.dart';
-class B extends A {
-}
+library
+ imports
+ foo.dart
+ definingUnit
+ classes
+ class B @104
+ supertype: A
+ constructors
+ synthetic @-1
''');
var typeA = library.definingCompilationUnit.getType('B')!.supertype!;
expect(typeA.element.source.shortName, 'foo.dart');
@@ -8642,9 +17987,15 @@
class B extends A {}
''');
checkElementText(library, r'''
-import 'foo_io.dart';
-class B extends A {
-}
+library
+ imports
+ foo_io.dart
+ definingUnit
+ classes
+ class B @104
+ supertype: A
+ constructors
+ synthetic @-1
''');
var typeA = library.definingCompilationUnit.getType('B')!.supertype!;
expect(typeA.element.source.shortName, 'foo_io.dart');
@@ -8666,9 +18017,15 @@
class B extends A {}
''');
checkElementText(library, r'''
-import 'foo_io.dart';
-class B extends A {
-}
+library
+ imports
+ foo_io.dart
+ definingUnit
+ classes
+ class B @124
+ supertype: A
+ constructors
+ synthetic @-1
''');
var typeA = library.definingCompilationUnit.getType('B')!.supertype!;
expect(typeA.element.source.shortName, 'foo_io.dart');
@@ -8690,9 +18047,15 @@
class B extends A {}
''');
checkElementText(library, r'''
-import 'foo_html.dart';
-class B extends A {
-}
+library
+ imports
+ foo_html.dart
+ definingUnit
+ classes
+ class B @104
+ supertype: A
+ constructors
+ synthetic @-1
''');
var typeA = library.definingCompilationUnit.getType('B')!.supertype!;
expect(typeA.element.source.shortName, 'foo_html.dart');
@@ -8714,9 +18077,15 @@
class B extends A {}
''');
checkElementText(library, r'''
-import 'foo_html.dart';
-class B extends A {
-}
+library
+ imports
+ foo_html.dart
+ definingUnit
+ classes
+ class B @124
+ supertype: A
+ constructors
+ synthetic @-1
''');
var typeA = library.definingCompilationUnit.getType('B')!.supertype!;
expect(typeA.element.source.shortName, 'foo_html.dart');
@@ -8727,31 +18096,38 @@
import 'dart:core';
import 'dart:math';
''');
- expect(library.imports, hasLength(2));
- expect(library.imports[0].uri, 'dart:core');
- expect(library.imports[1].uri, 'dart:math');
+ checkElementText(library, r'''
+library
+ imports
+ dart:core
+ dart:math
+ definingUnit
+''');
}
test_import_dartCore_implicit() async {
var library = await checkLibrary('''
import 'dart:math';
''');
- expect(library.imports, hasLength(2));
- expect(library.imports[0].uri, 'dart:math');
- expect(library.imports[1].uri, 'dart:core');
+ checkElementText(library, r'''
+library
+ imports
+ dart:math
+ definingUnit
+''');
}
test_import_deferred() async {
- addLibrarySource('/a.dart', 'f() {}');
+ testFile = convertPath('/home/test/lib/test.dart');
+ addLibrarySource('/home/test/lib/a.dart', 'f() {}');
var library = await checkLibrary('''
import 'a.dart' deferred as p;
-main() {
- p.f();
- }
''');
checkElementText(library, r'''
-import 'a.dart' deferred as p;
-dynamic main() {}
+library
+ imports
+ package:test/a.dart deferred as p @28
+ definingUnit
''');
}
@@ -8766,12 +18142,16 @@
export 'dart:math';
''');
checkElementText(library, r'''
-import 'dart:async' as i1;
-import 'dart:async' as i2;
-import 'dart:async' as i3;
-export 'dart:math';
-export 'dart:math';
-export 'dart:math';
+library
+ imports
+ dart:async as i1 @23
+ dart:async as i2 @70
+ dart:async as i3 @117
+ exports
+ dart:math
+ dart:math
+ dart:math
+ definingUnit
''');
}
@@ -8781,8 +18161,23 @@
import 'dart:async' hide Stream, Completer; Future f;
''');
checkElementText(library, r'''
-import 'dart:async' hide Stream, Completer;
-Future<dynamic> f;
+library
+ imports
+ dart:async
+ combinators
+ hide: Stream, Completer
+ definingUnit
+ topLevelVariables
+ static f @51
+ type: Future<dynamic>
+ accessors
+ synthetic static get f @51
+ returnType: Future<dynamic>
+ synthetic static set f @51
+ parameters
+ requiredPositional _f @51
+ type: Future<dynamic>
+ returnType: void
''');
}
@@ -8792,9 +18187,26 @@
import 'ht:';
''');
checkElementText(library, r'''
-@
- foo/*location: null*/
-import '<unresolved>';
+library
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: <null>
+ name: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: foo @-1
+ imports
+ <unresolved>
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: <null>
+ name: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: foo @-1
+ definingUnit
''');
}
@@ -8805,8 +18217,24 @@
Future f;
''');
checkElementText(library, r'''
-import 'dart:async' hide Stream show Future;
-Future<dynamic> f;
+library
+ imports
+ dart:async
+ combinators
+ hide: Stream
+ show: Future
+ definingUnit
+ topLevelVariables
+ static f @52
+ type: Future<dynamic>
+ accessors
+ synthetic static get f @52
+ returnType: Future<dynamic>
+ synthetic static set f @52
+ parameters
+ requiredPositional _f @52
+ type: Future<dynamic>
+ returnType: void
''');
}
@@ -8818,8 +18246,21 @@
expect(library.imports[0].prefix!.nameLength, 1);
checkElementText(library, r'''
-import 'a.dart' as a;
-C c;
+library
+ imports
+ a.dart as a @19
+ definingUnit
+ topLevelVariables
+ static c @26
+ type: C
+ accessors
+ synthetic static get c @26
+ returnType: C
+ synthetic static set c @26
+ parameters
+ requiredPositional _c @26
+ type: C
+ returnType: void
''');
}
@@ -8833,11 +18274,18 @@
expect(library.imports[0].importedLibrary!.location, library.location);
expect(library.imports[1].importedLibrary!.isDartCore, true);
checkElementText(library, r'''
-import 'test.dart' as p;
-class C {
-}
-class D extends C {
-}
+library
+ imports
+ test.dart as p @22
+ definingUnit
+ classes
+ class C @31
+ constructors
+ synthetic @-1
+ class D @42
+ supertype: C
+ constructors
+ synthetic @-1
''');
}
@@ -8849,8 +18297,21 @@
addLibrarySource(destinationPath, 'class C {}');
var library = await checkLibrary('import "/a.dart"; C c;');
checkElementText(library, r'''
-import 'a.dart';
-C c;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static c @20
+ type: C
+ accessors
+ synthetic static get c @20
+ returnType: C
+ synthetic static set c @20
+ parameters
+ requiredPositional _c @20
+ type: C
+ returnType: void
''');
}
@@ -8862,9 +18323,32 @@
Stream s;
''');
checkElementText(library, r'''
-import 'dart:async' show Future, Stream;
-Future<dynamic> f;
-Stream<dynamic> s;
+library
+ imports
+ dart:async
+ combinators
+ show: Future, Stream
+ definingUnit
+ topLevelVariables
+ static f @48
+ type: Future<dynamic>
+ static s @58
+ type: Stream<dynamic>
+ accessors
+ synthetic static get f @48
+ returnType: Future<dynamic>
+ synthetic static set f @48
+ parameters
+ requiredPositional _f @48
+ type: Future<dynamic>
+ returnType: void
+ synthetic static get s @58
+ returnType: Stream<dynamic>
+ synthetic static set s @58
+ parameters
+ requiredPositional _s @58
+ type: Stream<dynamic>
+ returnType: void
''');
}
@@ -8891,10 +18375,31 @@
var library =
await checkLibrary('import "a.dart"; import "b.dart"; C c; D d;');
checkElementText(library, r'''
-import 'a.dart';
-import 'b.dart';
-C c;
-D d;
+library
+ imports
+ a.dart
+ b.dart
+ definingUnit
+ topLevelVariables
+ static c @36
+ type: C
+ static d @41
+ type: D
+ accessors
+ synthetic static get c @36
+ returnType: C
+ synthetic static set c @36
+ parameters
+ requiredPositional _c @36
+ type: C
+ returnType: void
+ synthetic static get d @41
+ returnType: D
+ synthetic static set d @41
+ parameters
+ requiredPositional _d @41
+ type: D
+ returnType: void
''');
}
@@ -8908,17 +18413,73 @@
D<int,U> f<U>() => null;
const x = const C(f);
''');
- checkElementText(library, '''
-typedef F<T> = D<T, U> Function<U>();
-class C<V> {
- const C(D<V, U> Function<U>() f);
-}
-class D<T, U> {
-}
-const C<int> x = const
- C/*location: test.dart;C*/(
- f/*location: test.dart;f*/);
-D<int, U> f<U>() {}
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @43
+ typeParameters
+ covariant V @45
+ defaultType: dynamic
+ constructors
+ const @58
+ parameters
+ requiredPositional f @65
+ type: D<V, U> Function<U>()
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ V
+ class D @77
+ typeParameters
+ covariant T @79
+ defaultType: dynamic
+ covariant U @81
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ typeAliases
+ F @8
+ typeParameters
+ covariant T @10
+ defaultType: dynamic
+ aliasedType: D<T, U> Function<U>()
+ aliasedElement: GenericFunctionTypeElement
+ typeParameters
+ covariant U @-1
+ returnType: D<T, U>
+ topLevelVariables
+ static const x @118
+ type: C<int>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ SimpleIdentifier
+ staticElement: self::@function::f
+ staticType: D<int, U> Function<U>()
+ token: f @130
+ leftParenthesis: ( @129
+ rightParenthesis: ) @131
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::C::@constructor::•
+ substitution: {V: int}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @128
+ type: C<int>
+ keyword: const @122
+ staticType: C<int>
+ accessors
+ synthetic static get x @118
+ returnType: C<int>
+ functions
+ f @96
+ typeParameters
+ covariant U @98
+ returnType: D<int, U>
''');
}
@@ -8932,17 +18493,61 @@
D<T> f<T>() => null;
const x = const C(f);
''');
- checkElementText(library, '''
-typedef F = D<T> Function<T>();
-class C {
- const C(D<T> Function<T>() f);
-}
-class D<T> {
-}
-const C x = const
- C/*location: test.dart;C*/(
- f/*location: test.dart;f*/);
-D<T> f<T>() {}
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @38
+ constructors
+ const @50
+ parameters
+ requiredPositional f @54
+ type: D<T> Function<T>()
+ aliasElement: self::@typeAlias::F
+ class D @66
+ typeParameters
+ covariant T @68
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ typeAliases
+ F @8
+ aliasedType: D<T> Function<T>()
+ aliasedElement: GenericFunctionTypeElement
+ typeParameters
+ covariant T @-1
+ returnType: D<T>
+ topLevelVariables
+ static const x @101
+ type: C
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ SimpleIdentifier
+ staticElement: self::@function::f
+ staticType: D<T> Function<T>()
+ token: f @113
+ leftParenthesis: ( @112
+ rightParenthesis: ) @114
+ constructorName: ConstructorName
+ staticElement: self::@class::C::@constructor::•
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @111
+ type: C
+ keyword: const @105
+ staticType: C
+ accessors
+ synthetic static get x @101
+ returnType: C
+ functions
+ f @79
+ typeParameters
+ covariant T @81
+ returnType: D<T>
''');
}
@@ -8958,15 +18563,38 @@
var s = new S(new B());
''');
- checkElementText(library, '''
-class A {
-}
-class B extends A {
-}
-class S<T extends A = A> {
- S(T _);
-}
-S<B> s;
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ class B @18
+ supertype: A
+ constructors
+ synthetic @-1
+ class S @40
+ typeParameters
+ covariant T @42
+ bound: A
+ defaultType: A
+ constructors
+ @59
+ parameters
+ requiredPositional _ @63
+ type: T
+ topLevelVariables
+ static s @74
+ type: S<B>
+ accessors
+ synthetic static get s @74
+ returnType: S<B>
+ synthetic static set s @74
+ parameters
+ requiredPositional _s @74
+ type: S<B>
+ returnType: void
''');
}
@@ -8984,20 +18612,65 @@
var a = new A();
var x = a.b.c ??= new D();
''');
- checkElementText(library, '''
-class A {
- B b;
-}
-class B {
- C get c {}
- void set c(C value) {}
-}
-class C {
-}
-class D extends C {
-}
-A a;
-C x;
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ b @14
+ type: B
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get b @14
+ returnType: B
+ synthetic set b @14
+ parameters
+ requiredPositional _b @14
+ type: B
+ returnType: void
+ class B @25
+ fields
+ synthetic c @-1
+ type: C
+ constructors
+ synthetic @-1
+ accessors
+ get c @37
+ returnType: C
+ set c @59
+ parameters
+ requiredPositional value @63
+ type: C
+ returnType: void
+ class C @81
+ constructors
+ synthetic @-1
+ class D @92
+ supertype: C
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static a @111
+ type: A
+ static x @128
+ type: C
+ accessors
+ synthetic static get a @111
+ returnType: A
+ synthetic static set a @111
+ parameters
+ requiredPositional _a @111
+ type: A
+ returnType: void
+ synthetic static get x @128
+ returnType: C
+ synthetic static set x @128
+ parameters
+ requiredPositional _x @128
+ type: C
+ returnType: void
''');
}
@@ -9008,10 +18681,38 @@
var y = [3];
var z = x.toList();
''');
- checkElementText(library, '''
-Iterable<String> x;
-List<int> y;
-List<String> z;
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static x @4
+ type: Iterable<String>
+ static y @40
+ type: List<int>
+ static z @53
+ type: List<String>
+ accessors
+ synthetic static get x @4
+ returnType: Iterable<String>
+ synthetic static set x @4
+ parameters
+ requiredPositional _x @4
+ type: Iterable<String>
+ returnType: void
+ synthetic static get y @40
+ returnType: List<int>
+ synthetic static set y @40
+ parameters
+ requiredPositional _y @40
+ type: List<int>
+ returnType: void
+ synthetic static get z @53
+ returnType: List<String>
+ synthetic static set z @53
+ parameters
+ requiredPositional _z @53
+ type: List<String>
+ returnType: void
''');
}
@@ -9023,12 +18724,44 @@
var x = <C>[];
var y = x.map((c) => c.p);
''');
- checkElementText(library, '''
-class C {
- int p;
-}
-List<C> x;
-Iterable<int> y;
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ p @16
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get p @16
+ returnType: int
+ synthetic set p @16
+ parameters
+ requiredPositional _p @16
+ type: int
+ returnType: void
+ topLevelVariables
+ static x @25
+ type: List<C>
+ static y @40
+ type: Iterable<int>
+ accessors
+ synthetic static get x @25
+ returnType: List<C>
+ synthetic static set x @25
+ parameters
+ requiredPositional _x @25
+ type: List<C>
+ returnType: void
+ synthetic static get y @40
+ returnType: Iterable<int>
+ synthetic static set y @40
+ parameters
+ requiredPositional _y @40
+ type: Iterable<int>
+ returnType: void
''');
}
@@ -9041,7 +18774,14 @@
}
''');
checkElementText(library, r'''
-dynamic f<U, V>() {}
+library
+ definingUnit
+ functions
+ f @0
+ typeParameters
+ covariant U @2
+ covariant V @5
+ returnType: dynamic
''');
}
@@ -9055,10 +18795,23 @@
}
''');
checkElementText(library, r'''
-class C<U, V> {
- final dynamic x;
- C();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant U @8
+ defaultType: dynamic
+ covariant V @11
+ defaultType: dynamic
+ fields
+ final x @24
+ type: dynamic
+ constructors
+ @29
+ accessors
+ synthetic get x @24
+ returnType: dynamic
''');
}
@@ -9071,9 +18824,23 @@
}
''');
checkElementText(library, r'''
-class C<U, V> {
- dynamic get x {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant U @8
+ defaultType: dynamic
+ covariant V @11
+ defaultType: dynamic
+ fields
+ synthetic x @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ get x @22
+ returnType: dynamic
''');
}
@@ -9089,9 +18856,21 @@
}
''');
checkElementText(library, r'''
-class C<T> {
- dynamic f<U, V>() {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ f @15
+ typeParameters
+ covariant U @17
+ covariant V @20
+ returnType: dynamic
''');
}
@@ -9106,9 +18885,26 @@
}
''');
checkElementText(library, r'''
-class C<U, V> {
- void set x(dynamic value) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant U @8
+ defaultType: dynamic
+ covariant V @11
+ defaultType: dynamic
+ fields
+ synthetic x @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ set x @27
+ parameters
+ requiredPositional value @29
+ type: dynamic
+ returnType: void
''');
}
@@ -9121,7 +18917,13 @@
}
''');
checkElementText(library, r'''
-dynamic f<T>() {}
+library
+ definingUnit
+ functions
+ f @0
+ typeParameters
+ covariant T @2
+ returnType: dynamic
''');
}
@@ -9134,7 +18936,13 @@
}
''');
checkElementText(library, r'''
-dynamic f<T>() {}
+library
+ definingUnit
+ functions
+ f @0
+ typeParameters
+ covariant T @2
+ returnType: dynamic
''');
}
@@ -9148,11 +18956,25 @@
}
''');
checkElementText(library, r'''
-class A {
- static final int foo;
- static final int Function(double) bar;
- static int Function(double) baz() {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ static final foo @25
+ type: int
+ static final bar @56
+ type: int Function(double)
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get foo @25
+ returnType: int
+ synthetic static get bar @56
+ returnType: int Function(double)
+ methods
+ static baz @100
+ returnType: int Function(double)
''');
}
@@ -9164,10 +18986,49 @@
var d = 4;
''');
checkElementText(library, r'''
-dynamic a/*error: dependencyCycle*/;
-dynamic b/*error: dependencyCycle*/;
-dynamic c/*error: dependencyCycle*/;
-int d;
+library
+ definingUnit
+ topLevelVariables
+ static a @4
+ typeInferenceError: dependencyCycle
+ type: dynamic
+ static b @19
+ typeInferenceError: dependencyCycle
+ type: dynamic
+ static c @34
+ typeInferenceError: dependencyCycle
+ type: dynamic
+ static d @49
+ type: int
+ accessors
+ synthetic static get a @4
+ returnType: dynamic
+ synthetic static set a @4
+ parameters
+ requiredPositional _a @4
+ type: dynamic
+ returnType: void
+ synthetic static get b @19
+ returnType: dynamic
+ synthetic static set b @19
+ parameters
+ requiredPositional _b @19
+ type: dynamic
+ returnType: void
+ synthetic static get c @34
+ returnType: dynamic
+ synthetic static set c @34
+ parameters
+ requiredPositional _c @34
+ type: dynamic
+ returnType: void
+ synthetic static get d @49
+ returnType: int
+ synthetic static set d @49
+ parameters
+ requiredPositional _d @49
+ type: int
+ returnType: void
''');
}
@@ -9176,13 +19037,46 @@
' class C extends D { var v; }'
' abstract class D { F get v; }');
checkElementText(library, r'''
-typedef F = int Function(String s);
-class C extends D {
- int Function(String) v;
-}
-abstract class D {
- int Function(String) get v;
-}
+library
+ definingUnit
+ classes
+ class C @31
+ supertype: D
+ fields
+ v @49
+ type: int Function(String)
+ aliasElement: self::@typeAlias::F
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get v @49
+ returnType: int Function(String)
+ aliasElement: self::@typeAlias::F
+ synthetic set v @49
+ parameters
+ requiredPositional _v @49
+ type: int Function(String)
+ aliasElement: self::@typeAlias::F
+ returnType: void
+ abstract class D @69
+ fields
+ synthetic v @-1
+ type: int Function(String)
+ aliasElement: self::@typeAlias::F
+ constructors
+ synthetic @-1
+ accessors
+ abstract get v @79
+ returnType: int Function(String)
+ aliasElement: self::@typeAlias::F
+ typeAliases
+ functionTypeAliasBased F @12
+ aliasedType: int Function(String)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional s @-1
+ type: String
+ returnType: int
''');
}
@@ -9193,8 +19087,21 @@
var x = f();
''');
checkElementText(library, r'''
-import 'a.dart';
-int x;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static x @21
+ type: int
+ accessors
+ synthetic static get x @21
+ returnType: int
+ synthetic static set x @21
+ parameters
+ requiredPositional _x @21
+ type: int
+ returnType: void
''');
}
@@ -9205,8 +19112,21 @@
var x = f();
''');
checkElementText(library, r'''
-import 'a.dart';
-int? x;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static x @21
+ type: int?
+ accessors
+ synthetic static get x @21
+ returnType: int?
+ synthetic static set x @21
+ parameters
+ requiredPositional _x @21
+ type: int?
+ returnType: void
''');
}
@@ -9217,8 +19137,21 @@
var x = f();
''');
checkElementText(library, r'''
-import 'a.dart';
-void Function() x;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static x @21
+ type: void Function()
+ accessors
+ synthetic static get x @21
+ returnType: void Function()
+ synthetic static set x @21
+ parameters
+ requiredPositional _x @21
+ type: void Function()
+ returnType: void
''');
}
@@ -9229,8 +19162,21 @@
var x = f();
''');
checkElementText(library, r'''
-import 'a.dart';
-void Function()? x;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static x @21
+ type: void Function()?
+ accessors
+ synthetic static get x @21
+ returnType: void Function()?
+ synthetic static set x @21
+ parameters
+ requiredPositional _x @21
+ type: void Function()?
+ returnType: void
''');
}
@@ -9244,12 +19190,41 @@
}
''');
checkElementText(library, r'''
-class C<T> extends D<int, T> {
- Map<T, int> v;
-}
-abstract class D<U, V> {
- Map<V, U> get v;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ supertype: D<int, T>
+ fields
+ v @37
+ type: Map<T, int>
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get v @37
+ returnType: Map<T, int>
+ synthetic set v @37
+ parameters
+ requiredPositional _v @37
+ type: Map<T, int>
+ returnType: void
+ abstract class D @57
+ typeParameters
+ covariant U @59
+ defaultType: dynamic
+ covariant V @62
+ defaultType: dynamic
+ fields
+ synthetic v @-1
+ type: Map<V, U>
+ constructors
+ synthetic @-1
+ accessors
+ abstract get v @83
+ returnType: Map<V, U>
''');
}
@@ -9260,9 +19235,37 @@
var v = h((y) {});
''');
checkElementText(library, r'''
-typedef F = void Function(int Function(String) g/*(String s)*/);
-dynamic v;
-dynamic h(void Function(int Function(String)) f) {}
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @13
+ aliasedType: void Function(int Function(String))
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional g @-1
+ type: int Function(String)
+ parameters
+ requiredPositional s @-1
+ type: String
+ returnType: void
+ topLevelVariables
+ static v @53
+ type: dynamic
+ accessors
+ synthetic static get v @53
+ returnType: dynamic
+ synthetic static set v @53
+ parameters
+ requiredPositional _v @53
+ type: dynamic
+ returnType: void
+ functions
+ h @33
+ parameters
+ requiredPositional f @37
+ type: void Function(int Function(String))
+ aliasElement: self::@typeAlias::F
+ returnType: dynamic
''');
}
@@ -9275,12 +19278,45 @@
void f(int x, W g(V s));
}''');
checkElementText(library, r'''
-class C<T, U> extends D<U, int> {
- void f(int x, int Function(U) g) {}
-}
-abstract class D<V, W> {
- void f(int x, W Function(V) g/*(V s)*/);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ covariant U @11
+ defaultType: dynamic
+ supertype: D<U, int>
+ constructors
+ synthetic @-1
+ methods
+ f @41
+ parameters
+ requiredPositional x @47
+ type: int
+ requiredPositional g @50
+ type: int Function(U)
+ returnType: void
+ abstract class D @73
+ typeParameters
+ covariant V @75
+ defaultType: dynamic
+ covariant W @78
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ abstract f @90
+ parameters
+ requiredPositional x @96
+ type: int
+ requiredPositional g @101
+ type: W Function(V)
+ parameters
+ requiredPositional s @105
+ type: V
+ returnType: void
''');
}
@@ -9301,10 +19337,23 @@
}
''');
checkElementText(library, r'''
-import 'a.dart';
-class C extends D {
- void f(int x, int Function(String) g) {}
-}
+library
+ imports
+ a.dart
+ definingUnit
+ classes
+ class C @23
+ supertype: D
+ constructors
+ synthetic @-1
+ methods
+ f @44
+ parameters
+ requiredPositional x @50
+ type: int
+ requiredPositional g @53
+ type: int Function(String)
+ returnType: void
''');
}
@@ -9312,12 +19361,35 @@
var library = await checkLibrary('class C extends D { void f(int x, g) {} }'
' abstract class D { void f(int x, int g(String s)); }');
checkElementText(library, r'''
-class C extends D {
- void f(int x, int Function(String) g) {}
-}
-abstract class D {
- void f(int x, int Function(String) g/*(String s)*/);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ supertype: D
+ constructors
+ synthetic @-1
+ methods
+ f @25
+ parameters
+ requiredPositional x @31
+ type: int
+ requiredPositional g @34
+ type: int Function(String)
+ returnType: void
+ abstract class D @57
+ constructors
+ synthetic @-1
+ methods
+ abstract f @66
+ parameters
+ requiredPositional x @72
+ type: int
+ requiredPositional g @79
+ type: int Function(String)
+ parameters
+ requiredPositional s @88
+ type: String
+ returnType: void
''');
}
@@ -9327,8 +19399,30 @@
var v = f((x, y) {});
''');
checkElementText(library, r'''
-dynamic v;
-dynamic f(void Function(int, void Function()) g/*(int x, void Function() h)*/) {}
+library
+ definingUnit
+ topLevelVariables
+ static v @40
+ type: dynamic
+ accessors
+ synthetic static get v @40
+ returnType: dynamic
+ synthetic static set v @40
+ parameters
+ requiredPositional _v @40
+ type: dynamic
+ returnType: void
+ functions
+ f @0
+ parameters
+ requiredPositional g @7
+ type: void Function(int, void Function())
+ parameters
+ requiredPositional x @13
+ type: int
+ requiredPositional h @21
+ type: void Function()
+ returnType: dynamic
''');
}
@@ -9338,8 +19432,30 @@
var v = f(g: (x, y) {});
''');
checkElementText(library, r'''
-dynamic v;
-dynamic f({void Function(int, void Function()) g/*(int x, void Function() h)*/}) {}
+library
+ definingUnit
+ topLevelVariables
+ static v @42
+ type: dynamic
+ accessors
+ synthetic static get v @42
+ returnType: dynamic
+ synthetic static set v @42
+ parameters
+ requiredPositional _v @42
+ type: dynamic
+ returnType: void
+ functions
+ f @0
+ parameters
+ optionalNamed g @8
+ type: void Function(int, void Function())
+ parameters
+ requiredPositional x @14
+ type: int
+ requiredPositional h @22
+ type: void Function()
+ returnType: dynamic
''');
}
@@ -9347,12 +19463,37 @@
var library = await checkLibrary('class C extends D { void set f(g) {} }'
' abstract class D { void set f(int g(String s)); }');
checkElementText(library, r'''
-class C extends D {
- void set f(int Function(String) g) {}
-}
-abstract class D {
- void set f(int Function(String) g/*(String s)*/);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ supertype: D
+ fields
+ synthetic f @-1
+ type: int Function(String)
+ constructors
+ synthetic @-1
+ accessors
+ set f @29
+ parameters
+ requiredPositional g @31
+ type: int Function(String)
+ returnType: void
+ abstract class D @54
+ fields
+ synthetic f @-1
+ type: int Function(String)
+ constructors
+ synthetic @-1
+ accessors
+ abstract set f @67
+ parameters
+ requiredPositional g @73
+ type: int Function(String)
+ parameters
+ requiredPositional s @82
+ type: String
+ returnType: void
''');
}
@@ -9370,10 +19511,21 @@
}
''');
checkElementText(library, r'''
-import 'a.dart';
-class B extends A {
- dynamic m(Stream<dynamic> p) {}
-}
+library
+ imports
+ a.dart
+ definingUnit
+ classes
+ class B @23
+ supertype: A
+ constructors
+ synthetic @-1
+ methods
+ m @39
+ parameters
+ requiredPositional p @41
+ type: Stream<dynamic>
+ returnType: dynamic
''');
ClassElement b = library.definingCompilationUnit.classes[0];
ParameterElement p = b.methods[0].parameters[0];
@@ -9396,12 +19548,35 @@
var a2 = A.named();
''');
checkElementText(library, r'''
-class A {
- A();
- A.named();
-}
-A a1;
-A a2;
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ @12
+ named @21
+ periodOffset: 20
+ nameEnd: 26
+ topLevelVariables
+ static a1 @36
+ type: A
+ static a2 @50
+ type: A
+ accessors
+ synthetic static get a1 @36
+ returnType: A
+ synthetic static set a1 @36
+ parameters
+ requiredPositional _a1 @36
+ type: A
+ returnType: void
+ synthetic static get a2 @50
+ returnType: A
+ synthetic static set a2 @50
+ parameters
+ requiredPositional _a2 @50
+ type: A
+ returnType: void
''');
}
@@ -9418,9 +19593,30 @@
var a2 = foo.A.named();
''');
checkElementText(library, r'''
-import 'foo.dart' as foo;
-A a1;
-A a2;
+library
+ imports
+ foo.dart as foo @21
+ definingUnit
+ topLevelVariables
+ static a1 @30
+ type: A
+ static a2 @48
+ type: A
+ accessors
+ synthetic static get a1 @30
+ returnType: A
+ synthetic static set a1 @30
+ parameters
+ requiredPositional _a1 @30
+ type: A
+ returnType: void
+ synthetic static get a2 @48
+ returnType: A
+ synthetic static set a2 @48
+ parameters
+ requiredPositional _a2 @48
+ type: A
+ returnType: void
''');
}
@@ -9433,9 +19629,36 @@
var v = [f, g];
''');
checkElementText(library, r'''
-List<Object Function(int Function(String))> v;
-int f(int Function(String) x/*(String y)*/) {}
-String g(int Function(String) x/*(String y)*/) {}
+library
+ definingUnit
+ topLevelVariables
+ static v @71
+ type: List<Object Function(int Function(String))>
+ accessors
+ synthetic static get v @71
+ returnType: List<Object Function(int Function(String))>
+ synthetic static set v @71
+ parameters
+ requiredPositional _v @71
+ type: List<Object Function(int Function(String))>
+ returnType: void
+ functions
+ f @4
+ parameters
+ requiredPositional x @10
+ type: int Function(String)
+ parameters
+ requiredPositional y @19
+ type: String
+ returnType: int
+ g @39
+ parameters
+ requiredPositional x @45
+ type: int Function(String)
+ parameters
+ requiredPositional y @54
+ type: String
+ returnType: String
''');
}
@@ -9456,31 +19679,80 @@
}
''');
checkElementText(library, r'''
-abstract class A {
- int m();
-}
-abstract class B {
- String m();
-}
-abstract class C implements A, B {
-}
-abstract class D extends C {
- dynamic f;
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ constructors
+ synthetic @-1
+ methods
+ abstract m @25
+ returnType: int
+ abstract class B @48
+ constructors
+ synthetic @-1
+ methods
+ abstract m @61
+ returnType: String
+ abstract class C @84
+ interfaces
+ A
+ B
+ constructors
+ synthetic @-1
+ abstract class D @121
+ supertype: C
+ fields
+ f @141
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get f @141
+ returnType: dynamic
+ synthetic set f @141
+ parameters
+ requiredPositional _f @141
+ type: dynamic
+ returnType: void
''');
}
test_initializer_executable_with_return_type_from_closure() async {
var library = await checkLibrary('var v = () => 0;');
checkElementText(library, r'''
-int Function() v;
+library
+ definingUnit
+ topLevelVariables
+ static v @4
+ type: int Function()
+ accessors
+ synthetic static get v @4
+ returnType: int Function()
+ synthetic static set v @4
+ parameters
+ requiredPositional _v @4
+ type: int Function()
+ returnType: void
''');
}
test_initializer_executable_with_return_type_from_closure_await_dynamic() async {
var library = await checkLibrary('var v = (f) async => await f;');
checkElementText(library, r'''
-Future<dynamic> Function(dynamic) v;
+library
+ definingUnit
+ topLevelVariables
+ static v @4
+ type: Future<dynamic> Function(dynamic)
+ accessors
+ synthetic static get v @4
+ returnType: Future<dynamic> Function(dynamic)
+ synthetic static set v @4
+ parameters
+ requiredPositional _v @4
+ type: Future<dynamic> Function(dynamic)
+ returnType: void
''');
}
@@ -9491,8 +19763,21 @@
''');
// The analyzer type system over-flattens - see dartbug.com/31887
checkElementText(library, r'''
-import 'dart:async';
-Future<int> Function(Future<Future<Future<int>>>) v;
+library
+ imports
+ dart:async
+ definingUnit
+ topLevelVariables
+ static v @25
+ type: Future<int> Function(Future<Future<Future<int>>>)
+ accessors
+ synthetic static get v @25
+ returnType: Future<int> Function(Future<Future<Future<int>>>)
+ synthetic static set v @25
+ parameters
+ requiredPositional _v @25
+ type: Future<int> Function(Future<Future<Future<int>>>)
+ returnType: void
''');
}
@@ -9502,8 +19787,21 @@
var v = (Future<int> f) async => await f;
''');
checkElementText(library, r'''
-import 'dart:async';
-Future<int> Function(Future<int>) v;
+library
+ imports
+ dart:async
+ definingUnit
+ topLevelVariables
+ static v @25
+ type: Future<int> Function(Future<int>)
+ accessors
+ synthetic static get v @25
+ returnType: Future<int> Function(Future<int>)
+ synthetic static set v @25
+ parameters
+ requiredPositional _v @25
+ type: Future<int> Function(Future<int>)
+ returnType: void
''');
}
@@ -9513,8 +19811,21 @@
var v = (Future f) async => await f;
''');
checkElementText(library, r'''
-import 'dart:async';
-Future<dynamic> Function(Future<dynamic>) v;
+library
+ imports
+ dart:async
+ definingUnit
+ topLevelVariables
+ static v @25
+ type: Future<dynamic> Function(Future<dynamic>)
+ accessors
+ synthetic static get v @25
+ returnType: Future<dynamic> Function(Future<dynamic>)
+ synthetic static set v @25
+ parameters
+ requiredPositional _v @25
+ type: Future<dynamic> Function(Future<dynamic>)
+ returnType: void
''');
}
@@ -9525,9 +19836,23 @@
}
''');
checkElementText(library, r'''
-class C {
- int Function() v;
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ v @16
+ type: int Function()
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get v @16
+ returnType: int Function()
+ synthetic set v @16
+ parameters
+ requiredPositional _v @16
+ type: int Function()
+ returnType: void
''');
}
@@ -9539,7 +19864,11 @@
}
''');
checkElementText(library, r'''
-void f() {}
+library
+ definingUnit
+ functions
+ f @5
+ returnType: void
''');
}
@@ -9570,16 +19899,41 @@
}
''');
checkElementText(library, r'''
-import 'legacy.dart';
-class X1 extends LegacyDefault* {
- bool* ==(dynamic other) {}
-}
-class X2 extends LegacyObject* {
- bool* ==(Object* other) {}
-}
-class X3 extends LegacyInt* {
- bool* ==(int* other) {}
-}
+library
+ imports
+ legacy.dart
+ definingUnit
+ classes
+ class X1 @28
+ supertype: LegacyDefault*
+ constructors
+ synthetic @-1
+ methods
+ == @71
+ parameters
+ requiredPositional other @74
+ type: dynamic
+ returnType: bool*
+ class X2 @99
+ supertype: LegacyObject*
+ constructors
+ synthetic @-1
+ methods
+ == @140
+ parameters
+ requiredPositional other @143
+ type: Object*
+ returnType: bool*
+ class X3 @168
+ supertype: LegacyInt*
+ constructors
+ synthetic @-1
+ methods
+ == @206
+ parameters
+ requiredPositional other @209
+ type: int*
+ returnType: bool*
''');
}
@@ -9622,17 +19976,48 @@
}
''');
checkElementText(library, r'''
-import 'legacy.dart';
-import 'nullSafe.dart';
-class X1 extends LegacyDefault* implements NullSafeDefault* {
- bool* ==(dynamic other) {}
-}
-class X2 extends LegacyObject* implements NullSafeObject* {
- bool* ==(Object* other) {}
-}
-class X3 extends LegacyInt* implements NullSafeInt* {
- bool* ==(int* other) {}
-}
+library
+ imports
+ legacy.dart
+ nullSafe.dart
+ definingUnit
+ classes
+ class X1 @67
+ supertype: LegacyDefault*
+ interfaces
+ NullSafeDefault*
+ constructors
+ synthetic @-1
+ methods
+ == @136
+ parameters
+ requiredPositional other @139
+ type: dynamic
+ returnType: bool*
+ class X2 @164
+ supertype: LegacyObject*
+ interfaces
+ NullSafeObject*
+ constructors
+ synthetic @-1
+ methods
+ == @231
+ parameters
+ requiredPositional other @234
+ type: Object*
+ returnType: bool*
+ class X3 @259
+ supertype: LegacyInt*
+ interfaces
+ NullSafeInt*
+ constructors
+ synthetic @-1
+ methods
+ == @320
+ parameters
+ requiredPositional other @323
+ type: int*
+ returnType: bool*
''');
}
@@ -9661,16 +20046,41 @@
}
''');
checkElementText(library, r'''
-import 'nullSafe.dart';
-class X1 extends NullSafeDefault {
- bool ==(Object other) {}
-}
-class X2 extends NullSafeObject {
- bool ==(Object other) {}
-}
-class X3 extends NullSafeInt {
- bool ==(int other) {}
-}
+library
+ imports
+ nullSafe.dart
+ definingUnit
+ classes
+ class X1 @30
+ supertype: NullSafeDefault
+ constructors
+ synthetic @-1
+ methods
+ == @74
+ parameters
+ requiredPositional other @77
+ type: Object
+ returnType: bool
+ class X2 @102
+ supertype: NullSafeObject
+ constructors
+ synthetic @-1
+ methods
+ == @145
+ parameters
+ requiredPositional other @148
+ type: Object
+ returnType: bool
+ class X3 @173
+ supertype: NullSafeInt
+ constructors
+ synthetic @-1
+ methods
+ == @213
+ parameters
+ requiredPositional other @216
+ type: int
+ returnType: bool
''');
}
@@ -9680,9 +20090,30 @@
C c;
''');
checkElementText(library, r'''
-notSimplyBounded class C<S extends num = num, T extends C<S, T> = C<num, dynamic>> {
-}
-C<num, C<num, dynamic>> c;
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant S @8
+ bound: num
+ defaultType: num
+ covariant T @23
+ bound: C<S, T>
+ defaultType: C<num, dynamic>
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static c @47
+ type: C<num, C<num, dynamic>>
+ accessors
+ synthetic static get c @47
+ returnType: C<num, C<num, dynamic>>
+ synthetic static set c @47
+ parameters
+ requiredPositional _c @47
+ type: C<num, C<num, dynamic>>
+ returnType: void
''');
}
@@ -9696,13 +20127,50 @@
}
''');
checkElementText(library, r'''
-notSimplyBounded class C<T extends C<T> = C<dynamic>> {
-}
-class B {
- C<C<Object?>> c3;
-}
-C<C<dynamic>> c;
-C<C<Object?>> c2;
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant T @8
+ bound: C<T>
+ defaultType: C<dynamic>
+ constructors
+ synthetic @-1
+ class B @56
+ fields
+ c3 @66
+ type: C<C<Object?>>
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get c3 @66
+ returnType: C<C<Object?>>
+ synthetic set c3 @66
+ parameters
+ requiredPositional _c3 @66
+ type: C<C<Object?>>
+ returnType: void
+ topLevelVariables
+ static c @29
+ type: C<C<dynamic>>
+ static c2 @36
+ type: C<C<Object?>>
+ accessors
+ synthetic static get c @29
+ returnType: C<C<dynamic>>
+ synthetic static set c @29
+ parameters
+ requiredPositional _c @29
+ type: C<C<dynamic>>
+ returnType: void
+ synthetic static get c2 @36
+ returnType: C<C<Object?>>
+ synthetic static set c2 @36
+ parameters
+ requiredPositional _c2 @36
+ type: C<C<Object?>>
+ returnType: void
''');
}
@@ -9717,13 +20185,50 @@
}
''');
checkElementText(library, r'''
-notSimplyBounded class C<T extends C<T*>* = C<dynamic>*> {
-}
-class B {
- C<C<dynamic>*>* c3;
-}
-C<C<dynamic>*>* c;
-C<C<dynamic>*>* c2;
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant T @8
+ bound: C<T*>*
+ defaultType: C<dynamic>*
+ constructors
+ synthetic @-1
+ class B @56
+ fields
+ c3 @66
+ type: C<C<dynamic>*>*
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get c3 @66
+ returnType: C<C<dynamic>*>*
+ synthetic set c3 @66
+ parameters
+ requiredPositional _c3 @66
+ type: C<C<dynamic>*>*
+ returnType: void
+ topLevelVariables
+ static c @29
+ type: C<C<dynamic>*>*
+ static c2 @36
+ type: C<C<dynamic>*>*
+ accessors
+ synthetic static get c @29
+ returnType: C<C<dynamic>*>*
+ synthetic static set c @29
+ parameters
+ requiredPositional _c @29
+ type: C<C<dynamic>*>*
+ returnType: void
+ synthetic static get c2 @36
+ returnType: C<C<dynamic>*>*
+ synthetic static set c2 @36
+ parameters
+ requiredPositional _c2 @36
+ type: C<C<dynamic>*>*
+ returnType: void
''');
}
@@ -9733,9 +20238,30 @@
C c;
''');
checkElementText(library, r'''
-notSimplyBounded class C<T extends C<T, U> = C<dynamic, num>, U extends num = num> {
-}
-C<C<dynamic, num>, num> c;
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @6
+ typeParameters
+ covariant T @8
+ bound: C<T, U>
+ defaultType: C<dynamic, num>
+ covariant U @27
+ bound: num
+ defaultType: num
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static c @47
+ type: C<C<dynamic, num>, num>
+ accessors
+ synthetic static get c @47
+ returnType: C<C<dynamic, num>, num>
+ synthetic static set c @47
+ parameters
+ requiredPositional _c @47
+ type: C<C<dynamic, num>, num>
+ returnType: void
''');
}
@@ -9754,10 +20280,20 @@
}
''');
checkElementText(library, r'''
-import 'b.dart';
-class C {
- O Function(O) f() {}
-}
+library
+ imports
+ b.dart
+ definingUnit
+ classes
+ class C @23
+ constructors
+ synthetic @-1
+ methods
+ f @31
+ returnType: O Function(O)
+ aliasElement: a.dart::@typeAlias::F
+ aliasArguments
+ O
''');
}
@@ -9767,8 +20303,40 @@
F f;
''');
checkElementText(library, r'''
-typedef F<T extends num = num> = dynamic Function(T p);
-dynamic Function(num) f;
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @8
+ typeParameters
+ contravariant T @10
+ bound: num
+ defaultType: num
+ aliasedType: dynamic Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional p @-1
+ type: T
+ returnType: dynamic
+ topLevelVariables
+ static f @33
+ type: dynamic Function(num)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ num
+ accessors
+ synthetic static get f @33
+ returnType: dynamic Function(num)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ num
+ synthetic static set f @33
+ parameters
+ requiredPositional _f @33
+ type: dynamic Function(num)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ num
+ returnType: void
''');
}
@@ -9779,11 +20347,36 @@
B b;
''');
checkElementText(library, r'''
-class A<T> {
-}
-notSimplyBounded class B<T extends int Function() = int Function(), U extends A<T> = A<int Function()>> {
-}
-B<int Function(), A<int Function()>> b;
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ notSimplyBounded class B @20
+ typeParameters
+ covariant T @22
+ bound: int Function()
+ defaultType: int Function()
+ covariant U @48
+ bound: A<T>
+ defaultType: A<int Function()>
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static b @69
+ type: B<int Function(), A<int Function()>>
+ accessors
+ synthetic static get b @69
+ returnType: B<int Function(), A<int Function()>>
+ synthetic static set b @69
+ parameters
+ requiredPositional _b @69
+ type: B<int Function(), A<int Function()>>
+ returnType: void
''');
}
@@ -9793,8 +20386,42 @@
F f;
''');
checkElementText(library, r'''
-typedef F<T extends num = num> = S Function<S>(T p);
-S Function<S>(num) f;
+library
+ definingUnit
+ typeAliases
+ F @8
+ typeParameters
+ contravariant T @10
+ bound: num
+ defaultType: num
+ aliasedType: S Function<S>(T)
+ aliasedElement: GenericFunctionTypeElement
+ typeParameters
+ covariant S @-1
+ parameters
+ requiredPositional p @-1
+ type: T
+ returnType: S
+ topLevelVariables
+ static f @49
+ type: S Function<S>(num)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ num
+ accessors
+ synthetic static get f @49
+ returnType: S Function<S>(num)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ num
+ synthetic static set f @49
+ parameters
+ requiredPositional _f @49
+ type: S Function<S>(num)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ num
+ returnType: void
''');
}
@@ -9806,11 +20433,29 @@
class B<T extends num> {}
''');
checkElementText(library, r'''
-class A<R extends B<num> = B<num>> {
- final List<B<num>> values;
-}
-class B<T extends num = num> {
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant R @8
+ bound: B<num>
+ defaultType: B<num>
+ fields
+ final values @31
+ type: List<B<num>>
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get values @31
+ returnType: List<B<num>>
+ class B @55
+ typeParameters
+ covariant T @57
+ bound: num
+ defaultType: num
+ constructors
+ synthetic @-1
''');
}
@@ -9820,9 +20465,27 @@
C c;
''');
checkElementText(library, r'''
-class C<T extends num = num> {
-}
-C<num> c;
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ bound: num
+ defaultType: num
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static c @28
+ type: C<num>
+ accessors
+ synthetic static get c @28
+ returnType: C<num>
+ synthetic static set c @28
+ parameters
+ requiredPositional _c @28
+ type: C<num>
+ returnType: void
''');
}
@@ -9838,33 +20501,36 @@
@a.A.named
class C {}
''');
- checkElementText(
- library,
- r'''
-import 'package:test/a.dart' as a;
-class C {
-}
- metadata
- Annotation
- constructorName: SimpleIdentifier
- staticElement: package:test/a.dart::@class::A::@constructor::named
- staticType: null
- token: named
- element: package:test/a.dart::@class::A::@constructor::named
- name: PrefixedIdentifier
- identifier: SimpleIdentifier
- staticElement: package:test/a.dart::@class::A
- staticType: null
- token: A
- period: .
- prefix: SimpleIdentifier
- staticElement: self::@prefix::a
- staticType: null
- token: a
- staticElement: package:test/a.dart::@class::A
- staticType: null
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ imports
+ package:test/a.dart as a @19
+ definingUnit
+ classes
+ class C @39
+ metadata
+ Annotation
+ atSign.offset: 22
+ constructorName: SimpleIdentifier
+ staticElement: package:test/a.dart::@class::A::@constructor::named
+ staticType: null
+ token: named @27
+ element: package:test/a.dart::@class::A::@constructor::named
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: package:test/a.dart::@class::A
+ staticType: null
+ token: A @25
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::a
+ staticType: null
+ token: a @23
+ staticElement: package:test/a.dart::@class::A
+ staticType: null
+ constructors
+ synthetic @-1
+''');
}
test_invalid_annotation_unprefixed_constructor() async {
@@ -9879,29 +20545,32 @@
@A.named
class C {}
''');
- checkElementText(
- library,
- r'''
-import 'package:test/a.dart';
-class C {
-}
- metadata
- Annotation
- element: package:test/a.dart::@class::A::@constructor::named
- name: PrefixedIdentifier
- identifier: SimpleIdentifier
- staticElement: package:test/a.dart::@class::A::@constructor::named
- staticType: null
- token: named
- period: .
- prefix: SimpleIdentifier
- staticElement: package:test/a.dart::@class::A
- staticType: null
- token: A
- staticElement: package:test/a.dart::@class::A::@constructor::named
- staticType: null
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ imports
+ package:test/a.dart
+ definingUnit
+ classes
+ class C @32
+ metadata
+ Annotation
+ atSign.offset: 17
+ element: package:test/a.dart::@class::A::@constructor::named
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: package:test/a.dart::@class::A::@constructor::named
+ staticType: null
+ token: named @20
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: package:test/a.dart::@class::A
+ staticType: null
+ token: A @18
+ staticElement: package:test/a.dart::@class::A::@constructor::named
+ staticType: null
+ constructors
+ synthetic @-1
+''');
}
test_invalid_importPrefix_asTypeArgument() async {
@@ -9912,10 +20581,25 @@
}
''');
checkElementText(library, r'''
-import 'dart:async' as ppp;
-class C {
- List<dynamic> v;
-}
+library
+ imports
+ dart:async as ppp @23
+ definingUnit
+ classes
+ class C @34
+ fields
+ v @50
+ type: List<dynamic>
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get v @50
+ returnType: List<dynamic>
+ synthetic set v @50
+ parameters
+ requiredPositional _v @50
+ type: List<dynamic>
+ returnType: void
''');
}
@@ -9928,10 +20612,22 @@
foo([p = V]) {}
''');
checkElementText(library, r'''
-import 'a.dart';
-import 'b.dart';
-dynamic foo([dynamic p =
- V/*location: null*/]) {}
+library
+ imports
+ a.dart
+ b.dart
+ definingUnit
+ functions
+ foo @34
+ parameters
+ optionalPositional p @39
+ type: dynamic
+ constantInitializer
+ SimpleIdentifier
+ staticElement: <null>
+ staticType: dynamic
+ token: V @-1
+ returnType: dynamic
''');
}
@@ -9947,9 +20643,21 @@
foo([p = V]) {}
''');
checkElementText(library, r'''
-import 'c.dart';
-dynamic foo([dynamic p =
- V/*location: a.dart;V*/]) {}
+library
+ imports
+ c.dart
+ definingUnit
+ functions
+ foo @17
+ parameters
+ optionalPositional p @22
+ type: dynamic
+ constantInitializer
+ SimpleIdentifier
+ staticElement: a.dart::@function::V
+ staticType: dynamic Function()
+ token: V @-1
+ returnType: dynamic
''');
}
@@ -9960,10 +20668,32 @@
var V;
''');
checkElementText(library, r'''
-dynamic V;
-dynamic foo([dynamic p =
- V/*location: test.dart;V?*/]) {}
-dynamic V() {}
+library
+ definingUnit
+ topLevelVariables
+ static V @27
+ type: dynamic
+ accessors
+ synthetic static get V @27
+ returnType: dynamic
+ synthetic static set V @27
+ parameters
+ requiredPositional _V @27
+ type: dynamic
+ returnType: void
+ functions
+ foo @0
+ parameters
+ optionalPositional p @5
+ type: dynamic
+ constantInitializer
+ SimpleIdentifier
+ staticElement: self::@getter::V
+ staticType: dynamic
+ token: V @-1
+ returnType: dynamic
+ V @16
+ returnType: dynamic
''');
}
@@ -9975,10 +20705,30 @@
}
''');
checkElementText(library, r'''
-class C {
- int foo;
- void set bar(final dynamic this.foo) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ foo @16
+ type: int
+ synthetic bar @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get foo @16
+ returnType: int
+ synthetic set foo @16
+ parameters
+ requiredPositional _foo @16
+ type: int
+ returnType: void
+ set bar @32
+ parameters
+ requiredPositional final this.foo @41
+ type: dynamic
+ returnType: void
''');
}
@@ -9989,9 +20739,21 @@
}
''');
checkElementText(library, r'''
-class C {
- void set x(final dynamic this.x) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic x @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ set x @16
+ parameters
+ requiredPositional final this.x @23
+ type: dynamic
+ returnType: void
''');
}
@@ -10014,26 +20776,30 @@
part ':[invaliduri]';
''');
checkElementText(library, r'''
-import '<unresolved>';
-import '<unresolved>';
-import 'a1.dart';
-import '<unresolved>';
-import '<unresolved>';
-export '<unresolved>';
-export '<unresolved>';
-export 'a2.dart';
-export '<unresolved>';
-export '<unresolved>';
-part 'a3.dart';
---------------------
-unit: a3.dart
-
+library
+ imports
+ <unresolved>
+ <unresolved>
+ a1.dart
+ <unresolved>
+ <unresolved>
+ exports
+ <unresolved>
+ <unresolved>
+ a2.dart
+ <unresolved>
+ <unresolved>
+ definingUnit
+ parts
+ a3.dart
''');
}
test_library() async {
var library = await checkLibrary('');
checkElementText(library, r'''
+library
+ definingUnit
''');
}
@@ -10044,9 +20810,11 @@
library test;
''');
checkElementText(library, r'''
-/// aaa
-/// bbb
-library test;
+library
+ name: test
+ nameOffset: 24
+ documentationComment: /// aaa\n/// bbb
+ definingUnit
''');
}
@@ -10058,25 +20826,31 @@
*/
library test;''');
checkElementText(library, r'''
-/**
- * aaa
- * bbb
- */
-library test;
+library
+ name: test
+ nameOffset: 30
+ documentationComment: /**\n * aaa\n * bbb\n */
+ definingUnit
''');
}
test_library_name_with_spaces() async {
var library = await checkLibrary('library foo . bar ;');
checkElementText(library, r'''
-library foo.bar;
+library
+ name: foo.bar
+ nameOffset: 8
+ definingUnit
''');
}
test_library_named() async {
var library = await checkLibrary('library foo.bar;');
checkElementText(library, r'''
-library foo.bar;
+library
+ name: foo.bar
+ nameOffset: 8
+ definingUnit
''');
}
@@ -10090,7 +20864,11 @@
}
''');
checkElementText(library, r'''
-dynamic f() {}
+library
+ definingUnit
+ functions
+ f @0
+ returnType: dynamic
''');
}
@@ -10103,9 +20881,12 @@
}
''');
checkElementText(library, r'''
-class C {
- C();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ @12
''');
}
@@ -10118,9 +20899,15 @@
}
''');
checkElementText(library, r'''
-class C {
- dynamic m() {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ m @12
+ returnType: dynamic
''');
}
@@ -10131,7 +20918,14 @@
}
''');
checkElementText(library, r'''
-dynamic get g {}
+library
+ definingUnit
+ topLevelVariables
+ synthetic static g @-1
+ type: dynamic
+ accessors
+ get g @4
+ returnType: dynamic
''');
}
@@ -10148,9 +20942,12 @@
}
''', allowErrors: true);
checkElementText(library, r'''
-class C {
- C();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ @12
''');
}
@@ -10167,9 +20964,15 @@
}
''', allowErrors: true);
checkElementText(library, r'''
-class C {
- dynamic m() {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ m @12
+ returnType: dynamic
''');
}
@@ -10184,15 +20987,23 @@
}
''', allowErrors: true);
checkElementText(library, r'''
-dynamic main() {}
+library
+ definingUnit
+ functions
+ main @0
+ returnType: dynamic
''');
}
test_main_class() async {
var library = await checkLibrary('class main {}');
checkElementText(library, r'''
-class main {
-}
+library
+ definingUnit
+ classes
+ class main @6
+ constructors
+ synthetic @-1
''');
}
@@ -10200,13 +21011,27 @@
var library =
await checkLibrary('class main = C with D; class C {} class D {}');
checkElementText(library, r'''
-class alias main extends C with D {
- synthetic main() : super();
-}
-class C {
-}
-class D {
-}
+library
+ definingUnit
+ classes
+ class alias main @6
+ supertype: C
+ mixins
+ D
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::C::@constructor::•
+ class C @29
+ constructors
+ synthetic @-1
+ class D @40
+ constructors
+ synthetic @-1
''');
}
@@ -10214,7 +21039,10 @@
addLibrarySource('/a.dart', 'class main = C with D; class C {} class D {}');
var library = await checkLibrary('export "a.dart";');
checkElementText(library, r'''
-export 'a.dart';
+library
+ exports
+ a.dart
+ definingUnit
''');
}
@@ -10222,14 +21050,24 @@
addLibrarySource('/a.dart', 'class main {}');
var library = await checkLibrary('export "a.dart";');
checkElementText(library, r'''
-export 'a.dart';
+library
+ exports
+ a.dart
+ definingUnit
''');
}
test_main_getter() async {
var library = await checkLibrary('get main => null;');
checkElementText(library, r'''
-dynamic get main {}
+library
+ definingUnit
+ topLevelVariables
+ synthetic static main @-1
+ type: dynamic
+ accessors
+ get main @4
+ returnType: dynamic
''');
}
@@ -10237,14 +21075,23 @@
addLibrarySource('/a.dart', 'get main => null;');
var library = await checkLibrary('export "a.dart";');
checkElementText(library, r'''
-export 'a.dart';
+library
+ exports
+ a.dart
+ definingUnit
''');
}
test_main_typedef() async {
var library = await checkLibrary('typedef main();');
checkElementText(library, r'''
-typedef main = dynamic Function();
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased main @8
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
''');
}
@@ -10252,14 +21099,29 @@
addLibrarySource('/a.dart', 'typedef main();');
var library = await checkLibrary('export "a.dart";');
checkElementText(library, r'''
-export 'a.dart';
+library
+ exports
+ a.dart
+ definingUnit
''');
}
test_main_variable() async {
var library = await checkLibrary('var main;');
checkElementText(library, r'''
-dynamic main;
+library
+ definingUnit
+ topLevelVariables
+ static main @4
+ type: dynamic
+ accessors
+ synthetic static get main @4
+ returnType: dynamic
+ synthetic static set main @4
+ parameters
+ requiredPositional _main @4
+ type: dynamic
+ returnType: void
''');
}
@@ -10267,7 +21129,10 @@
addLibrarySource('/a.dart', 'var main;');
var library = await checkLibrary('export "a.dart";');
checkElementText(library, r'''
-export 'a.dart';
+library
+ exports
+ a.dart
+ definingUnit
''');
}
@@ -10279,10 +21144,17 @@
}
''');
checkElementText(library, r'''
-import 'dart:async';
-class C {
- Future<dynamic> f() async {}
-}
+library
+ imports
+ dart:async
+ definingUnit
+ classes
+ class C @27
+ constructors
+ synthetic @-1
+ methods
+ f @40 async
+ returnType: Future<dynamic>
''');
}
@@ -10294,10 +21166,17 @@
}
''');
checkElementText(library, r'''
-import 'dart:async';
-class C {
- Stream<dynamic> f() async* {}
-}
+library
+ imports
+ dart:async
+ definingUnit
+ classes
+ class C @27
+ constructors
+ synthetic @-1
+ methods
+ f @40 async*
+ returnType: Stream<dynamic>
''');
}
@@ -10310,9 +21189,15 @@
}
''');
checkElementText(library, r'''
-class C {
- Iterable<int> f() sync* {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ f @26 sync*
+ returnType: Iterable<int>
''');
}
@@ -10329,26 +21214,43 @@
as FieldElement;
expect(x.metadata, hasLength(1));
// Check details.
- checkElementText(
- library,
- r'''
-class C {
- int x;
- metadata
- Annotation
- element: self::@getter::a
- name: SimpleIdentifier
- staticElement: self::@getter::a
- staticType: null
- token: a
-}
-const int a;
- constantInitializer
- IntegerLiteral
- literal: 0
- staticType: int
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @19
+ fields
+ x @34
+ metadata
+ Annotation
+ atSign.offset: 25
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @26
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @34
+ returnType: int
+ synthetic set x @34
+ parameters
+ requiredPositional _x @34
+ type: int
+ returnType: void
+ topLevelVariables
+ static const a @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @10
+ staticType: int
+ accessors
+ synthetic static get a @6
+ returnType: int
+''');
}
test_metadata_class_scope() async {
@@ -10362,49 +21264,64 @@
void bar() {}
}
''');
- checkElementText(
- library,
- r'''
-class C {
- static const int foo;
- constantInitializer
- IntegerLiteral
- literal: 1
- staticType: int
- void bar() {}
- metadata
- Annotation
- element: self::@class::C::@getter::foo
- name: SimpleIdentifier
- staticElement: self::@class::C::@getter::foo
- staticType: null
- token: foo
-}
- metadata
- Annotation
- element: self::@getter::foo
- name: SimpleIdentifier
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- typeParameters
- T
- bound: null
- defaultType: dynamic
- metadata
- Annotation
- element: self::@getter::foo
- name: SimpleIdentifier
- staticElement: self::@getter::foo
- staticType: null
- token: foo
-const int foo;
- constantInitializer
- IntegerLiteral
- literal: 0
- staticType: int
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @27
+ metadata
+ Annotation
+ atSign.offset: 16
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @17
+ typeParameters
+ covariant T @34
+ defaultType: dynamic
+ metadata
+ Annotation
+ atSign.offset: 29
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @30
+ fields
+ static const foo @54
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 1 @60
+ staticType: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get foo @54
+ returnType: int
+ methods
+ bar @77
+ metadata
+ Annotation
+ atSign.offset: 65
+ element: self::@class::C::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@class::C::@getter::foo
+ staticType: null
+ token: foo @66
+ returnType: void
+ topLevelVariables
+ static const foo @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @12
+ staticType: int
+ accessors
+ synthetic static get foo @6
+ returnType: int
+''');
}
test_metadata_classDeclaration() async {
@@ -10415,14 +21332,45 @@
@b
class C {}''');
checkElementText(library, r'''
-@
- a/*location: test.dart;a?*/
-@
- b/*location: test.dart;b?*/
-class C {
-}
-const dynamic a = null;
-const dynamic b = null;
+library
+ definingUnit
+ classes
+ class C @44
+ metadata
+ Annotation
+ atSign.offset: 32
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @33
+ Annotation
+ atSign.offset: 35
+ element: self::@getter::b
+ name: SimpleIdentifier
+ staticElement: self::@getter::b
+ staticType: null
+ token: b @36
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ static const b @22
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
+ synthetic static get b @22
+ returnType: dynamic
''');
}
@@ -10430,16 +21378,45 @@
var library = await checkLibrary(
'const a = null; @a class C = D with E; class D {} class E {}');
checkElementText(library, r'''
-@
- a/*location: test.dart;a?*/
-class alias C extends D with E {
- synthetic C() : super();
-}
-class D {
-}
-class E {
-}
-const dynamic a = null;
+library
+ definingUnit
+ classes
+ class alias C @25
+ metadata
+ Annotation
+ atSign.offset: 16
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @17
+ supertype: D
+ mixins
+ E
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::D::@constructor::•
+ class D @45
+ constructors
+ synthetic @-1
+ class E @56
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
''');
}
@@ -10452,36 +21429,45 @@
@A.named(0)
class C {}
''');
- checkElementText(
- library,
- r'''
-class A {
- const A.named(int _);
-}
-class C {
-}
- metadata
- Annotation
- arguments: ArgumentList
- arguments
- IntegerLiteral
- literal: 0
- staticType: int
- element: self::@class::A::@constructor::named
- name: PrefixedIdentifier
- identifier: SimpleIdentifier
- staticElement: self::@class::A::@constructor::named
- staticType: null
- token: named
- period: .
- prefix: SimpleIdentifier
- staticElement: self::@class::A
- staticType: null
- token: A
- staticElement: self::@class::A::@constructor::named
- staticType: null
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ const named @20
+ periodOffset: 19
+ nameEnd: 25
+ parameters
+ requiredPositional _ @30
+ type: int
+ class C @54
+ metadata
+ Annotation
+ arguments: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @45
+ staticType: int
+ leftParenthesis: ( @44
+ rightParenthesis: ) @46
+ atSign.offset: 36
+ element: self::@class::A::@constructor::named
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: self::@class::A::@constructor::named
+ staticType: null
+ token: named @39
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @37
+ staticElement: self::@class::A::@constructor::named
+ staticType: null
+ constructors
+ synthetic @-1
+''');
}
test_metadata_constructor_call_named_generic_inference() async {
@@ -10494,46 +21480,54 @@
@A.named(0)
class C {}
''');
- checkElementText(
- library,
- r'''
-class A {
- const A.named(T _);
-}
- typeParameters
- T
- bound: null
- defaultType: dynamic
-class C {
-}
- metadata
- Annotation
- arguments: ArgumentList
- arguments
- IntegerLiteral
- literal: 0
- staticType: int
- element: ConstructorMember
- base: self::@class::A::@constructor::named
- substitution: {T: int}
- name: PrefixedIdentifier
- identifier: SimpleIdentifier
- staticElement: ConstructorMember
- base: self::@class::A::@constructor::named
- substitution: {T: int}
- staticType: null
- token: named
- period: .
- prefix: SimpleIdentifier
- staticElement: self::@class::A
- staticType: null
- token: A
- staticElement: ConstructorMember
- base: self::@class::A::@constructor::named
- substitution: {T: int}
- staticType: null
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const named @23
+ periodOffset: 22
+ nameEnd: 28
+ parameters
+ requiredPositional _ @31
+ type: T
+ class C @56
+ metadata
+ Annotation
+ arguments: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @47
+ staticType: int
+ leftParenthesis: ( @46
+ rightParenthesis: ) @48
+ atSign.offset: 38
+ element: ConstructorMember
+ base: self::@class::A::@constructor::named
+ substitution: {T: int}
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: ConstructorMember
+ base: self::@class::A::@constructor::named
+ substitution: {T: int}
+ staticType: null
+ token: named @41
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @39
+ staticElement: ConstructorMember
+ base: self::@class::A::@constructor::named
+ substitution: {T: int}
+ staticType: null
+ constructors
+ synthetic @-1
+''');
}
test_metadata_constructor_call_named_generic_typeArguments() async {
@@ -10546,44 +21540,51 @@
@A<int>.named()
class C {}
''');
- checkElementText(
- library,
- r'''
-class A {
- const A.named();
-}
- typeParameters
- T
- bound: null
- defaultType: dynamic
-class C {
-}
- metadata
- Annotation
- arguments: ArgumentList
- constructorName: SimpleIdentifier
- staticElement: ConstructorMember
- base: self::@class::A::@constructor::named
- substitution: {T: int}
- staticType: null
- token: named
- element: ConstructorMember
- base: self::@class::A::@constructor::named
- substitution: {T: int}
- name: SimpleIdentifier
- staticElement: self::@class::A
- staticType: null
- token: A
- typeArguments: TypeArgumentList
- arguments
- TypeName
- name: SimpleIdentifier
- staticElement: dart:core::@class::int
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const named @23
+ periodOffset: 22
+ nameEnd: 28
+ class C @57
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @48
+ rightParenthesis: ) @49
+ atSign.offset: 35
+ constructorName: SimpleIdentifier
+ staticElement: ConstructorMember
+ base: self::@class::A::@constructor::named
+ substitution: {T: int}
staticType: null
- token: int
- type: int
-''',
- withResolvedAst: true);
+ token: named @43
+ element: ConstructorMember
+ base: self::@class::A::@constructor::named
+ substitution: {T: int}
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @36
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @38
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ constructors
+ synthetic @-1
+''');
}
test_metadata_constructor_call_named_generic_typeArguments_disabledGenericMetadata() async {
@@ -10595,44 +21596,51 @@
@A<int>.named()
class C {}
''');
- checkElementText(
- library,
- r'''
-class A {
- const A.named();
-}
- typeParameters
- T
- bound: null
- defaultType: dynamic
-class C {
-}
- metadata
- Annotation
- arguments: ArgumentList
- constructorName: SimpleIdentifier
- staticElement: ConstructorMember
- base: self::@class::A::@constructor::named
- substitution: {T: dynamic}
- staticType: null
- token: named
- element: ConstructorMember
- base: self::@class::A::@constructor::named
- substitution: {T: dynamic}
- name: SimpleIdentifier
- staticElement: self::@class::A
- staticType: null
- token: A
- typeArguments: TypeArgumentList
- arguments
- TypeName
- name: SimpleIdentifier
- staticElement: dart:core::@class::int
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const named @23
+ periodOffset: 22
+ nameEnd: 28
+ class C @57
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @48
+ rightParenthesis: ) @49
+ atSign.offset: 35
+ constructorName: SimpleIdentifier
+ staticElement: ConstructorMember
+ base: self::@class::A::@constructor::named
+ substitution: {T: dynamic}
staticType: null
- token: int
- type: int
-''',
- withResolvedAst: true);
+ token: named @43
+ element: ConstructorMember
+ base: self::@class::A::@constructor::named
+ substitution: {T: dynamic}
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @36
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @38
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ constructors
+ synthetic @-1
+''');
}
test_metadata_constructor_call_named_prefixed() async {
@@ -10647,38 +21655,43 @@
@foo.A.named(0)
class C {}
''');
- checkElementText(
- library,
- r'''
-import 'package:test/foo.dart' as foo;
-class C {
-}
- metadata
- Annotation
- arguments: ArgumentList
- arguments
- IntegerLiteral
- literal: 0
- staticType: int
- constructorName: SimpleIdentifier
- staticElement: package:test/foo.dart::@class::A::@constructor::named
- staticType: null
- token: named
- element: package:test/foo.dart::@class::A::@constructor::named
- name: PrefixedIdentifier
- identifier: SimpleIdentifier
- staticElement: package:test/foo.dart::@class::A
- staticType: null
- token: A
- period: .
- prefix: SimpleIdentifier
- staticElement: self::@prefix::foo
- staticType: null
- token: foo
- staticElement: package:test/foo.dart::@class::A
- staticType: null
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ imports
+ package:test/foo.dart as foo @21
+ definingUnit
+ classes
+ class C @48
+ metadata
+ Annotation
+ arguments: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @39
+ staticType: int
+ leftParenthesis: ( @38
+ rightParenthesis: ) @40
+ atSign.offset: 26
+ constructorName: SimpleIdentifier
+ staticElement: package:test/foo.dart::@class::A::@constructor::named
+ staticType: null
+ token: named @33
+ element: package:test/foo.dart::@class::A::@constructor::named
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: package:test/foo.dart::@class::A
+ staticType: null
+ token: A @31
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::foo
+ staticType: null
+ token: foo @27
+ staticElement: package:test/foo.dart::@class::A
+ staticType: null
+ constructors
+ synthetic @-1
+''');
}
test_metadata_constructor_call_named_prefixed_generic_inference() async {
@@ -10694,42 +21707,47 @@
@foo.A.named(0)
class C {}
''');
- checkElementText(
- library,
- r'''
-import 'package:test/foo.dart' as foo;
-class C {
-}
- metadata
- Annotation
- arguments: ArgumentList
- arguments
- IntegerLiteral
- literal: 0
- staticType: int
- constructorName: SimpleIdentifier
- staticElement: ConstructorMember
- base: package:test/foo.dart::@class::A::@constructor::named
- substitution: {T: int}
- staticType: null
- token: named
- element: ConstructorMember
- base: package:test/foo.dart::@class::A::@constructor::named
- substitution: {T: int}
- name: PrefixedIdentifier
- identifier: SimpleIdentifier
- staticElement: package:test/foo.dart::@class::A
- staticType: null
- token: A
- period: .
- prefix: SimpleIdentifier
- staticElement: self::@prefix::foo
- staticType: null
- token: foo
- staticElement: package:test/foo.dart::@class::A
- staticType: null
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ imports
+ package:test/foo.dart as foo @21
+ definingUnit
+ classes
+ class C @48
+ metadata
+ Annotation
+ arguments: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @39
+ staticType: int
+ leftParenthesis: ( @38
+ rightParenthesis: ) @40
+ atSign.offset: 26
+ constructorName: SimpleIdentifier
+ staticElement: ConstructorMember
+ base: package:test/foo.dart::@class::A::@constructor::named
+ substitution: {T: int}
+ staticType: null
+ token: named @33
+ element: ConstructorMember
+ base: package:test/foo.dart::@class::A::@constructor::named
+ substitution: {T: int}
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: package:test/foo.dart::@class::A
+ staticType: null
+ token: A @31
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::foo
+ staticType: null
+ token: foo @27
+ staticElement: package:test/foo.dart::@class::A
+ staticType: null
+ constructors
+ synthetic @-1
+''');
}
test_metadata_constructor_call_named_prefixed_generic_typeArguments() async {
@@ -10745,46 +21763,53 @@
@foo.A<int>.named()
class C {}
''');
- checkElementText(
- library,
- r'''
-import 'package:test/foo.dart' as foo;
-class C {
-}
- metadata
- Annotation
- arguments: ArgumentList
- constructorName: SimpleIdentifier
- staticElement: ConstructorMember
- base: package:test/foo.dart::@class::A::@constructor::named
- substitution: {T: int}
- staticType: null
- token: named
- element: ConstructorMember
- base: package:test/foo.dart::@class::A::@constructor::named
- substitution: {T: int}
- name: PrefixedIdentifier
- identifier: SimpleIdentifier
- staticElement: package:test/foo.dart::@class::A
- staticType: null
- token: A
- period: .
- prefix: SimpleIdentifier
- staticElement: self::@prefix::foo
- staticType: null
- token: foo
- staticElement: package:test/foo.dart::@class::A
- staticType: null
- typeArguments: TypeArgumentList
- arguments
- TypeName
- name: SimpleIdentifier
- staticElement: dart:core::@class::int
+ checkElementText(library, r'''
+library
+ imports
+ package:test/foo.dart as foo @21
+ definingUnit
+ classes
+ class C @52
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @43
+ rightParenthesis: ) @44
+ atSign.offset: 26
+ constructorName: SimpleIdentifier
+ staticElement: ConstructorMember
+ base: package:test/foo.dart::@class::A::@constructor::named
+ substitution: {T: int}
staticType: null
- token: int
- type: int
-''',
- withResolvedAst: true);
+ token: named @38
+ element: ConstructorMember
+ base: package:test/foo.dart::@class::A::@constructor::named
+ substitution: {T: int}
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: package:test/foo.dart::@class::A
+ staticType: null
+ token: A @31
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::foo
+ staticType: null
+ token: foo @27
+ staticElement: package:test/foo.dart::@class::A
+ staticType: null
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @33
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ constructors
+ synthetic @-1
+''');
}
test_metadata_constructor_call_named_synthetic_ofClassAlias_generic() async {
@@ -10800,55 +21825,69 @@
@C.named()
class D {}
''');
- checkElementText(
- library,
- r'''
-class A {
- const A.named();
-}
-class alias C extends A with B {
- synthetic const C.named();
- constantInitializers
- SuperConstructorInvocation
- argumentList: ArgumentList
- constructorName: SimpleIdentifier
- staticElement: self::@class::A::@constructor::named
- staticType: null
- token: named
- staticElement: self::@class::A::@constructor::named
-}
- typeParameters
- T
- bound: null
- defaultType: dynamic
-class D {
-}
- metadata
- Annotation
- arguments: ArgumentList
- element: ConstructorMember
- base: self::@class::C::@constructor::named
- substitution: {T: dynamic}
- name: PrefixedIdentifier
- identifier: SimpleIdentifier
- staticElement: ConstructorMember
- base: self::@class::C::@constructor::named
- substitution: {T: dynamic}
- staticType: null
- token: named
- period: .
- prefix: SimpleIdentifier
- staticElement: self::@class::C
- staticType: null
- token: C
- staticElement: ConstructorMember
- base: self::@class::C::@constructor::named
- substitution: {T: dynamic}
- staticType: null
-mixin B on Object {
-}
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ const named @20
+ periodOffset: 19
+ nameEnd: 25
+ class alias C @50
+ typeParameters
+ covariant T @52
+ defaultType: dynamic
+ supertype: A
+ mixins
+ B
+ constructors
+ synthetic const named @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: SimpleIdentifier
+ staticElement: self::@class::A::@constructor::named
+ staticType: null
+ token: named @-1
+ staticElement: self::@class::A::@constructor::named
+ class D @85
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @76
+ rightParenthesis: ) @77
+ atSign.offset: 68
+ element: ConstructorMember
+ base: self::@class::C::@constructor::named
+ substitution: {T: dynamic}
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: ConstructorMember
+ base: self::@class::C::@constructor::named
+ substitution: {T: dynamic}
+ staticType: null
+ token: named @71
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @69
+ staticElement: ConstructorMember
+ base: self::@class::C::@constructor::named
+ substitution: {T: dynamic}
+ staticType: null
+ constructors
+ synthetic @-1
+ mixins
+ mixin B @38
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
+''');
}
test_metadata_constructor_call_unnamed() async {
@@ -10860,28 +21899,35 @@
@A(0)
class C {}
''');
- checkElementText(
- library,
- r'''
-class A {
- const A(int _);
-}
-class C {
-}
- metadata
- Annotation
- arguments: ArgumentList
- arguments
- IntegerLiteral
- literal: 0
- staticType: int
- element: self::@class::A::@constructor::•
- name: SimpleIdentifier
- staticElement: self::@class::A
- staticType: null
- token: A
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ const @18
+ parameters
+ requiredPositional _ @24
+ type: int
+ class C @42
+ metadata
+ Annotation
+ arguments: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @33
+ staticType: int
+ leftParenthesis: ( @32
+ rightParenthesis: ) @34
+ atSign.offset: 30
+ element: self::@class::A::@constructor::•
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @31
+ constructors
+ synthetic @-1
+''');
}
test_metadata_constructor_call_unnamed_generic_inference() async {
@@ -10894,34 +21940,40 @@
@A(0)
class C {}
''');
- checkElementText(
- library,
- r'''
-class A {
- const A(T _);
-}
- typeParameters
- T
- bound: null
- defaultType: dynamic
-class C {
-}
- metadata
- Annotation
- arguments: ArgumentList
- arguments
- IntegerLiteral
- literal: 0
- staticType: int
- element: ConstructorMember
- base: self::@class::A::@constructor::•
- substitution: {T: int}
- name: SimpleIdentifier
- staticElement: self::@class::A
- staticType: null
- token: A
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ parameters
+ requiredPositional _ @25
+ type: T
+ class C @44
+ metadata
+ Annotation
+ arguments: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @35
+ staticType: int
+ leftParenthesis: ( @34
+ rightParenthesis: ) @36
+ atSign.offset: 32
+ element: ConstructorMember
+ base: self::@class::A::@constructor::•
+ substitution: {T: int}
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @33
+ constructors
+ synthetic @-1
+''');
}
test_metadata_constructor_call_unnamed_generic_typeArguments() async {
@@ -10934,38 +21986,43 @@
@A<int>()
class C {}
''');
- checkElementText(
- library,
- r'''
-class A {
- const A();
-}
- typeParameters
- T
- bound: null
- defaultType: dynamic
-class C {
-}
- metadata
- Annotation
- arguments: ArgumentList
- element: ConstructorMember
- base: self::@class::A::@constructor::•
- substitution: {T: int}
- name: SimpleIdentifier
- staticElement: self::@class::A
- staticType: null
- token: A
- typeArguments: TypeArgumentList
- arguments
- TypeName
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ class C @45
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @36
+ rightParenthesis: ) @37
+ atSign.offset: 29
+ element: ConstructorMember
+ base: self::@class::A::@constructor::•
+ substitution: {T: int}
name: SimpleIdentifier
- staticElement: dart:core::@class::int
+ staticElement: self::@class::A
staticType: null
- token: int
- type: int
-''',
- withResolvedAst: true);
+ token: A @30
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @32
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ constructors
+ synthetic @-1
+''');
}
test_metadata_constructor_call_unnamed_prefixed() async {
@@ -10973,34 +22030,39 @@
addLibrarySource('/home/test/lib/foo.dart', 'class A { const A(_); }');
var library =
await checkLibrary('import "foo.dart" as foo; @foo.A(0) class C {}');
- checkElementText(
- library,
- r'''
-import 'package:test/foo.dart' as foo;
-class C {
-}
- metadata
- Annotation
- arguments: ArgumentList
- arguments
- IntegerLiteral
- literal: 0
- staticType: int
- element: package:test/foo.dart::@class::A::@constructor::•
- name: PrefixedIdentifier
- identifier: SimpleIdentifier
- staticElement: package:test/foo.dart::@class::A
- staticType: null
- token: A
- period: .
- prefix: SimpleIdentifier
- staticElement: self::@prefix::foo
- staticType: null
- token: foo
- staticElement: package:test/foo.dart::@class::A
- staticType: null
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ imports
+ package:test/foo.dart as foo @21
+ definingUnit
+ classes
+ class C @42
+ metadata
+ Annotation
+ arguments: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @33
+ staticType: int
+ leftParenthesis: ( @32
+ rightParenthesis: ) @34
+ atSign.offset: 26
+ element: package:test/foo.dart::@class::A::@constructor::•
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: package:test/foo.dart::@class::A
+ staticType: null
+ token: A @31
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::foo
+ staticType: null
+ token: foo @27
+ staticElement: package:test/foo.dart::@class::A
+ staticType: null
+ constructors
+ synthetic @-1
+''');
}
test_metadata_constructor_call_unnamed_prefixed_generic_inference() async {
@@ -11016,36 +22078,41 @@
@foo.A(0)
class C {}
''');
- checkElementText(
- library,
- r'''
-import 'package:test/foo.dart' as foo;
-class C {
-}
- metadata
- Annotation
- arguments: ArgumentList
- arguments
- IntegerLiteral
- literal: 0
- staticType: int
- element: ConstructorMember
- base: package:test/foo.dart::@class::A::@constructor::•
- substitution: {T: int}
- name: PrefixedIdentifier
- identifier: SimpleIdentifier
- staticElement: package:test/foo.dart::@class::A
- staticType: null
- token: A
- period: .
- prefix: SimpleIdentifier
- staticElement: self::@prefix::foo
- staticType: null
- token: foo
- staticElement: package:test/foo.dart::@class::A
- staticType: null
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ imports
+ package:test/foo.dart as foo @21
+ definingUnit
+ classes
+ class C @42
+ metadata
+ Annotation
+ arguments: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @33
+ staticType: int
+ leftParenthesis: ( @32
+ rightParenthesis: ) @34
+ atSign.offset: 26
+ element: ConstructorMember
+ base: package:test/foo.dart::@class::A::@constructor::•
+ substitution: {T: int}
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: package:test/foo.dart::@class::A
+ staticType: null
+ token: A @31
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::foo
+ staticType: null
+ token: foo @27
+ staticElement: package:test/foo.dart::@class::A
+ staticType: null
+ constructors
+ synthetic @-1
+''');
}
test_metadata_constructor_call_unnamed_prefixed_generic_typeArguments() async {
@@ -11061,40 +22128,47 @@
@foo.A<int>()
class C {}
''');
- checkElementText(
- library,
- r'''
-import 'package:test/foo.dart' as foo;
-class C {
-}
- metadata
- Annotation
- arguments: ArgumentList
- element: ConstructorMember
- base: package:test/foo.dart::@class::A::@constructor::•
- substitution: {T: int}
- name: PrefixedIdentifier
- identifier: SimpleIdentifier
- staticElement: package:test/foo.dart::@class::A
- staticType: null
- token: A
- period: .
- prefix: SimpleIdentifier
- staticElement: self::@prefix::foo
- staticType: null
- token: foo
- staticElement: package:test/foo.dart::@class::A
- staticType: null
- typeArguments: TypeArgumentList
- arguments
- TypeName
- name: SimpleIdentifier
- staticElement: dart:core::@class::int
+ checkElementText(library, r'''
+library
+ imports
+ package:test/foo.dart as foo @21
+ definingUnit
+ classes
+ class C @46
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @37
+ rightParenthesis: ) @38
+ atSign.offset: 26
+ element: ConstructorMember
+ base: package:test/foo.dart::@class::A::@constructor::•
+ substitution: {T: int}
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: package:test/foo.dart::@class::A
+ staticType: null
+ token: A @31
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::foo
+ staticType: null
+ token: foo @27
+ staticElement: package:test/foo.dart::@class::A
staticType: null
- token: int
- type: int
-''',
- withResolvedAst: true);
+ typeArguments: TypeArgumentList
+ arguments
+ TypeName
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::int
+ staticType: null
+ token: int @33
+ type: int
+ leftBracket: < @0
+ rightBracket: > @0
+ constructors
+ synthetic @-1
+''');
}
test_metadata_constructor_call_unnamed_synthetic_ofClassAlias_generic() async {
@@ -11110,52 +22184,84 @@
@C()
class D {}
''');
- checkElementText(
- library,
- r'''
-class A {
- const A();
-}
-class alias C extends A with B {
- synthetic const C();
- constantInitializers
- SuperConstructorInvocation
- argumentList: ArgumentList
- staticElement: self::@class::A::@constructor::•
-}
- typeParameters
- T
- bound: null
- defaultType: dynamic
-class D {
-}
- metadata
- Annotation
- arguments: ArgumentList
- element: ConstructorMember
- base: self::@class::C::@constructor::•
- substitution: {T: dynamic}
- name: SimpleIdentifier
- staticElement: self::@class::C
- staticType: null
- token: C
-mixin B on Object {
-}
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ const @18
+ class alias C @44
+ typeParameters
+ covariant T @46
+ defaultType: dynamic
+ supertype: A
+ mixins
+ B
+ constructors
+ synthetic const @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::A::@constructor::•
+ class D @73
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @64
+ rightParenthesis: ) @65
+ atSign.offset: 62
+ element: ConstructorMember
+ base: self::@class::C::@constructor::•
+ substitution: {T: dynamic}
+ name: SimpleIdentifier
+ staticElement: self::@class::C
+ staticType: null
+ token: C @63
+ constructors
+ synthetic @-1
+ mixins
+ mixin B @32
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
+''');
}
test_metadata_constructor_call_with_args() async {
var library =
await checkLibrary('class A { const A(x); } @A(null) class C {}');
checkElementText(library, r'''
-class A {
- const A(dynamic x);
-}
-@
- A/*location: test.dart;A*/(null)
-class C {
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ const @16
+ parameters
+ requiredPositional x @18
+ type: dynamic
+ class C @39
+ metadata
+ Annotation
+ arguments: ArgumentList
+ arguments
+ NullLiteral
+ literal: null @0
+ staticType: null
+ leftParenthesis: ( @26
+ rightParenthesis: ) @31
+ atSign.offset: 24
+ element: self::@class::A::@constructor::•
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @25
+ constructors
+ synthetic @-1
''');
}
@@ -11163,52 +22269,108 @@
var library =
await checkLibrary('const a = null; class C { @a C.named(); }');
checkElementText(library, r'''
-class C {
- @
- a/*location: test.dart;a?*/
- C.named();
-}
-const dynamic a = null;
+library
+ definingUnit
+ classes
+ class C @22
+ constructors
+ named @31
+ metadata
+ Annotation
+ atSign.offset: 26
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @27
+ periodOffset: 30
+ nameEnd: 36
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
''');
}
test_metadata_constructorDeclaration_unnamed() async {
var library = await checkLibrary('const a = null; class C { @a C(); }');
checkElementText(library, r'''
-class C {
- @
- a/*location: test.dart;a?*/
- C();
-}
-const dynamic a = null;
+library
+ definingUnit
+ classes
+ class C @22
+ constructors
+ @29
+ metadata
+ Annotation
+ atSign.offset: 26
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @27
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
''');
}
test_metadata_enumConstantDeclaration() async {
var library = await checkLibrary('const a = 42; enum E { @a v }');
- checkElementText(
- library,
- r'''
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E v;
- metadata
- Annotation
- element: self::@getter::a
- name: SimpleIdentifier
- staticElement: self::@getter::a
- staticType: null
- token: a
- String toString() {}
-}
-const int a;
- constantInitializer
- IntegerLiteral
- literal: 42
- staticType: int
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ enums
+ enum E @19
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const v @26
+ metadata
+ Annotation
+ atSign.offset: 23
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @24
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get v @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
+ topLevelVariables
+ static const a @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 42 @10
+ staticType: int
+ accessors
+ synthetic static get a @6
+ returnType: int
+''');
}
test_metadata_enumConstantDeclaration_instanceCreation() async {
@@ -11224,84 +22386,161 @@
@A(300) c,
}
''');
- checkElementText(
- library,
- r'''
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E a;
- metadata
- Annotation
- arguments: ArgumentList
- arguments
- IntegerLiteral
- literal: 100
- staticType: int
- element: self::@class::A::@constructor::•
- name: SimpleIdentifier
- staticElement: self::@class::A
- staticType: null
- token: A
- static const E b;
- static const E c;
- metadata
- Annotation
- arguments: ArgumentList
- arguments
- IntegerLiteral
- literal: 300
- staticType: int
- element: self::@class::A::@constructor::•
- name: SimpleIdentifier
- staticElement: self::@class::A
- staticType: null
- token: A
- String toString() {}
-}
-class A {
- final dynamic value;
- const A(final dynamic this.value);
-}
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ final value @26
+ type: dynamic
+ constructors
+ const @41
+ parameters
+ requiredPositional final this.value @48
+ type: dynamic
+ accessors
+ synthetic get value @26
+ returnType: dynamic
+ enums
+ enum E @64
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const a @78
+ metadata
+ Annotation
+ arguments: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 100 @73
+ staticType: int
+ leftParenthesis: ( @72
+ rightParenthesis: ) @76
+ atSign.offset: 70
+ element: self::@class::A::@constructor::•
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @71
+ type: E
+ static const b @83
+ type: E
+ static const c @96
+ metadata
+ Annotation
+ arguments: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 300 @91
+ staticType: int
+ leftParenthesis: ( @90
+ rightParenthesis: ) @94
+ atSign.offset: 88
+ element: self::@class::A::@constructor::•
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @89
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get a @-1
+ returnType: E
+ synthetic static get b @-1
+ returnType: E
+ synthetic static get c @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
+''');
}
test_metadata_enumDeclaration() async {
var library = await checkLibrary('const a = 42; @a enum E { v }');
- checkElementText(
- library,
- r'''
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E v;
- String toString() {}
-}
- metadata
- Annotation
- element: self::@getter::a
- name: SimpleIdentifier
- staticElement: self::@getter::a
- staticType: null
- token: a
-const int a;
- constantInitializer
- IntegerLiteral
- literal: 42
- staticType: int
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ enums
+ enum E @22
+ metadata
+ Annotation
+ atSign.offset: 14
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @15
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const v @26
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get v @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
+ topLevelVariables
+ static const a @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 42 @10
+ staticType: int
+ accessors
+ synthetic static get a @6
+ returnType: int
+''');
}
test_metadata_exportDirective() async {
addLibrarySource('/foo.dart', '');
var library = await checkLibrary('@a export "foo.dart"; const a = null;');
checkElementText(library, r'''
-@
- a/*location: test.dart;a?*/
-export 'foo.dart';
-const dynamic a = null;
+library
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ exports
+ foo.dart
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ definingUnit
+ topLevelVariables
+ static const a @28
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @28
+ returnType: dynamic
''');
}
@@ -11316,49 +22555,62 @@
void bar() {}
}
''');
- checkElementText(
- library,
- r'''
-extension E on int {
- static const int foo;
- constantInitializer
- IntegerLiteral
- literal: 1
- staticType: int
- void bar() {}
- metadata
- Annotation
- element: self::@extension::E::@getter::foo
- name: SimpleIdentifier
- staticElement: self::@extension::E::@getter::foo
- staticType: null
- token: foo
-}
- metadata
- Annotation
- element: self::@getter::foo
- name: SimpleIdentifier
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- typeParameters
- T
- bound: null
- defaultType: null
- metadata
- Annotation
- element: self::@getter::foo
- name: SimpleIdentifier
- staticElement: self::@getter::foo
- staticType: null
- token: foo
-const int foo;
- constantInitializer
- IntegerLiteral
- literal: 0
- staticType: int
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ extensions
+ E @31
+ metadata
+ Annotation
+ atSign.offset: 16
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @17
+ typeParameters
+ covariant T @38
+ metadata
+ Annotation
+ atSign.offset: 33
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @34
+ extendedType: int
+ fields
+ static const foo @65
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 1 @71
+ staticType: int
+ accessors
+ synthetic static get foo @65
+ returnType: int
+ methods
+ bar @88
+ metadata
+ Annotation
+ atSign.offset: 76
+ element: self::@extension::E::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@extension::E::@getter::foo
+ staticType: null
+ token: foo @77
+ returnType: void
+ topLevelVariables
+ static const foo @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @12
+ staticType: int
+ accessors
+ synthetic static get foo @6
+ returnType: int
+''');
}
test_metadata_extensionDeclaration() async {
@@ -11369,27 +22621,84 @@
@Object()
extension E on A {}''');
checkElementText(library, r'''
-class A {
-}
-@
- a/*location: test.dart;a?*/
-@
- Object/*location: dart:core;Object*/()
-extension E on A {
-}
-const dynamic a = null;
+library
+ definingUnit
+ classes
+ class A @22
+ constructors
+ synthetic @-1
+ extensions
+ E @50
+ metadata
+ Annotation
+ atSign.offset: 27
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @28
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @37
+ rightParenthesis: ) @38
+ atSign.offset: 30
+ element: dart:core::@class::Object::@constructor::•
+ name: SimpleIdentifier
+ staticElement: dart:core::@class::Object
+ staticType: null
+ token: Object @31
+ extendedType: A
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
''');
}
test_metadata_fieldDeclaration() async {
var library = await checkLibrary('const a = null; class C { @a int x; }');
checkElementText(library, r'''
-class C {
- @
- a/*location: test.dart;a?*/
- int x;
-}
-const dynamic a = null;
+library
+ definingUnit
+ classes
+ class C @22
+ fields
+ x @33
+ metadata
+ Annotation
+ atSign.offset: 26
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @27
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @33
+ returnType: int
+ synthetic set x @33
+ parameters
+ requiredPositional _x @33
+ type: int
+ returnType: void
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
''');
}
@@ -11402,12 +22711,44 @@
}
''');
checkElementText(library, r'''
-class C {
- dynamic x;
- C(@
- a/*location: test.dart;a?*/ final dynamic this.x);
-}
-const dynamic a = null;
+library
+ definingUnit
+ classes
+ class C @22
+ fields
+ x @32
+ type: dynamic
+ constructors
+ @37
+ parameters
+ requiredPositional final this.x @47
+ type: dynamic
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ accessors
+ synthetic get x @32
+ returnType: dynamic
+ synthetic set x @32
+ parameters
+ requiredPositional _x @32
+ type: dynamic
+ returnType: void
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
''');
}
@@ -11415,12 +22756,48 @@
var library = await checkLibrary(
'const a = null; class C { var x; C([@a this.x = null]); }');
checkElementText(library, r'''
-class C {
- dynamic x;
- C([@
- a/*location: test.dart;a?*/ final dynamic this.x = null]);
-}
-const dynamic a = null;
+library
+ definingUnit
+ classes
+ class C @22
+ fields
+ x @30
+ type: dynamic
+ constructors
+ @33
+ parameters
+ optionalPositional final this.x @44
+ type: dynamic
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic get x @30
+ returnType: dynamic
+ synthetic set x @30
+ parameters
+ requiredPositional _x @30
+ type: dynamic
+ returnType: void
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
''');
}
@@ -11431,58 +22808,191 @@
f() {}
''');
checkElementText(library, r'''
-const dynamic a = null;
-@
- a/*location: test.dart;a?*/
-dynamic f() {}
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
+ functions
+ f @19
+ metadata
+ Annotation
+ atSign.offset: 16
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @17
+ returnType: dynamic
''');
}
test_metadata_functionDeclaration_getter() async {
var library = await checkLibrary('const a = null; @a get f => null;');
checkElementText(library, r'''
-const dynamic a = null;
-@
- a/*location: test.dart;a?*/
-dynamic get f {}
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ synthetic static f @-1
+ type: dynamic
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
+ get f @23
+ metadata
+ Annotation
+ atSign.offset: 16
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @17
+ returnType: dynamic
''');
}
test_metadata_functionDeclaration_setter() async {
var library = await checkLibrary('const a = null; @a set f(value) {}');
checkElementText(library, r'''
-const dynamic a = null;
-@
- a/*location: test.dart;a?*/
-void set f(dynamic value) {}
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ synthetic static f @-1
+ type: dynamic
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
+ set f @23
+ metadata
+ Annotation
+ atSign.offset: 16
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @17
+ parameters
+ requiredPositional value @25
+ type: dynamic
+ returnType: void
''');
}
test_metadata_functionTypeAlias() async {
var library = await checkLibrary('const a = null; @a typedef F();');
checkElementText(library, r'''
-@
- a/*location: test.dart;a?*/
-typedef F = dynamic Function();
-const dynamic a = null;
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @27
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
''');
}
test_metadata_functionTypedFormalParameter() async {
var library = await checkLibrary('const a = null; f(@a g()) {}');
checkElementText(library, r'''
-const dynamic a = null;
-dynamic f(@
- a/*location: test.dart;a?*/ dynamic Function() g) {}
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
+ functions
+ f @16
+ parameters
+ requiredPositional g @21
+ type: dynamic Function()
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ returnType: dynamic
''');
}
test_metadata_functionTypedFormalParameter_withDefault() async {
var library = await checkLibrary('const a = null; f([@a g() = null]) {}');
checkElementText(library, r'''
-const dynamic a = null;
-dynamic f([@
- a/*location: test.dart;a?*/ dynamic Function() g = null]) {}
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
+ functions
+ f @16
+ parameters
+ optionalPositional g @22
+ type: dynamic Function()
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ returnType: dynamic
''');
}
@@ -11494,13 +23004,46 @@
@b
typedef F = void Function();''');
checkElementText(library, r'''
-@
- a/*location: test.dart;a?*/
-@
- b/*location: test.dart;b?*/
-typedef F = void Function();
-const dynamic a = null;
-const dynamic b = null;
+library
+ definingUnit
+ typeAliases
+ F @46
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::b
+ name: SimpleIdentifier
+ staticElement: self::@getter::b
+ staticType: null
+ token: b @-1
+ aliasedType: void Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ static const b @22
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
+ synthetic static get b @22
+ returnType: dynamic
''');
}
@@ -11510,24 +23053,38 @@
import "dart:math";
const a = 0;
''');
- checkElementText(
- library,
- '''
-import 'dart:math';
+ checkElementText(library, r'''
+library
metadata
Annotation
+ atSign.offset: 0
element: self::@getter::a
name: SimpleIdentifier
staticElement: self::@getter::a
staticType: null
- token: a
-const int a;
- constantInitializer
- IntegerLiteral
- literal: 0
- staticType: int
-''',
- withResolvedAst: true);
+ token: a @-1
+ imports
+ dart:math
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ definingUnit
+ topLevelVariables
+ static const a @29
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @33
+ staticType: int
+ accessors
+ synthetic static get a @29
+ returnType: int
+''');
}
test_metadata_importDirective_hasShow() async {
@@ -11537,24 +23094,40 @@
const a = 0;
''');
- checkElementText(
- library,
- r'''
-import 'dart:math' show Random;
+ checkElementText(library, r'''
+library
metadata
Annotation
+ atSign.offset: 0
element: self::@getter::a
name: SimpleIdentifier
staticElement: self::@getter::a
staticType: null
- token: a
-const int a;
- constantInitializer
- IntegerLiteral
- literal: 0
- staticType: int
-''',
- withResolvedAst: true);
+ token: a @-1
+ imports
+ dart:math
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ combinators
+ show: Random
+ definingUnit
+ topLevelVariables
+ static const a @42
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @46
+ staticType: int
+ accessors
+ synthetic static get a @42
+ returnType: int
+''');
}
test_metadata_inAliasedElement_formalParameter() async {
@@ -11562,27 +23135,36 @@
const a = 42;
typedef F = void Function(@a int first)
''');
- checkElementText(
- library,
- r'''
-typedef F = void Function(int first);
- aliasedElement
- parameters
- first
- metadata
- Annotation
- element: self::@getter::a
- name: SimpleIdentifier
- staticElement: self::@getter::a
- staticType: null
- token: a
-const int a;
- constantInitializer
- IntegerLiteral
- literal: 42
- staticType: int
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ F @22
+ aliasedType: void Function(int)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional first @-1
+ type: int
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ returnType: void
+ topLevelVariables
+ static const a @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 42 @10
+ staticType: int
+ accessors
+ synthetic static get a @6
+ returnType: int
+''');
}
test_metadata_inAliasedElement_formalParameter2() async {
@@ -11590,29 +23172,39 @@
const a = 42;
typedef F = void Function(int foo(@a int bar))
''');
- checkElementText(
- library,
- r'''
-typedef F = void Function(int Function(int) foo);
- aliasedElement
- parameters
- foo
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ F @22
+ aliasedType: void Function(int Function(int))
+ aliasedElement: GenericFunctionTypeElement
parameters
- bar
- metadata
- Annotation
- element: self::@getter::a
- name: SimpleIdentifier
- staticElement: self::@getter::a
- staticType: null
- token: a
-const int a;
- constantInitializer
- IntegerLiteral
- literal: 42
- staticType: int
-''',
- withResolvedAst: true);
+ requiredPositional foo @-1
+ type: int Function(int)
+ parameters
+ requiredPositional bar @-1
+ type: int
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ returnType: void
+ topLevelVariables
+ static const a @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 42 @10
+ staticType: int
+ accessors
+ synthetic static get a @6
+ returnType: int
+''');
}
test_metadata_inAliasedElement_typeParameter() async {
@@ -11620,51 +23212,98 @@
const a = 42;
typedef F = void Function<@a T>(int first)
''');
- checkElementText(
- library,
- r'''
-typedef F = void Function(int first);
- aliasedElement
- typeParameters
- T
- bound: null
- defaultType: null
- metadata
- Annotation
- element: self::@getter::a
- name: SimpleIdentifier
- staticElement: self::@getter::a
- staticType: null
- token: a
- parameters
- first
-const int a;
- constantInitializer
- IntegerLiteral
- literal: 42
- staticType: int
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ F @22
+ aliasedType: void Function<T>(int)
+ aliasedElement: GenericFunctionTypeElement
+ typeParameters
+ covariant T @-1
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ parameters
+ requiredPositional first @-1
+ type: int
+ returnType: void
+ topLevelVariables
+ static const a @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 42 @10
+ staticType: int
+ accessors
+ synthetic static get a @6
+ returnType: int
+''');
}
test_metadata_invalid_classDeclaration() async {
var library = await checkLibrary('f(_) {} @f(42) class C {}');
checkElementText(library, r'''
-@
- f/*location: test.dart;f*/(42)
-class C {
-}
-dynamic f(dynamic _) {}
+library
+ definingUnit
+ classes
+ class C @21
+ metadata
+ Annotation
+ arguments: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 42 @11
+ staticType: int
+ leftParenthesis: ( @10
+ rightParenthesis: ) @13
+ atSign.offset: 8
+ element: self::@function::f
+ name: SimpleIdentifier
+ staticElement: self::@function::f
+ staticType: null
+ token: f @9
+ constructors
+ synthetic @-1
+ functions
+ f @0
+ parameters
+ requiredPositional _ @2
+ type: dynamic
+ returnType: dynamic
''');
}
test_metadata_libraryDirective() async {
var library = await checkLibrary('@a library L; const a = null;');
checkElementText(library, r'''
-@
- a/*location: test.dart;a?*/
-library L;
-const dynamic a = null;
+library
+ name: L
+ nameOffset: 11
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ definingUnit
+ topLevelVariables
+ static const a @20
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @20
+ returnType: dynamic
''');
}
@@ -11672,12 +23311,36 @@
var library =
await checkLibrary('const a = null; class C { @a get m => null; }');
checkElementText(library, r'''
-class C {
- @
- a/*location: test.dart;a?*/
- dynamic get m {}
-}
-const dynamic a = null;
+library
+ definingUnit
+ classes
+ class C @22
+ fields
+ synthetic m @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ get m @33
+ metadata
+ Annotation
+ atSign.offset: 26
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @27
+ returnType: dynamic
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
''');
}
@@ -11692,15 +23355,48 @@
}
''');
checkElementText(library, r'''
-class C {
- @
- a/*location: test.dart;a?*/
- @
- b/*location: test.dart;b?*/
- dynamic m() {}
-}
-const dynamic a = null;
-const dynamic b = null;
+library
+ definingUnit
+ classes
+ class C @38
+ constructors
+ synthetic @-1
+ methods
+ m @54
+ metadata
+ Annotation
+ atSign.offset: 44
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @45
+ Annotation
+ atSign.offset: 49
+ element: self::@getter::b
+ name: SimpleIdentifier
+ staticElement: self::@getter::b
+ staticType: null
+ token: b @50
+ returnType: dynamic
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ static const b @22
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
+ synthetic static get b @22
+ returnType: dynamic
''');
}
@@ -11715,15 +23411,50 @@
}
''');
checkElementText(library, r'''
-mixin M on Object {
- @
- a/*location: test.dart;a?*/
- @
- b/*location: test.dart;b?*/
- dynamic m() {}
-}
-const dynamic a = null;
-const dynamic b = null;
+library
+ definingUnit
+ mixins
+ mixin M @38
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
+ methods
+ m @54
+ metadata
+ Annotation
+ atSign.offset: 44
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @45
+ Annotation
+ atSign.offset: 49
+ element: self::@getter::b
+ name: SimpleIdentifier
+ staticElement: self::@getter::b
+ staticType: null
+ token: b @50
+ returnType: dynamic
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ static const b @22
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
+ synthetic static get b @22
+ returnType: dynamic
''');
}
@@ -11736,12 +23467,39 @@
}
''');
checkElementText(library, r'''
-class C {
- @
- a/*location: test.dart;a?*/
- void set m(dynamic value) {}
-}
-const dynamic a = null;
+library
+ definingUnit
+ classes
+ class C @22
+ fields
+ synthetic m @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ set m @37
+ metadata
+ Annotation
+ atSign.offset: 28
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @29
+ parameters
+ requiredPositional value @39
+ type: dynamic
+ returnType: void
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
''');
}
@@ -11756,49 +23514,66 @@
void bar() {}
}
''');
- checkElementText(
- library,
- r'''
-mixin M on Object {
- static const int foo;
- constantInitializer
- IntegerLiteral
- literal: 1
- staticType: int
- void bar() {}
- metadata
- Annotation
- element: self::@mixin::M::@getter::foo
- name: SimpleIdentifier
- staticElement: self::@mixin::M::@getter::foo
- staticType: null
- token: foo
-}
- metadata
- Annotation
- element: self::@getter::foo
- name: SimpleIdentifier
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- typeParameters
- T
- bound: null
- defaultType: dynamic
- metadata
- Annotation
- element: self::@getter::foo
- name: SimpleIdentifier
- staticElement: self::@getter::foo
- staticType: null
- token: foo
-const int foo;
- constantInitializer
- IntegerLiteral
- literal: 0
- staticType: int
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ mixins
+ mixin M @27
+ metadata
+ Annotation
+ atSign.offset: 16
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @17
+ typeParameters
+ covariant T @34
+ defaultType: dynamic
+ metadata
+ Annotation
+ atSign.offset: 29
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @30
+ superclassConstraints
+ Object
+ fields
+ static const foo @54
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 1 @60
+ staticType: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get foo @54
+ returnType: int
+ methods
+ bar @77
+ metadata
+ Annotation
+ atSign.offset: 65
+ element: self::@mixin::M::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@mixin::M::@getter::foo
+ staticType: null
+ token: foo @66
+ returnType: void
+ topLevelVariables
+ static const foo @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @12
+ staticType: int
+ accessors
+ synthetic static get foo @6
+ returnType: int
+''');
}
test_metadata_mixinDeclaration() async {
@@ -11809,14 +23584,47 @@
@b
mixin M {}''');
checkElementText(library, r'''
-@
- a/*location: test.dart;a?*/
-@
- b/*location: test.dart;b?*/
-mixin M on Object {
-}
-const dynamic a = null;
-const dynamic b = null;
+library
+ definingUnit
+ mixins
+ mixin M @44
+ metadata
+ Annotation
+ atSign.offset: 32
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @33
+ Annotation
+ atSign.offset: 35
+ element: self::@getter::b
+ name: SimpleIdentifier
+ staticElement: self::@getter::b
+ staticType: null
+ token: b @36
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ static const b @22
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
+ synthetic static get b @22
+ returnType: dynamic
''');
}
@@ -11827,44 +23635,43 @@
@foo
class A<@foo T> {}
''');
- checkElementText(
- library,
- r'''
-class A {
-}
- metadata
- Annotation
- atSign.offset: 16
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 17
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 17
- typeParameters
- T
- bound: null
- defaultType: dynamic
- metadata
- Annotation
- atSign.offset: 29
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 30
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 30
-const int foo;
- constantInitializer
- IntegerLiteral
- literal: 0
- offset: 12
- staticType: int
-''',
- withResolvedAst: true,
- withResolvedAstOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @27
+ metadata
+ Annotation
+ atSign.offset: 16
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @17
+ typeParameters
+ covariant T @34
+ defaultType: dynamic
+ metadata
+ Annotation
+ atSign.offset: 29
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @30
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static const foo @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @12
+ staticType: int
+ accessors
+ synthetic static get foo @6
+ returnType: int
+''');
}
test_metadata_offsets_onClassConstructor() async {
@@ -11877,31 +23684,43 @@
}
''');
// TODO(scheglov) Enhance to show metadata on formal parameters?
- checkElementText(
- library,
- r'''
-class A {
- A(int a);
- metadata
- Annotation
- atSign.offset: 28
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 29
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 29
-}
-const int foo;
- constantInitializer
- IntegerLiteral
- literal: 0
- offset: 12
- staticType: int
-''',
- withResolvedAst: true,
- withResolvedAstOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @22
+ constructors
+ @35
+ metadata
+ Annotation
+ atSign.offset: 28
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @29
+ parameters
+ requiredPositional a @46
+ type: int
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @-1
+ topLevelVariables
+ static const foo @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @12
+ staticType: int
+ accessors
+ synthetic static get foo @6
+ returnType: int
+''');
}
test_metadata_offsets_onClassGetter() async {
@@ -11913,31 +23732,38 @@
int get getter => 0;
}
''');
- checkElementText(
- library,
- r'''
-class A {
- int get getter {}
- metadata
- Annotation
- atSign.offset: 28
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 29
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 29
-}
-const int foo;
- constantInitializer
- IntegerLiteral
- literal: 0
- offset: 12
- staticType: int
-''',
- withResolvedAst: true,
- withResolvedAstOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @22
+ fields
+ synthetic getter @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ get getter @43
+ metadata
+ Annotation
+ atSign.offset: 28
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @29
+ returnType: int
+ topLevelVariables
+ static const foo @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @12
+ staticType: int
+ accessors
+ synthetic static get foo @6
+ returnType: int
+''');
}
test_metadata_offsets_onClassMethod() async {
@@ -11950,45 +23776,56 @@
}
''');
// TODO(scheglov) Enhance to show metadata on formal parameters?
- checkElementText(
- library,
- r'''
-class A {
- void method(int a) {}
- typeParameters
- T
- bound: null
- defaultType: null
- metadata
- Annotation
- atSign.offset: 47
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 48
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 48
- metadata
- Annotation
- atSign.offset: 28
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 29
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 29
-}
-const int foo;
- constantInitializer
- IntegerLiteral
- literal: 0
- offset: 12
- staticType: int
-''',
- withResolvedAst: true,
- withResolvedAstOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @22
+ constructors
+ synthetic @-1
+ methods
+ method @40
+ metadata
+ Annotation
+ atSign.offset: 28
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @29
+ typeParameters
+ covariant T @52
+ metadata
+ Annotation
+ atSign.offset: 47
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @48
+ parameters
+ requiredPositional a @64
+ type: int
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @-1
+ returnType: void
+ topLevelVariables
+ static const foo @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @12
+ staticType: int
+ accessors
+ synthetic static get foo @6
+ returnType: int
+''');
}
test_metadata_offsets_onClassSetter() async {
@@ -12001,31 +23838,49 @@
}
''');
// TODO(scheglov) Enhance to show metadata on formal parameters?
- checkElementText(
- library,
- r'''
-class A {
- void set setter(int a) {}
- metadata
- Annotation
- atSign.offset: 28
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 29
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 29
-}
-const int foo;
- constantInitializer
- IntegerLiteral
- literal: 0
- offset: 12
- staticType: int
-''',
- withResolvedAst: true,
- withResolvedAstOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @22
+ fields
+ synthetic setter @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ set setter @39
+ metadata
+ Annotation
+ atSign.offset: 28
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @29
+ parameters
+ requiredPositional a @55
+ type: int
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @-1
+ returnType: void
+ topLevelVariables
+ static const foo @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @12
+ staticType: int
+ accessors
+ synthetic static get foo @6
+ returnType: int
+''');
}
test_metadata_offsets_onClassTypeAlias() async {
@@ -12038,53 +23893,61 @@
@foo
class B<@foo T> = A with M;
''');
- checkElementText(
- library,
- r'''
-class A {
-}
-class alias B extends A with M {
- synthetic B();
- constantInitializers
- SuperConstructorInvocation
- argumentList: ArgumentList
- staticElement: self::@class::A::@constructor::•
-}
- metadata
- Annotation
- atSign.offset: 39
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 40
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 40
- typeParameters
- T
- bound: null
- defaultType: dynamic
- metadata
- Annotation
- atSign.offset: 52
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 53
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 53
-mixin M on Object {
-}
-const int foo;
- constantInitializer
- IntegerLiteral
- literal: 0
- offset: 12
- staticType: int
-''',
- withResolvedAst: true,
- withResolvedAstOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @22
+ constructors
+ synthetic @-1
+ class alias B @50
+ metadata
+ Annotation
+ atSign.offset: 39
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @40
+ typeParameters
+ covariant T @57
+ defaultType: dynamic
+ metadata
+ Annotation
+ atSign.offset: 52
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @53
+ supertype: A
+ mixins
+ M
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::A::@constructor::•
+ mixins
+ mixin M @33
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static const foo @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @12
+ staticType: int
+ accessors
+ synthetic static get foo @6
+ returnType: int
+''');
}
test_metadata_offsets_onEnum() async {
@@ -12098,56 +23961,71 @@
@foo e3,
}
''');
- checkElementText(
- library,
- r'''
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E e1;
- metadata
- Annotation
- atSign.offset: 32
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 33
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 33
- static const E e2;
- static const E e3;
- metadata
- Annotation
- atSign.offset: 49
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 50
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 50
- String toString() {}
-}
- metadata
- Annotation
- atSign.offset: 16
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 17
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 17
-const int foo;
- constantInitializer
- IntegerLiteral
- literal: 0
- offset: 12
- staticType: int
-''',
- withResolvedAst: true,
- withResolvedAstOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ enums
+ enum E @26
+ metadata
+ Annotation
+ atSign.offset: 16
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @17
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const e1 @37
+ metadata
+ Annotation
+ atSign.offset: 32
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @33
+ type: E
+ static const e2 @43
+ type: E
+ static const e3 @54
+ metadata
+ Annotation
+ atSign.offset: 49
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @50
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get e1 @-1
+ returnType: E
+ synthetic static get e2 @-1
+ returnType: E
+ synthetic static get e3 @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
+ topLevelVariables
+ static const foo @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @12
+ staticType: int
+ accessors
+ synthetic static get foo @6
+ returnType: int
+''');
}
test_metadata_offsets_onExtension() async {
@@ -12157,44 +24035,41 @@
@foo
extension E<@foo T> on List<T> {}
''');
- checkElementText(
- library,
- r'''
-extension E on List<T> {
-}
- metadata
- Annotation
- atSign.offset: 16
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 17
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 17
- typeParameters
- T
- bound: null
- defaultType: null
- metadata
- Annotation
- atSign.offset: 33
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 34
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 34
-const int foo;
- constantInitializer
- IntegerLiteral
- literal: 0
- offset: 12
- staticType: int
-''',
- withResolvedAst: true,
- withResolvedAstOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ extensions
+ E @31
+ metadata
+ Annotation
+ atSign.offset: 16
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @17
+ typeParameters
+ covariant T @38
+ metadata
+ Annotation
+ atSign.offset: 33
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @34
+ extendedType: List<T>
+ topLevelVariables
+ static const foo @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @12
+ staticType: int
+ accessors
+ synthetic static get foo @6
+ returnType: int
+''');
}
test_metadata_offsets_onFieldDeclaration() async {
@@ -12209,47 +24084,59 @@
static const isConst = 2;
}
''');
- checkElementText(
- library,
- r'''
-class A {
- static int isNotConst;
- metadata
- Annotation
- atSign.offset: 28
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 29
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 29
- static const int isConst;
- metadata
- Annotation
- atSign.offset: 61
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 62
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 62
- constantInitializer
- IntegerLiteral
- literal: 2
- offset: 91
- staticType: int
-}
-const int foo;
- constantInitializer
- IntegerLiteral
- literal: 0
- offset: 12
- staticType: int
-''',
- withResolvedAst: true,
- withResolvedAstOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @22
+ fields
+ static isNotConst @42
+ metadata
+ Annotation
+ atSign.offset: 28
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @29
+ type: int
+ static const isConst @81
+ metadata
+ Annotation
+ atSign.offset: 61
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @62
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 2 @91
+ staticType: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get isNotConst @42
+ returnType: int
+ synthetic static set isNotConst @42
+ parameters
+ requiredPositional _isNotConst @42
+ type: int
+ returnType: void
+ synthetic static get isConst @81
+ returnType: int
+ topLevelVariables
+ static const foo @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @12
+ staticType: int
+ accessors
+ synthetic static get foo @6
+ returnType: int
+''');
}
test_metadata_offsets_onMixin() async {
@@ -12259,44 +24146,45 @@
@foo
mixin A<@foo T> {}
''');
- checkElementText(
- library,
- r'''
-mixin A on Object {
-}
- metadata
- Annotation
- atSign.offset: 16
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 17
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 17
- typeParameters
- T
- bound: null
- defaultType: dynamic
- metadata
- Annotation
- atSign.offset: 29
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 30
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 30
-const int foo;
- constantInitializer
- IntegerLiteral
- literal: 0
- offset: 12
- staticType: int
-''',
- withResolvedAst: true,
- withResolvedAstOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ mixins
+ mixin A @27
+ metadata
+ Annotation
+ atSign.offset: 16
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @17
+ typeParameters
+ covariant T @34
+ defaultType: dynamic
+ metadata
+ Annotation
+ atSign.offset: 29
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @30
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static const foo @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @12
+ staticType: int
+ accessors
+ synthetic static get foo @6
+ returnType: int
+''');
}
test_metadata_offsets_onUnitFunction() async {
@@ -12307,43 +24195,52 @@
void f<@foo T>(@foo int a) {}
''');
// TODO(scheglov) Enhance to show metadata on formal parameters?
- checkElementText(
- library,
- r'''
-const int foo;
- constantInitializer
- IntegerLiteral
- literal: 0
- offset: 12
- staticType: int
-void f(int a) {}
- typeParameters
- T
- bound: null
- defaultType: null
- metadata
- Annotation
- atSign.offset: 28
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 29
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 29
- metadata
- Annotation
- atSign.offset: 16
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 17
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 17
-''',
- withResolvedAst: true,
- withResolvedAstOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const foo @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @12
+ staticType: int
+ accessors
+ synthetic static get foo @6
+ returnType: int
+ functions
+ f @26
+ metadata
+ Annotation
+ atSign.offset: 16
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @17
+ typeParameters
+ covariant T @33
+ metadata
+ Annotation
+ atSign.offset: 28
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @29
+ parameters
+ requiredPositional a @45
+ type: int
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @-1
+ returnType: void
+''');
}
test_metadata_offsets_onUnitGetter() async {
@@ -12353,29 +24250,32 @@
@foo
int get getter => 0;
''');
- checkElementText(
- library,
- r'''
-const int foo;
- constantInitializer
- IntegerLiteral
- literal: 0
- offset: 12
- staticType: int
-int get getter {}
- metadata
- Annotation
- atSign.offset: 16
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 17
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 17
-''',
- withResolvedAst: true,
- withResolvedAstOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const foo @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @12
+ staticType: int
+ synthetic static getter @-1
+ type: int
+ accessors
+ synthetic static get foo @6
+ returnType: int
+ get getter @29
+ metadata
+ Annotation
+ atSign.offset: 16
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @17
+ returnType: int
+''');
}
test_metadata_offsets_onUnitSetter() async {
@@ -12386,29 +24286,43 @@
set setter(@foo int a) {}
''');
// TODO(scheglov) Enhance to show metadata on formal parameters?
- checkElementText(
- library,
- r'''
-const int foo;
- constantInitializer
- IntegerLiteral
- literal: 0
- offset: 12
- staticType: int
-void set setter(int a) {}
- metadata
- Annotation
- atSign.offset: 16
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 17
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 17
-''',
- withResolvedAst: true,
- withResolvedAstOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const foo @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @12
+ staticType: int
+ synthetic static setter @-1
+ type: int
+ accessors
+ synthetic static get foo @6
+ returnType: int
+ set setter @25
+ metadata
+ Annotation
+ atSign.offset: 16
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @17
+ parameters
+ requiredPositional a @41
+ type: int
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @-1
+ returnType: void
+''');
}
test_metadata_offsets_onUnitVariable() async {
@@ -12421,45 +24335,53 @@
@foo
const isConst = 2;
''');
- checkElementText(
- library,
- r'''
-const int foo;
- constantInitializer
- IntegerLiteral
- literal: 0
- offset: 12
- staticType: int
-int isNotConst;
- metadata
- Annotation
- atSign.offset: 16
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 17
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 17
-const int isConst;
- metadata
- Annotation
- atSign.offset: 42
- element: self::@getter::foo
- name: SimpleIdentifier
- offset: 43
- staticElement: self::@getter::foo
- staticType: null
- token: foo
- offset: 43
- constantInitializer
- IntegerLiteral
- literal: 2
- offset: 63
- staticType: int
-''',
- withResolvedAst: true,
- withResolvedAstOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const foo @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @12
+ staticType: int
+ static isNotConst @25
+ metadata
+ Annotation
+ atSign.offset: 16
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @17
+ type: int
+ static const isConst @53
+ metadata
+ Annotation
+ atSign.offset: 42
+ element: self::@getter::foo
+ name: SimpleIdentifier
+ staticElement: self::@getter::foo
+ staticType: null
+ token: foo @43
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 2 @63
+ staticType: int
+ accessors
+ synthetic static get foo @6
+ returnType: int
+ synthetic static get isNotConst @25
+ returnType: int
+ synthetic static set isNotConst @25
+ parameters
+ requiredPositional _isNotConst @25
+ type: int
+ returnType: void
+ synthetic static get isConst @53
+ returnType: int
+''');
}
test_metadata_partDirective() async {
@@ -12470,14 +24392,30 @@
part 'foo.dart';
const a = null;''');
checkElementText(library, r'''
-library L;
-@
- a/*location: test.dart;a?*/
-part 'foo.dart';
-const dynamic a = null;
---------------------
-unit: foo.dart
-
+library
+ name: L
+ nameOffset: 8
+ definingUnit
+ topLevelVariables
+ static const a @37
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @37
+ returnType: dynamic
+ parts
+ foo.dart
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
''');
}
@@ -12502,21 +24440,62 @@
addLibrarySource('/a.dart', 'const b = null;');
var library = await checkLibrary('import "a.dart" as a; @a.b class C {}');
checkElementText(library, r'''
-import 'a.dart' as a;
-@
- a/*location: test.dart;a*/.
- b/*location: a.dart;b?*/
-class C {
-}
+library
+ imports
+ a.dart as a @19
+ definingUnit
+ classes
+ class C @33
+ metadata
+ Annotation
+ atSign.offset: 22
+ element: a.dart::@getter::b
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: a.dart::@getter::b
+ staticType: null
+ token: b @25
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::a
+ staticType: null
+ token: a @23
+ staticElement: a.dart::@getter::b
+ staticType: null
+ constructors
+ synthetic @-1
''');
}
test_metadata_simpleFormalParameter() async {
var library = await checkLibrary('const a = null; f(@a x) {}');
checkElementText(library, r'''
-const dynamic a = null;
-dynamic f(@
- a/*location: test.dart;a?*/ dynamic x) {}
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
+ functions
+ f @16
+ parameters
+ requiredPositional x @21
+ type: dynamic
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ returnType: dynamic
''');
}
@@ -12529,11 +24508,36 @@
}
''');
checkElementText(library, r'''
-class C {
- dynamic m(@
- a/*location: test.dart;a?*/ dynamic x) {}
-}
-const dynamic a = null;
+library
+ definingUnit
+ classes
+ class C @23
+ constructors
+ synthetic @-1
+ methods
+ m @29
+ parameters
+ requiredPositional x @34
+ type: dynamic
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ returnType: dynamic
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
''');
}
@@ -12544,39 +24548,137 @@
set foo(@a int x) {}
''');
checkElementText(library, r'''
-const dynamic a = null;
-void set foo(@
- a/*location: test.dart;a?*/ int x) {}
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ synthetic static foo @-1
+ type: int
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
+ set foo @21
+ parameters
+ requiredPositional x @32
+ type: int
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ returnType: void
''');
}
test_metadata_simpleFormalParameter_withDefault() async {
var library = await checkLibrary('const a = null; f([@a x = null]) {}');
checkElementText(library, r'''
-const dynamic a = null;
-dynamic f([@
- a/*location: test.dart;a?*/ dynamic x = null]) {}
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
+ functions
+ f @16
+ parameters
+ optionalPositional x @22
+ type: dynamic
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ returnType: dynamic
''');
}
test_metadata_topLevelVariableDeclaration() async {
var library = await checkLibrary('const a = null; @a int v;');
checkElementText(library, r'''
-const dynamic a = null;
-@
- a/*location: test.dart;a?*/
-int v;
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ static v @23
+ metadata
+ Annotation
+ atSign.offset: 16
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @17
+ type: int
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
+ synthetic static get v @23
+ returnType: int
+ synthetic static set v @23
+ parameters
+ requiredPositional _v @23
+ type: int
+ returnType: void
''');
}
test_metadata_typeParameter_ofClass() async {
var library = await checkLibrary('const a = null; class C<@a T> {}');
checkElementText(library, r'''
-class C<@
- a/*location: test.dart;a?*/
-T> {
-}
-const dynamic a = null;
+library
+ definingUnit
+ classes
+ class C @22
+ typeParameters
+ covariant T @27
+ defaultType: dynamic
+ metadata
+ Annotation
+ atSign.offset: 24
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @25
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
''');
}
@@ -12587,36 +24689,113 @@
class D {}
class E {}''');
checkElementText(library, r'''
-class alias C<@
- a/*location: test.dart;a?*/
-T> extends D with E {
- synthetic C() : super();
-}
-class D {
-}
-class E {
-}
-const dynamic a = null;
+library
+ definingUnit
+ classes
+ class alias C @22
+ typeParameters
+ covariant T @27
+ defaultType: dynamic
+ metadata
+ Annotation
+ atSign.offset: 24
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @25
+ supertype: D
+ mixins
+ E
+ constructors
+ synthetic @-1
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::D::@constructor::•
+ class D @48
+ constructors
+ synthetic @-1
+ class E @59
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
''');
}
test_metadata_typeParameter_ofFunction() async {
var library = await checkLibrary('const a = null; f<@a T>() {}');
checkElementText(library, r'''
-const dynamic a = null;
-dynamic f<@
- a/*location: test.dart;a?*/
-T>() {}
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
+ functions
+ f @16
+ typeParameters
+ covariant T @21
+ metadata
+ Annotation
+ atSign.offset: 18
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @19
+ returnType: dynamic
''');
}
test_metadata_typeParameter_ofTypedef() async {
var library = await checkLibrary('const a = null; typedef F<@a T>();');
checkElementText(library, r'''
-typedef F<@
- a/*location: test.dart;a?*/
-T> = dynamic Function();
-const dynamic a = null;
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @24
+ typeParameters
+ unrelated T @29
+ defaultType: dynamic
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @-1
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
+ topLevelVariables
+ static const a @6
+ type: dynamic
+ constantInitializer
+ NullLiteral
+ literal: null @0
+ staticType: null
+ accessors
+ synthetic static get a @6
+ returnType: dynamic
''');
}
@@ -12631,24 +24810,37 @@
as TopLevelVariableElement;
expect(x.metadata, hasLength(1));
// Check details.
- checkElementText(
- library,
- r'''
-const int a;
- constantInitializer
- IntegerLiteral
- literal: 0
- staticType: int
-int x;
- metadata
- Annotation
- element: self::@getter::a
- name: SimpleIdentifier
- staticElement: self::@getter::a
- staticType: null
- token: a
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static const a @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @10
+ staticType: int
+ static x @20
+ metadata
+ Annotation
+ atSign.offset: 13
+ element: self::@getter::a
+ name: SimpleIdentifier
+ staticElement: self::@getter::a
+ staticType: null
+ token: a @14
+ type: int
+ accessors
+ synthetic static get a @6
+ returnType: int
+ synthetic static get x @20
+ returnType: int
+ synthetic static set x @20
+ parameters
+ requiredPositional _x @20
+ type: int
+ returnType: void
+''');
}
test_metadata_value_class_staticField() async {
@@ -12660,35 +24852,43 @@
@A.x
class C {}
''');
- checkElementText(
- library,
- r'''
-class A {
- static const int x;
- constantInitializer
- IntegerLiteral
- literal: 0
- staticType: int
-}
-class C {
-}
- metadata
- Annotation
- element: self::@class::A::@getter::x
- name: PrefixedIdentifier
- identifier: SimpleIdentifier
- staticElement: self::@class::A::@getter::x
- staticType: null
- token: x
- period: .
- prefix: SimpleIdentifier
- staticElement: self::@class::A
- staticType: null
- token: A
- staticElement: self::@class::A::@getter::x
- staticType: null
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ static const x @25
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @29
+ staticType: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get x @25
+ returnType: int
+ class C @45
+ metadata
+ Annotation
+ atSign.offset: 34
+ element: self::@class::A::@getter::x
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: self::@class::A::@getter::x
+ staticType: null
+ token: x @37
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @35
+ staticElement: self::@class::A::@getter::x
+ staticType: null
+ constructors
+ synthetic @-1
+''');
}
test_metadata_value_enum_constant() async {
@@ -12698,36 +24898,57 @@
@E.b
class C {}
''');
- checkElementText(
- library,
- r'''
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E a;
- static const E b;
- static const E c;
- String toString() {}
-}
-class C {
-}
- metadata
- Annotation
- element: self::@enum::E::@getter::b
- name: PrefixedIdentifier
- identifier: SimpleIdentifier
- staticElement: self::@enum::E::@getter::b
- staticType: null
- token: b
- period: .
- prefix: SimpleIdentifier
- staticElement: self::@enum::E
- staticType: null
- token: E
- staticElement: self::@enum::E::@getter::b
- staticType: null
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @28
+ metadata
+ Annotation
+ atSign.offset: 17
+ element: self::@enum::E::@getter::b
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: self::@enum::E::@getter::b
+ staticType: null
+ token: b @20
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @18
+ staticElement: self::@enum::E::@getter::b
+ staticType: null
+ constructors
+ synthetic @-1
+ enums
+ enum E @5
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const a @8
+ type: E
+ static const b @11
+ type: E
+ static const c @14
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get a @-1
+ returnType: E
+ synthetic static get b @-1
+ returnType: E
+ synthetic static get c @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
+''');
}
test_metadata_value_extension_staticField() async {
@@ -12739,35 +24960,43 @@
@E.x
class C {}
''');
- checkElementText(
- library,
- r'''
-class C {
-}
- metadata
- Annotation
- element: self::@extension::E::@getter::x
- name: PrefixedIdentifier
- identifier: SimpleIdentifier
- staticElement: self::@extension::E::@getter::x
- staticType: null
- token: x
- period: .
- prefix: SimpleIdentifier
- staticElement: self::@extension::E
- staticType: null
- token: E
- staticElement: self::@extension::E::@getter::x
- staticType: null
-extension E on int {
- static const int x;
- constantInitializer
- IntegerLiteral
- literal: 0
- staticType: int
-}
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @56
+ metadata
+ Annotation
+ atSign.offset: 45
+ element: self::@extension::E::@getter::x
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: self::@extension::E::@getter::x
+ staticType: null
+ token: x @48
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@extension::E
+ staticType: null
+ token: E @46
+ staticElement: self::@extension::E::@getter::x
+ staticType: null
+ constructors
+ synthetic @-1
+ extensions
+ E @10
+ extendedType: int
+ fields
+ static const x @36
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @40
+ staticType: int
+ accessors
+ synthetic static get x @36
+ returnType: int
+''');
}
test_metadata_value_prefix_extension_staticField() async {
@@ -12782,33 +25011,36 @@
@foo.E.x
class C {}
''');
- checkElementText(
- library,
- r'''
-import 'package:test/foo.dart' as foo;
-class C {
-}
- metadata
- Annotation
- constructorName: SimpleIdentifier
- staticElement: package:test/foo.dart::@extension::E::@getter::x
- staticType: null
- token: x
- element: package:test/foo.dart::@extension::E::@getter::x
- name: PrefixedIdentifier
- identifier: SimpleIdentifier
- staticElement: package:test/foo.dart::@extension::E
- staticType: null
- token: E
- period: .
- prefix: SimpleIdentifier
- staticElement: self::@prefix::foo
- staticType: null
- token: foo
- staticElement: package:test/foo.dart::@extension::E
- staticType: null
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ imports
+ package:test/foo.dart as foo @21
+ definingUnit
+ classes
+ class C @41
+ metadata
+ Annotation
+ atSign.offset: 26
+ constructorName: SimpleIdentifier
+ staticElement: package:test/foo.dart::@extension::E::@getter::x
+ staticType: null
+ token: x @33
+ element: package:test/foo.dart::@extension::E::@getter::x
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: package:test/foo.dart::@extension::E
+ staticType: null
+ token: E @31
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::foo
+ staticType: null
+ token: foo @27
+ staticElement: package:test/foo.dart::@extension::E
+ staticType: null
+ constructors
+ synthetic @-1
+''');
}
test_method_documented() async {
@@ -12820,12 +25052,16 @@
f() {}
}''');
checkElementText(library, r'''
-class C {
- /**
- * Docs
- */
- dynamic f() {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ f @34
+ documentationComment: /**\n * Docs\n */
+ returnType: dynamic
''');
}
@@ -12855,12 +25091,28 @@
var library = await checkLibrary('class C extends D { void f(value) {} }'
' abstract class D { void f(int value); }');
checkElementText(library, r'''
-class C extends D {
- void f(int value) {}
-}
-abstract class D {
- void f(int value);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ supertype: D
+ constructors
+ synthetic @-1
+ methods
+ f @25
+ parameters
+ requiredPositional value @27
+ type: int
+ returnType: void
+ abstract class D @54
+ constructors
+ synthetic @-1
+ methods
+ abstract f @63
+ parameters
+ requiredPositional value @69
+ type: int
+ returnType: void
''');
}
@@ -12874,21 +25126,43 @@
}
''');
checkElementText(library, r'''
-class C extends D {
- int f() {}
-}
-abstract class D {
- int f();
-}
+library
+ definingUnit
+ classes
+ class C @6
+ supertype: D
+ constructors
+ synthetic @-1
+ methods
+ f @22
+ returnType: int
+ abstract class D @52
+ constructors
+ synthetic @-1
+ methods
+ abstract f @62
+ returnType: int
''');
}
test_method_type_parameter() async {
var library = await checkLibrary('class C { T f<T, U>(U u) => null; }');
checkElementText(library, r'''
-class C {
- T f<T, U>(U u) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ f @12
+ typeParameters
+ covariant T @14
+ covariant U @17
+ parameters
+ requiredPositional u @22
+ type: U
+ returnType: T
''');
}
@@ -12899,18 +25173,54 @@
}
''');
checkElementText(library, r'''
-class C<T, U> {
- V f<V, W>(T t, U u, W w) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ covariant U @11
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ f @20
+ typeParameters
+ covariant V @22
+ covariant W @25
+ parameters
+ requiredPositional t @30
+ type: T
+ requiredPositional u @35
+ type: U
+ requiredPositional w @40
+ type: W
+ returnType: V
''');
}
test_method_type_parameter_with_function_typed_parameter() async {
var library = await checkLibrary('class C { void f<T, U>(T x(U u)) {} }');
checkElementText(library, r'''
-class C {
- void f<T, U>(T Function(U) x/*(U u)*/) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ f @15
+ typeParameters
+ covariant T @17
+ covariant U @20
+ parameters
+ requiredPositional x @25
+ type: T Function(U)
+ parameters
+ requiredPositional u @29
+ type: U
+ returnType: void
''');
}
@@ -12925,13 +25235,40 @@
var c = new B().a();
''');
checkElementText(library, r'''
-class A {
- double call() {}
-}
-class B {
- A a;
-}
-double c;
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ call @19
+ returnType: double
+ class B @42
+ fields
+ a @50
+ type: A
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get a @50
+ returnType: A
+ synthetic set a @50
+ parameters
+ requiredPositional _a @50
+ type: A
+ returnType: void
+ topLevelVariables
+ static c @59
+ type: double
+ accessors
+ synthetic static get c @59
+ returnType: double
+ synthetic static set c @59
+ parameters
+ requiredPositional _c @59
+ type: double
+ returnType: void
''');
}
@@ -12950,20 +25287,65 @@
}
''');
checkElementText(library, r'''
-class A {
-}
-class B {
-}
-class C {
-}
-class D {
-}
-mixin M<T extends num = num, U> on A, B implements C, D {
- T f;
- U get g {}
- void set s(int v) {}
- int m(double v) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ class B @17
+ constructors
+ synthetic @-1
+ class C @28
+ constructors
+ synthetic @-1
+ class D @39
+ constructors
+ synthetic @-1
+ mixins
+ mixin M @51
+ typeParameters
+ covariant T @53
+ bound: num
+ defaultType: num
+ covariant U @68
+ defaultType: dynamic
+ superclassConstraints
+ A
+ B
+ interfaces
+ C
+ D
+ fields
+ synthetic g @-1
+ type: U
+ synthetic s @-1
+ type: int
+ f @101
+ type: T
+ constructors
+ synthetic @-1
+ accessors
+ get g @112
+ returnType: U
+ set s @126
+ parameters
+ requiredPositional v @132
+ type: int
+ returnType: void
+ synthetic get f @101
+ returnType: T
+ synthetic set f @101
+ parameters
+ requiredPositional _f @101
+ type: T
+ returnType: void
+ methods
+ m @144
+ parameters
+ requiredPositional v @153
+ type: double
+ returnType: int
''');
}
@@ -12973,9 +25355,20 @@
final x = 0;
}''');
checkElementText(library, r'''
-mixin M on Object {
- final int x;
-}
+library
+ definingUnit
+ mixins
+ mixin M @6
+ superclassConstraints
+ Object
+ fields
+ final x @18
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @18
+ returnType: int
''');
}
@@ -12996,8 +25389,14 @@
mixin M {}
''');
checkElementText(library, r'''
-mixin M on Object {
-}
+library
+ definingUnit
+ mixins
+ mixin M @6
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
''');
}
@@ -13009,13 +25408,30 @@
class B extends A<int> with M {}
''');
checkElementText(library, r'''
-class A<T> {
-}
-class B extends A<int*>* with M<int*>* {
- synthetic B();
-}
-mixin M<U> on A<U*>* {
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class B @42
+ supertype: A<int*>*
+ mixins
+ M<int*>*
+ constructors
+ synthetic @-1
+ mixins
+ mixin M @20
+ typeParameters
+ covariant U @22
+ defaultType: dynamic
+ superclassConstraints
+ A<U*>*
+ constructors
+ synthetic @-1
''');
}
@@ -13026,13 +25442,30 @@
class B extends A<int> with M {}
''');
checkElementText(library, r'''
-class A<T> {
-}
-class B extends A<int> with M<int> {
- synthetic B();
-}
-mixin M<U> on A<U> {
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class B @42
+ supertype: A<int>
+ mixins
+ M<int>
+ constructors
+ synthetic @-1
+ mixins
+ mixin M @20
+ typeParameters
+ covariant U @22
+ defaultType: dynamic
+ superclassConstraints
+ A<U>
+ constructors
+ synthetic @-1
''');
}
@@ -13050,10 +25483,18 @@
class D extends A<int> with B<int>, C {}
''');
checkElementText(library, r'''
-import 'a.dart';
-class D extends A<int*>* with B<int*>*, C<int*>* {
- synthetic D();
-}
+library
+ imports
+ a.dart
+ definingUnit
+ classes
+ class D @37
+ supertype: A<int*>*
+ mixins
+ B<int*>*
+ C<int*>*
+ constructors
+ synthetic @-1
''');
}
@@ -13068,10 +25509,17 @@
class B extends A<int> with M {}
''');
checkElementText(library, r'''
-import 'a.dart';
-class B extends A<int*>* with M<int*>* {
- synthetic B();
-}
+library
+ imports
+ a.dart
+ definingUnit
+ classes
+ class B @38
+ supertype: A<int*>*
+ mixins
+ M<int*>*
+ constructors
+ synthetic @-1
''');
}
@@ -13103,56 +25551,94 @@
}
''');
checkElementText(library, r'''
-class A {
-}
-mixin B on A {
- void A() {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ mixins
+ mixin B @17
+ superclassConstraints
+ A
+ constructors
+ synthetic @-1
+ methods
+ A @33
+ returnType: void
''');
}
test_mixin_typeParameters_variance_contravariant() async {
var library = await checkLibrary('mixin M<in T> {}');
- checkElementText(
- library,
- r'''
-mixin M<contravariant T> on Object {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ mixins
+ mixin M @6
+ typeParameters
+ contravariant T @11
+ defaultType: dynamic
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
+''');
}
test_mixin_typeParameters_variance_covariant() async {
var library = await checkLibrary('mixin M<out T> {}');
- checkElementText(
- library,
- r'''
-mixin M<covariant T> on Object {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ mixins
+ mixin M @6
+ typeParameters
+ covariant T @12
+ defaultType: dynamic
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
+''');
}
test_mixin_typeParameters_variance_invariant() async {
var library = await checkLibrary('mixin M<inout T> {}');
- checkElementText(
- library,
- r'''
-mixin M<invariant T> on Object {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ mixins
+ mixin M @6
+ typeParameters
+ invariant T @14
+ defaultType: dynamic
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
+''');
}
test_mixin_typeParameters_variance_multiple() async {
var library = await checkLibrary('mixin M<inout T, in U, out V> {}');
- checkElementText(
- library,
- r'''
-mixin M<invariant T, contravariant U, covariant V> on Object {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ mixins
+ mixin M @6
+ typeParameters
+ invariant T @14
+ defaultType: dynamic
+ contravariant U @20
+ defaultType: dynamic
+ covariant V @27
+ defaultType: dynamic
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
+''');
}
test_nameConflict_exportedAndLocal() async {
@@ -13166,8 +25652,21 @@
C v = null;
''');
checkElementText(library, r'''
-import 'c.dart';
-C v;
+library
+ imports
+ c.dart
+ definingUnit
+ topLevelVariables
+ static v @19
+ type: C
+ accessors
+ synthetic static get v @19
+ returnType: C
+ synthetic static set v @19
+ parameters
+ requiredPositional _v @19
+ type: C
+ returnType: void
''');
}
@@ -13183,8 +25682,21 @@
C v = null;
''');
checkElementText(library, r'''
-import 'd.dart';
-C v;
+library
+ imports
+ d.dart
+ definingUnit
+ topLevelVariables
+ static v @19
+ type: C
+ accessors
+ synthetic static get v @19
+ returnType: C
+ synthetic static set v @19
+ parameters
+ requiredPositional _v @19
+ type: C
+ returnType: void
''');
}
@@ -13204,8 +25716,21 @@
C v = null;
''');
checkElementText(library, r'''
-import 'c.dart';
-C v;
+library
+ imports
+ c.dart
+ definingUnit
+ topLevelVariables
+ static v @19
+ type: C
+ accessors
+ synthetic static get v @19
+ returnType: C
+ synthetic static set v @19
+ parameters
+ requiredPositional _v @19
+ type: C
+ returnType: void
''');
}
@@ -13222,9 +25747,22 @@
A v = null;
''');
checkElementText(library, r'''
-import 'a.dart';
-import 'b.dart';
-A v;
+library
+ imports
+ a.dart
+ b.dart
+ definingUnit
+ topLevelVariables
+ static v @36
+ type: A
+ accessors
+ synthetic static get v @36
+ returnType: A
+ synthetic static set v @36
+ parameters
+ requiredPositional _v @36
+ type: A
+ returnType: void
''');
}
@@ -13235,15 +25773,17 @@
A.named();
}
''');
- checkElementText(
- library,
- r'''
-class A@6 {
- A[nameOffset: 12]();
- A.named[periodOffset: 20][nameOffset: 21][nameEnd: 26]();
-}
-''',
- withOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ @12
+ named @21
+ periodOffset: 20
+ nameEnd: 26
+''');
}
test_nameOffset_class_constructor_parameter() async {
@@ -13252,14 +25792,17 @@
A(int a);
}
''');
- checkElementText(
- library,
- r'''
-class A@6 {
- A[nameOffset: 12](int a@18);
-}
-''',
- withOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ @12
+ parameters
+ requiredPositional a @18
+ type: int
+''');
}
test_nameOffset_class_field() async {
@@ -13268,17 +25811,25 @@
int foo = 0;
}
''');
- checkElementText(
- library,
- r'''
-class A@6 {
- int foo@16;
- synthetic int get foo@16 {}
- synthetic void set foo@16(int _foo@16) {}
-}
-''',
- withOffsets: true,
- withSyntheticAccessors: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ foo @16
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get foo @16
+ returnType: int
+ synthetic set foo @16
+ parameters
+ requiredPositional _foo @16
+ type: int
+ returnType: void
+''');
}
test_nameOffset_class_getter() async {
@@ -13287,14 +25838,20 @@
int get foo => 0;
}
''');
- checkElementText(
- library,
- r'''
-class A@6 {
- int get foo@20 {}
-}
-''',
- withOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ synthetic foo @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ get foo @20
+ returnType: int
+''');
}
test_nameOffset_class_method() async {
@@ -13303,14 +25860,22 @@
void foo<T>(int a) {}
}
''');
- checkElementText(
- library,
- r'''
-class A@6 {
- void foo@17<T@21>(int a@28) {}
-}
-''',
- withOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ foo @17
+ typeParameters
+ covariant T @21
+ parameters
+ requiredPositional a @28
+ type: int
+ returnType: void
+''');
}
test_nameOffset_class_setter() async {
@@ -13319,125 +25884,183 @@
set foo(int x) {}
}
''');
- checkElementText(
- library,
- r'''
-class A@6 {
- void set foo@16(int x@24) {}
-}
-''',
- withOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ synthetic foo @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ set foo @16
+ parameters
+ requiredPositional x @24
+ type: int
+ returnType: void
+''');
}
test_nameOffset_class_typeParameter() async {
var library = await checkLibrary(r'''
class A<T> {}
''');
- checkElementText(
- library,
- r'''
-class A@6<T@8> {
-}
-''',
- withOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+''');
}
test_nameOffset_extension_typeParameter() async {
var library = await checkLibrary(r'''
extension E<T> on int {}
''');
- checkElementText(
- library,
- r'''
-extension E@10<T@12> on int {
-}
-''',
- withOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ extensions
+ E @10
+ typeParameters
+ covariant T @12
+ extendedType: int
+''');
}
test_nameOffset_function_functionTypedFormal_parameter() async {
var library = await checkLibrary(r'''
void f(void f<U>(int a)) {}
''');
- checkElementText(
- library,
- r'''
-void f@5(void Function<U>(int) f@12/*<U@14>*//*(int a@21)*/) {}
-''',
- withOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ functions
+ f @5
+ parameters
+ requiredPositional f @12
+ type: void Function<U>(int)
+ typeParameters
+ covariant U @14
+ parameters
+ requiredPositional a @21
+ type: int
+ returnType: void
+''');
}
test_nameOffset_function_functionTypedFormal_parameter2() async {
var library = await checkLibrary(r'''
void f({required void f<U>(int a)}) {}
''');
- checkElementText(
- library,
- r'''
-void f@5({void Function<U>(int) f@22/*<U@24>*//*(int a@31)*/}) {}
-''',
- withOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ functions
+ f @5
+ parameters
+ requiredName f @22
+ type: void Function<U>(int)
+ typeParameters
+ covariant U @24
+ parameters
+ requiredPositional a @31
+ type: int
+ returnType: void
+''');
}
test_nameOffset_function_typeParameter() async {
var library = await checkLibrary(r'''
void f<T>() {}
''');
- checkElementText(
- library,
- r'''
-void f@5<T@7>() {}
-''',
- withOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ functions
+ f @5
+ typeParameters
+ covariant T @7
+ returnType: void
+''');
}
test_nameOffset_functionTypeAlias_typeParameter() async {
var library = await checkLibrary(r'''
typedef void F<T>();
''');
- checkElementText(
- library,
- r'''
-typedef F@13<T@15> = void Function();
-''',
- withOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @13
+ typeParameters
+ unrelated T @15
+ defaultType: dynamic
+ aliasedType: void Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void
+''');
}
test_nameOffset_genericTypeAlias_typeParameter() async {
var library = await checkLibrary(r'''
typedef F<T> = void Function();
''');
- checkElementText(
- library,
- r'''
-typedef F@8<T@10> = void Function();
-''',
- withOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ F @8
+ typeParameters
+ unrelated T @10
+ defaultType: dynamic
+ aliasedType: void Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void
+''');
}
test_nameOffset_mixin_typeParameter() async {
var library = await checkLibrary(r'''
mixin M<T> {}
''');
- checkElementText(
- library,
- r'''
-mixin M@6<T@8> on Object {
-}
-''',
- withOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ mixins
+ mixin M @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
+''');
}
test_nameOffset_unit_getter() async {
var library = await checkLibrary(r'''
int get foo => 0;
''');
- checkElementText(
- library,
- r'''
-int get foo@8 {}
-''',
- withOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ synthetic static foo @-1
+ type: int
+ accessors
+ get foo @8
+ returnType: int
+''');
}
test_nested_generic_functions_in_generic_class_with_function_typed_params() async {
@@ -13450,9 +26073,23 @@
}
''');
checkElementText(library, r'''
-class C<T, U> {
- void g<V, W>() {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ covariant U @11
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ g @23
+ typeParameters
+ covariant V @25
+ covariant W @28
+ returnType: void
''');
}
@@ -13472,9 +26109,23 @@
}
''');
checkElementText(library, r'''
-class C<T, U> {
- void g<V, W>() {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ covariant U @11
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ g @23
+ typeParameters
+ covariant V @25
+ covariant W @28
+ returnType: void
''');
}
@@ -13488,7 +26139,14 @@
}
''');
checkElementText(library, r'''
-void f<T, U>() {}
+library
+ definingUnit
+ functions
+ f @5
+ typeParameters
+ covariant T @7
+ covariant U @10
+ returnType: void
''');
}
@@ -13508,7 +26166,14 @@
}
''');
checkElementText(library, r'''
-void f<T, U>() {}
+library
+ definingUnit
+ functions
+ f @5
+ typeParameters
+ covariant T @7
+ covariant U @10
+ returnType: void
''');
}
@@ -13518,8 +26183,17 @@
typedef G = F Function();
''');
checkElementText(library, r'''
-notSimplyBounded typedef F = dynamic Function() Function();
-notSimplyBounded typedef G = dynamic Function() Function();
+library
+ definingUnit
+ typeAliases
+ notSimplyBounded F @8
+ aliasedType: dynamic Function() Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic Function()
+ notSimplyBounded G @34
+ aliasedType: dynamic Function() Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic Function()
''');
}
@@ -13528,7 +26202,13 @@
typedef F = List<F> Function();
''');
checkElementText(library, r'''
-notSimplyBounded typedef F = List<dynamic Function()> Function();
+library
+ definingUnit
+ typeAliases
+ notSimplyBounded F @8
+ aliasedType: List<dynamic Function()> Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: List<dynamic Function()>
''');
}
@@ -13537,7 +26217,17 @@
typedef F<T extends F> = void Function();
''');
checkElementText(library, r'''
-notSimplyBounded typedef F<T extends dynamic Function()> = void Function();
+library
+ definingUnit
+ typeAliases
+ notSimplyBounded F @8
+ typeParameters
+ unrelated T @10
+ bound: dynamic Function()
+ defaultType: dynamic
+ aliasedType: void Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void
''');
}
@@ -13546,7 +26236,16 @@
typedef F<T> = void Function();
''');
checkElementText(library, r'''
-typedef F<T> = void Function();
+library
+ definingUnit
+ typeAliases
+ F @8
+ typeParameters
+ unrelated T @10
+ defaultType: dynamic
+ aliasedType: void Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void
''');
}
@@ -13555,7 +26254,13 @@
typedef F = void Function();
''');
checkElementText(library, r'''
-typedef F = void Function();
+library
+ definingUnit
+ typeAliases
+ F @8
+ aliasedType: void Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void
''');
}
@@ -13565,7 +26270,15 @@
typedef F<T extends F> = List<int>;
''');
checkElementText(library, r'''
-notSimplyBounded typedef F<T extends dynamic> = List<int>;
+library
+ definingUnit
+ typeAliases
+ notSimplyBounded F @8
+ typeParameters
+ unrelated T @10
+ bound: dynamic
+ defaultType: dynamic
+ aliasedType: List<int>
''');
}
@@ -13575,7 +26288,11 @@
typedef F = List<F>;
''');
checkElementText(library, r'''
-notSimplyBounded typedef F = List<dynamic>;
+library
+ definingUnit
+ typeAliases
+ notSimplyBounded F @8
+ aliasedType: List<dynamic>
''');
}
@@ -13584,7 +26301,17 @@
typedef void F<T extends F>();
''');
checkElementText(library, r'''
-notSimplyBounded typedef F<T extends dynamic Function()> = void Function();
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased notSimplyBounded F @13
+ typeParameters
+ unrelated T @15
+ bound: dynamic Function()
+ defaultType: dynamic
+ aliasedType: void Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void
''');
}
@@ -13593,14 +26320,29 @@
typedef void F();
''');
checkElementText(library, r'''
-typedef F = void Function();
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @13
+ aliasedType: void Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void
''');
}
test_old_typedef_notSimplyBounded_simple_no_bounds() async {
var library = await checkLibrary('typedef void F<T>();');
checkElementText(library, r'''
-typedef F<T> = void Function();
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @13
+ typeParameters
+ unrelated T @15
+ defaultType: dynamic
+ aliasedType: void Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void
''');
}
@@ -13608,9 +26350,18 @@
var library =
await checkLibrary('class C { C operator+(C other) => null; }');
checkElementText(library, r'''
-class C {
- C +(C other) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ + @20
+ parameters
+ requiredPositional other @24
+ type: C
+ returnType: C
''');
}
@@ -13621,9 +26372,18 @@
}
''');
checkElementText(library, r'''
-class C {
- bool ==(Object other) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ == @25
+ parameters
+ requiredPositional other @35
+ type: Object
+ returnType: bool
''');
}
@@ -13631,9 +26391,18 @@
var library =
await checkLibrary('class C { external C operator+(C other); }');
checkElementText(library, r'''
-class C {
- external C +(C other) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ external + @29
+ parameters
+ requiredPositional other @33
+ type: C
+ returnType: C
''');
}
@@ -13644,9 +26413,18 @@
}
''');
checkElementText(library, r'''
-class C {
- bool >=(C other) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ >= @25
+ parameters
+ requiredPositional other @30
+ type: C
+ returnType: bool
''');
}
@@ -13654,9 +26432,18 @@
var library =
await checkLibrary('class C { bool operator[](int i) => null; }');
checkElementText(library, r'''
-class C {
- bool [](int i) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ [] @23
+ parameters
+ requiredPositional i @30
+ type: int
+ returnType: bool
''');
}
@@ -13667,9 +26454,20 @@
}
''');
checkElementText(library, r'''
-class C {
- void []=(int i, bool v) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ []= @25
+ parameters
+ requiredPositional i @33
+ type: int
+ requiredPositional v @41
+ type: bool
+ returnType: void
''');
}
@@ -13680,20 +26478,33 @@
}
''');
checkElementText(library, r'''
-class C {
- bool <=(C other) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ <= @25
+ parameters
+ requiredPositional other @30
+ type: C
+ returnType: bool
''');
}
test_parameter() async {
var library = await checkLibrary('void main(int p) {}');
- checkElementText(
- library,
- r'''
-void main@5(int p@14) {}
-''',
- withOffsets: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ functions
+ main @5
+ parameters
+ requiredPositional p @14
+ type: int
+ returnType: void
+''');
}
test_parameter_covariant_explicit_named() async {
@@ -13703,9 +26514,18 @@
}
''');
checkElementText(library, r'''
-class A {
- void m({covariant A a}) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @17
+ parameters
+ optionalNamed covariant a @32
+ type: A
+ returnType: void
''');
}
@@ -13716,9 +26536,18 @@
}
''');
checkElementText(library, r'''
-class A {
- void m([covariant A a]) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @17
+ parameters
+ optionalPositional covariant a @32
+ type: A
+ returnType: void
''');
}
@@ -13729,9 +26558,18 @@
}
''');
checkElementText(library, r'''
-class A {
- void m(covariant A a) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @17
+ parameters
+ requiredPositional covariant a @31
+ type: A
+ returnType: void
''');
}
@@ -13745,12 +26583,34 @@
}
''');
checkElementText(library, r'''
-class A<T> {
- void f(covariant T t) {}
-}
-class B<T> extends A<T> {
- void f(covariant T t) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ f @20
+ parameters
+ requiredPositional covariant t @34
+ type: T
+ returnType: void
+ class B @48
+ typeParameters
+ covariant T @50
+ defaultType: dynamic
+ supertype: A<T>
+ constructors
+ synthetic @-1
+ methods
+ f @75
+ parameters
+ requiredPositional covariant t @79
+ type: T
+ returnType: void
''');
}
@@ -13764,48 +26624,113 @@
}
''');
checkElementText(library, r'''
-class A {
- void m({covariant A a}) {}
-}
-class B extends A {
- void m({covariant B a}) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @17
+ parameters
+ optionalNamed covariant a @32
+ type: A
+ returnType: void
+ class B @47
+ supertype: A
+ constructors
+ synthetic @-1
+ methods
+ m @68
+ parameters
+ optionalNamed covariant a @73
+ type: B
+ returnType: void
''');
}
test_parameter_parameters() async {
var library = await checkLibrary('class C { f(g(x, y)) {} }');
checkElementText(library, r'''
-class C {
- dynamic f(dynamic Function(dynamic, dynamic) g/*(dynamic x, dynamic y)*/) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ f @10
+ parameters
+ requiredPositional g @12
+ type: dynamic Function(dynamic, dynamic)
+ parameters
+ requiredPositional x @14
+ type: dynamic
+ requiredPositional y @17
+ type: dynamic
+ returnType: dynamic
''');
}
test_parameter_parameters_in_generic_class() async {
var library = await checkLibrary('class C<A, B> { f(A g(B x)) {} }');
checkElementText(library, r'''
-class C<A, B> {
- dynamic f(A Function(B) g/*(B x)*/) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant A @8
+ defaultType: dynamic
+ covariant B @11
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ f @16
+ parameters
+ requiredPositional g @20
+ type: A Function(B)
+ parameters
+ requiredPositional x @24
+ type: B
+ returnType: dynamic
''');
}
test_parameter_return_type() async {
var library = await checkLibrary('class C { f(int g()) {} }');
checkElementText(library, r'''
-class C {
- dynamic f(int Function() g) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ f @10
+ parameters
+ requiredPositional g @16
+ type: int Function()
+ returnType: dynamic
''');
}
test_parameter_return_type_void() async {
var library = await checkLibrary('class C { f(void g()) {} }');
checkElementText(library, r'''
-class C {
- dynamic f(void Function() g) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ f @10
+ parameters
+ requiredPositional g @17
+ type: void Function()
+ returnType: dynamic
''');
}
@@ -13814,7 +26739,20 @@
void f(T a<T, U>(U u)) {}
''');
checkElementText(library, r'''
-void f(T Function<T, U>(U) a/*<T, U>*//*(U u)*/) {}
+library
+ definingUnit
+ functions
+ f @5
+ parameters
+ requiredPositional a @9
+ type: T Function<T, U>(U)
+ typeParameters
+ covariant T @11
+ covariant U @14
+ parameters
+ requiredPositional u @19
+ type: U
+ returnType: void
''');
}
@@ -13828,10 +26766,31 @@
}
''');
checkElementText(library, r'''
-class C {
- C.positional([dynamic x = 1]);
- C.named({dynamic x: 1});
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ positional @14
+ periodOffset: 13
+ nameEnd: 24
+ parameters
+ optionalPositional x @26
+ type: dynamic
+ constantInitializer
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ named @39
+ periodOffset: 38
+ nameEnd: 44
+ parameters
+ optionalNamed x @46
+ type: dynamic
+ constantInitializer
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
''');
}
@@ -13846,11 +26805,42 @@
}
''');
checkElementText(library, r'''
-class C {
- dynamic x;
- C.positional([final dynamic this.x = 1]);
- C.named({final dynamic this.x: 1});
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ x @16
+ type: dynamic
+ constructors
+ positional @23
+ periodOffset: 22
+ nameEnd: 33
+ parameters
+ optionalPositional final this.x @40
+ type: dynamic
+ constantInitializer
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ named @53
+ periodOffset: 52
+ nameEnd: 58
+ parameters
+ optionalNamed final this.x @65
+ type: dynamic
+ constantInitializer
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ accessors
+ synthetic get x @16
+ returnType: dynamic
+ synthetic set x @16
+ parameters
+ requiredPositional _x @16
+ type: dynamic
+ returnType: void
''');
}
@@ -13864,10 +26854,31 @@
}
''');
checkElementText(library, r'''
-class C {
- static void positional([dynamic x = 1]) {}
- static void named({dynamic x: 1}) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ methods
+ static positional @24
+ parameters
+ optionalPositional x @36
+ type: dynamic
+ constantInitializer
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ returnType: void
+ static named @61
+ parameters
+ optionalNamed x @68
+ type: dynamic
+ constantInitializer
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ returnType: void
''');
}
@@ -13880,8 +26891,27 @@
void named({x: 1}) {}
''');
checkElementText(library, r'''
-void positional([dynamic x = 1]) {}
-void named({dynamic x: 1}) {}
+library
+ definingUnit
+ functions
+ positional @5
+ parameters
+ optionalPositional x @17
+ type: dynamic
+ constantInitializer
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ returnType: void
+ named @33
+ parameters
+ optionalNamed x @40
+ type: dynamic
+ constantInitializer
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ returnType: void
''');
}
@@ -13891,11 +26921,18 @@
class B extends A {}
''');
checkElementText(library, r'''
-part 'test.dart';
-class B {
-}
-class B {
-}
+library
+ definingUnit
+ classes
+ class B @15
+ constructors
+ synthetic @-1
+ parts
+
+ classes
+ class B @15
+ constructors
+ synthetic @-1
''');
}
@@ -13912,15 +26949,13 @@
var library =
await checkLibrary('library my.lib; part "a.dart"; part "b.dart";');
checkElementText(library, r'''
-library my.lib;
-part 'a.dart';
-part 'b.dart';
---------------------
-unit: a.dart
-
---------------------
-unit: b.dart
-
+library
+ name: my.lib
+ nameOffset: 8
+ definingUnit
+ parts
+ a.dart
+ b.dart
''');
}
@@ -13928,11 +26963,12 @@
addSource('/foo/bar.dart', 'part of my.lib;');
var library = await checkLibrary('library my.lib; part "foo/";');
checkElementText(library, r'''
-library my.lib;
-part '';
---------------------
-unit: foo
-
+library
+ name: my.lib
+ nameOffset: 8
+ definingUnit
+ parts
+ foo/
''');
}
@@ -13943,7 +26979,10 @@
part "${foo}/bar.dart";
''');
checkElementText(library, r'''
-library my.lib;
+library
+ name: my.lib
+ nameOffset: 8
+ definingUnit
''');
}
@@ -13955,7 +26994,11 @@
}
''');
checkElementText(library, r'''
-void f() {}
+library
+ definingUnit
+ functions
+ f @5
+ returnType: void
''');
}
@@ -13963,9 +27006,21 @@
var library =
await checkLibrary('class C { void set x(covariant int value); }');
checkElementText(library, r'''
-class C {
- void set x(covariant int value);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract set x @19
+ parameters
+ requiredPositional covariant value @35
+ type: int
+ returnType: void
''');
}
@@ -13977,17 +27032,35 @@
*/
void set x(value) {}''');
checkElementText(library, r'''
-/**
- * Docs
- */
-void set x(dynamic value) {}
+library
+ definingUnit
+ topLevelVariables
+ synthetic static x @-1
+ type: dynamic
+ accessors
+ set x @69
+ documentationComment: /**\n * Docs\n */
+ parameters
+ requiredPositional value @71
+ type: dynamic
+ returnType: void
''');
}
test_setter_external() async {
var library = await checkLibrary('external void set x(int value);');
checkElementText(library, r'''
-external void set x(int value);
+library
+ definingUnit
+ topLevelVariables
+ synthetic static x @-1
+ type: int
+ accessors
+ external set x @18
+ parameters
+ requiredPositional value @24
+ type: int
+ returnType: void
''');
}
@@ -14006,17 +27079,57 @@
}
''');
checkElementText(library, r'''
-class A {
- int t;
-}
-class B extends A {
- double t;
-}
-class C extends A implements B {
-}
-class D extends C {
- void set t(dynamic p) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ t @16
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get t @16
+ returnType: int
+ synthetic set t @16
+ parameters
+ requiredPositional _t @16
+ type: int
+ returnType: void
+ class B @27
+ supertype: A
+ fields
+ t @50
+ type: double
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get t @50
+ returnType: double
+ synthetic set t @50
+ parameters
+ requiredPositional _t @50
+ type: double
+ returnType: void
+ class C @61
+ supertype: A
+ interfaces
+ B
+ constructors
+ synthetic @-1
+ class D @96
+ supertype: C
+ fields
+ synthetic t @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ set t @121
+ parameters
+ requiredPositional p @123
+ type: dynamic
+ returnType: void
''');
}
@@ -14025,12 +27138,34 @@
await checkLibrary('class C extends D { void set f(value) {} }'
' abstract class D { void set f(int value); }');
checkElementText(library, r'''
-class C extends D {
- void set f(int value) {}
-}
-abstract class D {
- void set f(int value);
-}
+library
+ definingUnit
+ classes
+ class C @6
+ supertype: D
+ fields
+ synthetic f @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ set f @29
+ parameters
+ requiredPositional value @31
+ type: int
+ returnType: void
+ abstract class D @58
+ fields
+ synthetic f @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract set f @71
+ parameters
+ requiredPositional value @77
+ type: int
+ returnType: void
''');
}
@@ -14041,16 +27176,38 @@
}
''');
checkElementText(library, r'''
-class C {
- static void set f(int value) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic static f @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ static set f @23
+ parameters
+ requiredPositional value @29
+ type: int
+ returnType: void
''');
}
test_setter_inferred_type_top_level_implicit_return() async {
var library = await checkLibrary('set f(int value) {}');
checkElementText(library, r'''
-void set f(int value) {}
+library
+ definingUnit
+ topLevelVariables
+ synthetic static f @-1
+ type: int
+ accessors
+ set f @4
+ parameters
+ requiredPositional value @10
+ type: int
+ returnType: void
''');
}
@@ -14058,8 +27215,24 @@
var library =
await checkLibrary('void set x(int value) {} set y(value) {}');
checkElementText(library, r'''
-void set x(int value) {}
-void set y(dynamic value) {}
+library
+ definingUnit
+ topLevelVariables
+ synthetic static x @-1
+ type: int
+ synthetic static y @-1
+ type: dynamic
+ accessors
+ set x @9
+ parameters
+ requiredPositional value @15
+ type: int
+ returnType: void
+ set y @29
+ parameters
+ requiredPositional value @31
+ type: dynamic
+ returnType: void
''');
}
@@ -14069,8 +27242,17 @@
bool f() => true;
''');
checkElementText(library, r'''
-final int Function<T>(T) v;
-bool f() {}
+library
+ definingUnit
+ topLevelVariables
+ static final v @6
+ type: int Function<T>(T)
+ accessors
+ synthetic static get v @6
+ returnType: int Function<T>(T)
+ functions
+ f @52
+ returnType: bool
''');
}
@@ -14081,7 +27263,17 @@
}
''');
checkElementText(library, r'''
-void f<T, U>(bool b) {}
+library
+ definingUnit
+ functions
+ f @5
+ typeParameters
+ covariant T @7
+ covariant U @10
+ parameters
+ requiredPositional b @18
+ type: bool
+ returnType: void
''');
}
@@ -14093,10 +27285,31 @@
bool f() => false;
''');
checkElementText(library, r'''
-class C<T, U> {
- int Function(T, U) v;
-}
-bool f() {}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ covariant U @11
+ defaultType: dynamic
+ fields
+ v @22
+ type: int Function(T, U)
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get v @22
+ returnType: int Function(T, U)
+ synthetic set v @22
+ parameters
+ requiredPositional _v @22
+ type: int Function(T, U)
+ returnType: void
+ functions
+ f @74
+ returnType: bool
''');
}
@@ -14107,7 +27320,17 @@
}
''');
checkElementText(library, r'''
-void f<T, U>(bool b) {}
+library
+ definingUnit
+ functions
+ f @5
+ typeParameters
+ covariant T @7
+ covariant U @10
+ parameters
+ requiredPositional b @18
+ type: bool
+ returnType: void
''');
}
@@ -14117,8 +27340,17 @@
bool f() => true;
''');
checkElementText(library, r'''
-final int Function() v;
-bool f() {}
+library
+ definingUnit
+ topLevelVariables
+ static final v @6
+ type: int Function()
+ accessors
+ synthetic static get v @6
+ returnType: int Function()
+ functions
+ f @40
+ returnType: bool
''');
}
@@ -14128,8 +27360,17 @@
bool f() => true;
''');
checkElementText(library, r'''
-final int Function(int, String) v;
-bool f() {}
+library
+ definingUnit
+ topLevelVariables
+ static final v @6
+ type: int Function(int, String)
+ accessors
+ synthetic static get v @6
+ returnType: int Function(int, String)
+ functions
+ f @70
+ returnType: bool
''');
}
@@ -14137,50 +27378,134 @@
var library = await checkLibrary('''
external int i;
''');
- checkElementText(library, '''
-external int i;
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static i @13
+ type: int
+ accessors
+ synthetic static get i @13
+ returnType: int
+ synthetic static set i @13
+ parameters
+ requiredPositional _i @13
+ type: int
+ returnType: void
''');
}
test_type_arguments_explicit_dynamic_dynamic() async {
var library = await checkLibrary('Map<dynamic, dynamic> m;');
checkElementText(library, r'''
-Map<dynamic, dynamic> m;
+library
+ definingUnit
+ topLevelVariables
+ static m @22
+ type: Map<dynamic, dynamic>
+ accessors
+ synthetic static get m @22
+ returnType: Map<dynamic, dynamic>
+ synthetic static set m @22
+ parameters
+ requiredPositional _m @22
+ type: Map<dynamic, dynamic>
+ returnType: void
''');
}
test_type_arguments_explicit_dynamic_int() async {
var library = await checkLibrary('Map<dynamic, int> m;');
checkElementText(library, r'''
-Map<dynamic, int> m;
+library
+ definingUnit
+ topLevelVariables
+ static m @18
+ type: Map<dynamic, int>
+ accessors
+ synthetic static get m @18
+ returnType: Map<dynamic, int>
+ synthetic static set m @18
+ parameters
+ requiredPositional _m @18
+ type: Map<dynamic, int>
+ returnType: void
''');
}
test_type_arguments_explicit_String_dynamic() async {
var library = await checkLibrary('Map<String, dynamic> m;');
checkElementText(library, r'''
-Map<String, dynamic> m;
+library
+ definingUnit
+ topLevelVariables
+ static m @21
+ type: Map<String, dynamic>
+ accessors
+ synthetic static get m @21
+ returnType: Map<String, dynamic>
+ synthetic static set m @21
+ parameters
+ requiredPositional _m @21
+ type: Map<String, dynamic>
+ returnType: void
''');
}
test_type_arguments_explicit_String_int() async {
var library = await checkLibrary('Map<String, int> m;');
checkElementText(library, r'''
-Map<String, int> m;
+library
+ definingUnit
+ topLevelVariables
+ static m @17
+ type: Map<String, int>
+ accessors
+ synthetic static get m @17
+ returnType: Map<String, int>
+ synthetic static set m @17
+ parameters
+ requiredPositional _m @17
+ type: Map<String, int>
+ returnType: void
''');
}
test_type_arguments_implicit() async {
var library = await checkLibrary('Map m;');
checkElementText(library, r'''
-Map<dynamic, dynamic> m;
+library
+ definingUnit
+ topLevelVariables
+ static m @4
+ type: Map<dynamic, dynamic>
+ accessors
+ synthetic static get m @4
+ returnType: Map<dynamic, dynamic>
+ synthetic static set m @4
+ parameters
+ requiredPositional _m @4
+ type: Map<dynamic, dynamic>
+ returnType: void
''');
}
test_type_dynamic() async {
var library = await checkLibrary('dynamic d;');
checkElementText(library, r'''
-dynamic d;
+library
+ definingUnit
+ topLevelVariables
+ static d @8
+ type: dynamic
+ accessors
+ synthetic static get d @8
+ returnType: dynamic
+ synthetic static set d @8
+ parameters
+ requiredPositional _d @8
+ type: dynamic
+ returnType: void
''');
}
@@ -14192,9 +27517,29 @@
};
var b = 0;
''');
- checkElementText(library, '''
-int Function() a;
-int b;
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static a @4
+ type: int Function()
+ static b @42
+ type: int
+ accessors
+ synthetic static get a @4
+ returnType: int Function()
+ synthetic static set a @4
+ parameters
+ requiredPositional _a @4
+ type: int Function()
+ returnType: void
+ synthetic static get b @42
+ returnType: int
+ synthetic static set b @42
+ parameters
+ requiredPositional _b @42
+ type: int
+ returnType: void
''');
}
@@ -14204,9 +27549,22 @@
import 'a.dart' deferred as a;
var x = a.loadLibrary;
''');
- checkElementText(library, '''
-import 'a.dart' deferred as a;
-Future<dynamic> Function() x;
+ checkElementText(library, r'''
+library
+ imports
+ a.dart deferred as a @28
+ definingUnit
+ topLevelVariables
+ static x @35
+ type: Future<dynamic> Function()
+ accessors
+ synthetic static get x @35
+ returnType: Future<dynamic> Function()
+ synthetic static set x @35
+ parameters
+ requiredPositional _x @35
+ type: Future<dynamic> Function()
+ returnType: void
''');
}
@@ -14214,8 +27572,20 @@
var library = await checkLibrary('''
var x = (int f(String x)) => 0;
''');
- checkElementText(library, '''
-int Function(int Function(String)) x;
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static x @4
+ type: int Function(int Function(String))
+ accessors
+ synthetic static get x @4
+ returnType: int Function(int Function(String))
+ synthetic static set x @4
+ parameters
+ requiredPositional _x @4
+ type: int Function(int Function(String))
+ returnType: void
''');
}
@@ -14223,8 +27593,20 @@
var library = await checkLibrary('''
var x = (int Function(String) f) => 0;
''');
- checkElementText(library, '''
-int Function(int Function(String)) x;
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static x @4
+ type: int Function(int Function(String))
+ accessors
+ synthetic static get x @4
+ returnType: int Function(int Function(String))
+ synthetic static set x @4
+ parameters
+ requiredPositional _x @4
+ type: int Function(int Function(String))
+ returnType: void
''');
}
@@ -14235,9 +27617,22 @@
import 'a.dart';
var y = x;
''');
- checkElementText(library, '''
-import 'a.dart';
-int y;
+ checkElementText(library, r'''
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static y @21
+ type: int
+ accessors
+ synthetic static get y @21
+ returnType: int
+ synthetic static set y @21
+ parameters
+ requiredPositional _y @21
+ type: int
+ returnType: void
''');
}
@@ -14254,13 +27649,43 @@
}
''');
checkElementText(library, r'''
-class A<T> {
- T value;
- A(final T this.value);
-}
-class B {
- A<String> a;
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ fields
+ value @17
+ type: T
+ constructors
+ @27
+ parameters
+ requiredPositional final this.value @34
+ type: T
+ accessors
+ synthetic get value @17
+ returnType: T
+ synthetic set value @17
+ parameters
+ requiredPositional _value @17
+ type: T
+ returnType: void
+ class B @51
+ fields
+ a @61
+ type: A<String>
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get a @61
+ returnType: A<String>
+ synthetic set a @61
+ parameters
+ requiredPositional _a @61
+ type: A<String>
+ returnType: void
''');
}
@@ -14281,19 +27706,72 @@
mixin M {}
''');
checkElementText(library, r'''
-class A<T> {
- T value;
- A(final T this.value);
-}
-class alias B<T> extends A<T> with M {
- synthetic B(final T value) : super(
- value/*location: test.dart;B;;value*/);
-}
-class C {
- B<int> a;
-}
-mixin M on Object {
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ fields
+ value @17
+ type: T
+ constructors
+ @27
+ parameters
+ requiredPositional final this.value @34
+ type: T
+ accessors
+ synthetic get value @17
+ returnType: T
+ synthetic set value @17
+ parameters
+ requiredPositional _value @17
+ type: T
+ returnType: void
+ class alias B @51
+ typeParameters
+ covariant T @53
+ defaultType: dynamic
+ supertype: A<T>
+ mixins
+ M
+ constructors
+ synthetic @-1
+ parameters
+ requiredPositional final value @-1
+ type: T
+ constantInitializers
+ SuperConstructorInvocation
+ argumentList: ArgumentList
+ arguments
+ SimpleIdentifier
+ staticElement: value@-1
+ staticType: T
+ token: value @-1
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ staticElement: self::@class::A::@constructor::•
+ class C @78
+ fields
+ a @88
+ type: B<int>
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get a @88
+ returnType: B<int>
+ synthetic set a @88
+ parameters
+ requiredPositional _a @88
+ type: B<int>
+ returnType: void
+ mixins
+ mixin M @112
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
''');
}
@@ -14305,10 +27783,29 @@
}
''');
checkElementText(library, r'''
-class A<T> {
- int f;
- A(final int this.f);
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ fields
+ f @19
+ type: int
+ constructors
+ @28
+ parameters
+ requiredPositional final this.f @35
+ type: int
+ accessors
+ synthetic get f @19
+ returnType: int
+ synthetic set f @19
+ parameters
+ requiredPositional _f @19
+ type: int
+ returnType: void
''');
}
@@ -14322,12 +27819,36 @@
''');
// There is no cycle with `a` and `b`, because `A` is not generic,
// so the type of `new A(...)` does not depend on its arguments.
- checkElementText(library, '''
-class A {
- A(dynamic _);
-}
-A a;
-A b;
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ @12
+ parameters
+ requiredPositional _ @14
+ type: dynamic
+ topLevelVariables
+ static a @24
+ type: A
+ static b @44
+ type: A
+ accessors
+ synthetic static get a @24
+ returnType: A
+ synthetic static set a @24
+ parameters
+ requiredPositional _a @24
+ type: A
+ returnType: void
+ synthetic static get b @44
+ returnType: A
+ synthetic static set b @44
+ parameters
+ requiredPositional _b @44
+ type: A
+ returnType: void
''');
}
@@ -14340,9 +27861,22 @@
var v = C;
''');
checkElementText(library, r'''
-import 'a.dart';
-import 'b.dart';
-dynamic v;
+library
+ imports
+ a.dart
+ b.dart
+ definingUnit
+ topLevelVariables
+ static v @38
+ type: dynamic
+ accessors
+ synthetic static get v @38
+ returnType: dynamic
+ synthetic static set v @38
+ parameters
+ requiredPositional _v @38
+ type: dynamic
+ returnType: void
''');
}
@@ -14350,8 +27884,20 @@
var library = await checkLibrary('''
var x = (t) => (u) => t + u;
''');
- checkElementText(library, '''
-dynamic Function(dynamic) Function(dynamic) x;
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static x @4
+ type: dynamic Function(dynamic) Function(dynamic)
+ accessors
+ synthetic static get x @4
+ returnType: dynamic Function(dynamic) Function(dynamic)
+ synthetic static set x @4
+ parameters
+ requiredPositional _x @4
+ type: dynamic Function(dynamic) Function(dynamic)
+ returnType: void
''');
}
@@ -14359,8 +27905,20 @@
var library = await checkLibrary('''
var x = (int t) => (int u) => t + u;
''');
- checkElementText(library, '''
-int Function(int) Function(int) x;
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static x @4
+ type: int Function(int) Function(int)
+ accessors
+ synthetic static get x @4
+ returnType: int Function(int) Function(int)
+ synthetic static set x @4
+ parameters
+ requiredPositional _x @4
+ type: int Function(int) Function(int)
+ returnType: void
''');
}
@@ -14368,8 +27926,20 @@
var library = await checkLibrary('''
var x = ([y: 0]) => y;
''');
- checkElementText(library, '''
-dynamic Function([dynamic]) x;
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static x @4
+ type: dynamic Function([dynamic])
+ accessors
+ synthetic static get x @4
+ returnType: dynamic Function([dynamic])
+ synthetic static set x @4
+ parameters
+ requiredPositional _x @4
+ type: dynamic Function([dynamic])
+ returnType: void
''');
}
@@ -14388,16 +27958,42 @@
final c = C(b);
''');
checkElementText(library, r'''
-class A {
-}
-class B extends A {
-}
-class C<T extends A = A> {
- final T f;
- const C(final T this.f);
-}
-final B b;
-final C<B> c;
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ class B @18
+ supertype: A
+ constructors
+ synthetic @-1
+ class C @40
+ typeParameters
+ covariant T @42
+ bound: A
+ defaultType: A
+ fields
+ final f @67
+ type: T
+ constructors
+ const @78
+ parameters
+ requiredPositional final this.f @85
+ type: T
+ accessors
+ synthetic get f @67
+ returnType: T
+ topLevelVariables
+ static final b @98
+ type: B
+ static final c @113
+ type: C<B>
+ accessors
+ synthetic static get b @98
+ returnType: B
+ synthetic static get c @113
+ returnType: C<B>
''');
}
@@ -14408,11 +28004,29 @@
}
var v = 'a'.foo;
''');
- checkElementText(library, '''
-extension on String {
- int get foo {}
-}
-int v;
+ checkElementText(library, r'''
+library
+ definingUnit
+ extensions
+ @-1
+ extendedType: String
+ fields
+ synthetic foo @-1
+ type: int
+ accessors
+ get foo @32
+ returnType: int
+ topLevelVariables
+ static v @48
+ type: int
+ accessors
+ synthetic static get v @48
+ returnType: int
+ synthetic static set v @48
+ parameters
+ requiredPositional _v @48
+ type: int
+ returnType: void
''');
}
@@ -14425,12 +28039,50 @@
int V = 0;
''', allowErrors: true);
checkElementText(library, r'''
-typedef F = dynamic Function(dynamic p);
-class C<T extends dynamic> {
-}
-dynamic V2;
-int V;
-dynamic f(dynamic p) {}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ bound: dynamic
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ typeAliases
+ functionTypeAliasBased F @34
+ aliasedType: dynamic Function(dynamic)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional p @-1
+ type: dynamic
+ returnType: dynamic
+ topLevelVariables
+ static V2 @56
+ type: dynamic
+ static V @71
+ type: int
+ accessors
+ synthetic static get V2 @56
+ returnType: dynamic
+ synthetic static set V2 @56
+ parameters
+ requiredPositional _V2 @56
+ type: dynamic
+ returnType: void
+ synthetic static get V @71
+ returnType: int
+ synthetic static set V @71
+ parameters
+ requiredPositional _V @71
+ type: int
+ returnType: void
+ functions
+ f @44
+ parameters
+ requiredPositional p @48
+ type: dynamic
+ returnType: dynamic
''');
}
@@ -14440,8 +28092,28 @@
static List<V> V2;
''', allowErrors: true);
checkElementText(library, r'''
-dynamic V;
-List<dynamic> V2;
+library
+ definingUnit
+ topLevelVariables
+ static V @4
+ type: dynamic
+ static V2 @22
+ type: List<dynamic>
+ accessors
+ synthetic static get V @4
+ returnType: dynamic
+ synthetic static set V @4
+ parameters
+ requiredPositional _V @4
+ type: dynamic
+ returnType: void
+ synthetic static get V2 @22
+ returnType: List<dynamic>
+ synthetic static set V2 @22
+ parameters
+ requiredPositional _V2 @22
+ type: List<dynamic>
+ returnType: void
''');
}
@@ -14452,9 +28124,21 @@
}
''', allowErrors: true);
checkElementText(library, r'''
-class C<T> {
- dynamic m(dynamic p) {}
-}
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ m @15
+ parameters
+ requiredPositional p @21
+ type: dynamic
+ returnType: dynamic
''');
}
@@ -14463,7 +28147,19 @@
p.C v;
''', allowErrors: true);
checkElementText(library, r'''
-dynamic v;
+library
+ definingUnit
+ topLevelVariables
+ static v @4
+ type: dynamic
+ accessors
+ synthetic static get v @4
+ returnType: dynamic
+ synthetic static set v @4
+ parameters
+ requiredPositional _v @4
+ type: dynamic
+ returnType: void
''');
}
@@ -14471,14 +28167,38 @@
featureSet = FeatureSets.beforeNullSafe;
var library = await checkLibrary('Never d;');
checkElementText(library, r'''
-Null* d;
+library
+ definingUnit
+ topLevelVariables
+ static d @6
+ type: Null*
+ accessors
+ synthetic static get d @6
+ returnType: Null*
+ synthetic static set d @6
+ parameters
+ requiredPositional _d @6
+ type: Null*
+ returnType: void
''');
}
test_type_never_enableNnbd() async {
var library = await checkLibrary('Never d;');
checkElementText(library, r'''
-Never d;
+library
+ definingUnit
+ topLevelVariables
+ static d @6
+ type: Never
+ accessors
+ synthetic static get d @6
+ returnType: Never
+ synthetic static set d @6
+ parameters
+ requiredPositional _d @6
+ type: Never
+ returnType: void
''');
}
@@ -14488,10 +28208,27 @@
T t;
}
''');
- checkElementText(library, '''
-class C<T> {
- T t;
-}
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ fields
+ t @17
+ type: T
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get t @17
+ returnType: T
+ synthetic set t @17
+ parameters
+ requiredPositional _t @17
+ type: T
+ returnType: void
''');
}
@@ -14501,10 +28238,27 @@
T? t;
}
''');
- checkElementText(library, '''
-class C<T> {
- T? t;
-}
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ fields
+ t @18
+ type: T?
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get t @18
+ returnType: T?
+ synthetic set t @18
+ parameters
+ requiredPositional _t @18
+ type: T?
+ returnType: void
''');
}
@@ -14515,10 +28269,27 @@
T t;
}
''');
- checkElementText(library, '''
-class C<T> {
- T* t;
-}
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ fields
+ t @17
+ type: T*
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get t @17
+ returnType: T*
+ synthetic set t @17
+ parameters
+ requiredPositional _t @17
+ type: T*
+ returnType: void
''');
}
@@ -14531,18 +28302,68 @@
E e;
F f;''');
checkElementText(library, r'''
-typedef F = dynamic Function();
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E v;
- String toString() {}
-}
-class C {
-}
-C c;
-E e;
-dynamic Function() f;
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ enums
+ enum E @16
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const v @20
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get v @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
+ typeAliases
+ functionTypeAliasBased F @32
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
+ topLevelVariables
+ static c @39
+ type: C
+ static e @44
+ type: E
+ static f @49
+ type: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ accessors
+ synthetic static get c @39
+ returnType: C
+ synthetic static set c @39
+ parameters
+ requiredPositional _c @39
+ type: C
+ returnType: void
+ synthetic static get e @44
+ returnType: E
+ synthetic static set e @44
+ parameters
+ requiredPositional _e @44
+ type: E
+ returnType: void
+ synthetic static get f @49
+ returnType: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ synthetic static set f @49
+ parameters
+ requiredPositional _f @49
+ type: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ returnType: void
''');
}
@@ -14551,23 +28372,72 @@
var library =
await checkLibrary('library l; part "a.dart"; C c; E e; F f;');
checkElementText(library, r'''
-library l;
-part 'a.dart';
-C c;
-E e;
-dynamic Function() f;
---------------------
-unit: a.dart
-
-typedef F = dynamic Function();
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E v;
- String toString() {}
-}
-class C {
-}
+library
+ name: l
+ nameOffset: 8
+ definingUnit
+ topLevelVariables
+ static c @28
+ type: C
+ static e @33
+ type: E
+ static f @38
+ type: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ accessors
+ synthetic static get c @28
+ returnType: C
+ synthetic static set c @28
+ parameters
+ requiredPositional _c @28
+ type: C
+ returnType: void
+ synthetic static get e @33
+ returnType: E
+ synthetic static set e @33
+ parameters
+ requiredPositional _e @33
+ type: E
+ returnType: void
+ synthetic static get f @38
+ returnType: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ synthetic static set f @38
+ parameters
+ requiredPositional _f @38
+ type: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ returnType: void
+ parts
+ a.dart
+ classes
+ class C @17
+ constructors
+ synthetic @-1
+ enums
+ enum E @27
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const v @31
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get v @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
+ typeAliases
+ functionTypeAliasBased F @43
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
''');
}
@@ -14576,23 +28446,72 @@
var library = await checkLibrary(
'library l; part "a.dart"; class C {} enum E { v } typedef F();');
checkElementText(library, r'''
-library l;
-part 'a.dart';
-typedef F = dynamic Function();
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E v;
- String toString() {}
-}
-class C {
-}
---------------------
-unit: a.dart
-
-C c;
-E e;
-dynamic Function() f;
+library
+ name: l
+ nameOffset: 8
+ definingUnit
+ classes
+ class C @32
+ constructors
+ synthetic @-1
+ enums
+ enum E @42
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const v @46
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get v @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
+ typeAliases
+ functionTypeAliasBased F @58
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
+ parts
+ a.dart
+ topLevelVariables
+ static c @13
+ type: C
+ static e @18
+ type: E
+ static f @23
+ type: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ accessors
+ synthetic static get c @13
+ returnType: C
+ synthetic static set c @13
+ parameters
+ requiredPositional _c @13
+ type: C
+ returnType: void
+ synthetic static get e @18
+ returnType: E
+ synthetic static set e @18
+ parameters
+ requiredPositional _e @18
+ type: E
+ returnType: void
+ synthetic static get f @23
+ returnType: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ synthetic static set f @23
+ parameters
+ requiredPositional _f @23
+ type: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ returnType: void
''');
}
@@ -14602,27 +28521,73 @@
var library =
await checkLibrary('library l; part "a.dart"; part "b.dart";');
checkElementText(library, r'''
-library l;
-part 'a.dart';
-part 'b.dart';
---------------------
-unit: a.dart
-
-typedef F = dynamic Function();
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E v;
- String toString() {}
-}
-class C {
-}
---------------------
-unit: b.dart
-
-C c;
-E e;
-dynamic Function() f;
+library
+ name: l
+ nameOffset: 8
+ definingUnit
+ parts
+ a.dart
+ classes
+ class C @17
+ constructors
+ synthetic @-1
+ enums
+ enum E @27
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const v @31
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get v @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
+ typeAliases
+ functionTypeAliasBased F @43
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
+ b.dart
+ topLevelVariables
+ static c @13
+ type: C
+ static e @18
+ type: E
+ static f @23
+ type: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ accessors
+ synthetic static get c @13
+ returnType: C
+ synthetic static set c @13
+ parameters
+ requiredPositional _c @13
+ type: C
+ returnType: void
+ synthetic static get e @18
+ returnType: E
+ synthetic static set e @18
+ parameters
+ requiredPositional _e @18
+ type: E
+ returnType: void
+ synthetic static get f @23
+ returnType: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ synthetic static set f @23
+ parameters
+ requiredPositional _f @23
+ type: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ returnType: void
''');
}
@@ -14631,63 +28596,189 @@
'part of l; class C {} enum E { v } typedef F(); C c; E e; F f;');
var library = await checkLibrary('library l; part "a.dart";');
checkElementText(library, r'''
-library l;
-part 'a.dart';
---------------------
-unit: a.dart
-
-typedef F = dynamic Function();
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E v;
- String toString() {}
-}
-class C {
-}
-C c;
-E e;
-dynamic Function() f;
+library
+ name: l
+ nameOffset: 8
+ definingUnit
+ parts
+ a.dart
+ classes
+ class C @17
+ constructors
+ synthetic @-1
+ enums
+ enum E @27
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const v @31
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get v @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
+ typeAliases
+ functionTypeAliasBased F @43
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
+ topLevelVariables
+ static c @50
+ type: C
+ static e @55
+ type: E
+ static f @60
+ type: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ accessors
+ synthetic static get c @50
+ returnType: C
+ synthetic static set c @50
+ parameters
+ requiredPositional _c @50
+ type: C
+ returnType: void
+ synthetic static get e @55
+ returnType: E
+ synthetic static set e @55
+ parameters
+ requiredPositional _e @55
+ type: E
+ returnType: void
+ synthetic static get f @60
+ returnType: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ synthetic static set f @60
+ parameters
+ requiredPositional _f @60
+ type: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ returnType: void
''');
}
test_type_reference_to_class() async {
var library = await checkLibrary('class C {} C c;');
checkElementText(library, r'''
-class C {
-}
-C c;
+library
+ definingUnit
+ classes
+ class C @6
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static c @13
+ type: C
+ accessors
+ synthetic static get c @13
+ returnType: C
+ synthetic static set c @13
+ parameters
+ requiredPositional _c @13
+ type: C
+ returnType: void
''');
}
test_type_reference_to_class_with_type_arguments() async {
var library = await checkLibrary('class C<T, U> {} C<int, String> c;');
checkElementText(library, r'''
-class C<T, U> {
-}
-C<int, String> c;
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ covariant U @11
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static c @32
+ type: C<int, String>
+ accessors
+ synthetic static get c @32
+ returnType: C<int, String>
+ synthetic static set c @32
+ parameters
+ requiredPositional _c @32
+ type: C<int, String>
+ returnType: void
''');
}
test_type_reference_to_class_with_type_arguments_implicit() async {
var library = await checkLibrary('class C<T, U> {} C c;');
checkElementText(library, r'''
-class C<T, U> {
-}
-C<dynamic, dynamic> c;
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ covariant U @11
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static c @19
+ type: C<dynamic, dynamic>
+ accessors
+ synthetic static get c @19
+ returnType: C<dynamic, dynamic>
+ synthetic static set c @19
+ parameters
+ requiredPositional _c @19
+ type: C<dynamic, dynamic>
+ returnType: void
''');
}
test_type_reference_to_enum() async {
var library = await checkLibrary('enum E { v } E e;');
checkElementText(library, r'''
-enum E {
- synthetic final int index;
- synthetic static const List<E> values;
- static const E v;
- String toString() {}
-}
-E e;
+library
+ definingUnit
+ enums
+ enum E @5
+ fields
+ synthetic final index @-1
+ type: int
+ synthetic static const values @-1
+ type: List<E>
+ static const v @9
+ type: E
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get values @-1
+ returnType: List<E>
+ synthetic static get v @-1
+ returnType: E
+ methods
+ toString @-1
+ returnType: String
+ topLevelVariables
+ static e @15
+ type: E
+ accessors
+ synthetic static get e @15
+ returnType: E
+ synthetic static set e @15
+ parameters
+ requiredPositional _e @15
+ type: E
+ returnType: void
''');
}
@@ -14695,10 +28786,42 @@
addLibrarySource('/a.dart', 'class C {} enum E { v } typedef F();');
var library = await checkLibrary('import "a.dart"; C c; E e; F f;');
checkElementText(library, r'''
-import 'a.dart';
-C c;
-E e;
-dynamic Function() f;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static c @19
+ type: C
+ static e @24
+ type: E
+ static f @29
+ type: dynamic Function()
+ aliasElement: a.dart::@typeAlias::F
+ accessors
+ synthetic static get c @19
+ returnType: C
+ synthetic static set c @19
+ parameters
+ requiredPositional _c @19
+ type: C
+ returnType: void
+ synthetic static get e @24
+ returnType: E
+ synthetic static set e @24
+ parameters
+ requiredPositional _e @24
+ type: E
+ returnType: void
+ synthetic static get f @29
+ returnType: dynamic Function()
+ aliasElement: a.dart::@typeAlias::F
+ synthetic static set f @29
+ parameters
+ requiredPositional _f @29
+ type: dynamic Function()
+ aliasElement: a.dart::@typeAlias::F
+ returnType: void
''');
}
@@ -14707,10 +28830,42 @@
addLibrarySource('/b.dart', 'class C {} enum E { v } typedef F();');
var library = await checkLibrary('import "a.dart"; C c; E e; F f;');
checkElementText(library, r'''
-import 'a.dart';
-C c;
-E e;
-dynamic Function() f;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static c @19
+ type: C
+ static e @24
+ type: E
+ static f @29
+ type: dynamic Function()
+ aliasElement: b.dart::@typeAlias::F
+ accessors
+ synthetic static get c @19
+ returnType: C
+ synthetic static set c @19
+ parameters
+ requiredPositional _c @19
+ type: C
+ returnType: void
+ synthetic static get e @24
+ returnType: E
+ synthetic static set e @24
+ parameters
+ requiredPositional _e @24
+ type: E
+ returnType: void
+ synthetic static get f @29
+ returnType: dynamic Function()
+ aliasElement: b.dart::@typeAlias::F
+ synthetic static set f @29
+ parameters
+ requiredPositional _f @29
+ type: dynamic Function()
+ aliasElement: b.dart::@typeAlias::F
+ returnType: void
''');
}
@@ -14720,10 +28875,42 @@
addLibrarySource('/c.dart', 'class C {} enum E { v } typedef F();');
var library = await checkLibrary('import "a.dart"; C c; E e; F f;');
checkElementText(library, r'''
-import 'a.dart';
-C c;
-E e;
-dynamic Function() f;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static c @19
+ type: C
+ static e @24
+ type: E
+ static f @29
+ type: dynamic Function()
+ aliasElement: c.dart::@typeAlias::F
+ accessors
+ synthetic static get c @19
+ returnType: C
+ synthetic static set c @19
+ parameters
+ requiredPositional _c @19
+ type: C
+ returnType: void
+ synthetic static get e @24
+ returnType: E
+ synthetic static set e @24
+ parameters
+ requiredPositional _e @24
+ type: E
+ returnType: void
+ synthetic static get f @29
+ returnType: dynamic Function()
+ aliasElement: c.dart::@typeAlias::F
+ synthetic static set f @29
+ parameters
+ requiredPositional _f @29
+ type: dynamic Function()
+ aliasElement: c.dart::@typeAlias::F
+ returnType: void
''');
}
@@ -14733,10 +28920,42 @@
addLibrarySource('/a/c/c.dart', 'class C {} enum E { v } typedef F();');
var library = await checkLibrary('import "a/a.dart"; C c; E e; F f;');
checkElementText(library, r'''
-import 'a.dart';
-C c;
-E e;
-dynamic Function() f;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static c @21
+ type: C
+ static e @26
+ type: E
+ static f @31
+ type: dynamic Function()
+ aliasElement: c.dart::@typeAlias::F
+ accessors
+ synthetic static get c @21
+ returnType: C
+ synthetic static set c @21
+ parameters
+ requiredPositional _c @21
+ type: C
+ returnType: void
+ synthetic static get e @26
+ returnType: E
+ synthetic static set e @26
+ parameters
+ requiredPositional _e @26
+ type: E
+ returnType: void
+ synthetic static get f @31
+ returnType: dynamic Function()
+ aliasElement: c.dart::@typeAlias::F
+ synthetic static set f @31
+ parameters
+ requiredPositional _f @31
+ type: dynamic Function()
+ aliasElement: c.dart::@typeAlias::F
+ returnType: void
''');
}
@@ -14745,10 +28964,42 @@
addLibrarySource('/a/b/b.dart', 'class C {} enum E { v } typedef F();');
var library = await checkLibrary('import "a/a.dart"; C c; E e; F f;');
checkElementText(library, r'''
-import 'a.dart';
-C c;
-E e;
-dynamic Function() f;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static c @21
+ type: C
+ static e @26
+ type: E
+ static f @31
+ type: dynamic Function()
+ aliasElement: b.dart::@typeAlias::F
+ accessors
+ synthetic static get c @21
+ returnType: C
+ synthetic static set c @21
+ parameters
+ requiredPositional _c @21
+ type: C
+ returnType: void
+ synthetic static get e @26
+ returnType: E
+ synthetic static set e @26
+ parameters
+ requiredPositional _e @26
+ type: E
+ returnType: void
+ synthetic static get f @31
+ returnType: dynamic Function()
+ aliasElement: b.dart::@typeAlias::F
+ synthetic static set f @31
+ parameters
+ requiredPositional _f @31
+ type: dynamic Function()
+ aliasElement: b.dart::@typeAlias::F
+ returnType: void
''');
}
@@ -14757,10 +29008,42 @@
addSource('/b.dart', 'part of l; class C {} enum E { v } typedef F();');
var library = await checkLibrary('import "a.dart"; C c; E e; F f;');
checkElementText(library, r'''
-import 'a.dart';
-C c;
-E e;
-dynamic Function() f;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static c @19
+ type: C
+ static e @24
+ type: E
+ static f @29
+ type: dynamic Function()
+ aliasElement: a.dart::@typeAlias::F
+ accessors
+ synthetic static get c @19
+ returnType: C
+ synthetic static set c @19
+ parameters
+ requiredPositional _c @19
+ type: C
+ returnType: void
+ synthetic static get e @24
+ returnType: E
+ synthetic static set e @24
+ parameters
+ requiredPositional _e @24
+ type: E
+ returnType: void
+ synthetic static get f @29
+ returnType: dynamic Function()
+ aliasElement: a.dart::@typeAlias::F
+ synthetic static set f @29
+ parameters
+ requiredPositional _f @29
+ type: dynamic Function()
+ aliasElement: a.dart::@typeAlias::F
+ returnType: void
''');
}
@@ -14770,9 +29053,30 @@
addSource('/p2.dart', 'part of l; class C2 {}');
var library = await checkLibrary('import "a.dart"; C1 c1; C2 c2;');
checkElementText(library, r'''
-import 'a.dart';
-C1 c1;
-C2 c2;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static c1 @20
+ type: C1
+ static c2 @27
+ type: C2
+ accessors
+ synthetic static get c1 @20
+ returnType: C1
+ synthetic static set c1 @20
+ parameters
+ requiredPositional _c1 @20
+ type: C1
+ returnType: void
+ synthetic static get c2 @27
+ returnType: C2
+ synthetic static set c2 @27
+ parameters
+ requiredPositional _c2 @27
+ type: C2
+ returnType: void
''');
}
@@ -14781,10 +29085,42 @@
addSource('/a/c.dart', 'part of l; class C {} enum E { v } typedef F();');
var library = await checkLibrary('import "a/b.dart"; C c; E e; F f;');
checkElementText(library, r'''
-import 'b.dart';
-C c;
-E e;
-dynamic Function() f;
+library
+ imports
+ b.dart
+ definingUnit
+ topLevelVariables
+ static c @21
+ type: C
+ static e @26
+ type: E
+ static f @31
+ type: dynamic Function()
+ aliasElement: b.dart::@typeAlias::F
+ accessors
+ synthetic static get c @21
+ returnType: C
+ synthetic static set c @21
+ parameters
+ requiredPositional _c @21
+ type: C
+ returnType: void
+ synthetic static get e @26
+ returnType: E
+ synthetic static set e @26
+ parameters
+ requiredPositional _e @26
+ type: E
+ returnType: void
+ synthetic static get f @31
+ returnType: dynamic Function()
+ aliasElement: b.dart::@typeAlias::F
+ synthetic static set f @31
+ parameters
+ requiredPositional _f @31
+ type: dynamic Function()
+ aliasElement: b.dart::@typeAlias::F
+ returnType: void
''');
}
@@ -14792,18 +29128,69 @@
addLibrarySource('/a.dart', 'class C {} enum E { v } typedef F();');
var library = await checkLibrary('import "a.dart"; C c; E e; F f;');
checkElementText(library, r'''
-import 'a.dart';
-C c;
-E e;
-dynamic Function() f;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static c @19
+ type: C
+ static e @24
+ type: E
+ static f @29
+ type: dynamic Function()
+ aliasElement: a.dart::@typeAlias::F
+ accessors
+ synthetic static get c @19
+ returnType: C
+ synthetic static set c @19
+ parameters
+ requiredPositional _c @19
+ type: C
+ returnType: void
+ synthetic static get e @24
+ returnType: E
+ synthetic static set e @24
+ parameters
+ requiredPositional _e @24
+ type: E
+ returnType: void
+ synthetic static get f @29
+ returnType: dynamic Function()
+ aliasElement: a.dart::@typeAlias::F
+ synthetic static set f @29
+ parameters
+ requiredPositional _f @29
+ type: dynamic Function()
+ aliasElement: a.dart::@typeAlias::F
+ returnType: void
''');
}
test_type_reference_to_typedef() async {
var library = await checkLibrary('typedef F(); F f;');
checkElementText(library, r'''
-typedef F = dynamic Function();
-dynamic Function() f;
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @8
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
+ topLevelVariables
+ static f @15
+ type: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ accessors
+ synthetic static get f @15
+ returnType: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ synthetic static set f @15
+ parameters
+ requiredPositional _f @15
+ type: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ returnType: void
''');
}
@@ -14811,23 +29198,107 @@
var library =
await checkLibrary('typedef U F<T, U>(T t); F<int, String> f;');
checkElementText(library, r'''
-typedef F<T, U> = U Function(T t);
-String Function(int) f;
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @10
+ typeParameters
+ contravariant T @12
+ defaultType: dynamic
+ covariant U @15
+ defaultType: dynamic
+ aliasedType: U Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional t @-1
+ type: T
+ returnType: U
+ topLevelVariables
+ static f @39
+ type: String Function(int)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ int
+ String
+ accessors
+ synthetic static get f @39
+ returnType: String Function(int)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ int
+ String
+ synthetic static set f @39
+ parameters
+ requiredPositional _f @39
+ type: String Function(int)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ int
+ String
+ returnType: void
''');
}
test_type_reference_to_typedef_with_type_arguments_implicit() async {
var library = await checkLibrary('typedef U F<T, U>(T t); F f;');
checkElementText(library, r'''
-typedef F<T, U> = U Function(T t);
-dynamic Function(dynamic) f;
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @10
+ typeParameters
+ contravariant T @12
+ defaultType: dynamic
+ covariant U @15
+ defaultType: dynamic
+ aliasedType: U Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional t @-1
+ type: T
+ returnType: U
+ topLevelVariables
+ static f @26
+ type: dynamic Function(dynamic)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ dynamic
+ dynamic
+ accessors
+ synthetic static get f @26
+ returnType: dynamic Function(dynamic)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ dynamic
+ dynamic
+ synthetic static set f @26
+ parameters
+ requiredPositional _f @26
+ type: dynamic Function(dynamic)
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ dynamic
+ dynamic
+ returnType: void
''');
}
test_type_unresolved() async {
var library = await checkLibrary('C c;', allowErrors: true);
checkElementText(library, r'''
-dynamic c;
+library
+ definingUnit
+ topLevelVariables
+ static c @2
+ type: dynamic
+ accessors
+ synthetic static get c @2
+ returnType: dynamic
+ synthetic static set c @2
+ parameters
+ requiredPositional _c @2
+ type: dynamic
+ returnType: void
''');
}
@@ -14835,8 +29306,21 @@
var library = await checkLibrary('import "dart:core" as core; core.C c;',
allowErrors: true);
checkElementText(library, r'''
-import 'dart:core' as core;
-dynamic c;
+library
+ imports
+ dart:core as core @22
+ definingUnit
+ topLevelVariables
+ static c @35
+ type: dynamic
+ accessors
+ synthetic static get c @35
+ returnType: dynamic
+ synthetic static set c @35
+ parameters
+ requiredPositional _c @35
+ type: dynamic
+ returnType: void
''');
}
@@ -14844,24 +29328,45 @@
var library = await checkLibrary(r'''
typedef void F(T a<T, U>(U u));
''');
- checkElementText(
- library,
- r'''
-typedef F = void Function(T Function<T, U>(U) a/*<covariant T, covariant U>*//*(U u)*/);
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @13
+ aliasedType: void Function(T Function<T, U>(U))
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional a @-1
+ type: T Function<T, U>(U)
+ typeParameters
+ covariant T @-1
+ covariant U @-1
+ parameters
+ requiredPositional u @-1
+ type: U
+ returnType: void
+''');
}
test_typeAlias_typeParameters_variance_function_contravariant() async {
var library = await checkLibrary(r'''
typedef F<T> = void Function(T);
''');
- checkElementText(
- library,
- r'''
-typedef F<contravariant T> = void Function(T );
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ F @8
+ typeParameters
+ contravariant T @10
+ defaultType: dynamic
+ aliasedType: void Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional @-1
+ type: T
+ returnType: void
+''');
}
test_typeAlias_typeParameters_variance_function_contravariant2() async {
@@ -14869,37 +29374,67 @@
typedef F1<T> = void Function(T);
typedef F2<T> = F1<T> Function();
''');
- checkElementText(
- library,
- r'''
-typedef F1<contravariant T> = void Function(T );
-typedef F2<contravariant T> = void Function(T) Function();
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ F1 @8
+ typeParameters
+ contravariant T @11
+ defaultType: dynamic
+ aliasedType: void Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional @-1
+ type: T
+ returnType: void
+ F2 @42
+ typeParameters
+ contravariant T @45
+ defaultType: dynamic
+ aliasedType: void Function(T) Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void Function(T)
+ aliasElement: self::@typeAlias::F1
+ aliasArguments
+ T
+''');
}
test_typeAlias_typeParameters_variance_function_covariant() async {
var library = await checkLibrary(r'''
typedef F<T> = T Function();
''');
- checkElementText(
- library,
- r'''
-typedef F<covariant T> = T Function();
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ F @8
+ typeParameters
+ covariant T @10
+ defaultType: dynamic
+ aliasedType: T Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: T
+''');
}
test_typeAlias_typeParameters_variance_function_covariant2() async {
var library = await checkLibrary(r'''
typedef F<T> = List<T> Function();
''');
- checkElementText(
- library,
- r'''
-typedef F<covariant T> = List<T> Function();
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ F @8
+ typeParameters
+ covariant T @10
+ defaultType: dynamic
+ aliasedType: List<T> Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: List<T>
+''');
}
test_typeAlias_typeParameters_variance_function_covariant3() async {
@@ -14907,13 +29442,28 @@
typedef F1<T> = T Function();
typedef F2<T> = F1<T> Function();
''');
- checkElementText(
- library,
- r'''
-typedef F1<covariant T> = T Function();
-typedef F2<covariant T> = T Function() Function();
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ F1 @8
+ typeParameters
+ covariant T @11
+ defaultType: dynamic
+ aliasedType: T Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: T
+ F2 @38
+ typeParameters
+ covariant T @41
+ defaultType: dynamic
+ aliasedType: T Function() Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: T Function()
+ aliasElement: self::@typeAlias::F1
+ aliasArguments
+ T
+''');
}
test_typeAlias_typeParameters_variance_function_covariant4() async {
@@ -14921,13 +29471,34 @@
typedef F1<T> = void Function(T);
typedef F2<T> = void Function(F1<T>);
''');
- checkElementText(
- library,
- r'''
-typedef F1<contravariant T> = void Function(T );
-typedef F2<covariant T> = void Function(void Function(T) );
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ F1 @8
+ typeParameters
+ contravariant T @11
+ defaultType: dynamic
+ aliasedType: void Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional @-1
+ type: T
+ returnType: void
+ F2 @42
+ typeParameters
+ covariant T @45
+ defaultType: dynamic
+ aliasedType: void Function(void Function(T))
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional @-1
+ type: void Function(T)
+ aliasElement: self::@typeAlias::F1
+ aliasArguments
+ T
+ returnType: void
+''');
}
test_typeAlias_typeParameters_variance_function_invalid() async {
@@ -14935,14 +29506,25 @@
class A {}
typedef F<T> = void Function(A<int>);
''');
- checkElementText(
- library,
- r'''
-typedef F<unrelated T> = void Function(A );
-class A {
-}
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ typeAliases
+ F @19
+ typeParameters
+ unrelated T @21
+ defaultType: dynamic
+ aliasedType: void Function(A)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional @-1
+ type: A
+ returnType: void
+''');
}
test_typeAlias_typeParameters_variance_function_invalid2() async {
@@ -14950,25 +29532,47 @@
typedef F = void Function();
typedef G<T> = void Function(F<int>);
''');
- checkElementText(
- library,
- r'''
-typedef F = void Function();
-typedef G<unrelated T> = void Function(void Function() );
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ F @8
+ aliasedType: void Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void
+ G @37
+ typeParameters
+ unrelated T @39
+ defaultType: dynamic
+ aliasedType: void Function(void Function())
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional @-1
+ type: void Function()
+ aliasElement: self::@typeAlias::F
+ returnType: void
+''');
}
test_typeAlias_typeParameters_variance_function_invariant() async {
var library = await checkLibrary(r'''
typedef F<T> = T Function(T);
''');
- checkElementText(
- library,
- r'''
-typedef F<invariant T> = T Function(T );
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ F @8
+ typeParameters
+ invariant T @10
+ defaultType: dynamic
+ aliasedType: T Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional @-1
+ type: T
+ returnType: T
+''');
}
test_typeAlias_typeParameters_variance_function_invariant2() async {
@@ -14976,25 +29580,52 @@
typedef F1<T> = T Function();
typedef F2<T> = F1<T> Function(T);
''');
- checkElementText(
- library,
- r'''
-typedef F1<covariant T> = T Function();
-typedef F2<invariant T> = T Function() Function(T );
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ F1 @8
+ typeParameters
+ covariant T @11
+ defaultType: dynamic
+ aliasedType: T Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: T
+ F2 @38
+ typeParameters
+ invariant T @41
+ defaultType: dynamic
+ aliasedType: T Function() Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional @-1
+ type: T
+ returnType: T Function()
+ aliasElement: self::@typeAlias::F1
+ aliasArguments
+ T
+''');
}
test_typeAlias_typeParameters_variance_function_unrelated() async {
var library = await checkLibrary(r'''
typedef F<T> = void Function(int);
''');
- checkElementText(
- library,
- r'''
-typedef F<unrelated T> = void Function(int );
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ F @8
+ typeParameters
+ unrelated T @10
+ defaultType: dynamic
+ aliasedType: void Function(int)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional @-1
+ type: int
+ returnType: void
+''');
}
test_typeAlias_typeParameters_variance_interface_contravariant() async {
@@ -15002,12 +29633,16 @@
var library = await checkLibrary(r'''
typedef A<T> = List<void Function(T)>;
''');
- checkElementText(
- library,
- r'''
-typedef A<contravariant T> = List<void Function(T)>;
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ A @8
+ typeParameters
+ contravariant T @10
+ defaultType: dynamic
+ aliasedType: List<void Function(T)>
+''');
}
test_typeAlias_typeParameters_variance_interface_contravariant2() async {
@@ -15016,13 +29651,26 @@
typedef A<T> = void Function(T);
typedef B<T> = List<A<T>>;
''');
- checkElementText(
- library,
- r'''
-typedef A<contravariant T> = void Function(T );
-typedef B<contravariant T> = List<void Function(T)>;
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ A @8
+ typeParameters
+ contravariant T @10
+ defaultType: dynamic
+ aliasedType: void Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional @-1
+ type: T
+ returnType: void
+ B @41
+ typeParameters
+ contravariant T @43
+ defaultType: dynamic
+ aliasedType: List<void Function(T)>
+''');
}
test_typeAlias_typeParameters_variance_interface_covariant() async {
@@ -15030,12 +29678,16 @@
var library = await checkLibrary(r'''
typedef A<T> = List<T>;
''');
- checkElementText(
- library,
- r'''
-typedef A<covariant T> = List<T>;
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ A @8
+ typeParameters
+ covariant T @10
+ defaultType: dynamic
+ aliasedType: List<T>
+''');
}
test_typeAlias_typeParameters_variance_interface_covariant2() async {
@@ -15044,13 +29696,21 @@
typedef A<T> = Map<int, T>;
typedef B<T> = List<A<T>>;
''');
- checkElementText(
- library,
- r'''
-typedef A<covariant T> = Map<int, T>;
-typedef B<covariant T> = List<Map<int, T>>;
-''',
- withTypeParameterVariance: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ A @8
+ typeParameters
+ covariant T @10
+ defaultType: dynamic
+ aliasedType: Map<int, T>
+ B @36
+ typeParameters
+ covariant T @38
+ defaultType: dynamic
+ aliasedType: List<Map<int, T>>
+''');
}
test_typedef_documented() async {
@@ -15061,10 +29721,14 @@
*/
typedef F();''');
checkElementText(library, r'''
-/**
- * Docs
- */
-typedef F = dynamic Function();
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @68
+ documentationComment: /**\n * Docs\n */
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
''');
}
@@ -15072,7 +29736,25 @@
var library = await checkLibrary(
'typedef F<T> = int Function<S>(List<S> list, num Function<A>(A), T);');
checkElementText(library, r'''
-typedef F<T> = int Function<S>(List<S> list, num Function<A>(A) , T );
+library
+ definingUnit
+ typeAliases
+ F @8
+ typeParameters
+ contravariant T @10
+ defaultType: dynamic
+ aliasedType: int Function<S>(List<S>, num Function<A>(A), T)
+ aliasedElement: GenericFunctionTypeElement
+ typeParameters
+ covariant S @-1
+ parameters
+ requiredPositional list @-1
+ type: List<S>
+ requiredPositional @-1
+ type: num Function<A>(A)
+ requiredPositional @-1
+ type: T
+ returnType: int
''');
}
@@ -15084,10 +29766,45 @@
}
''');
checkElementText(library, r'''
-typedef Foo<S> = S Function<T>(T x);
-class A {
- int Function<T>(T) f;
-}
+library
+ definingUnit
+ classes
+ class A @43
+ fields
+ f @58
+ type: int Function<T>(T)
+ aliasElement: self::@typeAlias::Foo
+ aliasArguments
+ int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get f @58
+ returnType: int Function<T>(T)
+ aliasElement: self::@typeAlias::Foo
+ aliasArguments
+ int
+ synthetic set f @58
+ parameters
+ requiredPositional _f @58
+ type: int Function<T>(T)
+ aliasElement: self::@typeAlias::Foo
+ aliasArguments
+ int
+ returnType: void
+ typeAliases
+ Foo @8
+ typeParameters
+ covariant S @12
+ defaultType: dynamic
+ aliasedType: S Function<T>(T)
+ aliasedElement: GenericFunctionTypeElement
+ typeParameters
+ covariant T @-1
+ parameters
+ requiredPositional x @-1
+ type: T
+ returnType: S
''');
}
@@ -15097,8 +29814,25 @@
F f;
''');
checkElementText(library, r'''
-typedef F = dynamic Function();
-dynamic Function() f;
+library
+ definingUnit
+ typeAliases
+ F @8
+ aliasedType: dynamic Function()
+ topLevelVariables
+ static f @19
+ type: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ accessors
+ synthetic static get f @19
+ returnType: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ synthetic static set f @19
+ parameters
+ requiredPositional _f @19
+ type: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ returnType: void
''');
}
@@ -15113,13 +29847,10 @@
void f(A a) {}
''');
- checkElementText(
- library,
- r'''
+ checkElementText(library, r'''
typedef A = dynamic;
void f(dynamic<aliasElement: self::@typeAlias::A> a) {}
-''',
- withAliasElementArguments: true);
+''');
}
test_typedef_nonFunction_aliasElement_functionType() async {
@@ -15131,15 +29862,37 @@
void f2(A2<int> a) {}
''');
- checkElementText(
- library,
- r'''
-typedef A1 = void Function();
-typedef A2<R> = R Function();
-void f1(void Function()<aliasElement: self::@typeAlias::A1> a) {}
-void f2(int Function()<aliasElement: self::@typeAlias::A2, aliasArguments: [int]> a) {}
-''',
- withAliasElementArguments: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ A1 @8
+ aliasedType: void Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void
+ A2 @38
+ typeParameters
+ covariant R @41
+ defaultType: dynamic
+ aliasedType: R Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: R
+ functions
+ f1 @65
+ parameters
+ requiredPositional a @71
+ type: void Function()
+ aliasElement: self::@typeAlias::A1
+ returnType: void
+ f2 @82
+ parameters
+ requiredPositional a @93
+ type: int Function()
+ aliasElement: self::@typeAlias::A2
+ aliasArguments
+ int
+ returnType: void
+''');
}
test_typedef_nonFunction_aliasElement_interfaceType() async {
@@ -15151,15 +29904,36 @@
void f2(A2<int, String> a) {}
''');
- checkElementText(
- library,
- r'''
-typedef A1 = List<int>;
-typedef A2<T, U> = Map<T, U>;
-void f1(List<int><aliasElement: self::@typeAlias::A1> a) {}
-void f2(Map<int, String><aliasElement: self::@typeAlias::A2, aliasArguments: [int, String]> a) {}
-''',
- withAliasElementArguments: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ A1 @8
+ aliasedType: List<int>
+ A2 @32
+ typeParameters
+ covariant T @35
+ defaultType: dynamic
+ covariant U @38
+ defaultType: dynamic
+ aliasedType: Map<T, U>
+ functions
+ f1 @59
+ parameters
+ requiredPositional a @65
+ type: List<int>
+ aliasElement: self::@typeAlias::A1
+ returnType: void
+ f2 @76
+ parameters
+ requiredPositional a @95
+ type: Map<int, String>
+ aliasElement: self::@typeAlias::A2
+ aliasArguments
+ int
+ String
+ returnType: void
+''');
}
@FailingTest(
@@ -15175,15 +29949,12 @@
void f2(A2<int> a) {}
''');
- checkElementText(
- library,
- r'''
+ checkElementText(library, r'''
typedef A1 = Never;
typedef A2<T> = Never?;
void f1(Never<aliasElement: self::@typeAlias::A1> a) {}
void f2(Never?<aliasElement: self::@typeAlias::A2, aliasArguments: [int]> a) {}
-''',
- withAliasElementArguments: true);
+''');
}
test_typedef_nonFunction_aliasElement_typeParameterType() async {
@@ -15193,13 +29964,27 @@
void f<U>(A<U> a) {}
''');
- checkElementText(
- library,
- r'''
-typedef A<T> = T;
-void f<U>(U<aliasElement: self::@typeAlias::A, aliasArguments: [U]> a) {}
-''',
- withAliasElementArguments: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ typeAliases
+ A @8
+ typeParameters
+ covariant T @10
+ defaultType: dynamic
+ aliasedType: T
+ functions
+ f @23
+ typeParameters
+ covariant U @25
+ parameters
+ requiredPositional a @33
+ type: U
+ aliasElement: self::@typeAlias::A
+ aliasArguments
+ U
+ returnType: void
+''');
}
@FailingTest(
@@ -15213,13 +29998,10 @@
void f(A a) {}
''');
- checkElementText(
- library,
- r'''
+ checkElementText(library, r'''
typedef A = void;
void f(void<aliasElement: self::@typeAlias::A> a) {}
-''',
- withAliasElementArguments: true);
+''');
}
test_typedef_nonFunction_asInterfaceType_interfaceType_none() async {
@@ -15230,11 +30012,28 @@
class B implements X<String> {}
''');
checkElementText(library, r'''
-typedef X<T> = A<int, T>;
-class A<T, U> {
-}
-class B implements A<int, String> {
-}
+library
+ definingUnit
+ classes
+ class A @32
+ typeParameters
+ covariant T @34
+ defaultType: dynamic
+ covariant U @37
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class B @49
+ interfaces
+ A<int, String>
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ typeParameters
+ covariant T @10
+ defaultType: dynamic
+ aliasedType: A<int, T>
''');
}
@@ -15248,15 +30047,33 @@
class D implements B, X<int>, C {}
''');
checkElementText(library, r'''
-typedef X<T> = A<T>?;
-class A<T> {
-}
-class B {
-}
-class C {
-}
-class D implements B, C {
-}
+library
+ definingUnit
+ classes
+ class A @28
+ typeParameters
+ covariant T @30
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class B @42
+ constructors
+ synthetic @-1
+ class C @53
+ constructors
+ synthetic @-1
+ class D @64
+ interfaces
+ B
+ C
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ typeParameters
+ covariant T @10
+ defaultType: dynamic
+ aliasedType: A<T>?
''');
}
@@ -15270,15 +30087,34 @@
class D implements B, X<int>, C {}
''');
checkElementText(library, r'''
-typedef X<T> = A<T?>;
-class A<T> {
-}
-class B {
-}
-class C {
-}
-class D implements B, A<int?>, C {
-}
+library
+ definingUnit
+ classes
+ class A @28
+ typeParameters
+ covariant T @30
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class B @42
+ constructors
+ synthetic @-1
+ class C @53
+ constructors
+ synthetic @-1
+ class D @64
+ interfaces
+ B
+ A<int?>
+ C
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ typeParameters
+ covariant T @10
+ defaultType: dynamic
+ aliasedType: A<T?>
''');
}
@@ -15289,9 +30125,15 @@
class A implements X {}
''');
checkElementText(library, r'''
-typedef X = Never;
-class A {
-}
+library
+ definingUnit
+ classes
+ class A @25
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ aliasedType: Never
''');
}
@@ -15302,9 +30144,15 @@
class A implements X {}
''');
checkElementText(library, r'''
-typedef X = Null;
-class A {
-}
+library
+ definingUnit
+ classes
+ class A @24
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ aliasedType: Null
''');
}
@@ -15317,13 +30165,30 @@
class C<U> implements A, X<U>, B {}
''');
checkElementText(library, r'''
-typedef X<T> = T;
-class A {
-}
-class B {
-}
-class C<U> implements A, B {
-}
+library
+ definingUnit
+ classes
+ class A @24
+ constructors
+ synthetic @-1
+ class B @35
+ constructors
+ synthetic @-1
+ class C @46
+ typeParameters
+ covariant U @48
+ defaultType: dynamic
+ interfaces
+ A
+ B
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ typeParameters
+ covariant T @10
+ defaultType: dynamic
+ aliasedType: T
''');
}
@@ -15336,13 +30201,24 @@
class C implements A, X, B {}
''');
checkElementText(library, r'''
-typedef X = void;
-class A {
-}
-class B {
-}
-class C implements A, B {
-}
+library
+ definingUnit
+ classes
+ class A @24
+ constructors
+ synthetic @-1
+ class B @35
+ constructors
+ synthetic @-1
+ class C @46
+ interfaces
+ A
+ B
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ aliasedType: void
''');
}
@@ -15354,12 +30230,24 @@
class B with X {}
''');
checkElementText(library, r'''
-typedef X = A<int>;
-class A<T> {
-}
-class B extends Object with A<int> {
- synthetic B();
-}
+library
+ definingUnit
+ classes
+ class A @26
+ typeParameters
+ covariant T @28
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class B @40
+ supertype: Object
+ mixins
+ A<int>
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ aliasedType: A<int>
''');
}
@@ -15373,16 +30261,36 @@
class B with M1, X, M2 {}
''');
checkElementText(library, r'''
-typedef X = A<int>?;
-class A<T> {
-}
-class B extends Object with M1, M2 {
- synthetic B();
-}
-mixin M1 on Object {
-}
-mixin M2 on Object {
-}
+library
+ definingUnit
+ classes
+ class A @27
+ typeParameters
+ covariant T @29
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class B @65
+ supertype: Object
+ mixins
+ M1
+ M2
+ constructors
+ synthetic @-1
+ mixins
+ mixin M1 @41
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
+ mixin M2 @53
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ aliasedType: A<int>?
''');
}
@@ -15396,16 +30304,37 @@
class B with M1, X, M2 {}
''');
checkElementText(library, r'''
-typedef X = A<int?>;
-class A<T> {
-}
-class B extends Object with M1, A<int?>, M2 {
- synthetic B();
-}
-mixin M1 on Object {
-}
-mixin M2 on Object {
-}
+library
+ definingUnit
+ classes
+ class A @27
+ typeParameters
+ covariant T @29
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class B @65
+ supertype: Object
+ mixins
+ M1
+ A<int?>
+ M2
+ constructors
+ synthetic @-1
+ mixins
+ mixin M1 @41
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
+ mixin M2 @53
+ superclassConstraints
+ Object
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ aliasedType: A<int?>
''');
}
@@ -15416,9 +30345,15 @@
class A extends X {}
''');
checkElementText(library, r'''
-typedef X = Never;
-class A {
-}
+library
+ definingUnit
+ classes
+ class A @25
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ aliasedType: Never
''');
}
@@ -15430,11 +30365,22 @@
class B extends X {}
''');
checkElementText(library, r'''
-typedef X = A<int>;
-class A<T> {
-}
-class B extends A<int> {
-}
+library
+ definingUnit
+ classes
+ class A @26
+ typeParameters
+ covariant T @28
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class B @40
+ supertype: A<int>
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ aliasedType: A<int>
''');
}
@@ -15446,11 +30392,25 @@
class B extends X<A<int>> {}
''');
checkElementText(library, r'''
-typedef X<T> = T;
-class A<T> {
-}
-class B extends A<int> {
-}
+library
+ definingUnit
+ classes
+ class A @24
+ typeParameters
+ covariant T @26
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class B @38
+ supertype: A<int>
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ typeParameters
+ covariant T @10
+ defaultType: dynamic
+ aliasedType: T
''');
}
@@ -15461,9 +30421,15 @@
class A extends X {}
''');
checkElementText(library, r'''
-typedef X = Null;
-class A {
-}
+library
+ definingUnit
+ classes
+ class A @24
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ aliasedType: Null
''');
}
@@ -15475,11 +30441,21 @@
class D extends X {}
''');
checkElementText(library, r'''
-typedef X = A<int>?;
-class A<T> {
-}
-class D {
-}
+library
+ definingUnit
+ classes
+ class A @27
+ typeParameters
+ covariant T @29
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class D @41
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ aliasedType: A<int>?
''');
}
@@ -15491,11 +30467,22 @@
class D extends X {}
''');
checkElementText(library, r'''
-typedef X = A<int?>;
-class A<T> {
-}
-class D extends A<int?> {
-}
+library
+ definingUnit
+ classes
+ class A @27
+ typeParameters
+ covariant T @29
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ class D @41
+ supertype: A<int?>
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ aliasedType: A<int?>
''');
}
@@ -15506,9 +30493,15 @@
class A extends X {}
''');
checkElementText(library, r'''
-typedef X = Never;
-class A {
-}
+library
+ definingUnit
+ classes
+ class A @25
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ aliasedType: Never
''');
}
@@ -15519,9 +30512,15 @@
class A extends X {}
''');
checkElementText(library, r'''
-typedef X = Null;
-class A {
-}
+library
+ definingUnit
+ classes
+ class A @24
+ constructors
+ synthetic @-1
+ typeAliases
+ X @8
+ aliasedType: Null
''');
}
@@ -15532,8 +30531,17 @@
void f(A a) {}
''');
checkElementText(library, r'''
-typedef A = dynamic;
-void f(dynamic a) {}
+library
+ definingUnit
+ typeAliases
+ A @8
+ aliasedType: dynamic
+ functions
+ f @26
+ parameters
+ requiredPositional a @30
+ type: dynamic
+ returnType: void
''');
}
@@ -15547,8 +30555,18 @@
_assertTypeStr(alias.aliasedType, 'dynamic Function()');
checkElementText(library, r'''
-typedef A = dynamic Function();
-void f(dynamic Function() a) {}
+library
+ definingUnit
+ typeAliases
+ A @8
+ aliasedType: dynamic Function()
+ functions
+ f @22
+ parameters
+ requiredPositional a @26
+ type: dynamic Function()
+ aliasElement: self::@typeAlias::A
+ returnType: void
''');
}
@@ -15559,8 +30577,18 @@
void f(A a) {}
''');
checkElementText(library, r'''
-typedef A = int;
-void f(int a) {}
+library
+ definingUnit
+ typeAliases
+ A @8
+ aliasedType: int
+ functions
+ f @22
+ parameters
+ requiredPositional a @26
+ type: int
+ aliasElement: self::@typeAlias::A
+ returnType: void
''');
}
@@ -15575,8 +30603,17 @@
void f(A a) {}
''');
checkElementText(library, r'''
-import 'a.dart';
-void f(List<int*>* a) {}
+library
+ imports
+ a.dart
+ definingUnit
+ functions
+ f @37
+ parameters
+ requiredPositional a @41
+ type: List<int*>*
+ aliasElement: a.dart::@typeAlias::A
+ returnType: void
''');
}
@@ -15587,8 +30624,18 @@
void f(A a) {}
''');
checkElementText(library, r'''
-typedef A = int?;
-void f(int? a) {}
+library
+ definingUnit
+ typeAliases
+ A @8
+ aliasedType: int?
+ functions
+ f @23
+ parameters
+ requiredPositional a @27
+ type: int?
+ aliasElement: self::@typeAlias::A
+ returnType: void
''');
}
@@ -15599,8 +30646,23 @@
void f(A<String> a) {}
''');
checkElementText(library, r'''
-typedef A<T> = Map<int, T>;
-void f(Map<int, String> a) {}
+library
+ definingUnit
+ typeAliases
+ A @8
+ typeParameters
+ covariant T @10
+ defaultType: dynamic
+ aliasedType: Map<int, T>
+ functions
+ f @33
+ parameters
+ requiredPositional a @45
+ type: Map<int, String>
+ aliasElement: self::@typeAlias::A
+ aliasArguments
+ String
+ returnType: void
''');
}
@@ -15611,8 +30673,17 @@
void f(A a) {}
''');
checkElementText(library, r'''
-typedef A = Never;
-void f(Never a) {}
+library
+ definingUnit
+ typeAliases
+ A @8
+ aliasedType: Never
+ functions
+ f @24
+ parameters
+ requiredPositional a @28
+ type: Never
+ returnType: void
''');
}
@@ -15623,8 +30694,17 @@
void f(A a) {}
''');
checkElementText(library, r'''
-typedef A = Never?;
-void f(Never? a) {}
+library
+ definingUnit
+ typeAliases
+ A @8
+ aliasedType: Never?
+ functions
+ f @25
+ parameters
+ requiredPositional a @29
+ type: Never?
+ returnType: void
''');
}
@@ -15636,9 +30716,28 @@
void f2(A<int> a) {}
''');
checkElementText(library, r'''
-typedef A<T> = T;
-void f1(dynamic a) {}
-void f2(int a) {}
+library
+ definingUnit
+ typeAliases
+ A @8
+ typeParameters
+ covariant T @10
+ defaultType: dynamic
+ aliasedType: T
+ functions
+ f1 @23
+ parameters
+ requiredPositional a @28
+ type: dynamic
+ returnType: void
+ f2 @39
+ parameters
+ requiredPositional a @49
+ type: int
+ aliasElement: self::@typeAlias::A
+ aliasArguments
+ int
+ returnType: void
''');
}
@@ -15650,9 +30749,28 @@
void f2(A<int> a) {}
''');
checkElementText(library, r'''
-typedef A<T> = T?;
-void f1(dynamic a) {}
-void f2(int? a) {}
+library
+ definingUnit
+ typeAliases
+ A @8
+ typeParameters
+ covariant T @10
+ defaultType: dynamic
+ aliasedType: T?
+ functions
+ f1 @24
+ parameters
+ requiredPositional a @29
+ type: dynamic
+ returnType: void
+ f2 @40
+ parameters
+ requiredPositional a @50
+ type: int?
+ aliasElement: self::@typeAlias::A
+ aliasArguments
+ int
+ returnType: void
''');
}
@@ -15663,8 +30781,17 @@
void f(A a) {}
''');
checkElementText(library, r'''
-typedef A = void;
-void f(void a) {}
+library
+ definingUnit
+ typeAliases
+ A @8
+ aliasedType: void
+ functions
+ f @23
+ parameters
+ requiredPositional a @27
+ type: void
+ returnType: void
''');
}
@@ -15676,9 +30803,24 @@
class C<T extends C<T>> {}
''');
checkElementText(library, r'''
-notSimplyBounded typedef F = void Function(C<C<dynamic>> c);
-notSimplyBounded class C<T extends C<T> = C<dynamic>> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @38
+ typeParameters
+ covariant T @40
+ bound: C<T>
+ defaultType: C<dynamic>
+ constructors
+ synthetic @-1
+ typeAliases
+ notSimplyBounded F @8
+ aliasedType: void Function(C<C<dynamic>>)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional c @-1
+ type: C<C<dynamic>>
+ returnType: void
''');
}
@@ -15690,9 +30832,24 @@
class C<T extends C<T>> {}
''');
checkElementText(library, r'''
-notSimplyBounded typedef F = void Function(C<C<dynamic>> );
-notSimplyBounded class C<T extends C<T> = C<dynamic>> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @36
+ typeParameters
+ covariant T @38
+ bound: C<T>
+ defaultType: C<dynamic>
+ constructors
+ synthetic @-1
+ typeAliases
+ notSimplyBounded F @8
+ aliasedType: void Function(C<C<dynamic>>)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional @-1
+ type: C<C<dynamic>>
+ returnType: void
''');
}
@@ -15704,9 +30861,24 @@
class C<T extends C<T>> {}
''');
checkElementText(library, r'''
-notSimplyBounded typedef F = void Function(C<C<dynamic>> c);
-notSimplyBounded class C<T extends C<T> = C<dynamic>> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @27
+ typeParameters
+ covariant T @29
+ bound: C<T>
+ defaultType: C<dynamic>
+ constructors
+ synthetic @-1
+ typeAliases
+ functionTypeAliasBased notSimplyBounded F @13
+ aliasedType: void Function(C<C<dynamic>>)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional c @-1
+ type: C<C<dynamic>>
+ returnType: void
''');
}
@@ -15718,9 +30890,21 @@
class C<T extends C<T>> {}
''');
checkElementText(library, r'''
-notSimplyBounded typedef F = C<C<dynamic>> Function();
-notSimplyBounded class C<T extends C<T> = C<dynamic>> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @32
+ typeParameters
+ covariant T @34
+ bound: C<T>
+ defaultType: C<dynamic>
+ constructors
+ synthetic @-1
+ typeAliases
+ notSimplyBounded F @8
+ aliasedType: C<C<dynamic>> Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: C<C<dynamic>>
''');
}
@@ -15732,9 +30916,21 @@
class C<T extends C<T>> {}
''');
checkElementText(library, r'''
-notSimplyBounded typedef F = C<C<dynamic>> Function();
-notSimplyBounded class C<T extends C<T> = C<dynamic>> {
-}
+library
+ definingUnit
+ classes
+ notSimplyBounded class C @21
+ typeParameters
+ covariant T @23
+ bound: C<T>
+ defaultType: C<dynamic>
+ constructors
+ synthetic @-1
+ typeAliases
+ functionTypeAliasBased notSimplyBounded F @10
+ aliasedType: C<C<dynamic>> Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: C<C<dynamic>>
''');
}
@@ -15754,84 +30950,210 @@
test_typedef_parameter_parameters() async {
var library = await checkLibrary('typedef F(g(x, y));');
checkElementText(library, r'''
-typedef F = dynamic Function(dynamic Function(dynamic, dynamic) g/*(dynamic x, dynamic y)*/);
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @8
+ aliasedType: dynamic Function(dynamic Function(dynamic, dynamic))
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional g @-1
+ type: dynamic Function(dynamic, dynamic)
+ parameters
+ requiredPositional x @-1
+ type: dynamic
+ requiredPositional y @-1
+ type: dynamic
+ returnType: dynamic
''');
}
test_typedef_parameter_parameters_in_generic_class() async {
var library = await checkLibrary('typedef F<A, B>(A g(B x));');
checkElementText(library, r'''
-typedef F<A, B> = dynamic Function(A Function(B) g/*(B x)*/);
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @8
+ typeParameters
+ contravariant A @10
+ defaultType: dynamic
+ covariant B @13
+ defaultType: dynamic
+ aliasedType: dynamic Function(A Function(B))
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional g @-1
+ type: A Function(B)
+ parameters
+ requiredPositional x @-1
+ type: B
+ returnType: dynamic
''');
}
test_typedef_parameter_return_type() async {
var library = await checkLibrary('typedef F(int g());');
checkElementText(library, r'''
-typedef F = dynamic Function(int Function() g);
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @8
+ aliasedType: dynamic Function(int Function())
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional g @-1
+ type: int Function()
+ returnType: dynamic
''');
}
test_typedef_parameter_type() async {
var library = await checkLibrary('typedef F(int i);');
checkElementText(library, r'''
-typedef F = dynamic Function(int i);
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @8
+ aliasedType: dynamic Function(int)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional i @-1
+ type: int
+ returnType: dynamic
''');
}
test_typedef_parameter_type_generic() async {
var library = await checkLibrary('typedef F<T>(T t);');
checkElementText(library, r'''
-typedef F<T> = dynamic Function(T t);
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @8
+ typeParameters
+ contravariant T @10
+ defaultType: dynamic
+ aliasedType: dynamic Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional t @-1
+ type: T
+ returnType: dynamic
''');
}
test_typedef_parameters() async {
var library = await checkLibrary('typedef F(x, y);');
checkElementText(library, r'''
-typedef F = dynamic Function(dynamic x, dynamic y);
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @8
+ aliasedType: dynamic Function(dynamic, dynamic)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional x @-1
+ type: dynamic
+ requiredPositional y @-1
+ type: dynamic
+ returnType: dynamic
''');
}
test_typedef_parameters_named() async {
var library = await checkLibrary('typedef F({y, z, x});');
checkElementText(library, r'''
-typedef F = dynamic Function({dynamic y}, {dynamic z}, {dynamic x});
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @8
+ aliasedType: dynamic Function({dynamic x, dynamic y, dynamic z})
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ optionalNamed y @-1
+ type: dynamic
+ optionalNamed z @-1
+ type: dynamic
+ optionalNamed x @-1
+ type: dynamic
+ returnType: dynamic
''');
}
test_typedef_return_type() async {
var library = await checkLibrary('typedef int F();');
checkElementText(library, r'''
-typedef F = int Function();
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @12
+ aliasedType: int Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: int
''');
}
test_typedef_return_type_generic() async {
var library = await checkLibrary('typedef T F<T>();');
checkElementText(library, r'''
-typedef F<T> = T Function();
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @10
+ typeParameters
+ covariant T @12
+ defaultType: dynamic
+ aliasedType: T Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: T
''');
}
test_typedef_return_type_implicit() async {
var library = await checkLibrary('typedef F();');
checkElementText(library, r'''
-typedef F = dynamic Function();
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @8
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
''');
}
test_typedef_return_type_void() async {
var library = await checkLibrary('typedef void F();');
checkElementText(library, r'''
-typedef F = void Function();
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @13
+ aliasedType: void Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void
''');
}
test_typedef_type_parameters() async {
var library = await checkLibrary('typedef U F<T, U>(T t);');
checkElementText(library, r'''
-typedef F<T, U> = U Function(T t);
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased F @10
+ typeParameters
+ contravariant T @12
+ defaultType: dynamic
+ covariant U @15
+ defaultType: dynamic
+ aliasedType: U Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional t @-1
+ type: T
+ returnType: U
''');
}
@@ -15839,9 +31161,27 @@
var library = await checkLibrary(
'typedef U F<T extends Object, U extends D>(T t); class D {}');
checkElementText(library, r'''
-typedef F<T = Object, U extends D = D> = U Function(T t);
-class D {
-}
+library
+ definingUnit
+ classes
+ class D @55
+ constructors
+ synthetic @-1
+ typeAliases
+ functionTypeAliasBased F @10
+ typeParameters
+ contravariant T @12
+ bound: Object
+ defaultType: Object
+ covariant U @30
+ bound: D
+ defaultType: D
+ aliasedType: U Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional t @-1
+ type: T
+ returnType: U
''');
}
@@ -15849,7 +31189,17 @@
var library = await checkLibrary('typedef void F<T extends F>();');
// Typedefs cannot reference themselves.
checkElementText(library, r'''
-notSimplyBounded typedef F<T extends dynamic Function()> = void Function();
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased notSimplyBounded F @13
+ typeParameters
+ unrelated T @15
+ bound: dynamic Function()
+ defaultType: dynamic
+ aliasedType: void Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void
''');
}
@@ -15857,14 +31207,39 @@
var library = await checkLibrary('typedef void F<T extends List<F>>();');
// Typedefs cannot reference themselves.
checkElementText(library, r'''
-notSimplyBounded typedef F<T extends List<dynamic Function()>> = void Function();
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased notSimplyBounded F @13
+ typeParameters
+ unrelated T @15
+ bound: List<dynamic Function()>
+ defaultType: dynamic
+ aliasedType: void Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: void
''');
}
test_typedef_type_parameters_f_bound_complex() async {
var library = await checkLibrary('typedef U F<T extends List<U>, U>(T t);');
checkElementText(library, r'''
-notSimplyBounded typedef F<T extends List<U> = List<Never>, U> = U Function(T t);
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased notSimplyBounded F @10
+ typeParameters
+ contravariant T @12
+ bound: List<U>
+ defaultType: List<Never>
+ covariant U @31
+ defaultType: dynamic
+ aliasedType: U Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional t @-1
+ type: T
+ returnType: U
''');
}
@@ -15872,14 +31247,44 @@
featureSet = FeatureSets.beforeNullSafe;
var library = await checkLibrary('typedef U F<T extends List<U>, U>(T t);');
checkElementText(library, r'''
-notSimplyBounded typedef F<T extends List<U*>* = List<Null*>*, U> = U* Function(T* t);
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased notSimplyBounded F @10
+ typeParameters
+ contravariant T @12
+ bound: List<U*>*
+ defaultType: List<Null*>*
+ covariant U @31
+ defaultType: dynamic
+ aliasedType: U* Function(T*)*
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional t @-1
+ type: T*
+ returnType: U*
''');
}
test_typedef_type_parameters_f_bound_simple() async {
var library = await checkLibrary('typedef U F<T extends U, U>(T t);');
checkElementText(library, r'''
-notSimplyBounded typedef F<T extends U = Never, U> = U Function(T t);
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased notSimplyBounded F @10
+ typeParameters
+ contravariant T @12
+ bound: U
+ defaultType: Never
+ covariant U @25
+ defaultType: dynamic
+ aliasedType: U Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional t @-1
+ type: T
+ returnType: U
''');
}
@@ -15887,7 +31292,22 @@
featureSet = FeatureSets.beforeNullSafe;
var library = await checkLibrary('typedef U F<T extends U, U>(T t);');
checkElementText(library, r'''
-notSimplyBounded typedef F<T extends U* = Null*, U> = U* Function(T* t);
+library
+ definingUnit
+ typeAliases
+ functionTypeAliasBased notSimplyBounded F @10
+ typeParameters
+ contravariant T @12
+ bound: U*
+ defaultType: Null*
+ covariant U @25
+ defaultType: dynamic
+ aliasedType: U* Function(T*)*
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional t @-1
+ type: T*
+ returnType: U*
''');
}
@@ -15895,7 +31315,22 @@
var library =
await checkLibrary('typedef F<T extends U, U> = U Function(T t);');
checkElementText(library, r'''
-notSimplyBounded typedef F<T extends U = Never, U> = U Function(T t);
+library
+ definingUnit
+ typeAliases
+ notSimplyBounded F @8
+ typeParameters
+ contravariant T @10
+ bound: U
+ defaultType: Never
+ covariant U @23
+ defaultType: dynamic
+ aliasedType: U Function(T)
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional t @-1
+ type: T
+ returnType: U
''');
}
@@ -15904,15 +31339,35 @@
var library =
await checkLibrary('typedef F<T extends U, U> = U Function(T t);');
checkElementText(library, r'''
-notSimplyBounded typedef F<T extends U* = Null*, U> = U* Function(T* t);
+library
+ definingUnit
+ typeAliases
+ notSimplyBounded F @8
+ typeParameters
+ contravariant T @10
+ bound: U*
+ defaultType: Null*
+ covariant U @23
+ defaultType: dynamic
+ aliasedType: U* Function(T*)*
+ aliasedElement: GenericFunctionTypeElement
+ parameters
+ requiredPositional t @-1
+ type: T*
+ returnType: U*
''');
}
test_typedefs() async {
var library = await checkLibrary('f() {} g() {}');
checkElementText(library, r'''
-dynamic f() {}
-dynamic g() {}
+library
+ definingUnit
+ functions
+ f @0
+ returnType: dynamic
+ g @7
+ returnType: dynamic
''');
}
@@ -15921,14 +31376,21 @@
int get x => 0;
void set x(int value) {}
''');
- checkElementText(
- library,
- r'''
-synthetic int x;
-int get x {}
-void set x(int value) {}
-''',
- withSyntheticFields: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ synthetic static x @-1
+ type: int
+ accessors
+ get x @8
+ returnType: int
+ set x @25
+ parameters
+ requiredPositional value @31
+ type: int
+ returnType: void
+''');
}
test_unit_implicitVariable_setterFirst() async {
@@ -15936,14 +31398,21 @@
void set x(int value) {}
int get x => 0;
''');
- checkElementText(
- library,
- r'''
-synthetic int x;
-void set x(int value) {}
-int get x {}
-''',
- withSyntheticFields: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ synthetic static x @-1
+ type: int
+ accessors
+ set x @9
+ parameters
+ requiredPositional value @15
+ type: int
+ returnType: void
+ get x @33
+ returnType: int
+''');
}
test_unit_variable_final_withSetter() async {
@@ -15951,15 +31420,21 @@
final int foo = 0;
set foo(int newValue) {}
''');
- checkElementText(
- library,
- r'''
-final int foo;
-synthetic int get foo {}
-void set foo(int newValue) {}
-''',
- withSyntheticFields: true,
- withSyntheticAccessors: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static final foo @10
+ type: int
+ accessors
+ synthetic static get foo @10
+ returnType: int
+ set foo @10
+ parameters
+ requiredPositional newValue @31
+ type: int
+ returnType: void
+''');
}
test_unresolved_annotation_instanceCreation_argument_super() async {
@@ -15972,13 +31447,33 @@
class C {}
''', allowErrors: true);
checkElementText(library, r'''
-class A {
- const A(dynamic _);
-}
-@
- A/*location: test.dart;A*/(super)
-class C {
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ const @18
+ parameters
+ requiredPositional _ @20
+ type: dynamic
+ class C @43
+ metadata
+ Annotation
+ arguments: ArgumentList
+ arguments
+ SuperExpression
+ staticType: dynamic
+ superKeyword: super @0
+ leftParenthesis: ( @29
+ rightParenthesis: ) @35
+ atSign.offset: 27
+ element: self::@class::A::@constructor::•
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @28
+ constructors
+ synthetic @-1
''');
}
@@ -15992,13 +31487,33 @@
class C {}
''', allowErrors: true);
checkElementText(library, r'''
-class A {
- const A(dynamic _);
-}
-@
- A/*location: test.dart;A*/(this)
-class C {
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ const @18
+ parameters
+ requiredPositional _ @20
+ type: dynamic
+ class C @42
+ metadata
+ Annotation
+ arguments: ArgumentList
+ arguments
+ ThisExpression
+ staticType: dynamic
+ thisKeyword: this @0
+ leftParenthesis: ( @29
+ rightParenthesis: ) @34
+ atSign.offset: 27
+ element: self::@class::A::@constructor::•
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @28
+ constructors
+ synthetic @-1
''');
}
@@ -16006,11 +31521,31 @@
var library =
await checkLibrary('@foo.bar() class C {}', allowErrors: true);
checkElementText(library, r'''
-@
- foo/*location: null*/.
- bar/*location: null*/()
-class C {
-}
+library
+ definingUnit
+ classes
+ class C @17
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @8
+ rightParenthesis: ) @9
+ atSign.offset: 0
+ element: <null>
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: bar @5
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: foo @1
+ staticElement: <null>
+ staticType: null
+ constructors
+ synthetic @-1
''');
}
@@ -16018,22 +31553,59 @@
var library =
await checkLibrary('@String.foo() class C {}', allowErrors: true);
checkElementText(library, r'''
-@
- String/*location: dart:core;String*/.
- foo/*location: null*/()
-class C {
-}
+library
+ definingUnit
+ classes
+ class C @20
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @11
+ rightParenthesis: ) @12
+ atSign.offset: 0
+ element: <null>
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: foo @8
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: dart:core::@class::String
+ staticType: null
+ token: String @1
+ staticElement: <null>
+ staticType: null
+ constructors
+ synthetic @-1
''');
}
test_unresolved_annotation_prefixedIdentifier_badPrefix() async {
var library = await checkLibrary('@foo.bar class C {}', allowErrors: true);
checkElementText(library, r'''
-@
- foo/*location: null*/.
- bar/*location: null*/
-class C {
-}
+library
+ definingUnit
+ classes
+ class C @15
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: <null>
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: bar @5
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: foo @1
+ staticElement: <null>
+ staticType: null
+ constructors
+ synthetic @-1
''');
}
@@ -16042,12 +31614,30 @@
'import "dart:async" as foo; @foo.bar class C {}',
allowErrors: true);
checkElementText(library, r'''
-import 'dart:async' as foo;
-@
- foo/*location: test.dart;foo*/.
- bar/*location: null*/
-class C {
-}
+library
+ imports
+ dart:async as foo @23
+ definingUnit
+ classes
+ class C @43
+ metadata
+ Annotation
+ atSign.offset: 28
+ element: <null>
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: bar @33
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::foo
+ staticType: null
+ token: foo @29
+ staticElement: <null>
+ staticType: null
+ constructors
+ synthetic @-1
''');
}
@@ -16055,12 +31645,35 @@
var library =
await checkLibrary('@foo.bar.baz() class C {}', allowErrors: true);
checkElementText(library, r'''
-@
- foo/*location: null*/.
- bar/*location: null*/.
- baz/*location: null*/()
-class C {
-}
+library
+ definingUnit
+ classes
+ class C @21
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @12
+ rightParenthesis: ) @13
+ atSign.offset: 0
+ constructorName: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: baz @9
+ element: <null>
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: bar @5
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: foo @1
+ staticElement: <null>
+ staticType: null
+ constructors
+ synthetic @-1
''');
}
@@ -16069,13 +31682,37 @@
'import "dart:async" as foo; @foo.bar.baz() class C {}',
allowErrors: true);
checkElementText(library, r'''
-import 'dart:async' as foo;
-@
- foo/*location: test.dart;foo*/.
- bar/*location: null*/.
- baz/*location: null*/()
-class C {
-}
+library
+ imports
+ dart:async as foo @23
+ definingUnit
+ classes
+ class C @49
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @40
+ rightParenthesis: ) @41
+ atSign.offset: 28
+ constructorName: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: baz @37
+ element: <null>
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: bar @33
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::foo
+ staticType: null
+ token: foo @29
+ staticElement: <null>
+ staticType: null
+ constructors
+ synthetic @-1
''');
}
@@ -16084,13 +31721,37 @@
'import "dart:async" as foo; @foo.Future.bar() class C {}',
allowErrors: true);
checkElementText(library, r'''
-import 'dart:async' as foo;
-@
- foo/*location: test.dart;foo*/.
- Future/*location: dart:async;Future*/.
- bar/*location: null*/()
-class C {
-}
+library
+ imports
+ dart:async as foo @23
+ definingUnit
+ classes
+ class C @52
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @43
+ rightParenthesis: ) @44
+ atSign.offset: 28
+ constructorName: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: bar @40
+ element: <null>
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: dart:async::@class::Future
+ staticType: null
+ token: Future @33
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::foo
+ staticType: null
+ token: foo @29
+ staticElement: dart:async::@class::Future
+ staticType: null
+ constructors
+ synthetic @-1
''');
}
@@ -16098,11 +31759,31 @@
var library =
await checkLibrary('@foo.bar() class C {}', allowErrors: true);
checkElementText(library, r'''
-@
- foo/*location: null*/.
- bar/*location: null*/()
-class C {
-}
+library
+ definingUnit
+ classes
+ class C @17
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @8
+ rightParenthesis: ) @9
+ atSign.offset: 0
+ element: <null>
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: bar @5
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: foo @1
+ staticElement: <null>
+ staticType: null
+ constructors
+ synthetic @-1
''');
}
@@ -16111,31 +31792,54 @@
'import "dart:async" as foo; @foo.bar() class C {}',
allowErrors: true);
checkElementText(library, r'''
-import 'dart:async' as foo;
-@
- foo/*location: test.dart;foo*/.
- bar/*location: null*/()
-class C {
-}
+library
+ imports
+ dart:async as foo @23
+ definingUnit
+ classes
+ class C @45
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @36
+ rightParenthesis: ) @37
+ atSign.offset: 28
+ element: <null>
+ name: PrefixedIdentifier
+ identifier: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: bar @33
+ period: . @0
+ prefix: SimpleIdentifier
+ staticElement: self::@prefix::foo
+ staticType: null
+ token: foo @29
+ staticElement: <null>
+ staticType: null
+ constructors
+ synthetic @-1
''');
}
test_unresolved_annotation_simpleIdentifier() async {
var library = await checkLibrary('@foo class C {}', allowErrors: true);
- checkElementText(
- library,
- r'''
-class C {
-}
- metadata
- Annotation
- element: <null>
- name: SimpleIdentifier
- staticElement: <null>
- staticType: null
- token: foo
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class C @11
+ metadata
+ Annotation
+ atSign.offset: 0
+ element: <null>
+ name: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: foo @1
+ constructors
+ synthetic @-1
+''');
}
test_unresolved_annotation_simpleIdentifier_multiplyDefined() async {
@@ -16148,38 +31852,57 @@
@v
class C {}
''');
- checkElementText(
- library,
- r'''
-import 'a.dart';
-import 'b.dart';
-class C {
-}
- metadata
- Annotation
- element: <null>
- name: SimpleIdentifier
- staticElement: <null>
- staticType: null
- token: v
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ imports
+ a.dart
+ b.dart
+ definingUnit
+ classes
+ class C @44
+ metadata
+ Annotation
+ atSign.offset: 35
+ element: <null>
+ name: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: v @36
+ constructors
+ synthetic @-1
+''');
}
test_unresolved_annotation_unnamedConstructorCall_noClass() async {
var library = await checkLibrary('@foo() class C {}', allowErrors: true);
checkElementText(library, r'''
-@
- foo/*location: null*/()
-class C {
-}
+library
+ definingUnit
+ classes
+ class C @13
+ metadata
+ Annotation
+ arguments: ArgumentList
+ leftParenthesis: ( @4
+ rightParenthesis: ) @5
+ atSign.offset: 0
+ element: <null>
+ name: SimpleIdentifier
+ staticElement: <null>
+ staticType: null
+ token: foo @1
+ constructors
+ synthetic @-1
''');
}
test_unresolved_export() async {
var library = await checkLibrary("export 'foo.dart';", allowErrors: true);
checkElementText(library, r'''
-export 'foo.dart';
+library
+ exports
+ foo.dart
+ definingUnit
''');
}
@@ -16190,17 +31913,20 @@
expect(importedLibrary.publicNamespace, isNotNull);
expect(importedLibrary.exportNamespace, isNotNull);
checkElementText(library, r'''
-import 'foo.dart';
+library
+ imports
+ foo.dart
+ definingUnit
''');
}
test_unresolved_part() async {
var library = await checkLibrary("part 'foo.dart';", allowErrors: true);
checkElementText(library, r'''
-part 'foo.dart';
---------------------
-unit: foo.dart
-
+library
+ definingUnit
+ parts
+ foo.dart
''');
}
@@ -16213,38 +31939,93 @@
var v = c.f;
''');
checkElementText(library, r'''
-class C<T> {
- void f() {}
-}
-C<int> c;
-void Function() v;
+library
+ definingUnit
+ classes
+ class C @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ f @20
+ returnType: void
+ topLevelVariables
+ static c @36
+ type: C<int>
+ static v @43
+ type: void Function()
+ accessors
+ synthetic static get c @36
+ returnType: C<int>
+ synthetic static set c @36
+ parameters
+ requiredPositional _c @36
+ type: C<int>
+ returnType: void
+ synthetic static get v @43
+ returnType: void Function()
+ synthetic static set v @43
+ parameters
+ requiredPositional _v @43
+ type: void Function()
+ returnType: void
''');
}
test_variable() async {
var library = await checkLibrary('int x = 0;');
- checkElementText(
- library,
- r'''
-int x@4;
-synthetic int get x@4 {}
-synthetic void set x@4(int _x@4) {}
-''',
- withOffsets: true,
- withSyntheticAccessors: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static x @4
+ type: int
+ accessors
+ synthetic static get x @4
+ returnType: int
+ synthetic static set x @4
+ parameters
+ requiredPositional _x @4
+ type: int
+ returnType: void
+''');
}
test_variable_const() async {
var library = await checkLibrary('const int i = 0;');
checkElementText(library, r'''
-const int i = 0;
+library
+ definingUnit
+ topLevelVariables
+ static const i @10
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @14
+ staticType: int
+ accessors
+ synthetic static get i @10
+ returnType: int
''');
}
test_variable_const_late() async {
var library = await checkLibrary('late const int i = 0;');
checkElementText(library, r'''
-late const int i = 0;
+library
+ definingUnit
+ topLevelVariables
+ static late const i @15
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @19
+ staticType: int
+ accessors
+ synthetic static get i @15
+ returnType: int
''');
}
@@ -16256,17 +32037,34 @@
*/
var x;''');
checkElementText(library, r'''
-/**
- * Docs
- */
-dynamic x;
+library
+ definingUnit
+ topLevelVariables
+ static x @64
+ documentationComment: /**\n * Docs\n */
+ type: dynamic
+ accessors
+ synthetic static get x @64
+ returnType: dynamic
+ synthetic static set x @64
+ parameters
+ requiredPositional _x @64
+ type: dynamic
+ returnType: void
''');
}
test_variable_final() async {
var library = await checkLibrary('final int x = 0;');
checkElementText(library, r'''
-final int x;
+library
+ definingUnit
+ topLevelVariables
+ static final x @10
+ type: int
+ accessors
+ synthetic static get x @10
+ returnType: int
''');
}
@@ -16280,13 +32078,27 @@
part 'a.dart';
int get x => 42;''');
checkElementText(library, r'''
-library my.lib;
-part 'a.dart';
-int get x {}
---------------------
-unit: a.dart
-
-void set x(int _) {}
+library
+ name: my.lib
+ nameOffset: 8
+ definingUnit
+ topLevelVariables
+ synthetic static x @-1
+ type: int
+ accessors
+ get x @39
+ returnType: int
+ parts
+ a.dart
+ topLevelVariables
+ synthetic static x @-1
+ type: int
+ accessors
+ set x @25
+ parameters
+ requiredPositional _ @31
+ type: int
+ returnType: void
''');
}
@@ -16301,13 +32113,27 @@
void set x(int _) {}
''');
checkElementText(library, r'''
-library my.lib;
-part 'a.dart';
-void set x(int _) {}
---------------------
-unit: a.dart
-
-int get x {}
+library
+ name: my.lib
+ nameOffset: 8
+ definingUnit
+ topLevelVariables
+ synthetic static x @-1
+ type: int
+ accessors
+ set x @40
+ parameters
+ requiredPositional _ @46
+ type: int
+ returnType: void
+ parts
+ a.dart
+ topLevelVariables
+ synthetic static x @-1
+ type: int
+ accessors
+ get x @24
+ returnType: int
''');
}
@@ -16317,17 +32143,28 @@
var library =
await checkLibrary('library my.lib; part "a.dart"; part "b.dart";');
checkElementText(library, r'''
-library my.lib;
-part 'a.dart';
-part 'b.dart';
---------------------
-unit: a.dart
-
-int get x {}
---------------------
-unit: b.dart
-
-void set x(int _) {}
+library
+ name: my.lib
+ nameOffset: 8
+ definingUnit
+ parts
+ a.dart
+ topLevelVariables
+ synthetic static x @-1
+ type: int
+ accessors
+ get x @24
+ returnType: int
+ b.dart
+ topLevelVariables
+ synthetic static x @-1
+ type: int
+ accessors
+ set x @25
+ parameters
+ requiredPositional _ @31
+ type: int
+ returnType: void
''');
}
@@ -16349,35 +32186,85 @@
test_variable_implicit_type() async {
var library = await checkLibrary('var x;');
checkElementText(library, r'''
-dynamic x;
+library
+ definingUnit
+ topLevelVariables
+ static x @4
+ type: dynamic
+ accessors
+ synthetic static get x @4
+ returnType: dynamic
+ synthetic static set x @4
+ parameters
+ requiredPositional _x @4
+ type: dynamic
+ returnType: void
''');
}
test_variable_inferred_type_implicit_initialized() async {
var library = await checkLibrary('var v = 0;');
checkElementText(library, r'''
-int v;
+library
+ definingUnit
+ topLevelVariables
+ static v @4
+ type: int
+ accessors
+ synthetic static get v @4
+ returnType: int
+ synthetic static set v @4
+ parameters
+ requiredPositional _v @4
+ type: int
+ returnType: void
''');
}
test_variable_initializer() async {
var library = await checkLibrary('int v = 0;');
checkElementText(library, r'''
-int v;
+library
+ definingUnit
+ topLevelVariables
+ static v @4
+ type: int
+ accessors
+ synthetic static get v @4
+ returnType: int
+ synthetic static set v @4
+ parameters
+ requiredPositional _v @4
+ type: int
+ returnType: void
''');
}
test_variable_initializer_final() async {
var library = await checkLibrary('final int v = 0;');
checkElementText(library, r'''
-final int v;
+library
+ definingUnit
+ topLevelVariables
+ static final v @10
+ type: int
+ accessors
+ synthetic static get v @10
+ returnType: int
''');
}
test_variable_initializer_final_untyped() async {
var library = await checkLibrary('final v = 0;');
checkElementText(library, r'''
-final int v;
+library
+ definingUnit
+ topLevelVariables
+ static final v @6
+ type: int
+ accessors
+ synthetic static get v @6
+ returnType: int
''');
}
@@ -16390,61 +32277,118 @@
var x = E.f();
''');
checkElementText(library, r'''
-class A {
-}
-extension E on A {
- static int f() {}
-}
-int x;
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ extensions
+ E @21
+ extendedType: A
+ methods
+ static f @43
+ returnType: int
+ topLevelVariables
+ static x @59
+ type: int
+ accessors
+ synthetic static get x @59
+ returnType: int
+ synthetic static set x @59
+ parameters
+ requiredPositional _x @59
+ type: int
+ returnType: void
''');
}
test_variable_initializer_untyped() async {
var library = await checkLibrary('var v = 0;');
checkElementText(library, r'''
-int v;
+library
+ definingUnit
+ topLevelVariables
+ static v @4
+ type: int
+ accessors
+ synthetic static get v @4
+ returnType: int
+ synthetic static set v @4
+ parameters
+ requiredPositional _v @4
+ type: int
+ returnType: void
''');
}
test_variable_late() async {
var library = await checkLibrary('late int x = 0;');
- checkElementText(
- library,
- r'''
-late int x;
-synthetic int get x {}
-synthetic void set x(int _x) {}
-''',
- withSyntheticAccessors: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static late x @9
+ type: int
+ accessors
+ synthetic static get x @9
+ returnType: int
+ synthetic static set x @9
+ parameters
+ requiredPositional _x @9
+ type: int
+ returnType: void
+''');
}
test_variable_late_final() async {
var library = await checkLibrary('late final int x;');
- checkElementText(
- library,
- r'''
-late final int x;
-synthetic int get x {}
-synthetic void set x(int _x) {}
-''',
- withSyntheticAccessors: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static late final x @15
+ type: int
+ accessors
+ synthetic static get x @15
+ returnType: int
+ synthetic static set x @15
+ parameters
+ requiredPositional _x @15
+ type: int
+ returnType: void
+''');
}
test_variable_late_final_initialized() async {
var library = await checkLibrary('late final int x = 0;');
- checkElementText(
- library,
- r'''
-late final int x;
-synthetic int get x {}
-''',
- withSyntheticAccessors: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ topLevelVariables
+ static late final x @15
+ type: int
+ accessors
+ synthetic static get x @15
+ returnType: int
+''');
}
test_variable_propagatedType_const_noDep() async {
var library = await checkLibrary('const i = 0;');
checkElementText(library, r'''
-const int i = 0;
+library
+ definingUnit
+ topLevelVariables
+ static const i @6
+ type: int
+ constantInitializer
+ IntegerLiteral
+ literal: 0 @10
+ staticType: int
+ accessors
+ synthetic static get i @6
+ returnType: int
''');
}
@@ -16452,8 +32396,16 @@
addLibrarySource('/a.dart', 'final a = 1;');
var library = await checkLibrary('import "a.dart"; final b = a / 2;');
checkElementText(library, r'''
-import 'a.dart';
-final double b;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static final b @23
+ type: double
+ accessors
+ synthetic static get b @23
+ returnType: double
''');
}
@@ -16462,20 +32414,38 @@
var library =
await checkLibrary('library lib; part "a.dart"; final b = a / 2;');
checkElementText(library, r'''
-library lib;
-part 'a.dart';
-final double b;
---------------------
-unit: a.dart
-
-final int a;
+library
+ name: lib
+ nameOffset: 8
+ definingUnit
+ topLevelVariables
+ static final b @34
+ type: double
+ accessors
+ synthetic static get b @34
+ returnType: double
+ parts
+ a.dart
+ topLevelVariables
+ static final a @19
+ type: int
+ accessors
+ synthetic static get a @19
+ returnType: int
''');
}
test_variable_propagatedType_final_noDep() async {
var library = await checkLibrary('final i = 0;');
checkElementText(library, r'''
-final int i;
+library
+ definingUnit
+ topLevelVariables
+ static final i @6
+ type: int
+ accessors
+ synthetic static get i @6
+ returnType: int
''');
}
@@ -16485,8 +32455,16 @@
addLibrarySource('/b.dart', 'import "a.dart"; C f() => null;');
var library = await checkLibrary('import "b.dart"; final x = f();');
checkElementText(library, r'''
-import 'b.dart';
-final C x;
+library
+ imports
+ b.dart
+ definingUnit
+ topLevelVariables
+ static final x @23
+ type: C
+ accessors
+ synthetic static get x @23
+ returnType: C
''');
}
@@ -16496,17 +32474,28 @@
var library =
await checkLibrary('library my.lib; part "a.dart"; part "b.dart";');
checkElementText(library, r'''
-library my.lib;
-part 'a.dart';
-part 'b.dart';
---------------------
-unit: a.dart
-
-void set x(int _) {}
---------------------
-unit: b.dart
-
-int get x {}
+library
+ name: my.lib
+ nameOffset: 8
+ definingUnit
+ parts
+ a.dart
+ topLevelVariables
+ synthetic static x @-1
+ type: int
+ accessors
+ set x @25
+ parameters
+ requiredPositional _ @31
+ type: int
+ returnType: void
+ b.dart
+ topLevelVariables
+ synthetic static x @-1
+ type: int
+ accessors
+ get x @24
+ returnType: int
''');
}
@@ -16516,7 +32505,19 @@
''');
checkElementText(library, r'''
-Never a;
+library
+ definingUnit
+ topLevelVariables
+ static a @4
+ type: Never
+ accessors
+ synthetic static get a @4
+ returnType: Never
+ synthetic static set a @4
+ parameters
+ requiredPositional _a @4
+ type: Never
+ returnType: void
''');
}
@@ -16526,7 +32527,19 @@
''');
checkElementText(library, r'''
-dynamic a;
+library
+ definingUnit
+ topLevelVariables
+ static a @4
+ type: dynamic
+ accessors
+ synthetic static get a @4
+ returnType: dynamic
+ synthetic static set a @4
+ parameters
+ requiredPositional _a @4
+ type: dynamic
+ returnType: void
''');
}
@@ -16542,8 +32555,21 @@
''');
checkElementText(library, r'''
-import 'a.dart';
-int b;
+library
+ imports
+ a.dart
+ definingUnit
+ topLevelVariables
+ static b @21
+ type: int
+ accessors
+ synthetic static get b @21
+ returnType: int
+ synthetic static set b @21
+ parameters
+ requiredPositional _b @21
+ type: int
+ returnType: void
''');
}
@@ -16554,40 +32580,66 @@
}
const A<int> a = A();
''');
- checkElementText(
- library,
- r'''
-class A {
- const A();
-}
- typeParameters
- T
- bound: null
- defaultType: dynamic
-const A<int> a;
- constantInitializer
- InstanceCreationExpression
- argumentList: ArgumentList
- constructorName: ConstructorName
- staticElement: ConstructorMember
- base: self::@class::A::@constructor::•
- substitution: {T: int}
- type: TypeName
- name: SimpleIdentifier
- staticElement: self::@class::A
- staticType: null
- token: A
- type: A<int>
- staticType: A<int>
-''',
- withResolvedAst: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ const @21
+ topLevelVariables
+ static const a @41
+ type: A<int>
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ leftParenthesis: ( @46
+ rightParenthesis: ) @47
+ constructorName: ConstructorName
+ staticElement: ConstructorMember
+ base: self::@class::A::@constructor::•
+ substitution: {T: int}
+ type: TypeName
+ name: SimpleIdentifier
+ staticElement: self::@class::A
+ staticType: null
+ token: A @45
+ type: A<int>
+ staticType: A<int>
+ accessors
+ synthetic static get a @41
+ returnType: A<int>
+''');
}
test_variables() async {
var library = await checkLibrary('int i; int j;');
checkElementText(library, r'''
-int i;
-int j;
+library
+ definingUnit
+ topLevelVariables
+ static i @4
+ type: int
+ static j @11
+ type: int
+ accessors
+ synthetic static get i @4
+ returnType: int
+ synthetic static set i @4
+ parameters
+ requiredPositional _i @4
+ type: int
+ returnType: void
+ synthetic static get j @11
+ returnType: int
+ synthetic static set j @11
+ parameters
+ requiredPositional _j @11
+ type: int
+ returnType: void
''');
}
diff --git a/pkg/analyzer/test/src/summary/top_level_inference_test.dart b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
index b778258..217f91b 100644
--- a/pkg/analyzer/test/src/summary/top_level_inference_test.dart
+++ b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
@@ -14,7 +14,7 @@
defineReflectiveSuite(() {
defineReflectiveTests(TopLevelInferenceTest);
defineReflectiveTests(TopLevelInferenceErrorsTest);
-// defineReflectiveTests(ApplyCheckElementTextReplacements);
+ // defineReflectiveTests(ApplyCheckElementTextReplacements);
});
}
@@ -363,14 +363,82 @@
var vMinusDoubleDouble = 1.0 - 2.0;
''');
checkElementText(library, r'''
-int vPlusIntInt;
-double vPlusIntDouble;
-double vPlusDoubleInt;
-double vPlusDoubleDouble;
-int vMinusIntInt;
-double vMinusIntDouble;
-double vMinusDoubleInt;
-double vMinusDoubleDouble;
+library
+ definingUnit
+ topLevelVariables
+ static vPlusIntInt @4
+ type: int
+ static vPlusIntDouble @29
+ type: double
+ static vPlusDoubleInt @59
+ type: double
+ static vPlusDoubleDouble @89
+ type: double
+ static vMinusIntInt @124
+ type: int
+ static vMinusIntDouble @150
+ type: double
+ static vMinusDoubleInt @181
+ type: double
+ static vMinusDoubleDouble @212
+ type: double
+ accessors
+ synthetic static get vPlusIntInt @4
+ returnType: int
+ synthetic static set vPlusIntInt @4
+ parameters
+ requiredPositional _vPlusIntInt @4
+ type: int
+ returnType: void
+ synthetic static get vPlusIntDouble @29
+ returnType: double
+ synthetic static set vPlusIntDouble @29
+ parameters
+ requiredPositional _vPlusIntDouble @29
+ type: double
+ returnType: void
+ synthetic static get vPlusDoubleInt @59
+ returnType: double
+ synthetic static set vPlusDoubleInt @59
+ parameters
+ requiredPositional _vPlusDoubleInt @59
+ type: double
+ returnType: void
+ synthetic static get vPlusDoubleDouble @89
+ returnType: double
+ synthetic static set vPlusDoubleDouble @89
+ parameters
+ requiredPositional _vPlusDoubleDouble @89
+ type: double
+ returnType: void
+ synthetic static get vMinusIntInt @124
+ returnType: int
+ synthetic static set vMinusIntInt @124
+ parameters
+ requiredPositional _vMinusIntInt @124
+ type: int
+ returnType: void
+ synthetic static get vMinusIntDouble @150
+ returnType: double
+ synthetic static set vMinusIntDouble @150
+ parameters
+ requiredPositional _vMinusIntDouble @150
+ type: double
+ returnType: void
+ synthetic static get vMinusDoubleInt @181
+ returnType: double
+ synthetic static set vMinusDoubleInt @181
+ parameters
+ requiredPositional _vMinusDoubleInt @181
+ type: double
+ returnType: void
+ synthetic static get vMinusDoubleDouble @212
+ returnType: double
+ synthetic static set vMinusDoubleDouble @212
+ parameters
+ requiredPositional _vMinusDoubleDouble @212
+ type: double
+ returnType: void
''');
}
@@ -379,7 +447,19 @@
var V = 1 as num;
''');
checkElementText(library, r'''
-num V;
+library
+ definingUnit
+ topLevelVariables
+ static V @4
+ type: num
+ accessors
+ synthetic static get V @4
+ returnType: num
+ synthetic static set V @4
+ parameters
+ requiredPositional _V @4
+ type: num
+ returnType: void
''');
}
@@ -390,9 +470,37 @@
var t2 = (a += 2);
''');
checkElementText(library, r'''
-int a;
-int t1;
-int t2;
+library
+ definingUnit
+ topLevelVariables
+ static a @4
+ type: int
+ static t1 @15
+ type: int
+ static t2 @33
+ type: int
+ accessors
+ synthetic static get a @4
+ returnType: int
+ synthetic static set a @4
+ parameters
+ requiredPositional _a @4
+ type: int
+ returnType: void
+ synthetic static get t1 @15
+ returnType: int
+ synthetic static set t1 @15
+ parameters
+ requiredPositional _t1 @15
+ type: int
+ returnType: void
+ synthetic static get t2 @33
+ returnType: int
+ synthetic static set t2 @33
+ parameters
+ requiredPositional _t2 @33
+ type: int
+ returnType: void
''');
}
@@ -403,9 +511,37 @@
var t2 = (a[0] += 2);
''');
checkElementText(library, r'''
-List<int> a;
-int t1;
-int t2;
+library
+ definingUnit
+ topLevelVariables
+ static a @4
+ type: List<int>
+ static t1 @17
+ type: int
+ static t2 @38
+ type: int
+ accessors
+ synthetic static get a @4
+ returnType: List<int>
+ synthetic static set a @4
+ parameters
+ requiredPositional _a @4
+ type: List<int>
+ returnType: void
+ synthetic static get t1 @17
+ returnType: int
+ synthetic static set t1 @17
+ parameters
+ requiredPositional _t1 @17
+ type: int
+ returnType: void
+ synthetic static get t2 @38
+ returnType: int
+ synthetic static set t2 @38
+ parameters
+ requiredPositional _t2 @38
+ type: int
+ returnType: void
''');
}
@@ -419,12 +555,52 @@
var t2 = (a.f += 2);
''');
checkElementText(library, r'''
-class A {
- int f;
-}
-A a;
-int t1;
-int t2;
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ f @16
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get f @16
+ returnType: int
+ synthetic set f @16
+ parameters
+ requiredPositional _f @16
+ type: int
+ returnType: void
+ topLevelVariables
+ static a @25
+ type: A
+ static t1 @42
+ type: int
+ static t2 @62
+ type: int
+ accessors
+ synthetic static get a @25
+ returnType: A
+ synthetic static set a @25
+ parameters
+ requiredPositional _a @25
+ type: A
+ returnType: void
+ synthetic static get t1 @42
+ returnType: int
+ synthetic static set t1 @42
+ parameters
+ requiredPositional _t1 @42
+ type: int
+ returnType: void
+ synthetic static get t2 @62
+ returnType: int
+ synthetic static set t2 @62
+ parameters
+ requiredPositional _t2 @62
+ type: int
+ returnType: void
''');
}
@@ -439,14 +615,57 @@
var t2 = (c.f += 2);
''');
checkElementText(library, r'''
-class I {
- int f;
-}
-abstract class C implements I {
-}
-C c;
-int t1;
-int t2;
+library
+ definingUnit
+ classes
+ class I @6
+ fields
+ f @16
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get f @16
+ returnType: int
+ synthetic set f @16
+ parameters
+ requiredPositional _f @16
+ type: int
+ returnType: void
+ abstract class C @36
+ interfaces
+ I
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static c @56
+ type: C
+ static t1 @63
+ type: int
+ static t2 @83
+ type: int
+ accessors
+ synthetic static get c @56
+ returnType: C
+ synthetic static set c @56
+ parameters
+ requiredPositional _c @56
+ type: C
+ returnType: void
+ synthetic static get t1 @63
+ returnType: int
+ synthetic static set t1 @63
+ parameters
+ requiredPositional _t1 @63
+ type: int
+ returnType: void
+ synthetic static get t2 @83
+ returnType: int
+ synthetic static set t2 @83
+ parameters
+ requiredPositional _t2 @83
+ type: int
+ returnType: void
''');
}
@@ -461,14 +680,51 @@
var t2 = (getC().f += 2);
''');
checkElementText(library, r'''
-class I {
- int f;
-}
-abstract class C implements I {
-}
-int t1;
-int t2;
-C getC() {}
+library
+ definingUnit
+ classes
+ class I @6
+ fields
+ f @16
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get f @16
+ returnType: int
+ synthetic set f @16
+ parameters
+ requiredPositional _f @16
+ type: int
+ returnType: void
+ abstract class C @36
+ interfaces
+ I
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static t1 @76
+ type: int
+ static t2 @101
+ type: int
+ accessors
+ synthetic static get t1 @76
+ returnType: int
+ synthetic static set t1 @76
+ parameters
+ requiredPositional _t1 @76
+ type: int
+ returnType: void
+ synthetic static get t2 @101
+ returnType: int
+ synthetic static set t2 @101
+ parameters
+ requiredPositional _t2 @101
+ type: int
+ returnType: void
+ functions
+ getC @56
+ returnType: C
''');
}
@@ -481,11 +737,35 @@
var uFuture = () async => await fFuture();
''');
checkElementText(library, r'''
-import 'dart:async';
-Future<int> Function() uValue;
-Future<int> Function() uFuture;
-int fValue() {}
-Future<int> fFuture() async {}
+library
+ imports
+ dart:async
+ definingUnit
+ topLevelVariables
+ static uValue @80
+ type: Future<int> Function()
+ static uFuture @121
+ type: Future<int> Function()
+ accessors
+ synthetic static get uValue @80
+ returnType: Future<int> Function()
+ synthetic static set uValue @80
+ parameters
+ requiredPositional _uValue @80
+ type: Future<int> Function()
+ returnType: void
+ synthetic static get uFuture @121
+ returnType: Future<int> Function()
+ synthetic static set uFuture @121
+ parameters
+ requiredPositional _uFuture @121
+ type: Future<int> Function()
+ returnType: void
+ functions
+ fValue @25
+ returnType: int
+ fFuture @53 async
+ returnType: Future<int>
''');
}
@@ -498,11 +778,55 @@
var vBitShiftRight = 1 >> 2;
''');
checkElementText(library, r'''
-int vBitXor;
-int vBitAnd;
-int vBitOr;
-int vBitShiftLeft;
-int vBitShiftRight;
+library
+ definingUnit
+ topLevelVariables
+ static vBitXor @4
+ type: int
+ static vBitAnd @25
+ type: int
+ static vBitOr @46
+ type: int
+ static vBitShiftLeft @66
+ type: int
+ static vBitShiftRight @94
+ type: int
+ accessors
+ synthetic static get vBitXor @4
+ returnType: int
+ synthetic static set vBitXor @4
+ parameters
+ requiredPositional _vBitXor @4
+ type: int
+ returnType: void
+ synthetic static get vBitAnd @25
+ returnType: int
+ synthetic static set vBitAnd @25
+ parameters
+ requiredPositional _vBitAnd @25
+ type: int
+ returnType: void
+ synthetic static get vBitOr @46
+ returnType: int
+ synthetic static set vBitOr @46
+ parameters
+ requiredPositional _vBitOr @46
+ type: int
+ returnType: void
+ synthetic static get vBitShiftLeft @66
+ returnType: int
+ synthetic static set vBitShiftLeft @66
+ parameters
+ requiredPositional _vBitShiftLeft @66
+ type: int
+ returnType: void
+ synthetic static get vBitShiftRight @94
+ returnType: int
+ synthetic static set vBitShiftRight @94
+ parameters
+ requiredPositional _vBitShiftRight @94
+ type: int
+ returnType: void
''');
}
@@ -517,13 +841,55 @@
var vBoth = new A()..a = 1..m();
''');
checkElementText(library, r'''
-class A {
- int a;
- void m() {}
-}
-A vSetField;
-A vInvokeMethod;
-A vBoth;
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ a @16
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get a @16
+ returnType: int
+ synthetic set a @16
+ parameters
+ requiredPositional _a @16
+ type: int
+ returnType: void
+ methods
+ m @26
+ returnType: void
+ topLevelVariables
+ static vSetField @39
+ type: A
+ static vInvokeMethod @71
+ type: A
+ static vBoth @105
+ type: A
+ accessors
+ synthetic static get vSetField @39
+ returnType: A
+ synthetic static set vSetField @39
+ parameters
+ requiredPositional _vSetField @39
+ type: A
+ returnType: void
+ synthetic static get vInvokeMethod @71
+ returnType: A
+ synthetic static set vInvokeMethod @71
+ parameters
+ requiredPositional _vInvokeMethod @71
+ type: A
+ returnType: void
+ synthetic static get vBoth @105
+ returnType: A
+ synthetic static set vBoth @105
+ parameters
+ requiredPositional _vBoth @105
+ type: A
+ returnType: void
''');
}
@@ -561,32 +927,171 @@
C newC() => new C();
''');
checkElementText(library, r'''
-class A {
- int f;
-}
-class B {
- A a;
-}
-class C {
- B b;
-}
-class X {
- A a;
- B b;
- C c;
- int t01;
- int t02;
- int t03;
- int t11;
- int t12;
- int t13;
- int t21;
- int t22;
- int t23;
-}
-A newA() {}
-B newB() {}
-C newC() {}
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ f @16
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get f @16
+ returnType: int
+ synthetic set f @16
+ parameters
+ requiredPositional _f @16
+ type: int
+ returnType: void
+ class B @31
+ fields
+ a @39
+ type: A
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get a @39
+ returnType: A
+ synthetic set a @39
+ parameters
+ requiredPositional _a @39
+ type: A
+ returnType: void
+ class C @50
+ fields
+ b @58
+ type: B
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get b @58
+ returnType: B
+ synthetic set b @58
+ parameters
+ requiredPositional _b @58
+ type: B
+ returnType: void
+ class X @69
+ fields
+ a @77
+ type: A
+ b @94
+ type: B
+ c @111
+ type: C
+ t01 @130
+ type: int
+ t02 @147
+ type: int
+ t03 @166
+ type: int
+ t11 @187
+ type: int
+ t12 @210
+ type: int
+ t13 @235
+ type: int
+ t21 @262
+ type: int
+ t22 @284
+ type: int
+ t23 @308
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get a @77
+ returnType: A
+ synthetic set a @77
+ parameters
+ requiredPositional _a @77
+ type: A
+ returnType: void
+ synthetic get b @94
+ returnType: B
+ synthetic set b @94
+ parameters
+ requiredPositional _b @94
+ type: B
+ returnType: void
+ synthetic get c @111
+ returnType: C
+ synthetic set c @111
+ parameters
+ requiredPositional _c @111
+ type: C
+ returnType: void
+ synthetic get t01 @130
+ returnType: int
+ synthetic set t01 @130
+ parameters
+ requiredPositional _t01 @130
+ type: int
+ returnType: void
+ synthetic get t02 @147
+ returnType: int
+ synthetic set t02 @147
+ parameters
+ requiredPositional _t02 @147
+ type: int
+ returnType: void
+ synthetic get t03 @166
+ returnType: int
+ synthetic set t03 @166
+ parameters
+ requiredPositional _t03 @166
+ type: int
+ returnType: void
+ synthetic get t11 @187
+ returnType: int
+ synthetic set t11 @187
+ parameters
+ requiredPositional _t11 @187
+ type: int
+ returnType: void
+ synthetic get t12 @210
+ returnType: int
+ synthetic set t12 @210
+ parameters
+ requiredPositional _t12 @210
+ type: int
+ returnType: void
+ synthetic get t13 @235
+ returnType: int
+ synthetic set t13 @235
+ parameters
+ requiredPositional _t13 @235
+ type: int
+ returnType: void
+ synthetic get t21 @262
+ returnType: int
+ synthetic set t21 @262
+ parameters
+ requiredPositional _t21 @262
+ type: int
+ returnType: void
+ synthetic get t22 @284
+ returnType: int
+ synthetic set t22 @284
+ parameters
+ requiredPositional _t22 @284
+ type: int
+ returnType: void
+ synthetic get t23 @308
+ returnType: int
+ synthetic set t23 @308
+ parameters
+ requiredPositional _t23 @308
+ type: int
+ returnType: void
+ functions
+ newA @332
+ returnType: A
+ newB @353
+ returnType: B
+ newC @374
+ returnType: C
''');
}
@@ -595,7 +1100,19 @@
var V = true ? 1 : 2.3;
''');
checkElementText(library, r'''
-num V;
+library
+ definingUnit
+ topLevelVariables
+ static V @4
+ type: num
+ accessors
+ synthetic static get V @4
+ returnType: num
+ synthetic static set V @4
+ parameters
+ requiredPositional _V @4
+ type: num
+ returnType: void
''');
}
@@ -605,8 +1122,28 @@
var vNotEq = 1 != 2;
''');
checkElementText(library, r'''
-bool vEq;
-bool vNotEq;
+library
+ definingUnit
+ topLevelVariables
+ static vEq @4
+ type: bool
+ static vNotEq @22
+ type: bool
+ accessors
+ synthetic static get vEq @4
+ returnType: bool
+ synthetic static set vEq @4
+ parameters
+ requiredPositional _vEq @4
+ type: bool
+ returnType: void
+ synthetic static get vNotEq @22
+ returnType: bool
+ synthetic static set vNotEq @22
+ parameters
+ requiredPositional _vNotEq @22
+ type: bool
+ returnType: void
''');
}
@@ -616,8 +1153,30 @@
var b = a.foo();
''');
checkElementText(library, r'''
-dynamic a/*error: dependencyCycle*/;
-dynamic b/*error: dependencyCycle*/;
+library
+ definingUnit
+ topLevelVariables
+ static a @4
+ typeInferenceError: dependencyCycle
+ type: dynamic
+ static b @21
+ typeInferenceError: dependencyCycle
+ type: dynamic
+ accessors
+ synthetic static get a @4
+ returnType: dynamic
+ synthetic static set a @4
+ parameters
+ requiredPositional _a @4
+ type: dynamic
+ returnType: void
+ synthetic static get b @21
+ returnType: dynamic
+ synthetic static set b @21
+ parameters
+ requiredPositional _b @21
+ type: dynamic
+ returnType: void
''');
}
@@ -626,7 +1185,20 @@
var a = a.foo();
''');
checkElementText(library, r'''
-dynamic a/*error: dependencyCycle*/;
+library
+ definingUnit
+ topLevelVariables
+ static a @4
+ typeInferenceError: dependencyCycle
+ type: dynamic
+ accessors
+ synthetic static get a @4
+ returnType: dynamic
+ synthetic static set a @4
+ parameters
+ requiredPositional _a @4
+ type: dynamic
+ returnType: void
''');
}
@@ -637,9 +1209,37 @@
var b1 = a[1];
''');
checkElementText(library, r'''
-List<num> a;
-num b0;
-num b1;
+library
+ definingUnit
+ topLevelVariables
+ static a @4
+ type: List<num>
+ static b0 @22
+ type: num
+ static b1 @37
+ type: num
+ accessors
+ synthetic static get a @4
+ returnType: List<num>
+ synthetic static set a @4
+ parameters
+ requiredPositional _a @4
+ type: List<num>
+ returnType: void
+ synthetic static get b0 @22
+ returnType: num
+ synthetic static set b0 @22
+ parameters
+ requiredPositional _b0 @22
+ type: num
+ returnType: void
+ synthetic static get b1 @37
+ returnType: num
+ synthetic static set b1 @37
+ parameters
+ requiredPositional _b1 @37
+ type: num
+ returnType: void
''');
}
@@ -654,8 +1254,21 @@
var x = new C().f;
''');
checkElementText(library, r'''
-import 'package:test/a.dart';
-int x;
+library
+ imports
+ package:test/a.dart
+ definingUnit
+ topLevelVariables
+ static x @21
+ type: int
+ accessors
+ synthetic static get x @21
+ returnType: int
+ synthetic static set x @21
+ parameters
+ requiredPositional _x @21
+ type: int
+ returnType: void
''');
}
@@ -667,10 +1280,34 @@
var x = new C().f;
''');
checkElementText(library, r'''
-class C {
- int f;
-}
-int x;
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ f @16
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get f @16
+ returnType: int
+ synthetic set f @16
+ parameters
+ requiredPositional _f @16
+ type: int
+ returnType: void
+ topLevelVariables
+ static x @29
+ type: int
+ accessors
+ synthetic static get x @29
+ returnType: int
+ synthetic static set x @29
+ parameters
+ requiredPositional _x @29
+ type: int
+ returnType: void
''');
}
@@ -686,8 +1323,21 @@
var x = new C().f;
''');
checkElementText(library, r'''
-import 'package:test/a.dart';
-int x;
+library
+ imports
+ package:test/a.dart
+ definingUnit
+ topLevelVariables
+ static x @21
+ type: int
+ accessors
+ synthetic static get x @21
+ returnType: int
+ synthetic static set x @21
+ parameters
+ requiredPositional _x @21
+ type: int
+ returnType: void
''');
}
@@ -702,8 +1352,21 @@
var x = new C().f;
''');
checkElementText(library, r'''
-import 'package:test/a.dart';
-int x;
+library
+ imports
+ package:test/a.dart
+ definingUnit
+ topLevelVariables
+ static x @21
+ type: int
+ accessors
+ synthetic static get x @21
+ returnType: int
+ synthetic static set x @21
+ parameters
+ requiredPositional _x @21
+ type: int
+ returnType: void
''');
}
@@ -715,10 +1378,34 @@
var x = new C().f;
''');
checkElementText(library, r'''
-class C {
- int f;
-}
-int x;
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ f @16
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get f @16
+ returnType: int
+ synthetic set f @16
+ parameters
+ requiredPositional _f @16
+ type: int
+ returnType: void
+ topLevelVariables
+ static x @29
+ type: int
+ accessors
+ synthetic static get x @29
+ returnType: int
+ synthetic static set x @29
+ parameters
+ requiredPositional _x @29
+ type: int
+ returnType: void
''');
}
@@ -734,8 +1421,21 @@
var x = new C().f;
''');
checkElementText(library, r'''
-import 'package:test/a.dart';
-int x;
+library
+ imports
+ package:test/a.dart
+ definingUnit
+ topLevelVariables
+ static x @21
+ type: int
+ accessors
+ synthetic static get x @21
+ returnType: int
+ synthetic static set x @21
+ parameters
+ requiredPositional _x @21
+ type: int
+ returnType: void
''');
}
@@ -749,12 +1449,37 @@
}
''');
checkElementText(library, r'''
-class A {
- int f;
-}
-class B {
- static int t;
-}
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ f @16
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get f @16
+ returnType: int
+ synthetic set f @16
+ parameters
+ requiredPositional _f @16
+ type: int
+ returnType: void
+ class B @27
+ fields
+ static t @44
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get t @44
+ returnType: int
+ synthetic static set t @44
+ parameters
+ requiredPositional _t @44
+ type: int
+ returnType: void
''');
}
@@ -767,11 +1492,43 @@
var x = c.b;
''');
checkElementText(library, r'''
-class C {
- bool b;
-}
-C c;
-bool x;
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ b @17
+ type: bool
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get b @17
+ returnType: bool
+ synthetic set b @17
+ parameters
+ requiredPositional _b @17
+ type: bool
+ returnType: void
+ topLevelVariables
+ static c @24
+ type: C
+ static x @31
+ type: bool
+ accessors
+ synthetic static get c @24
+ returnType: C
+ synthetic static set c @24
+ parameters
+ requiredPositional _c @24
+ type: C
+ returnType: void
+ synthetic static get x @31
+ returnType: bool
+ synthetic static set x @31
+ parameters
+ requiredPositional _x @31
+ type: bool
+ returnType: void
''');
}
@@ -785,13 +1542,48 @@
var x = c.b;
''');
checkElementText(library, r'''
-class I {
- bool b;
-}
-abstract class C implements I {
-}
-C c;
-bool x;
+library
+ definingUnit
+ classes
+ class I @6
+ fields
+ b @17
+ type: bool
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get b @17
+ returnType: bool
+ synthetic set b @17
+ parameters
+ requiredPositional _b @17
+ type: bool
+ returnType: void
+ abstract class C @37
+ interfaces
+ I
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static c @57
+ type: C
+ static x @64
+ type: bool
+ accessors
+ synthetic static get c @57
+ returnType: C
+ synthetic static set c @57
+ parameters
+ requiredPositional _c @57
+ type: C
+ returnType: void
+ synthetic static get x @64
+ returnType: bool
+ synthetic static set x @64
+ parameters
+ requiredPositional _x @64
+ type: bool
+ returnType: void
''');
}
@@ -805,13 +1597,42 @@
var x = f().b;
''');
checkElementText(library, r'''
-class I {
- bool b;
-}
-abstract class C implements I {
-}
-bool x;
-C f() {}
+library
+ definingUnit
+ classes
+ class I @6
+ fields
+ b @17
+ type: bool
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get b @17
+ returnType: bool
+ synthetic set b @17
+ parameters
+ requiredPositional _b @17
+ type: bool
+ returnType: void
+ abstract class C @37
+ interfaces
+ I
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static x @74
+ type: bool
+ accessors
+ synthetic static get x @74
+ returnType: bool
+ synthetic static set x @74
+ parameters
+ requiredPositional _x @74
+ type: bool
+ returnType: void
+ functions
+ f @57
+ returnType: C
''');
}
@@ -827,14 +1648,42 @@
var y = B().foo();
''');
checkElementText(library, r'''
-class A {
- int foo() {}
-}
-class B extends A {
- int foo() {}
-}
-int x;
-int y;
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ foo @16
+ returnType: int
+ class B @36
+ supertype: A
+ constructors
+ synthetic @-1
+ methods
+ foo @52
+ returnType: int
+ topLevelVariables
+ static x @70
+ type: int
+ static y @89
+ type: int
+ accessors
+ synthetic static get x @70
+ returnType: int
+ synthetic static set x @70
+ parameters
+ requiredPositional _x @70
+ type: int
+ returnType: void
+ synthetic static get y @89
+ returnType: int
+ synthetic static set y @89
+ parameters
+ requiredPositional _y @89
+ type: int
+ returnType: void
''');
}
@@ -849,13 +1698,66 @@
var v_async_returnFuture = () async => vFuture;
''');
checkElementText(library, r'''
-import 'dart:async';
-Future<int> vFuture;
-int Function() v_noParameters_inferredReturnType;
-int Function(String) v_hasParameter_withType_inferredReturnType;
-String Function(String) v_hasParameter_withType_returnParameter;
-Future<int> Function() v_async_returnValue;
-Future<int> Function() v_async_returnFuture;
+library
+ imports
+ dart:async
+ definingUnit
+ topLevelVariables
+ static vFuture @25
+ type: Future<int>
+ static v_noParameters_inferredReturnType @60
+ type: int Function()
+ static v_hasParameter_withType_inferredReturnType @110
+ type: int Function(String)
+ static v_hasParameter_withType_returnParameter @177
+ type: String Function(String)
+ static v_async_returnValue @240
+ type: Future<int> Function()
+ static v_async_returnFuture @282
+ type: Future<int> Function()
+ accessors
+ synthetic static get vFuture @25
+ returnType: Future<int>
+ synthetic static set vFuture @25
+ parameters
+ requiredPositional _vFuture @25
+ type: Future<int>
+ returnType: void
+ synthetic static get v_noParameters_inferredReturnType @60
+ returnType: int Function()
+ synthetic static set v_noParameters_inferredReturnType @60
+ parameters
+ requiredPositional _v_noParameters_inferredReturnType @60
+ type: int Function()
+ returnType: void
+ synthetic static get v_hasParameter_withType_inferredReturnType @110
+ returnType: int Function(String)
+ synthetic static set v_hasParameter_withType_inferredReturnType @110
+ parameters
+ requiredPositional _v_hasParameter_withType_inferredReturnType @110
+ type: int Function(String)
+ returnType: void
+ synthetic static get v_hasParameter_withType_returnParameter @177
+ returnType: String Function(String)
+ synthetic static set v_hasParameter_withType_returnParameter @177
+ parameters
+ requiredPositional _v_hasParameter_withType_returnParameter @177
+ type: String Function(String)
+ returnType: void
+ synthetic static get v_async_returnValue @240
+ returnType: Future<int> Function()
+ synthetic static set v_async_returnValue @240
+ parameters
+ requiredPositional _v_async_returnValue @240
+ type: Future<int> Function()
+ returnType: void
+ synthetic static get v_async_returnFuture @282
+ returnType: Future<int> Function()
+ synthetic static set v_async_returnFuture @282
+ parameters
+ requiredPositional _v_async_returnFuture @282
+ type: Future<int> Function()
+ returnType: void
''');
}
@@ -865,7 +1767,19 @@
''');
// TODO(scheglov) add more function expression tests
checkElementText(library, r'''
-int v;
+library
+ definingUnit
+ topLevelVariables
+ static v @4
+ type: int
+ accessors
+ synthetic static get v @4
+ returnType: int
+ synthetic static set v @4
+ parameters
+ requiredPositional _v @4
+ type: int
+ returnType: void
''');
}
@@ -876,9 +1790,33 @@
var vNoTypeArgument = f();
''');
checkElementText(library, r'''
-int vHasTypeArgument;
-dynamic vNoTypeArgument;
-T f<T>() {}
+library
+ definingUnit
+ topLevelVariables
+ static vHasTypeArgument @22
+ type: int
+ static vNoTypeArgument @55
+ type: dynamic
+ accessors
+ synthetic static get vHasTypeArgument @22
+ returnType: int
+ synthetic static set vHasTypeArgument @22
+ parameters
+ requiredPositional _vHasTypeArgument @22
+ type: int
+ returnType: void
+ synthetic static get vNoTypeArgument @55
+ returnType: dynamic
+ synthetic static set vNoTypeArgument @55
+ parameters
+ requiredPositional _vNoTypeArgument @55
+ type: dynamic
+ returnType: void
+ functions
+ f @2
+ typeParameters
+ covariant T @4
+ returnType: T
''');
}
@@ -889,9 +1827,34 @@
var vWrongArgumentType = f(2.0);
''');
checkElementText(library, r'''
-String vOkArgumentType;
-String vWrongArgumentType;
-String f(int p) {}
+library
+ definingUnit
+ topLevelVariables
+ static vOkArgumentType @29
+ type: String
+ static vWrongArgumentType @57
+ type: String
+ accessors
+ synthetic static get vOkArgumentType @29
+ returnType: String
+ synthetic static set vOkArgumentType @29
+ parameters
+ requiredPositional _vOkArgumentType @29
+ type: String
+ returnType: void
+ synthetic static get vWrongArgumentType @57
+ returnType: String
+ synthetic static set vWrongArgumentType @57
+ parameters
+ requiredPositional _vWrongArgumentType @57
+ type: String
+ returnType: void
+ functions
+ f @7
+ parameters
+ requiredPositional p @13
+ type: int
+ returnType: String
''');
}
@@ -916,23 +1879,131 @@
var r_instanceClassMethod = instanceOfA.instanceClassMethod;
''');
checkElementText(library, r'''
-class A {
- static int staticClassVariable;
- static int get staticGetter {}
- static String staticClassMethod(int p) {}
- String instanceClassMethod(int p) {}
-}
-int topLevelVariable;
-String Function(int) r_topLevelFunction;
-int r_topLevelVariable;
-int r_topLevelGetter;
-int r_staticClassVariable;
-int r_staticGetter;
-String Function(int) r_staticClassMethod;
-A instanceOfA;
-String Function(int) r_instanceClassMethod;
-int get topLevelGetter {}
-String topLevelFunction(int p) {}
+library
+ definingUnit
+ classes
+ class A @101
+ fields
+ static staticClassVariable @118
+ type: int
+ synthetic static staticGetter @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get staticClassVariable @118
+ returnType: int
+ synthetic static set staticClassVariable @118
+ parameters
+ requiredPositional _staticClassVariable @118
+ type: int
+ returnType: void
+ static get staticGetter @160
+ returnType: int
+ methods
+ static staticClassMethod @195
+ parameters
+ requiredPositional p @217
+ type: int
+ returnType: String
+ instanceClassMethod @238
+ parameters
+ requiredPositional p @262
+ type: int
+ returnType: String
+ topLevelVariables
+ static topLevelVariable @44
+ type: int
+ static r_topLevelFunction @280
+ type: String Function(int)
+ static r_topLevelVariable @323
+ type: int
+ static r_topLevelGetter @366
+ type: int
+ static r_staticClassVariable @405
+ type: int
+ static r_staticGetter @456
+ type: int
+ static r_staticClassMethod @493
+ type: String Function(int)
+ static instanceOfA @540
+ type: A
+ static r_instanceClassMethod @567
+ type: String Function(int)
+ synthetic static topLevelGetter @-1
+ type: int
+ accessors
+ synthetic static get topLevelVariable @44
+ returnType: int
+ synthetic static set topLevelVariable @44
+ parameters
+ requiredPositional _topLevelVariable @44
+ type: int
+ returnType: void
+ synthetic static get r_topLevelFunction @280
+ returnType: String Function(int)
+ synthetic static set r_topLevelFunction @280
+ parameters
+ requiredPositional _r_topLevelFunction @280
+ type: String Function(int)
+ returnType: void
+ synthetic static get r_topLevelVariable @323
+ returnType: int
+ synthetic static set r_topLevelVariable @323
+ parameters
+ requiredPositional _r_topLevelVariable @323
+ type: int
+ returnType: void
+ synthetic static get r_topLevelGetter @366
+ returnType: int
+ synthetic static set r_topLevelGetter @366
+ parameters
+ requiredPositional _r_topLevelGetter @366
+ type: int
+ returnType: void
+ synthetic static get r_staticClassVariable @405
+ returnType: int
+ synthetic static set r_staticClassVariable @405
+ parameters
+ requiredPositional _r_staticClassVariable @405
+ type: int
+ returnType: void
+ synthetic static get r_staticGetter @456
+ returnType: int
+ synthetic static set r_staticGetter @456
+ parameters
+ requiredPositional _r_staticGetter @456
+ type: int
+ returnType: void
+ synthetic static get r_staticClassMethod @493
+ returnType: String Function(int)
+ synthetic static set r_staticClassMethod @493
+ parameters
+ requiredPositional _r_staticClassMethod @493
+ type: String Function(int)
+ returnType: void
+ synthetic static get instanceOfA @540
+ returnType: A
+ synthetic static set instanceOfA @540
+ parameters
+ requiredPositional _instanceOfA @540
+ type: A
+ returnType: void
+ synthetic static get r_instanceClassMethod @567
+ returnType: String Function(int)
+ synthetic static set r_instanceClassMethod @567
+ parameters
+ requiredPositional _r_instanceClassMethod @567
+ type: String Function(int)
+ returnType: void
+ get topLevelGetter @74
+ returnType: int
+ functions
+ topLevelFunction @7
+ parameters
+ requiredPositional p @28
+ type: int
+ returnType: String
''');
}
@@ -947,13 +2018,50 @@
var c = A.a;
''');
checkElementText(library, r'''
-class A {
- static dynamic a/*error: dependencyCycle*/;
-}
-class B {
- static dynamic b/*error: dependencyCycle*/;
-}
-dynamic c;
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ static a @23
+ typeInferenceError: dependencyCycle
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get a @23
+ returnType: dynamic
+ synthetic static set a @23
+ parameters
+ requiredPositional _a @23
+ type: dynamic
+ returnType: void
+ class B @40
+ fields
+ static b @57
+ typeInferenceError: dependencyCycle
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get b @57
+ returnType: dynamic
+ synthetic static set b @57
+ parameters
+ requiredPositional _b @57
+ type: dynamic
+ returnType: void
+ topLevelVariables
+ static c @72
+ type: dynamic
+ accessors
+ synthetic static get c @72
+ returnType: dynamic
+ synthetic static set c @72
+ parameters
+ requiredPositional _c @72
+ type: dynamic
+ returnType: void
''');
}
@@ -966,11 +2074,45 @@
var c = b;
''');
checkElementText(library, r'''
-class A {
- static dynamic a/*error: dependencyCycle*/;
-}
-dynamic b/*error: dependencyCycle*/;
-dynamic c;
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ static a @23
+ typeInferenceError: dependencyCycle
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get a @23
+ returnType: dynamic
+ synthetic static set a @23
+ parameters
+ requiredPositional _a @23
+ type: dynamic
+ returnType: void
+ topLevelVariables
+ static b @36
+ typeInferenceError: dependencyCycle
+ type: dynamic
+ static c @49
+ type: dynamic
+ accessors
+ synthetic static get b @36
+ returnType: dynamic
+ synthetic static set b @36
+ parameters
+ requiredPositional _b @36
+ type: dynamic
+ returnType: void
+ synthetic static get c @49
+ returnType: dynamic
+ synthetic static set c @49
+ parameters
+ requiredPositional _c @49
+ type: dynamic
+ returnType: void
''');
}
@@ -982,10 +2124,49 @@
var d = a;
''');
checkElementText(library, r'''
-dynamic a/*error: dependencyCycle*/;
-dynamic b/*error: dependencyCycle*/;
-dynamic c/*error: dependencyCycle*/;
-dynamic d;
+library
+ definingUnit
+ topLevelVariables
+ static a @4
+ typeInferenceError: dependencyCycle
+ type: dynamic
+ static b @15
+ typeInferenceError: dependencyCycle
+ type: dynamic
+ static c @26
+ typeInferenceError: dependencyCycle
+ type: dynamic
+ static d @37
+ type: dynamic
+ accessors
+ synthetic static get a @4
+ returnType: dynamic
+ synthetic static set a @4
+ parameters
+ requiredPositional _a @4
+ type: dynamic
+ returnType: void
+ synthetic static get b @15
+ returnType: dynamic
+ synthetic static set b @15
+ parameters
+ requiredPositional _b @15
+ type: dynamic
+ returnType: void
+ synthetic static get c @26
+ returnType: dynamic
+ synthetic static set c @26
+ parameters
+ requiredPositional _c @26
+ type: dynamic
+ returnType: void
+ synthetic static get d @37
+ returnType: dynamic
+ synthetic static set d @37
+ parameters
+ requiredPositional _d @37
+ type: dynamic
+ returnType: void
''');
}
@@ -1015,9 +2196,23 @@
var a = new A();
''');
checkElementText(library, r'''
-class A {
-}
-A a;
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ topLevelVariables
+ static a @15
+ type: A
+ accessors
+ synthetic static get a @15
+ returnType: A
+ synthetic static set a @15
+ parameters
+ requiredPositional _a @15
+ type: A
+ returnType: void
''');
}
@@ -1028,9 +2223,31 @@
var h = f().hashCode;
''');
checkElementText(library, r'''
-String s;
-int h;
-dynamic f() {}
+library
+ definingUnit
+ topLevelVariables
+ static s @25
+ type: String
+ static h @49
+ type: int
+ accessors
+ synthetic static get s @25
+ returnType: String
+ synthetic static set s @25
+ parameters
+ requiredPositional _s @25
+ type: String
+ returnType: void
+ synthetic static get h @49
+ returnType: int
+ synthetic static set h @49
+ parameters
+ requiredPositional _h @49
+ type: int
+ returnType: void
+ functions
+ f @8
+ returnType: dynamic
''');
}
@@ -1041,9 +2258,37 @@
var h = d.hashCode;
''');
checkElementText(library, r'''
-dynamic d;
-String s;
-int h;
+library
+ definingUnit
+ topLevelVariables
+ static d @8
+ type: dynamic
+ static s @15
+ type: String
+ static h @37
+ type: int
+ accessors
+ synthetic static get d @8
+ returnType: dynamic
+ synthetic static set d @8
+ parameters
+ requiredPositional _d @8
+ type: dynamic
+ returnType: void
+ synthetic static get s @15
+ returnType: String
+ synthetic static set s @15
+ parameters
+ requiredPositional _s @15
+ type: String
+ returnType: void
+ synthetic static get h @37
+ returnType: int
+ synthetic static set h @37
+ parameters
+ requiredPositional _h @37
+ type: int
+ returnType: void
''');
}
@@ -1053,8 +2298,28 @@
var b = a is int;
''');
checkElementText(library, r'''
-double a;
-bool b;
+library
+ definingUnit
+ topLevelVariables
+ static a @4
+ type: double
+ static b @17
+ type: bool
+ accessors
+ synthetic static get a @4
+ returnType: double
+ synthetic static set a @4
+ parameters
+ requiredPositional _a @4
+ type: double
+ returnType: void
+ synthetic static get b @17
+ returnType: bool
+ synthetic static set b @17
+ parameters
+ requiredPositional _b @17
+ type: bool
+ returnType: void
''');
}
@@ -1094,10 +2359,46 @@
var vInt = <int>[1, 2, 3];
''');
checkElementText(library, r'''
-List<Object> vObject;
-List<num> vNum;
-List<num> vNumEmpty;
-List<int> vInt;
+library
+ definingUnit
+ topLevelVariables
+ static vObject @4
+ type: List<Object>
+ static vNum @37
+ type: List<num>
+ static vNumEmpty @64
+ type: List<num>
+ static vInt @89
+ type: List<int>
+ accessors
+ synthetic static get vObject @4
+ returnType: List<Object>
+ synthetic static set vObject @4
+ parameters
+ requiredPositional _vObject @4
+ type: List<Object>
+ returnType: void
+ synthetic static get vNum @37
+ returnType: List<num>
+ synthetic static set vNum @37
+ parameters
+ requiredPositional _vNum @37
+ type: List<num>
+ returnType: void
+ synthetic static get vNumEmpty @64
+ returnType: List<num>
+ synthetic static set vNumEmpty @64
+ parameters
+ requiredPositional _vNumEmpty @64
+ type: List<num>
+ returnType: void
+ synthetic static get vInt @89
+ returnType: List<int>
+ synthetic static set vInt @89
+ parameters
+ requiredPositional _vInt @89
+ type: List<int>
+ returnType: void
''');
}
@@ -1108,9 +2409,37 @@
var vObject = [1, 2.0, '333'];
''');
checkElementText(library, r'''
-List<int> vInt;
-List<num> vNum;
-List<Object> vObject;
+library
+ definingUnit
+ topLevelVariables
+ static vInt @4
+ type: List<int>
+ static vNum @26
+ type: List<num>
+ static vObject @47
+ type: List<Object>
+ accessors
+ synthetic static get vInt @4
+ returnType: List<int>
+ synthetic static set vInt @4
+ parameters
+ requiredPositional _vInt @4
+ type: List<int>
+ returnType: void
+ synthetic static get vNum @26
+ returnType: List<num>
+ synthetic static set vNum @26
+ parameters
+ requiredPositional _vNum @26
+ type: List<num>
+ returnType: void
+ synthetic static get vObject @47
+ returnType: List<Object>
+ synthetic static set vObject @47
+ parameters
+ requiredPositional _vObject @47
+ type: List<Object>
+ returnType: void
''');
}
@@ -1135,11 +2464,55 @@
var vIntString = <int, String>{};
''');
checkElementText(library, r'''
-Map<Object, Object> vObjectObject;
-Map<Comparable<int>, Object> vComparableObject;
-Map<num, String> vNumString;
-Map<num, String> vNumStringEmpty;
-Map<int, String> vIntString;
+library
+ definingUnit
+ topLevelVariables
+ static vObjectObject @4
+ type: Map<Object, Object>
+ static vComparableObject @50
+ type: Map<Comparable<int>, Object>
+ static vNumString @109
+ type: Map<num, String>
+ static vNumStringEmpty @149
+ type: Map<num, String>
+ static vIntString @188
+ type: Map<int, String>
+ accessors
+ synthetic static get vObjectObject @4
+ returnType: Map<Object, Object>
+ synthetic static set vObjectObject @4
+ parameters
+ requiredPositional _vObjectObject @4
+ type: Map<Object, Object>
+ returnType: void
+ synthetic static get vComparableObject @50
+ returnType: Map<Comparable<int>, Object>
+ synthetic static set vComparableObject @50
+ parameters
+ requiredPositional _vComparableObject @50
+ type: Map<Comparable<int>, Object>
+ returnType: void
+ synthetic static get vNumString @109
+ returnType: Map<num, String>
+ synthetic static set vNumString @109
+ parameters
+ requiredPositional _vNumString @109
+ type: Map<num, String>
+ returnType: void
+ synthetic static get vNumStringEmpty @149
+ returnType: Map<num, String>
+ synthetic static set vNumStringEmpty @149
+ parameters
+ requiredPositional _vNumStringEmpty @149
+ type: Map<num, String>
+ returnType: void
+ synthetic static get vIntString @188
+ returnType: Map<int, String>
+ synthetic static set vIntString @188
+ parameters
+ requiredPositional _vIntString @188
+ type: Map<int, String>
+ returnType: void
''');
}
@@ -1150,9 +2523,37 @@
var vIntObject = {1: 'a', 2: 3.0};
''');
checkElementText(library, r'''
-Map<int, String> vIntString;
-Map<num, String> vNumString;
-Map<int, Object> vIntObject;
+library
+ definingUnit
+ topLevelVariables
+ static vIntString @4
+ type: Map<int, String>
+ static vNumString @39
+ type: Map<num, String>
+ static vIntObject @76
+ type: Map<int, Object>
+ accessors
+ synthetic static get vIntString @4
+ returnType: Map<int, String>
+ synthetic static set vIntString @4
+ parameters
+ requiredPositional _vIntString @4
+ type: Map<int, String>
+ returnType: void
+ synthetic static get vNumString @39
+ returnType: Map<num, String>
+ synthetic static set vNumString @39
+ parameters
+ requiredPositional _vNumString @39
+ type: Map<num, String>
+ returnType: void
+ synthetic static get vIntObject @76
+ returnType: Map<int, Object>
+ synthetic static set vIntObject @76
+ parameters
+ requiredPositional _vIntObject @76
+ type: Map<int, Object>
+ returnType: void
''');
}
@@ -1177,11 +2578,55 @@
var vOr = a || b;
''');
checkElementText(library, r'''
-bool a;
-bool b;
-bool vEq;
-bool vAnd;
-bool vOr;
+library
+ definingUnit
+ topLevelVariables
+ static a @4
+ type: bool
+ static b @18
+ type: bool
+ static vEq @32
+ type: bool
+ static vAnd @50
+ type: bool
+ static vOr @69
+ type: bool
+ accessors
+ synthetic static get a @4
+ returnType: bool
+ synthetic static set a @4
+ parameters
+ requiredPositional _a @4
+ type: bool
+ returnType: void
+ synthetic static get b @18
+ returnType: bool
+ synthetic static set b @18
+ parameters
+ requiredPositional _b @18
+ type: bool
+ returnType: void
+ synthetic static get vEq @32
+ returnType: bool
+ synthetic static set vEq @32
+ parameters
+ requiredPositional _vEq @32
+ type: bool
+ returnType: void
+ synthetic static get vAnd @50
+ returnType: bool
+ synthetic static set vAnd @50
+ parameters
+ requiredPositional _vAnd @50
+ type: bool
+ returnType: void
+ synthetic static get vOr @69
+ returnType: bool
+ synthetic static set vOr @69
+ parameters
+ requiredPositional _vOr @69
+ type: bool
+ returnType: void
''');
}
@@ -1214,12 +2659,47 @@
var v2 = new A().m();
''');
checkElementText(library, r'''
-class A {
- String m(int p) {}
-}
-A instanceOfA;
-String v1;
-String v2;
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @19
+ parameters
+ requiredPositional p @25
+ type: int
+ returnType: String
+ topLevelVariables
+ static instanceOfA @43
+ type: A
+ static v1 @70
+ type: String
+ static v2 @96
+ type: String
+ accessors
+ synthetic static get instanceOfA @43
+ returnType: A
+ synthetic static set instanceOfA @43
+ parameters
+ requiredPositional _instanceOfA @43
+ type: A
+ returnType: void
+ synthetic static get v1 @70
+ returnType: String
+ synthetic static set v1 @70
+ parameters
+ requiredPositional _v1 @70
+ type: String
+ returnType: void
+ synthetic static get v2 @96
+ returnType: String
+ synthetic static set v2 @96
+ parameters
+ requiredPositional _v2 @96
+ type: String
+ returnType: void
''');
}
@@ -1238,17 +2718,109 @@
var vFloorDivide = 1 ~/ 2;
''');
checkElementText(library, r'''
-int vModuloIntInt;
-double vModuloIntDouble;
-int vMultiplyIntInt;
-double vMultiplyIntDouble;
-double vMultiplyDoubleInt;
-double vMultiplyDoubleDouble;
-double vDivideIntInt;
-double vDivideIntDouble;
-double vDivideDoubleInt;
-double vDivideDoubleDouble;
-int vFloorDivide;
+library
+ definingUnit
+ topLevelVariables
+ static vModuloIntInt @4
+ type: int
+ static vModuloIntDouble @31
+ type: double
+ static vMultiplyIntInt @63
+ type: int
+ static vMultiplyIntDouble @92
+ type: double
+ static vMultiplyDoubleInt @126
+ type: double
+ static vMultiplyDoubleDouble @160
+ type: double
+ static vDivideIntInt @199
+ type: double
+ static vDivideIntDouble @226
+ type: double
+ static vDivideDoubleInt @258
+ type: double
+ static vDivideDoubleDouble @290
+ type: double
+ static vFloorDivide @327
+ type: int
+ accessors
+ synthetic static get vModuloIntInt @4
+ returnType: int
+ synthetic static set vModuloIntInt @4
+ parameters
+ requiredPositional _vModuloIntInt @4
+ type: int
+ returnType: void
+ synthetic static get vModuloIntDouble @31
+ returnType: double
+ synthetic static set vModuloIntDouble @31
+ parameters
+ requiredPositional _vModuloIntDouble @31
+ type: double
+ returnType: void
+ synthetic static get vMultiplyIntInt @63
+ returnType: int
+ synthetic static set vMultiplyIntInt @63
+ parameters
+ requiredPositional _vMultiplyIntInt @63
+ type: int
+ returnType: void
+ synthetic static get vMultiplyIntDouble @92
+ returnType: double
+ synthetic static set vMultiplyIntDouble @92
+ parameters
+ requiredPositional _vMultiplyIntDouble @92
+ type: double
+ returnType: void
+ synthetic static get vMultiplyDoubleInt @126
+ returnType: double
+ synthetic static set vMultiplyDoubleInt @126
+ parameters
+ requiredPositional _vMultiplyDoubleInt @126
+ type: double
+ returnType: void
+ synthetic static get vMultiplyDoubleDouble @160
+ returnType: double
+ synthetic static set vMultiplyDoubleDouble @160
+ parameters
+ requiredPositional _vMultiplyDoubleDouble @160
+ type: double
+ returnType: void
+ synthetic static get vDivideIntInt @199
+ returnType: double
+ synthetic static set vDivideIntInt @199
+ parameters
+ requiredPositional _vDivideIntInt @199
+ type: double
+ returnType: void
+ synthetic static get vDivideIntDouble @226
+ returnType: double
+ synthetic static set vDivideIntDouble @226
+ parameters
+ requiredPositional _vDivideIntDouble @226
+ type: double
+ returnType: void
+ synthetic static get vDivideDoubleInt @258
+ returnType: double
+ synthetic static set vDivideDoubleInt @258
+ parameters
+ requiredPositional _vDivideDoubleInt @258
+ type: double
+ returnType: void
+ synthetic static get vDivideDoubleDouble @290
+ returnType: double
+ synthetic static set vDivideDoubleDouble @290
+ parameters
+ requiredPositional _vDivideDoubleDouble @290
+ type: double
+ returnType: void
+ synthetic static get vFloorDivide @327
+ returnType: int
+ synthetic static set vFloorDivide @327
+ parameters
+ requiredPositional _vFloorDivide @327
+ type: int
+ returnType: void
''');
}
@@ -1259,9 +2831,37 @@
var vNotEq = a != ((a = 2) == 0);
''');
checkElementText(library, r'''
-int a;
-bool vEq;
-bool vNotEq;
+library
+ definingUnit
+ topLevelVariables
+ static a @4
+ type: int
+ static vEq @15
+ type: bool
+ static vNotEq @46
+ type: bool
+ accessors
+ synthetic static get a @4
+ returnType: int
+ synthetic static set a @4
+ parameters
+ requiredPositional _a @4
+ type: int
+ returnType: void
+ synthetic static get vEq @15
+ returnType: bool
+ synthetic static set vEq @15
+ parameters
+ requiredPositional _vEq @15
+ type: bool
+ returnType: void
+ synthetic static get vNotEq @46
+ returnType: bool
+ synthetic static set vNotEq @46
+ parameters
+ requiredPositional _vNotEq @46
+ type: bool
+ returnType: void
''');
}
@@ -1270,7 +2870,19 @@
var V = (42);
''');
checkElementText(library, r'''
-int V;
+library
+ definingUnit
+ topLevelVariables
+ static V @4
+ type: int
+ accessors
+ synthetic static get V @4
+ returnType: int
+ synthetic static set V @4
+ parameters
+ requiredPositional _V @4
+ type: int
+ returnType: void
''');
}
@@ -1284,12 +2896,64 @@
var vDecDouble = vDouble--;
''');
checkElementText(library, r'''
-int vInt;
-double vDouble;
-int vIncInt;
-int vDecInt;
-double vIncDouble;
-double vDecDouble;
+library
+ definingUnit
+ topLevelVariables
+ static vInt @4
+ type: int
+ static vDouble @18
+ type: double
+ static vIncInt @37
+ type: int
+ static vDecInt @59
+ type: int
+ static vIncDouble @81
+ type: double
+ static vDecDouble @109
+ type: double
+ accessors
+ synthetic static get vInt @4
+ returnType: int
+ synthetic static set vInt @4
+ parameters
+ requiredPositional _vInt @4
+ type: int
+ returnType: void
+ synthetic static get vDouble @18
+ returnType: double
+ synthetic static set vDouble @18
+ parameters
+ requiredPositional _vDouble @18
+ type: double
+ returnType: void
+ synthetic static get vIncInt @37
+ returnType: int
+ synthetic static set vIncInt @37
+ parameters
+ requiredPositional _vIncInt @37
+ type: int
+ returnType: void
+ synthetic static get vDecInt @59
+ returnType: int
+ synthetic static set vDecInt @59
+ parameters
+ requiredPositional _vDecInt @59
+ type: int
+ returnType: void
+ synthetic static get vIncDouble @81
+ returnType: double
+ synthetic static set vIncDouble @81
+ parameters
+ requiredPositional _vIncDouble @81
+ type: double
+ returnType: void
+ synthetic static get vDecDouble @109
+ returnType: double
+ synthetic static set vDecDouble @109
+ parameters
+ requiredPositional _vDecDouble @109
+ type: double
+ returnType: void
''');
}
@@ -1303,12 +2967,64 @@
var vDecDouble = vDouble[0]--;
''');
checkElementText(library, r'''
-List<int> vInt;
-List<double> vDouble;
-int vIncInt;
-int vDecInt;
-double vIncDouble;
-double vDecDouble;
+library
+ definingUnit
+ topLevelVariables
+ static vInt @4
+ type: List<int>
+ static vDouble @20
+ type: List<double>
+ static vIncInt @41
+ type: int
+ static vDecInt @66
+ type: int
+ static vIncDouble @91
+ type: double
+ static vDecDouble @122
+ type: double
+ accessors
+ synthetic static get vInt @4
+ returnType: List<int>
+ synthetic static set vInt @4
+ parameters
+ requiredPositional _vInt @4
+ type: List<int>
+ returnType: void
+ synthetic static get vDouble @20
+ returnType: List<double>
+ synthetic static set vDouble @20
+ parameters
+ requiredPositional _vDouble @20
+ type: List<double>
+ returnType: void
+ synthetic static get vIncInt @41
+ returnType: int
+ synthetic static set vIncInt @41
+ parameters
+ requiredPositional _vIncInt @41
+ type: int
+ returnType: void
+ synthetic static get vDecInt @66
+ returnType: int
+ synthetic static set vDecInt @66
+ parameters
+ requiredPositional _vDecInt @66
+ type: int
+ returnType: void
+ synthetic static get vIncDouble @91
+ returnType: double
+ synthetic static set vIncDouble @91
+ parameters
+ requiredPositional _vIncDouble @91
+ type: double
+ returnType: void
+ synthetic static get vDecDouble @122
+ returnType: double
+ synthetic static set vDecDouble @122
+ parameters
+ requiredPositional _vDecDouble @122
+ type: double
+ returnType: void
''');
}
@@ -1322,12 +3038,64 @@
var vDecInt = --vDouble;
''');
checkElementText(library, r'''
-int vInt;
-double vDouble;
-int vIncInt;
-int vDecInt;
-double vIncDouble;
-double vDecInt;
+library
+ definingUnit
+ topLevelVariables
+ static vInt @4
+ type: int
+ static vDouble @18
+ type: double
+ static vIncInt @37
+ type: int
+ static vDecInt @59
+ type: int
+ static vIncDouble @81
+ type: double
+ static vDecInt @109
+ type: double
+ accessors
+ synthetic static get vInt @4
+ returnType: int
+ synthetic static set vInt @4
+ parameters
+ requiredPositional _vInt @4
+ type: int
+ returnType: void
+ synthetic static get vDouble @18
+ returnType: double
+ synthetic static set vDouble @18
+ parameters
+ requiredPositional _vDouble @18
+ type: double
+ returnType: void
+ synthetic static get vIncInt @37
+ returnType: int
+ synthetic static set vIncInt @37
+ parameters
+ requiredPositional _vIncInt @37
+ type: int
+ returnType: void
+ synthetic static get vDecInt @59
+ returnType: int
+ synthetic static set vDecInt @59
+ parameters
+ requiredPositional _vDecInt @59
+ type: int
+ returnType: void
+ synthetic static get vIncDouble @81
+ returnType: double
+ synthetic static set vIncDouble @81
+ parameters
+ requiredPositional _vIncDouble @81
+ type: double
+ returnType: void
+ synthetic static get vDecInt @109
+ returnType: double
+ synthetic static set vDecInt @109
+ parameters
+ requiredPositional _vDecInt @109
+ type: double
+ returnType: void
''');
}
@@ -1359,12 +3127,64 @@
var vDecInt = --vDouble[0];
''');
checkElementText(library, r'''
-List<int> vInt;
-List<double> vDouble;
-int vIncInt;
-int vDecInt;
-double vIncDouble;
-double vDecInt;
+library
+ definingUnit
+ topLevelVariables
+ static vInt @4
+ type: List<int>
+ static vDouble @20
+ type: List<double>
+ static vIncInt @41
+ type: int
+ static vDecInt @66
+ type: int
+ static vIncDouble @91
+ type: double
+ static vDecInt @122
+ type: double
+ accessors
+ synthetic static get vInt @4
+ returnType: List<int>
+ synthetic static set vInt @4
+ parameters
+ requiredPositional _vInt @4
+ type: List<int>
+ returnType: void
+ synthetic static get vDouble @20
+ returnType: List<double>
+ synthetic static set vDouble @20
+ parameters
+ requiredPositional _vDouble @20
+ type: List<double>
+ returnType: void
+ synthetic static get vIncInt @41
+ returnType: int
+ synthetic static set vIncInt @41
+ parameters
+ requiredPositional _vIncInt @41
+ type: int
+ returnType: void
+ synthetic static get vDecInt @66
+ returnType: int
+ synthetic static set vDecInt @66
+ parameters
+ requiredPositional _vDecInt @66
+ type: int
+ returnType: void
+ synthetic static get vIncDouble @91
+ returnType: double
+ synthetic static set vIncDouble @91
+ parameters
+ requiredPositional _vIncDouble @91
+ type: double
+ returnType: void
+ synthetic static get vDecInt @122
+ returnType: double
+ synthetic static set vDecInt @122
+ parameters
+ requiredPositional _vDecInt @122
+ type: double
+ returnType: void
''');
}
@@ -1373,7 +3193,19 @@
var vNot = !true;
''');
checkElementText(library, r'''
-bool vNot;
+library
+ definingUnit
+ topLevelVariables
+ static vNot @4
+ type: bool
+ accessors
+ synthetic static get vNot @4
+ returnType: bool
+ synthetic static set vNot @4
+ parameters
+ requiredPositional _vNot @4
+ type: bool
+ returnType: void
''');
}
@@ -1384,9 +3216,37 @@
var vComplement = ~1;
''');
checkElementText(library, r'''
-int vNegateInt;
-double vNegateDouble;
-int vComplement;
+library
+ definingUnit
+ topLevelVariables
+ static vNegateInt @4
+ type: int
+ static vNegateDouble @25
+ type: double
+ static vComplement @51
+ type: int
+ accessors
+ synthetic static get vNegateInt @4
+ returnType: int
+ synthetic static set vNegateInt @4
+ parameters
+ requiredPositional _vNegateInt @4
+ type: int
+ returnType: void
+ synthetic static get vNegateDouble @25
+ returnType: double
+ synthetic static set vNegateDouble @25
+ parameters
+ requiredPositional _vNegateDouble @25
+ type: double
+ returnType: void
+ synthetic static get vComplement @51
+ returnType: int
+ synthetic static set vComplement @51
+ parameters
+ requiredPositional _vComplement @51
+ type: int
+ returnType: void
''');
}
@@ -1401,13 +3261,43 @@
final x = C.d.i;
''');
checkElementText(library, r'''
-class C {
- static D d;
-}
-class D {
- int i;
-}
-final int x;
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ static d @21
+ type: D
+ constructors
+ synthetic @-1
+ accessors
+ synthetic static get d @21
+ returnType: D
+ synthetic static set d @21
+ parameters
+ requiredPositional _d @21
+ type: D
+ returnType: void
+ class D @32
+ fields
+ i @42
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get i @42
+ returnType: int
+ synthetic set i @42
+ parameters
+ requiredPositional _i @42
+ type: int
+ returnType: void
+ topLevelVariables
+ static final x @53
+ type: int
+ accessors
+ synthetic static get x @53
+ returnType: int
''');
}
@@ -1422,13 +3312,43 @@
var x = C.d.i;
''');
checkElementText(library, r'''
-class C {
- static D get d {}
-}
-class D {
- int i;
-}
-int x;
+library
+ definingUnit
+ classes
+ class C @6
+ fields
+ synthetic static d @-1
+ type: D
+ constructors
+ synthetic @-1
+ accessors
+ static get d @25
+ returnType: D
+ class D @44
+ fields
+ i @54
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get i @54
+ returnType: int
+ synthetic set i @54
+ parameters
+ requiredPositional _i @54
+ type: int
+ returnType: void
+ topLevelVariables
+ static x @63
+ type: int
+ accessors
+ synthetic static get x @63
+ returnType: int
+ synthetic static set x @63
+ parameters
+ requiredPositional _x @63
+ type: int
+ returnType: void
''');
}
@@ -1440,10 +3360,46 @@
var vGreaterOrEqual = 1 >= 2;
''');
checkElementText(library, r'''
-bool vLess;
-bool vLessOrEqual;
-bool vGreater;
-bool vGreaterOrEqual;
+library
+ definingUnit
+ topLevelVariables
+ static vLess @4
+ type: bool
+ static vLessOrEqual @23
+ type: bool
+ static vGreater @50
+ type: bool
+ static vGreaterOrEqual @72
+ type: bool
+ accessors
+ synthetic static get vLess @4
+ returnType: bool
+ synthetic static set vLess @4
+ parameters
+ requiredPositional _vLess @4
+ type: bool
+ returnType: void
+ synthetic static get vLessOrEqual @23
+ returnType: bool
+ synthetic static set vLessOrEqual @23
+ parameters
+ requiredPositional _vLessOrEqual @23
+ type: bool
+ returnType: void
+ synthetic static get vGreater @50
+ returnType: bool
+ synthetic static set vGreater @50
+ parameters
+ requiredPositional _vGreater @50
+ type: bool
+ returnType: void
+ synthetic static get vGreaterOrEqual @72
+ returnType: bool
+ synthetic static set vGreaterOrEqual @72
+ parameters
+ requiredPositional _vGreaterOrEqual @72
+ type: bool
+ returnType: void
''');
}
@@ -1467,12 +3423,34 @@
}
''');
checkElementText(library, r'''
-abstract class A {
- int x;
-}
-class B implements A {
- void set x() {}
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ x @25
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @25
+ returnType: int
+ synthetic set x @25
+ parameters
+ requiredPositional _x @25
+ type: int
+ returnType: void
+ class B @36
+ interfaces
+ A
+ fields
+ synthetic x @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ set x @59
+ returnType: void
''');
}
@@ -1484,10 +3462,29 @@
}
''');
checkElementText(library, r'''
-class A {
- int f;
- A([final int this.f = 'hello']);
-}
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ f @16
+ type: int
+ constructors
+ @25
+ parameters
+ optionalPositional final this.f @33
+ type: int
+ constantInitializer
+ SimpleStringLiteral
+ literal: 'hello' @0
+ accessors
+ synthetic get f @16
+ returnType: int
+ synthetic set f @16
+ parameters
+ requiredPositional _f @16
+ type: int
+ returnType: void
''');
}
@@ -1504,23 +3501,70 @@
set z(_) {}
}
''');
- checkElementText(
- library,
- r'''
-abstract class A {
- int x;
- int y;
- int z;
-}
-class B implements A {
- int x;
- synthetic int y;
- synthetic int z;
- int get y {}
- void set z(int _) {}
-}
-''',
- withSyntheticFields: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ x @25
+ type: int
+ y @34
+ type: int
+ z @43
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @25
+ returnType: int
+ synthetic set x @25
+ parameters
+ requiredPositional _x @25
+ type: int
+ returnType: void
+ synthetic get y @34
+ returnType: int
+ synthetic set y @34
+ parameters
+ requiredPositional _y @34
+ type: int
+ returnType: void
+ synthetic get z @43
+ returnType: int
+ synthetic set z @43
+ parameters
+ requiredPositional _z @43
+ type: int
+ returnType: void
+ class B @54
+ interfaces
+ A
+ fields
+ x @77
+ type: int
+ synthetic y @-1
+ type: int
+ synthetic z @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @77
+ returnType: int
+ synthetic set x @77
+ parameters
+ requiredPositional _x @77
+ type: int
+ returnType: void
+ get y @86
+ returnType: int
+ set z @103
+ parameters
+ requiredPositional _ @105
+ type: int
+ returnType: void
+''');
}
test_instanceField_fromField_explicitDynamic() async {
@@ -1533,12 +3577,39 @@
}
''');
checkElementText(library, r'''
-abstract class A {
- dynamic x;
-}
-class B implements A {
- dynamic x;
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ x @29
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @29
+ returnType: dynamic
+ synthetic set x @29
+ parameters
+ requiredPositional _x @29
+ type: dynamic
+ returnType: void
+ class B @40
+ interfaces
+ A
+ fields
+ x @63
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @63
+ returnType: dynamic
+ synthetic set x @63
+ parameters
+ requiredPositional _x @63
+ type: dynamic
+ returnType: void
''');
}
@@ -1555,23 +3626,76 @@
set z(_) {}
}
''');
- checkElementText(
- library,
- r'''
-abstract class A<E> {
- E x;
- E y;
- E z;
-}
-class B<T> implements A<T> {
- T x;
- synthetic T y;
- synthetic T z;
- T get y {}
- void set z(T _) {}
-}
-''',
- withSyntheticFields: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ abstract class A @15
+ typeParameters
+ covariant E @17
+ defaultType: dynamic
+ fields
+ x @26
+ type: E
+ y @33
+ type: E
+ z @40
+ type: E
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @26
+ returnType: E
+ synthetic set x @26
+ parameters
+ requiredPositional _x @26
+ type: E
+ returnType: void
+ synthetic get y @33
+ returnType: E
+ synthetic set y @33
+ parameters
+ requiredPositional _y @33
+ type: E
+ returnType: void
+ synthetic get z @40
+ returnType: E
+ synthetic set z @40
+ parameters
+ requiredPositional _z @40
+ type: E
+ returnType: void
+ class B @51
+ typeParameters
+ covariant T @53
+ defaultType: dynamic
+ interfaces
+ A<T>
+ fields
+ x @80
+ type: T
+ synthetic y @-1
+ type: T
+ synthetic z @-1
+ type: T
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @80
+ returnType: T
+ synthetic set x @80
+ parameters
+ requiredPositional _x @80
+ type: T
+ returnType: void
+ get y @89
+ returnType: T
+ set z @106
+ parameters
+ requiredPositional _ @108
+ type: T
+ returnType: void
+''');
}
test_instanceField_fromField_implicitDynamic() async {
@@ -1584,12 +3708,39 @@
}
''');
checkElementText(library, r'''
-abstract class A {
- dynamic x;
-}
-class B implements A {
- dynamic x;
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ x @25
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @25
+ returnType: dynamic
+ synthetic set x @25
+ parameters
+ requiredPositional _x @25
+ type: dynamic
+ returnType: void
+ class B @36
+ interfaces
+ A
+ fields
+ x @59
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @59
+ returnType: dynamic
+ synthetic set x @59
+ parameters
+ requiredPositional _x @59
+ type: dynamic
+ returnType: void
''');
}
@@ -1603,12 +3754,39 @@
}
''');
checkElementText(library, r'''
-abstract class A {
- num x;
-}
-class B implements A {
- num x;
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ x @25
+ type: num
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @25
+ returnType: num
+ synthetic set x @25
+ parameters
+ requiredPositional _x @25
+ type: num
+ returnType: void
+ class B @36
+ interfaces
+ A
+ fields
+ x @59
+ type: num
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @59
+ returnType: num
+ synthetic set x @59
+ parameters
+ requiredPositional _x @59
+ type: num
+ returnType: void
''');
}
@@ -1626,16 +3804,53 @@
}
''');
checkElementText(library, r'''
-abstract class A {
- int get x;
- int get y;
- int get z;
-}
-class B implements A {
- int x;
- int get y {}
- void set z(int _) {}
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ synthetic x @-1
+ type: int
+ synthetic y @-1
+ type: int
+ synthetic z @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @29
+ returnType: int
+ abstract get y @42
+ returnType: int
+ abstract get z @55
+ returnType: int
+ class B @66
+ interfaces
+ A
+ fields
+ x @89
+ type: int
+ synthetic y @-1
+ type: int
+ synthetic z @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @89
+ returnType: int
+ synthetic set x @89
+ parameters
+ requiredPositional _x @89
+ type: int
+ returnType: void
+ get y @98
+ returnType: int
+ set z @115
+ parameters
+ requiredPositional _ @117
+ type: int
+ returnType: void
''');
}
@@ -1653,16 +3868,59 @@
}
''');
checkElementText(library, r'''
-abstract class A<E> {
- E get x;
- E get y;
- E get z;
-}
-class B<T> implements A<T> {
- T x;
- T get y {}
- void set z(T _) {}
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ typeParameters
+ covariant E @17
+ defaultType: dynamic
+ fields
+ synthetic x @-1
+ type: E
+ synthetic y @-1
+ type: E
+ synthetic z @-1
+ type: E
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @30
+ returnType: E
+ abstract get y @41
+ returnType: E
+ abstract get z @52
+ returnType: E
+ class B @63
+ typeParameters
+ covariant T @65
+ defaultType: dynamic
+ interfaces
+ A<T>
+ fields
+ x @92
+ type: T
+ synthetic y @-1
+ type: T
+ synthetic z @-1
+ type: T
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @92
+ returnType: T
+ synthetic set x @92
+ parameters
+ requiredPositional _x @92
+ type: T
+ returnType: void
+ get y @101
+ returnType: T
+ set z @118
+ parameters
+ requiredPositional _ @120
+ type: T
+ returnType: void
''');
}
@@ -1680,15 +3938,39 @@
''');
// TODO(scheglov) test for inference failure error
checkElementText(library, r'''
-abstract class A {
- int get x;
-}
-abstract class B {
- String get x;
-}
-class C implements A, B {
- dynamic get x {}
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @29
+ returnType: int
+ abstract class B @49
+ fields
+ synthetic x @-1
+ type: String
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @66
+ returnType: String
+ class C @77
+ interfaces
+ A
+ B
+ fields
+ synthetic x @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ get x @103
+ returnType: dynamic
''');
}
@@ -1706,15 +3988,39 @@
''');
// TODO(scheglov) test for inference failure error
checkElementText(library, r'''
-abstract class A {
- int get x;
-}
-abstract class B {
- dynamic get x;
-}
-class C implements A, B {
- int get x {}
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @29
+ returnType: int
+ abstract class B @49
+ fields
+ synthetic x @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @67
+ returnType: dynamic
+ class C @78
+ interfaces
+ A
+ B
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ get x @104
+ returnType: int
''');
}
@@ -1732,15 +4038,45 @@
''');
// TODO(scheglov) test for inference failure error
checkElementText(library, r'''
-abstract class A<T> {
- T get x;
-}
-abstract class B<T> {
- T get x;
-}
-class C implements A<int>, B<String> {
- dynamic get x {}
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ typeParameters
+ covariant T @17
+ defaultType: dynamic
+ fields
+ synthetic x @-1
+ type: T
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @30
+ returnType: T
+ abstract class B @50
+ typeParameters
+ covariant T @52
+ defaultType: dynamic
+ fields
+ synthetic x @-1
+ type: T
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @65
+ returnType: T
+ class C @76
+ interfaces
+ A<int>
+ B<String>
+ fields
+ synthetic x @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ get x @115
+ returnType: dynamic
''');
}
@@ -1757,15 +4093,39 @@
}
''');
checkElementText(library, r'''
-abstract class A {
- int get x;
-}
-abstract class B {
- int get x;
-}
-class C implements A, B {
- int get x {}
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @29
+ returnType: int
+ abstract class B @49
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @63
+ returnType: int
+ class C @74
+ interfaces
+ A
+ B
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ get x @100
+ returnType: int
''');
}
@@ -1785,18 +4145,63 @@
}
''');
checkElementText(library, r'''
-abstract class A {
- int get x;
- int get y;
-}
-abstract class B {
- void set x(String _);
- void set y(String _);
-}
-class C implements A, B {
- dynamic x/*error: overrideConflictFieldType*/;
- final int y;
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ synthetic x @-1
+ type: int
+ synthetic y @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @29
+ returnType: int
+ abstract get y @42
+ returnType: int
+ abstract class B @62
+ fields
+ synthetic x @-1
+ type: String
+ synthetic y @-1
+ type: String
+ constructors
+ synthetic @-1
+ accessors
+ abstract set x @77
+ parameters
+ requiredPositional _ @86
+ type: String
+ returnType: void
+ abstract set y @101
+ parameters
+ requiredPositional _ @110
+ type: String
+ returnType: void
+ class C @122
+ interfaces
+ A
+ B
+ fields
+ x @148
+ typeInferenceError: overrideConflictFieldType
+ type: dynamic
+ final y @159
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @148
+ returnType: dynamic
+ synthetic set x @148
+ parameters
+ requiredPositional _x @148
+ type: dynamic
+ returnType: void
+ synthetic get y @159
+ returnType: int
''');
}
@@ -1812,23 +4217,44 @@
get x => null;
}
''');
- checkElementText(
- library,
- r'''
-abstract class A {
- synthetic int x;
- int get x;
-}
-abstract class B {
- synthetic String x;
- void set x(String _);
-}
-class C implements A, B {
- synthetic int x;
- int get x {}
-}
-''',
- withSyntheticFields: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @29
+ returnType: int
+ abstract class B @49
+ fields
+ synthetic x @-1
+ type: String
+ constructors
+ synthetic @-1
+ accessors
+ abstract set x @64
+ parameters
+ requiredPositional _ @73
+ type: String
+ returnType: void
+ class C @85
+ interfaces
+ A
+ B
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ get x @111
+ returnType: int
+''');
}
test_instanceField_fromGetterSetter_different_setter() async {
@@ -1844,23 +4270,47 @@
}
''');
// TODO(scheglov) test for inference failure error
- checkElementText(
- library,
- r'''
-abstract class A {
- synthetic int x;
- int get x;
-}
-abstract class B {
- synthetic String x;
- void set x(String _);
-}
-class C implements A, B {
- synthetic String x;
- void set x(String _);
-}
-''',
- withSyntheticFields: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @29
+ returnType: int
+ abstract class B @49
+ fields
+ synthetic x @-1
+ type: String
+ constructors
+ synthetic @-1
+ accessors
+ abstract set x @64
+ parameters
+ requiredPositional _ @73
+ type: String
+ returnType: void
+ class C @85
+ interfaces
+ A
+ B
+ fields
+ synthetic x @-1
+ type: String
+ constructors
+ synthetic @-1
+ accessors
+ abstract set x @111
+ parameters
+ requiredPositional _ @113
+ type: String
+ returnType: void
+''');
}
test_instanceField_fromGetterSetter_same_field() async {
@@ -1876,15 +4326,47 @@
}
''');
checkElementText(library, r'''
-abstract class A {
- int get x;
-}
-abstract class B {
- void set x(int _);
-}
-class C implements A, B {
- int x;
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @29
+ returnType: int
+ abstract class B @49
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract set x @64
+ parameters
+ requiredPositional _ @70
+ type: int
+ returnType: void
+ class C @82
+ interfaces
+ A
+ B
+ fields
+ x @108
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @108
+ returnType: int
+ synthetic set x @108
+ parameters
+ requiredPositional _x @108
+ type: int
+ returnType: void
''');
}
@@ -1900,23 +4382,44 @@
get x => null;
}
''');
- checkElementText(
- library,
- r'''
-abstract class A {
- synthetic int x;
- int get x;
-}
-abstract class B {
- synthetic int x;
- void set x(int _);
-}
-class C implements A, B {
- synthetic int x;
- int get x {}
-}
-''',
- withSyntheticFields: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @29
+ returnType: int
+ abstract class B @49
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract set x @64
+ parameters
+ requiredPositional _ @70
+ type: int
+ returnType: void
+ class C @82
+ interfaces
+ A
+ B
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ get x @108
+ returnType: int
+''');
}
test_instanceField_fromGetterSetter_same_setter() async {
@@ -1931,23 +4434,47 @@
set x(_);
}
''');
- checkElementText(
- library,
- r'''
-abstract class A {
- synthetic int x;
- int get x;
-}
-abstract class B {
- synthetic int x;
- void set x(int _);
-}
-class C implements A, B {
- synthetic int x;
- void set x(int _);
-}
-''',
- withSyntheticFields: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @29
+ returnType: int
+ abstract class B @49
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract set x @64
+ parameters
+ requiredPositional _ @70
+ type: int
+ returnType: void
+ class C @82
+ interfaces
+ A
+ B
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract set x @108
+ parameters
+ requiredPositional _ @110
+ type: int
+ returnType: void
+''');
}
test_instanceField_fromSetter() async {
@@ -1964,16 +4491,62 @@
}
''');
checkElementText(library, r'''
-abstract class A {
- void set x(int _);
- void set y(int _);
- void set z(int _);
-}
-class B implements A {
- int x;
- int get y {}
- void set z(int _) {}
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ synthetic x @-1
+ type: int
+ synthetic y @-1
+ type: int
+ synthetic z @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract set x @30
+ parameters
+ requiredPositional _ @36
+ type: int
+ returnType: void
+ abstract set y @51
+ parameters
+ requiredPositional _ @57
+ type: int
+ returnType: void
+ abstract set z @72
+ parameters
+ requiredPositional _ @78
+ type: int
+ returnType: void
+ class B @90
+ interfaces
+ A
+ fields
+ x @113
+ type: int
+ synthetic y @-1
+ type: int
+ synthetic z @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @113
+ returnType: int
+ synthetic set x @113
+ parameters
+ requiredPositional _x @113
+ type: int
+ returnType: void
+ get y @122
+ returnType: int
+ set z @139
+ parameters
+ requiredPositional _ @141
+ type: int
+ returnType: void
''');
}
@@ -1990,15 +4563,45 @@
}
''');
checkElementText(library, r'''
-abstract class A {
- void set x(int _);
-}
-abstract class B {
- void set x(String _);
-}
-class C implements A, B {
- dynamic get x {}
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract set x @30
+ parameters
+ requiredPositional _ @36
+ type: int
+ returnType: void
+ abstract class B @57
+ fields
+ synthetic x @-1
+ type: String
+ constructors
+ synthetic @-1
+ accessors
+ abstract set x @72
+ parameters
+ requiredPositional _ @81
+ type: String
+ returnType: void
+ class C @93
+ interfaces
+ A
+ B
+ fields
+ synthetic x @-1
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ get x @119
+ returnType: dynamic
''');
}
@@ -2015,15 +4618,45 @@
}
''');
checkElementText(library, r'''
-abstract class A {
- void set x(int _);
-}
-abstract class B {
- void set x(int _);
-}
-class C implements A, B {
- int get x {}
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract set x @30
+ parameters
+ requiredPositional _ @36
+ type: int
+ returnType: void
+ abstract class B @57
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ abstract set x @72
+ parameters
+ requiredPositional _ @78
+ type: int
+ returnType: void
+ class C @90
+ interfaces
+ A
+ B
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ get x @116
+ returnType: int
''');
}
@@ -2042,15 +4675,59 @@
}
''');
checkElementText(library, r'''
-typedef F<T> = dynamic Function();
-class A<T> {
- dynamic Function() get x {}
- List<dynamic Function()> get y {}
-}
-class B extends A<int> {
- dynamic Function() get x {}
- List<dynamic Function()> get y {}
-}
+library
+ definingUnit
+ classes
+ class A @23
+ typeParameters
+ covariant T @25
+ defaultType: dynamic
+ fields
+ synthetic x @-1
+ type: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ T
+ synthetic y @-1
+ type: List<dynamic Function()>
+ constructors
+ synthetic @-1
+ accessors
+ get x @41
+ returnType: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ T
+ get y @69
+ returnType: List<dynamic Function()>
+ class B @89
+ supertype: A<int>
+ fields
+ synthetic x @-1
+ type: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ int
+ synthetic y @-1
+ type: List<dynamic Function()>
+ constructors
+ synthetic @-1
+ accessors
+ get x @114
+ returnType: dynamic Function()
+ aliasElement: self::@typeAlias::F
+ aliasArguments
+ int
+ get y @131
+ returnType: List<dynamic Function()>
+ typeAliases
+ functionTypeAliasBased F @8
+ typeParameters
+ unrelated T @10
+ defaultType: dynamic
+ aliasedType: dynamic Function()
+ aliasedElement: GenericFunctionTypeElement
+ returnType: dynamic
''');
}
@@ -2064,20 +4741,41 @@
int x;
}
''');
- checkElementText(
- library,
- r'''
-abstract class A {
- num get x;
- void set x(covariant num _);
-}
-class B implements A {
- int x;
- synthetic int get x {}
- synthetic void set x(covariant int _x) {}
-}
-''',
- withSyntheticAccessors: true);
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ synthetic x @-1
+ type: num
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @29
+ returnType: num
+ abstract set x @43
+ parameters
+ requiredPositional covariant _ @59
+ type: num
+ returnType: void
+ class B @71
+ interfaces
+ A
+ fields
+ x @94
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get x @94
+ returnType: int
+ synthetic set x @94
+ parameters
+ requiredPositional covariant _x @94
+ type: int
+ returnType: void
+''');
}
test_instanceField_inheritsCovariant_fromSetter_setter() async {
@@ -2091,13 +4789,37 @@
}
''');
checkElementText(library, r'''
-abstract class A {
- num get x;
- void set x(covariant num _);
-}
-class B implements A {
- void set x(covariant int _) {}
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ fields
+ synthetic x @-1
+ type: num
+ constructors
+ synthetic @-1
+ accessors
+ abstract get x @29
+ returnType: num
+ abstract set x @43
+ parameters
+ requiredPositional covariant _ @59
+ type: num
+ returnType: void
+ class B @71
+ interfaces
+ A
+ fields
+ synthetic x @-1
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ set x @94
+ parameters
+ requiredPositional covariant _ @100
+ type: int
+ returnType: void
''');
}
@@ -2110,11 +4832,41 @@
}
''');
checkElementText(library, r'''
-class A {
- int t1;
- double t2;
- dynamic t3;
-}
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ t1 @16
+ type: int
+ t2 @30
+ type: double
+ t3 @46
+ type: dynamic
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get t1 @16
+ returnType: int
+ synthetic set t1 @16
+ parameters
+ requiredPositional _t1 @16
+ type: int
+ returnType: void
+ synthetic get t2 @30
+ returnType: double
+ synthetic set t2 @30
+ parameters
+ requiredPositional _t2 @30
+ type: double
+ returnType: void
+ synthetic get t3 @46
+ returnType: dynamic
+ synthetic set t3 @46
+ parameters
+ requiredPositional _t3 @46
+ type: dynamic
+ returnType: void
''');
}
@@ -2130,12 +4882,30 @@
// It's an error to add a new required parameter, but it is not a
// top-level type inference error.
checkElementText(library, r'''
-class A {
- void m(int a) {}
-}
-class B extends A {
- void m(int a, dynamic b) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @17
+ parameters
+ requiredPositional a @23
+ type: int
+ returnType: void
+ class B @37
+ supertype: A
+ constructors
+ synthetic @-1
+ methods
+ m @58
+ parameters
+ requiredPositional a @60
+ type: int
+ requiredPositional b @63
+ type: dynamic
+ returnType: void
''');
}
@@ -2152,15 +4922,40 @@
}
''');
checkElementText(library, r'''
-class A {
- void m(int a) {}
-}
-class B {
- void m(String a) {}
-}
-class C extends A implements B {
- dynamic m/*error: overrideNoCombinedSuperSignature*/(dynamic a) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @17
+ parameters
+ requiredPositional a @23
+ type: int
+ returnType: void
+ class B @37
+ constructors
+ synthetic @-1
+ methods
+ m @48
+ parameters
+ requiredPositional a @57
+ type: String
+ returnType: void
+ class C @71
+ supertype: A
+ interfaces
+ B
+ constructors
+ synthetic @-1
+ methods
+ m @100
+ typeInferenceError: overrideNoCombinedSuperSignature
+ parameters
+ requiredPositional a @102
+ type: dynamic
+ returnType: dynamic
''');
}
@@ -2179,15 +4974,40 @@
}
''');
checkElementText(library, r'''
-abstract class A {
- int foo(int x);
-}
-abstract class B {
- double foo(int x);
-}
-abstract class C implements A, B {
- Never foo/*error: overrideNoCombinedSuperSignature*/(dynamic x);
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ constructors
+ synthetic @-1
+ methods
+ abstract foo @25
+ parameters
+ requiredPositional x @33
+ type: int
+ returnType: int
+ abstract class B @55
+ constructors
+ synthetic @-1
+ methods
+ abstract foo @68
+ parameters
+ requiredPositional x @76
+ type: int
+ returnType: double
+ abstract class C @98
+ interfaces
+ A
+ B
+ constructors
+ synthetic @-1
+ methods
+ abstract foo @126
+ typeInferenceError: overrideNoCombinedSuperSignature
+ parameters
+ requiredPositional x @130
+ type: dynamic
+ returnType: Never
''');
}
@@ -2207,15 +5027,40 @@
}
''');
checkElementText(library, r'''
-abstract class A {
- int* foo(int* x);
-}
-abstract class B {
- double* foo(int* x);
-}
-abstract class C implements A*, B* {
- Null* foo/*error: overrideNoCombinedSuperSignature*/(dynamic x);
-}
+library
+ definingUnit
+ classes
+ abstract class A @30
+ constructors
+ synthetic @-1
+ methods
+ abstract foo @40
+ parameters
+ requiredPositional x @48
+ type: int*
+ returnType: int*
+ abstract class B @70
+ constructors
+ synthetic @-1
+ methods
+ abstract foo @83
+ parameters
+ requiredPositional x @91
+ type: int*
+ returnType: double*
+ abstract class C @113
+ interfaces
+ A*
+ B*
+ constructors
+ synthetic @-1
+ methods
+ abstract foo @141
+ typeInferenceError: overrideNoCombinedSuperSignature
+ parameters
+ requiredPositional x @145
+ type: dynamic
+ returnType: Null*
''');
}
@@ -2233,15 +5078,31 @@
''');
// TODO(scheglov) test for inference failure error
checkElementText(library, r'''
-class A {
- int m() {}
-}
-class B {
- String m() {}
-}
-class C extends A implements B {
- dynamic m/*error: overrideNoCombinedSuperSignature*/() {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @16
+ returnType: int
+ class B @31
+ constructors
+ synthetic @-1
+ methods
+ m @44
+ returnType: String
+ class C @59
+ supertype: A
+ interfaces
+ B
+ constructors
+ synthetic @-1
+ methods
+ m @88
+ typeInferenceError: overrideNoCombinedSuperSignature
+ returnType: dynamic
''');
}
@@ -2258,15 +5119,46 @@
}
''');
checkElementText(library, r'''
-class A<T> {
- void m(T a) {}
-}
-class B<E> {
- void m(E a) {}
-}
-class C extends A<int> implements B<double> {
- dynamic m/*error: overrideNoCombinedSuperSignature*/(dynamic a) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant T @8
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ m @20
+ parameters
+ requiredPositional a @24
+ type: T
+ returnType: void
+ class B @38
+ typeParameters
+ covariant E @40
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ m @52
+ parameters
+ requiredPositional a @56
+ type: E
+ returnType: void
+ class C @70
+ supertype: A<int>
+ interfaces
+ B<double>
+ constructors
+ synthetic @-1
+ methods
+ m @112
+ typeInferenceError: overrideNoCombinedSuperSignature
+ parameters
+ requiredPositional a @114
+ type: dynamic
+ returnType: dynamic
''');
}
@@ -2283,15 +5175,48 @@
}
''');
checkElementText(library, r'''
-class A<K, V> {
- V m(K a) {}
-}
-class B<T> {
- T m(int a) {}
-}
-class C extends A<int, String> implements B<double> {
- dynamic m/*error: overrideNoCombinedSuperSignature*/(dynamic a) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant K @8
+ defaultType: dynamic
+ covariant V @11
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ m @20
+ parameters
+ requiredPositional a @24
+ type: K
+ returnType: V
+ class B @38
+ typeParameters
+ covariant T @40
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ m @49
+ parameters
+ requiredPositional a @55
+ type: int
+ returnType: T
+ class C @69
+ supertype: A<int, String>
+ interfaces
+ B<double>
+ constructors
+ synthetic @-1
+ methods
+ m @119
+ typeInferenceError: overrideNoCombinedSuperSignature
+ parameters
+ requiredPositional a @121
+ type: dynamic
+ returnType: dynamic
''');
}
@@ -2305,12 +5230,30 @@
}
''');
checkElementText(library, r'''
-class A {
- void m(int a) {}
-}
-class B extends A {
- void m(int a, {dynamic b}) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @17
+ parameters
+ requiredPositional a @23
+ type: int
+ returnType: void
+ class B @37
+ supertype: A
+ constructors
+ synthetic @-1
+ methods
+ m @53
+ parameters
+ requiredPositional a @55
+ type: int
+ optionalNamed b @59
+ type: dynamic
+ returnType: void
''');
}
@@ -2324,12 +5267,30 @@
}
''');
checkElementText(library, r'''
-class A {
- void m(int a) {}
-}
-class B extends A {
- void m(int a, [dynamic b]) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @17
+ parameters
+ requiredPositional a @23
+ type: int
+ returnType: void
+ class B @37
+ supertype: A
+ constructors
+ synthetic @-1
+ methods
+ m @53
+ parameters
+ requiredPositional a @55
+ type: int
+ optionalPositional b @59
+ type: dynamic
+ returnType: void
''');
}
@@ -2343,12 +5304,28 @@
}
''');
checkElementText(library, r'''
-class A {
- dynamic m(dynamic a) {}
-}
-class B extends A {
- dynamic m(dynamic a) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @12
+ parameters
+ requiredPositional a @14
+ type: dynamic
+ returnType: dynamic
+ class B @28
+ supertype: A
+ constructors
+ synthetic @-1
+ methods
+ m @44
+ parameters
+ requiredPositional a @46
+ type: dynamic
+ returnType: dynamic
''');
}
@@ -2362,12 +5339,28 @@
}
''');
checkElementText(library, r'''
-class A {
- int foo(String a) {}
-}
-class B extends A {
- dynamic m(dynamic a) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ foo @16
+ parameters
+ requiredPositional a @27
+ type: String
+ returnType: int
+ class B @47
+ supertype: A
+ constructors
+ synthetic @-1
+ methods
+ m @63
+ parameters
+ requiredPositional a @65
+ type: dynamic
+ returnType: dynamic
''');
}
@@ -2381,12 +5374,33 @@
}
''');
checkElementText(library, r'''
-class A {
- int m;
-}
-class B extends A {
- dynamic m(dynamic a) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ fields
+ m @16
+ type: int
+ constructors
+ synthetic @-1
+ accessors
+ synthetic get m @16
+ returnType: int
+ synthetic set m @16
+ parameters
+ requiredPositional _m @16
+ type: int
+ returnType: void
+ class B @32
+ supertype: A
+ constructors
+ synthetic @-1
+ methods
+ m @48
+ parameters
+ requiredPositional a @50
+ type: dynamic
+ returnType: dynamic
''');
}
@@ -2401,14 +5415,40 @@
}
''');
checkElementText(library, r'''
-class A<K, V> {
- V m(K a) {}
-}
-class B<T> extends A<int, T> {
-}
-class C extends B<String> {
- String m(int a) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant K @8
+ defaultType: dynamic
+ covariant V @11
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ m @20
+ parameters
+ requiredPositional a @24
+ type: K
+ returnType: V
+ class B @38
+ typeParameters
+ covariant T @40
+ defaultType: dynamic
+ supertype: A<int, T>
+ constructors
+ synthetic @-1
+ class C @70
+ supertype: B<String>
+ constructors
+ synthetic @-1
+ methods
+ m @94
+ parameters
+ requiredPositional a @96
+ type: int
+ returnType: String
''');
}
@@ -2425,15 +5465,38 @@
}
''');
checkElementText(library, r'''
-class A {
- String m(int a) {}
-}
-class B extends A {
- String m(int a) {}
-}
-class C extends B {
- String m(int a) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @19
+ parameters
+ requiredPositional a @25
+ type: int
+ returnType: String
+ class B @39
+ supertype: A
+ constructors
+ synthetic @-1
+ methods
+ m @55
+ parameters
+ requiredPositional a @57
+ type: int
+ returnType: String
+ class C @71
+ supertype: B
+ constructors
+ synthetic @-1
+ methods
+ m @87
+ parameters
+ requiredPositional a @89
+ type: int
+ returnType: String
''');
}
@@ -2450,15 +5513,39 @@
}
''');
checkElementText(library, r'''
-class A {
- String m(int a) {}
-}
-class B implements A {
- String m(int a) {}
-}
-class C extends B {
- String m(int a) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @19
+ parameters
+ requiredPositional a @25
+ type: int
+ returnType: String
+ class B @39
+ interfaces
+ A
+ constructors
+ synthetic @-1
+ methods
+ m @58
+ parameters
+ requiredPositional a @60
+ type: int
+ returnType: String
+ class C @74
+ supertype: B
+ constructors
+ synthetic @-1
+ methods
+ m @90
+ parameters
+ requiredPositional a @92
+ type: int
+ returnType: String
''');
}
@@ -2475,16 +5562,40 @@
}
''');
checkElementText(library, r'''
-class A {
- String m(int a) {}
-}
-class B extends Object with A {
- synthetic B();
- String m(int a) {}
-}
-class C extends B {
- String m(int a) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @19
+ parameters
+ requiredPositional a @25
+ type: int
+ returnType: String
+ class B @39
+ supertype: Object
+ mixins
+ A
+ constructors
+ synthetic @-1
+ methods
+ m @67
+ parameters
+ requiredPositional a @69
+ type: int
+ returnType: String
+ class C @83
+ supertype: B
+ constructors
+ synthetic @-1
+ methods
+ m @99
+ parameters
+ requiredPositional a @101
+ type: int
+ returnType: String
''');
}
@@ -2498,12 +5609,37 @@
}
''');
checkElementText(library, r'''
-class A<K, V> {
- V m(K a, double b) {}
-}
-class B extends A<int, String> {
- String m(int a, double b) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant K @8
+ defaultType: dynamic
+ covariant V @11
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ m @20
+ parameters
+ requiredPositional a @24
+ type: K
+ requiredPositional b @34
+ type: double
+ returnType: V
+ class B @48
+ supertype: A<int, String>
+ constructors
+ synthetic @-1
+ methods
+ m @77
+ parameters
+ requiredPositional a @79
+ type: int
+ requiredPositional b @82
+ type: double
+ returnType: String
''');
}
@@ -2517,12 +5653,28 @@
}
''');
checkElementText(library, r'''
-class A {
- String m(int a) {}
-}
-class B extends A {
- String m(int a) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @19
+ parameters
+ requiredPositional a @25
+ type: int
+ returnType: String
+ class B @39
+ supertype: A
+ constructors
+ synthetic @-1
+ methods
+ m @55
+ parameters
+ requiredPositional a @57
+ type: int
+ returnType: String
''');
}
@@ -2536,12 +5688,32 @@
}
''');
checkElementText(library, r'''
-class A {
- String m(int a, {double b}) {}
-}
-class B extends A {
- String m(int a, {double b}) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @19
+ parameters
+ requiredPositional a @25
+ type: int
+ optionalNamed b @36
+ type: double
+ returnType: String
+ class B @51
+ supertype: A
+ constructors
+ synthetic @-1
+ methods
+ m @67
+ parameters
+ requiredPositional a @69
+ type: int
+ optionalNamed b @73
+ type: double
+ returnType: String
''');
}
@@ -2555,12 +5727,32 @@
}
''');
checkElementText(library, r'''
-class A {
- String m(int a, [double b]) {}
-}
-class B extends A {
- String m(int a, [double b]) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @19
+ parameters
+ requiredPositional a @25
+ type: int
+ optionalPositional b @36
+ type: double
+ returnType: String
+ class B @51
+ supertype: A
+ constructors
+ synthetic @-1
+ methods
+ m @67
+ parameters
+ requiredPositional a @69
+ type: int
+ optionalPositional b @73
+ type: double
+ returnType: String
''');
}
@@ -2575,14 +5767,40 @@
}
''');
checkElementText(library, r'''
-class A<K, V> {
- V m(K a) {}
-}
-class B<T> extends A<int, T> {
-}
-class C extends B<String> {
- String m(int a) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant K @8
+ defaultType: dynamic
+ covariant V @11
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ m @20
+ parameters
+ requiredPositional a @24
+ type: K
+ returnType: V
+ class B @38
+ typeParameters
+ covariant T @40
+ defaultType: dynamic
+ supertype: A<int, T>
+ constructors
+ synthetic @-1
+ class C @70
+ supertype: B<String>
+ constructors
+ synthetic @-1
+ methods
+ m @94
+ parameters
+ requiredPositional a @96
+ type: int
+ returnType: String
''');
}
@@ -2596,12 +5814,34 @@
}
''');
checkElementText(library, r'''
-abstract class A<K, V> {
- V m(K a);
-}
-class B implements A<int, String> {
- String m(int a) {}
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ typeParameters
+ covariant K @17
+ defaultType: dynamic
+ covariant V @20
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ abstract m @29
+ parameters
+ requiredPositional a @33
+ type: K
+ returnType: V
+ class B @45
+ interfaces
+ A<int, String>
+ constructors
+ synthetic @-1
+ methods
+ m @77
+ parameters
+ requiredPositional a @79
+ type: int
+ returnType: String
''');
}
@@ -2615,12 +5855,29 @@
}
''');
checkElementText(library, r'''
-abstract class A {
- String m(int a);
-}
-class B implements A {
- String m(int a) {}
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ constructors
+ synthetic @-1
+ methods
+ abstract m @28
+ parameters
+ requiredPositional a @34
+ type: int
+ returnType: String
+ class B @46
+ interfaces
+ A
+ constructors
+ synthetic @-1
+ methods
+ m @65
+ parameters
+ requiredPositional a @67
+ type: int
+ returnType: String
''');
}
@@ -2635,14 +5892,43 @@
}
''');
checkElementText(library, r'''
-abstract class A<K, V> {
- V m(K a);
-}
-abstract class B<T1, T2> extends A<T2, T1> {
-}
-class C implements B<int, String> {
- int m(String a) {}
-}
+library
+ definingUnit
+ classes
+ abstract class A @15
+ typeParameters
+ covariant K @17
+ defaultType: dynamic
+ covariant V @20
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ abstract m @29
+ parameters
+ requiredPositional a @33
+ type: K
+ returnType: V
+ abstract class B @54
+ typeParameters
+ covariant T1 @56
+ defaultType: dynamic
+ covariant T2 @60
+ defaultType: dynamic
+ supertype: A<T2, T1>
+ constructors
+ synthetic @-1
+ class C @91
+ interfaces
+ B<int, String>
+ constructors
+ synthetic @-1
+ methods
+ m @123
+ parameters
+ requiredPositional a @125
+ type: String
+ returnType: int
''');
}
@@ -2661,13 +5947,24 @@
}
''');
checkElementText(library, r'''
-import 'package:test/other.dart';
-class A1 {
- int _foo() {}
-}
-class A2 extends A1 {
- int _foo() {}
-}
+library
+ imports
+ package:test/other.dart
+ definingUnit
+ classes
+ class A1 @27
+ constructors
+ synthetic @-1
+ methods
+ _foo @38
+ returnType: int
+ class A2 @59
+ supertype: A1
+ constructors
+ synthetic @-1
+ methods
+ _foo @77
+ returnType: int
''');
}
@@ -2681,13 +5978,30 @@
}
''');
checkElementText(library, r'''
-class A {
- String m(int a) {}
-}
-class B extends Object with A {
- synthetic B();
- String m(int a) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @19
+ parameters
+ requiredPositional a @25
+ type: int
+ returnType: String
+ class B @39
+ supertype: Object
+ mixins
+ A
+ constructors
+ synthetic @-1
+ methods
+ m @67
+ parameters
+ requiredPositional a @69
+ type: int
+ returnType: String
''');
}
@@ -2704,15 +6018,47 @@
}
''');
checkElementText(library, r'''
-class A<K, V> {
- V m(K a) {}
-}
-class B<T> {
- T m(int a) {}
-}
-class C extends A<int, String> implements B<String> {
- String m(int a) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ typeParameters
+ covariant K @8
+ defaultType: dynamic
+ covariant V @11
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ m @20
+ parameters
+ requiredPositional a @24
+ type: K
+ returnType: V
+ class B @38
+ typeParameters
+ covariant T @40
+ defaultType: dynamic
+ constructors
+ synthetic @-1
+ methods
+ m @49
+ parameters
+ requiredPositional a @55
+ type: int
+ returnType: T
+ class C @69
+ supertype: A<int, String>
+ interfaces
+ B<String>
+ constructors
+ synthetic @-1
+ methods
+ m @119
+ parameters
+ requiredPositional a @121
+ type: int
+ returnType: String
''');
}
@@ -2729,15 +6075,39 @@
}
''');
checkElementText(library, r'''
-class A {
- String m(int a) {}
-}
-class B {
- String m(int a) {}
-}
-class C extends A implements B {
- String m(int a) {}
-}
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ synthetic @-1
+ methods
+ m @19
+ parameters
+ requiredPositional a @25
+ type: int
+ returnType: String
+ class B @39
+ constructors
+ synthetic @-1
+ methods
+ m @52
+ parameters
+ requiredPositional a @58
+ type: int
+ returnType: String
+ class C @72
+ supertype: A
+ interfaces
+ B
+ constructors
+ synthetic @-1
+ methods
+ m @101
+ parameters
+ requiredPositional a @103
+ type: int
+ returnType: String
''');
}
diff --git a/pkg/analyzer_cli/lib/src/driver.dart b/pkg/analyzer_cli/lib/src/driver.dart
index ad49da2..523b2f2 100644
--- a/pkg/analyzer_cli/lib/src/driver.dart
+++ b/pkg/analyzer_cli/lib/src/driver.dart
@@ -242,7 +242,11 @@
var content = file.readAsStringSync();
var lineInfo = LineInfo.fromContent(content);
var errors = analyzeAnalysisOptions(
- file.createSource(), content, analysisDriver.sourceFactory);
+ file.createSource(),
+ content,
+ analysisDriver.sourceFactory,
+ analysisDriver.currentSession.analysisContext.contextRoot.root.path,
+ );
formatter.formatErrors([
ErrorsResultImpl(analysisDriver.currentSession, path, null,
lineInfo, false, errors)
diff --git a/pkg/compiler/lib/src/commandline_options.dart b/pkg/compiler/lib/src/commandline_options.dart
index 7e0a44d..33cc919 100644
--- a/pkg/compiler/lib/src/commandline_options.dart
+++ b/pkg/compiler/lib/src/commandline_options.dart
@@ -69,8 +69,6 @@
static const String omitImplicitChecks = '--omit-implicit-checks';
static const String omitAsCasts = '--omit-as-casts';
static const String laxRuntimeTypeToString = '--lax-runtime-type-to-string';
- static const String legacyJavaScript = '--legacy-javascript';
- static const String noLegacyJavaScript = '--no-legacy-javascript';
static const String platformBinaries = '--platform-binaries=.+';
@@ -169,6 +167,16 @@
// Experimental flags.
static const String resolveOnly = '--resolve-only';
+
+ // `--no-shipping` and `--canary` control sets of flags. For simplicity, these
+ // flags live in options.dart.
+ // Shipping features default to on, but can be disabled individually. All
+ // shipping features can be disabled with the the [noShipping] flag.
+ static const String noShipping = '--no-shipping';
+
+ // Canary features default to off, but can still be enabled individually. All
+ // canary features can be enabled with the [canary] flag.
+ static const String canary = '--canary';
}
class Option {
diff --git a/pkg/compiler/lib/src/dart2js.dart b/pkg/compiler/lib/src/dart2js.dart
index 43f80a5..bdbd352 100644
--- a/pkg/compiler/lib/src/dart2js.dart
+++ b/pkg/compiler/lib/src/dart2js.dart
@@ -13,7 +13,7 @@
import '../compiler_new.dart' as api;
import 'commandline_options.dart';
-import 'options.dart' show CompilerOptions;
+import 'options.dart' show CompilerOptions, FeatureOptions;
import 'source_file_provider.dart';
import 'util/command_line.dart';
import 'util/util.dart' show stackTraceFilePrefix;
@@ -135,6 +135,7 @@
Map<String, String> environment = new Map<String, String>();
ReadStrategy readStrategy = ReadStrategy.fromDart;
WriteStrategy writeStrategy = WriteStrategy.toJs;
+ FeatureOptions features = FeatureOptions();
void passThrough(String argument) => options.add(argument);
void ignoreOption(String argument) {}
@@ -564,8 +565,6 @@
new OptionHandler(Flags.omitImplicitChecks, passThrough),
new OptionHandler(Flags.omitAsCasts, passThrough),
new OptionHandler(Flags.laxRuntimeTypeToString, passThrough),
- new OptionHandler(Flags.legacyJavaScript, passThrough),
- new OptionHandler(Flags.noLegacyJavaScript, passThrough),
new OptionHandler(Flags.benchmarkingProduction, passThrough),
new OptionHandler(Flags.benchmarkingExperiment, passThrough),
new OptionHandler(Flags.soundNullSafety, setNullSafetyMode),
@@ -605,6 +604,18 @@
new OptionHandler(Flags.experimentLateInstanceVariables, passThrough),
new OptionHandler('${Flags.mergeFragmentsThreshold}=.+', passThrough),
+ // Wire up feature flags.
+ OptionHandler(Flags.canary, passThrough),
+ OptionHandler(Flags.noShipping, passThrough),
+ for (var feature in features.shipping)
+ OptionHandler('--${feature.flag}', passThrough),
+ for (var feature in features.shipping)
+ OptionHandler('--no-${feature.flag}', passThrough),
+ for (var feature in features.canary)
+ OptionHandler('--${feature.flag}', passThrough),
+ for (var feature in features.canary)
+ OptionHandler('--no-${feature.flag}', passThrough),
+
// The following three options must come last.
new OptionHandler('-D.+=.*|--define=.+=.*|--define', addInEnvironment,
multipleArguments: true),
@@ -974,6 +985,7 @@
diagnosticHandler.autoReadFileUri = true;
CompilerOptions compilerOptions = CompilerOptions.parse(options,
+ featureOptions: features,
librariesSpecificationUri: librariesSpecificationUri,
platformBinaries: platformBinaries,
onError: (String message) => fail(message),
diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
index bea472a..6590471 100644
--- a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
@@ -1042,7 +1042,7 @@
// to `inherit(P.Object, null)` in the generated code. See if we can
// remove that.
- if (_options.legacyJavaScript) {
+ if (_options.features.legacyJavaScript.isEnabled) {
// IE11 might require us to set 'constructor' but we aren't 100% sure.
properties
.add(js.Property(js.string("constructor"), classReference(cls)));
@@ -1870,7 +1870,7 @@
globals.add(js.Property(
js.string(ARRAY_RTI_PROPERTY),
- _options.legacyJavaScript
+ _options.features.legacyJavaScript.isEnabled
? js.js(
r'typeof Symbol == "function" && typeof Symbol() == "symbol"'
r' ? Symbol("$ti")'
diff --git a/pkg/compiler/lib/src/options.dart b/pkg/compiler/lib/src/options.dart
index 1133c6d..e309a00 100644
--- a/pkg/compiler/lib/src/options.dart
+++ b/pkg/compiler/lib/src/options.dart
@@ -15,6 +15,67 @@
sound,
}
+enum FeatureStatus {
+ shipping,
+ canary,
+}
+
+/// A [FeatureOption] is both a set of flags and an option. By default, creating
+/// a [FeatureOption] will create two flags, [--$flag] and [--no-$flag]. The
+/// default behavior for a [FeatureOption] in the [canary] set is to be
+/// disabled by default unless explicity enabled or [--canary] is passed.
+/// When the [FeatureOption] is moved to [staging], the behavior flips, and by
+/// default it is enabled unless explicitly disabled or [--no-shipping] is
+/// passed. The [isNegativeFlag] bool flips things around so while in [canary]
+/// the [FeatureOption] is enabled unless explicitly disabled, and while in
+/// [staging] it is disabled unless explicitly enabled.
+class FeatureOption {
+ final String flag;
+ final bool isNegativeFlag;
+ bool _state;
+ bool get isEnabled => _state;
+ bool get isDisabled => !isEnabled;
+ void set state(bool value) {
+ assert(_state == null);
+ _state = value;
+ }
+
+ FeatureOption(this.flag, {this.isNegativeFlag = false});
+}
+
+/// A class to simplify management of features which will end up being enabled
+/// by default. New features should be added as properties, and then to the
+/// [canary] list. Features in [canary] default to disabled unless they are
+/// explicitly enabled or unless `--canary` is passed on the commandline. When
+/// a feature is ready to ship, it should be moved to the [shipping] list,
+/// whereupon it will immediately default to enabled but can still be disabled.
+/// Once a feature is shipped, it can be deleted from this class entirely.
+class FeatureOptions {
+ /// Whether to restrict the generated JavaScript to features that work on the
+ /// oldest supported versions of JavaScript. This currently means IE11. If
+ /// `true`, the generated code runs on the legacy JavaScript platform. If
+ /// `false`, the code will fail on the legacy JavaScript platform.
+ FeatureOption legacyJavaScript =
+ FeatureOption('legacy-javascript', isNegativeFlag: true);
+
+ /// [FeatureOption]s which default to enabled.
+ List<FeatureOption> shipping;
+
+ /// [FeatureOption]s which default to disabled.
+ List<FeatureOption> canary;
+
+ // Initialize feature lists.
+ FeatureOptions() {
+ shipping = [];
+ canary = [legacyJavaScript];
+ }
+
+ void parse(List<String> options) {
+ _extractFeatures(options, shipping, FeatureStatus.shipping);
+ _extractFeatures(options, canary, FeatureStatus.canary);
+ }
+}
+
/// Options used for controlling diagnostic messages.
abstract class DiagnosticOptions {
const DiagnosticOptions();
@@ -310,14 +371,6 @@
/// `Object.runtimeType`.
bool laxRuntimeTypeToString = false;
- /// Whether to restrict the generated JavaScript to features that work on the
- /// oldest supported versions of JavaScript. This currently means IE11. If
- /// `true`, the generated code runs on the legacy JavaScript platform. If
- /// `false`, the code will fail on the legacy JavaScript platform.
- bool legacyJavaScript = true; // default value.
- bool _legacyJavaScript = false;
- bool _noLegacyJavaScript = false;
-
/// What should the compiler do with parameter type assertions.
///
/// This is an internal configuration option derived from other flags.
@@ -449,16 +502,21 @@
/// Verbosity level used for filtering messages during compilation.
fe.Verbosity verbosity = fe.Verbosity.all;
+ FeatureOptions features;
+
// -------------------------------------------------
// Options for deprecated features
// -------------------------------------------------
/// Create an options object by parsing flags from [options].
static CompilerOptions parse(List<String> options,
- {Uri librariesSpecificationUri,
+ {FeatureOptions featureOptions,
+ Uri librariesSpecificationUri,
Uri platformBinaries,
void Function(String) onError,
void Function(String) onWarning}) {
+ if (featureOptions == null) featureOptions = FeatureOptions();
+ featureOptions.parse(options);
Map<fe.ExperimentalFlag, bool> explicitExperimentalFlags =
_extractExperiments(options, onError: onError, onWarning: onWarning);
@@ -466,7 +524,7 @@
// for compiling user code vs. the sdk. To simplify things, we prebuild the
// sdk with the correct flags.
platformBinaries ??= fe.computePlatformBinariesLocation();
- return new CompilerOptions()
+ return CompilerOptions()
..librariesSpecificationUri = librariesSpecificationUri
..allowMockCompilation = _hasOption(options, Flags.allowMockCompilation)
..benchmarkingProduction =
@@ -533,8 +591,6 @@
..omitAsCasts = _hasOption(options, Flags.omitAsCasts)
..laxRuntimeTypeToString =
_hasOption(options, Flags.laxRuntimeTypeToString)
- .._legacyJavaScript = _hasOption(options, Flags.legacyJavaScript)
- .._noLegacyJavaScript = _hasOption(options, Flags.noLegacyJavaScript)
..testMode = _hasOption(options, Flags.testMode)
..trustPrimitives = _hasOption(options, Flags.trustPrimitives)
..useContentSecurityPolicy =
@@ -573,7 +629,8 @@
..verbosity = fe.Verbosity.parseArgument(
_extractStringOption(
options, '${Flags.verbosity}=', fe.Verbosity.defaultValue),
- onError: onError);
+ onError: onError)
+ ..features = featureOptions;
}
void validate() {
@@ -594,10 +651,6 @@
equalMaps(experimentalFlags, fe.defaultExperimentalFlags)) {
throw new ArgumentError("Missing required ${Flags.platformBinaries}");
}
- if (_legacyJavaScript && _noLegacyJavaScript) {
- throw ArgumentError("'${Flags.legacyJavaScript}' incompatible with "
- "'${Flags.noLegacyJavaScript}'");
- }
if (_soundNullSafety && _noSoundNullSafety) {
throw ArgumentError("'${Flags.soundNullSafety}' incompatible with "
"'${Flags.noSoundNullSafety}'");
@@ -624,9 +677,6 @@
useContentSecurityPolicy = true;
}
- if (_noLegacyJavaScript) legacyJavaScript = false;
- if (_legacyJavaScript) legacyJavaScript = true;
-
if (_soundNullSafety) nullSafetyMode = NullSafetyMode.sound;
if (_noSoundNullSafety) nullSafetyMode = NullSafetyMode.unsound;
@@ -792,4 +842,25 @@
onError: onError, onWarning: onWarning);
}
+void _extractFeatures(
+ List<String> options, List<FeatureOption> features, FeatureStatus status) {
+ bool hasCanaryFlag = _hasOption(options, Flags.canary);
+ bool hasNoShippingFlag = _hasOption(options, Flags.noShipping);
+ for (var feature in features) {
+ String featureFlag = feature.flag;
+ String enableFeatureFlag = '--${featureFlag}';
+ String disableFeatureFlag = '--no-$featureFlag';
+ bool enableFeature = _hasOption(options, enableFeatureFlag);
+ bool disableFeature = _hasOption(options, disableFeatureFlag);
+ if (enableFeature && disableFeature) {
+ throw ArgumentError("'$enableFeatureFlag' incompatible with "
+ "'$disableFeatureFlag'");
+ }
+ bool globalEnable = hasCanaryFlag ||
+ (status == FeatureStatus.shipping && !hasNoShippingFlag);
+ globalEnable = feature.isNegativeFlag ? !globalEnable : globalEnable;
+ feature.state = (enableFeature || globalEnable) && !disableFeature;
+ }
+}
+
const String _UNDETERMINED_BUILD_ID = "build number could not be determined";
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index c7bb93e..20a3676 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -369,7 +369,7 @@
case 'LEGACY':
return options.useLegacySubtyping;
case 'LEGACY_JAVASCRIPT':
- return options.legacyJavaScript;
+ return options.features.legacyJavaScript.isEnabled;
case 'PRINT_LEGACY_STARS':
return options.printLegacyStars;
default:
diff --git a/pkg/compiler/test/end_to_end/feature_options_test.dart b/pkg/compiler/test/end_to_end/feature_options_test.dart
new file mode 100644
index 0000000..3481941
--- /dev/null
+++ b/pkg/compiler/test/end_to_end/feature_options_test.dart
@@ -0,0 +1,141 @@
+// 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.
+
+// @dart = 2.7
+
+// Test the command line options of dart2js.
+
+import 'package:expect/expect.dart';
+
+import 'package:compiler/src/commandline_options.dart';
+import 'package:compiler/src/options.dart' show FeatureOptions, FeatureOption;
+
+class TestFeatureOptions extends FeatureOptions {
+ FeatureOption sf1 = FeatureOption('sf1');
+ FeatureOption sf2 = FeatureOption('sf2');
+ FeatureOption noSf3 = FeatureOption('sf3', isNegativeFlag: true);
+ FeatureOption noSf4 = FeatureOption('sf4', isNegativeFlag: true);
+ FeatureOption cf1 = FeatureOption('cf1');
+ FeatureOption cf2 = FeatureOption('cf2');
+ FeatureOption noCf3 = FeatureOption('cf3', isNegativeFlag: true);
+ FeatureOption noCf4 = FeatureOption('cf4', isNegativeFlag: true);
+
+ @override
+ List<FeatureOption> shipping;
+
+ @override
+ List<FeatureOption> canary;
+
+ // Initialize feature lists.
+ TestFeatureOptions() {
+ shipping = [sf1, sf2, noSf3, noSf4];
+ canary = [cf1, cf2, noCf3, noCf4];
+ }
+}
+
+TestFeatureOptions test(List<String> flags) {
+ var tfo = TestFeatureOptions();
+ tfo.parse(flags);
+ return tfo;
+}
+
+void testShipping() {
+ var tfo = test([]);
+ Expect.isTrue(tfo.sf1.isEnabled);
+ Expect.isTrue(tfo.sf2.isEnabled);
+ Expect.isTrue(tfo.noSf3.isDisabled);
+ Expect.isTrue(tfo.noSf4.isDisabled);
+ Expect.isTrue(tfo.cf1.isDisabled);
+ Expect.isTrue(tfo.cf2.isDisabled);
+ Expect.isTrue(tfo.noCf3.isEnabled);
+ Expect.isTrue(tfo.noCf4.isEnabled);
+}
+
+void testNoShipping() {
+ var tfo = test([Flags.noShipping]);
+ Expect.isTrue(tfo.sf1.isDisabled);
+ Expect.isTrue(tfo.sf2.isDisabled);
+ Expect.isTrue(tfo.noSf3.isEnabled);
+ Expect.isTrue(tfo.noSf4.isEnabled);
+ Expect.isTrue(tfo.cf1.isDisabled);
+ Expect.isTrue(tfo.cf2.isDisabled);
+ Expect.isTrue(tfo.noCf3.isEnabled);
+ Expect.isTrue(tfo.noCf4.isEnabled);
+}
+
+void testCanary() {
+ var tfo = test([Flags.canary]);
+ Expect.isTrue(tfo.sf1.isEnabled);
+ Expect.isTrue(tfo.sf2.isEnabled);
+ Expect.isTrue(tfo.noSf3.isDisabled);
+ Expect.isTrue(tfo.noSf4.isDisabled);
+ Expect.isTrue(tfo.cf1.isEnabled);
+ Expect.isTrue(tfo.cf2.isEnabled);
+ Expect.isTrue(tfo.noCf3.isDisabled);
+ Expect.isTrue(tfo.noCf4.isDisabled);
+}
+
+void testShippingDisabled() {
+ var tfo = test(['--no-sf2', '--sf3']);
+ Expect.isTrue(tfo.sf1.isEnabled);
+ Expect.isTrue(tfo.sf2.isDisabled);
+ Expect.isTrue(tfo.noSf3.isEnabled);
+ Expect.isTrue(tfo.noSf4.isDisabled);
+ Expect.isTrue(tfo.cf1.isDisabled);
+ Expect.isTrue(tfo.cf2.isDisabled);
+ Expect.isTrue(tfo.noCf3.isEnabled);
+ Expect.isTrue(tfo.noCf4.isEnabled);
+}
+
+void testCanaryDisabled() {
+ var tfo = test([Flags.canary, '--no-sf2', '--sf3', '--no-cf1', '--cf3']);
+ Expect.isTrue(tfo.sf1.isEnabled);
+ Expect.isTrue(tfo.sf2.isDisabled);
+ Expect.isTrue(tfo.noSf3.isEnabled);
+ Expect.isTrue(tfo.noSf4.isDisabled);
+ Expect.isTrue(tfo.cf1.isDisabled);
+ Expect.isTrue(tfo.cf2.isEnabled);
+ Expect.isTrue(tfo.noCf3.isEnabled);
+ Expect.isTrue(tfo.noCf4.isDisabled);
+}
+
+void testNoShippingEnabled() {
+ var tfo = test([Flags.noShipping, '--sf1', '--no-sf3', '--cf2', '--no-cf3']);
+ Expect.isTrue(tfo.sf1.isEnabled);
+ Expect.isTrue(tfo.sf2.isDisabled);
+ Expect.isTrue(tfo.noSf3.isDisabled);
+ Expect.isTrue(tfo.noSf4.isEnabled);
+ Expect.isTrue(tfo.cf1.isDisabled);
+ Expect.isTrue(tfo.cf2.isEnabled);
+ Expect.isTrue(tfo.noCf3.isDisabled);
+ Expect.isTrue(tfo.noCf4.isEnabled);
+}
+
+void testNoCanaryEnabled() {
+ var tfo = test(['--cf1', '--no-cf3']);
+ Expect.isTrue(tfo.sf1.isEnabled);
+ Expect.isTrue(tfo.sf2.isEnabled);
+ Expect.isTrue(tfo.noSf3.isDisabled);
+ Expect.isTrue(tfo.noSf4.isDisabled);
+ Expect.isTrue(tfo.cf1.isEnabled);
+ Expect.isTrue(tfo.cf2.isDisabled);
+ Expect.isTrue(tfo.noCf3.isDisabled);
+ Expect.isTrue(tfo.noCf4.isEnabled);
+}
+
+void testFlagCollision() {
+ Expect.throwsArgumentError(() => test(['--cf1', '--no-cf1']));
+}
+
+void main() {
+ testShipping();
+ testNoShipping();
+ testCanary();
+ testShippingDisabled();
+ testCanaryDisabled();
+ testNoShippingEnabled();
+ testNoCanaryEnabled();
+ testNoShippingEnabled();
+ testFlagCollision();
+}
diff --git a/pkg/dev_compiler/lib/src/compiler/shared_command.dart b/pkg/dev_compiler/lib/src/compiler/shared_command.dart
index c0a9c24..cf67f91 100644
--- a/pkg/dev_compiler/lib/src/compiler/shared_command.dart
+++ b/pkg/dev_compiler/lib/src/compiler/shared_command.dart
@@ -92,13 +92,6 @@
/// the browser.
final bool emitDebugMetadata;
- /// Whether to emit the debug symbols
- ///
- /// Debugger uses this information about to construct mapping between
- /// dart and js objecys that otherwise requires expensive communication with
- /// the browser.
- final bool emitDebugSymbols;
-
final Map<String, String> summaryModules;
final List<ModuleFormat> moduleFormats;
@@ -130,7 +123,6 @@
this.enableAsserts = true,
this.replCompile = false,
this.emitDebugMetadata = false,
- this.emitDebugSymbols = false,
this.emitFullCompiledKernel = false,
this.summaryModules = const {},
this.moduleFormats = const [],
@@ -148,7 +140,6 @@
enableAsserts: args['enable-asserts'] as bool,
replCompile: args['repl-compile'] as bool,
emitDebugMetadata: args['experimental-emit-debug-metadata'] as bool,
- emitDebugSymbols: args['emit-debug-symbols'] as bool,
emitFullCompiledKernel:
args['experimental-output-compiled-kernel'] as bool,
summaryModules:
@@ -204,11 +195,6 @@
'Output a metadata file for debug tools next to the .js output.',
defaultsTo: false,
hide: true)
- ..addFlag('emit-debug-symbols',
- help: 'Experimental option for compiler development.\n'
- 'Output a symbols file for debug tools next to the .js output.',
- defaultsTo: false,
- hide: true)
..addFlag('experimental-output-compiled-kernel',
help: 'Experimental option for compiler development.\n'
'Output a full kernel file for currently compiled module next to '
diff --git a/pkg/dev_compiler/lib/src/kernel/command.dart b/pkg/dev_compiler/lib/src/kernel/command.dart
index 2bac27d..8ddd4dc 100644
--- a/pkg/dev_compiler/lib/src/kernel/command.dart
+++ b/pkg/dev_compiler/lib/src/kernel/command.dart
@@ -11,7 +11,6 @@
import 'package:args/args.dart';
import 'package:build_integration/file_system/multi_root.dart';
import 'package:cli_util/cli_util.dart' show getSdkPath;
-import 'package:dev_compiler/src/kernel/module_symbols.dart';
import 'package:front_end/src/api_unstable/ddc.dart' as fe;
import 'package:kernel/binary/ast_to_binary.dart' as kernel show BinaryPrinter;
import 'package:kernel/class_hierarchy.dart';
@@ -444,13 +443,11 @@
buildSourceMap: options.sourceMap,
inlineSourceMap: options.inlineSourceMap,
emitDebugMetadata: options.emitDebugMetadata,
- emitDebugSymbols: options.emitDebugSymbols,
jsUrl: p.toUri(output).toString(),
mapUrl: mapUrl,
fullDillUri: fullDillUri,
customScheme: options.multiRootScheme,
multiRootOutputPath: multiRootOutputPath,
- compiler: compiler,
component: compiledLibraries);
outFiles.add(file.writeAsString(jsCode.code));
@@ -462,11 +459,6 @@
outFiles.add(
File('$output.metadata').writeAsString(json.encode(jsCode.metadata)));
}
-
- if (jsCode.symbols != null) {
- outFiles.add(
- File('$output.symbols').writeAsString(json.encode(jsCode.symbols)));
- }
}
if (recordUsedInputs) {
@@ -643,13 +635,7 @@
/// see: https://goto.google.com/dart-web-debugger-metadata
final ModuleMetadata metadata;
- /// Module debug symbols.
- ///
- /// The [symbols] is a contract between compiler and the debugger,
- /// helping the debugger map between dart and JS objects.
- final ModuleSymbols symbols;
-
- JSCode(this.code, this.sourceMap, {this.symbols, this.metadata});
+ JSCode(this.code, this.sourceMap, {this.metadata});
}
/// Converts [moduleTree] to [JSCode], using [format].
@@ -660,14 +646,12 @@
{bool buildSourceMap = false,
bool inlineSourceMap = false,
bool emitDebugMetadata = false,
- bool emitDebugSymbols = false,
String jsUrl,
String mapUrl,
String fullDillUri,
String sourceMapBase,
String customScheme,
String multiRootOutputPath,
- ProgramCompiler compiler,
Component component}) {
var opts = js_ast.JavaScriptPrintingOptions(
allowKeywordsInProperties: true, allowSingleLineIfStatements: true);
@@ -682,8 +666,8 @@
}
var tree = transformModuleFormat(format, moduleTree);
- var namer = js_ast.TemporaryNamer(tree);
- tree.accept(js_ast.Printer(opts, printer, localNamer: namer));
+ tree.accept(
+ js_ast.Printer(opts, printer, localNamer: js_ast.TemporaryNamer(tree)));
Map builtMap;
if (buildSourceMap && sourceMap != null) {
@@ -726,15 +710,7 @@
? _emitMetadata(moduleTree, component, mapUrl, jsUrl, fullDillUri)
: null;
- var debugSymbols =
- emitDebugSymbols ? _emitSymbols(compiler, component) : null;
-
- return JSCode(text, builtMap, symbols: debugSymbols, metadata: debugMetadata);
-}
-
-ModuleSymbols _emitSymbols(ProgramCompiler compiler, Component component) {
- // TODO(annagrin): collect module symbols.
- return ModuleSymbols();
+ return JSCode(text, builtMap, metadata: debugMetadata);
}
ModuleMetadata _emitMetadata(js_ast.Program program, Component component,
diff --git a/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart b/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart
index 7300029..7f79898 100644
--- a/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart
+++ b/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart
@@ -152,10 +152,8 @@
inlineSourceMap: true,
buildSourceMap: true,
emitDebugMetadata: true,
- emitDebugSymbols: true,
jsUrl: '$output',
mapUrl: '$output.map',
- compiler: kernel2jsCompiler,
component: component,
);
metadata = code.metadata;
diff --git a/pkg/dev_compiler/test/expression_compiler/expression_compiler_worker_test.dart b/pkg/dev_compiler/test/expression_compiler/expression_compiler_worker_test.dart
index 7141bb4..8cda5d8 100644
--- a/pkg/dev_compiler/test/expression_compiler/expression_compiler_worker_test.dart
+++ b/pkg/dev_compiler/test/expression_compiler/expression_compiler_worker_test.dart
@@ -769,7 +769,6 @@
config.testModule3.jsPath.toFilePath(),
'--source-map',
'--experimental-emit-debug-metadata',
- '--emit-debug-symbols',
'--experimental-output-compiled-kernel',
'--dart-sdk-summary',
config.sdkSummaryPath.path,
@@ -798,7 +797,6 @@
config.testModule2.jsPath.toFilePath(),
'--source-map',
'--experimental-emit-debug-metadata',
- '--emit-debug-symbols',
'--experimental-output-compiled-kernel',
'--dart-sdk-summary',
config.sdkSummaryPath.path,
@@ -829,7 +827,6 @@
config.testModule.jsPath.toFilePath(),
'--source-map',
'--experimental-emit-debug-metadata',
- '--emit-debug-symbols',
'--experimental-output-compiled-kernel',
'--dart-sdk-summary',
config.sdkSummaryPath.path,
@@ -862,7 +859,6 @@
config.mainModule.jsPath.toFilePath(),
'--source-map',
'--experimental-emit-debug-metadata',
- '--emit-debug-symbols',
'--experimental-output-compiled-kernel',
'--dart-sdk-summary',
config.sdkSummaryPath.path,
diff --git a/pkg/frontend_server/lib/frontend_server.dart b/pkg/frontend_server/lib/frontend_server.dart
index 4ba6641..5881625 100644
--- a/pkg/frontend_server/lib/frontend_server.dart
+++ b/pkg/frontend_server/lib/frontend_server.dart
@@ -168,8 +168,6 @@
..addFlag('experimental-emit-debug-metadata',
help: 'Emit module and library metadata for the debugger',
defaultsTo: false)
- ..addFlag('emit-debug-symbols',
- help: 'Emit debug symbols for the debugger', defaultsTo: false)
..addOption('dartdevc-module-format',
help: 'The module format to use on for the dartdevc compiler',
defaultsTo: 'amd')
@@ -326,8 +324,7 @@
this.unsafePackageSerialization,
this.incrementalSerialization: true,
this.useDebuggerModuleNames: false,
- this.emitDebugMetadata: false,
- this.emitDebugSymbols: false}) {
+ this.emitDebugMetadata: false}) {
_outputStream ??= stdout;
printerFactory ??= new BinaryPrinterFactory();
}
@@ -338,7 +335,6 @@
bool incrementalSerialization;
bool useDebuggerModuleNames;
bool emitDebugMetadata;
- bool emitDebugSymbols;
bool _printIncrementalDependencies;
CompilerOptions _compilerOptions;
@@ -629,7 +625,6 @@
final File manifestFile = File('$filename.json');
final File sourceMapsFile = File('$filename.map');
final File metadataFile = File('$filename.metadata');
- final File symbolsFile = File('$filename.symbols');
if (!sourceFile.parent.existsSync()) {
sourceFile.parent.createSync(recursive: true);
}
@@ -637,7 +632,6 @@
component, strongComponents, fileSystemScheme, packageConfig,
useDebuggerModuleNames: useDebuggerModuleNames,
emitDebugMetadata: emitDebugMetadata,
- emitDebugSymbols: emitDebugSymbols,
moduleFormat: moduleFormat,
soundNullSafety: soundNullSafety);
final sourceFileSink = sourceFile.openWrite();
@@ -645,7 +639,6 @@
final sourceMapsFileSink = sourceMapsFile.openWrite();
final metadataFileSink =
emitDebugMetadata ? metadataFile.openWrite() : null;
- final symbolsFileSink = emitDebugSymbols ? symbolsFile.openWrite() : null;
final kernel2JsCompilers = await _bundler.compile(
results.classHierarchy,
results.coreTypes,
@@ -653,8 +646,7 @@
sourceFileSink,
manifestFileSink,
sourceMapsFileSink,
- metadataFileSink,
- symbolsFileSink);
+ metadataFileSink);
cachedProgramCompilers.addAll(kernel2JsCompilers);
await Future.wait([
sourceFileSink.close(),
@@ -1354,8 +1346,7 @@
unsafePackageSerialization: options["unsafe-package-serialization"],
incrementalSerialization: options["incremental-serialization"],
useDebuggerModuleNames: options['debugger-module-names'],
- emitDebugMetadata: options['experimental-emit-debug-metadata'],
- emitDebugSymbols: options['emit-debug-symbols']);
+ emitDebugMetadata: options['experimental-emit-debug-metadata']);
if (options.rest.isNotEmpty) {
return await compiler.compile(options.rest[0], options,
diff --git a/pkg/frontend_server/lib/src/javascript_bundle.dart b/pkg/frontend_server/lib/src/javascript_bundle.dart
index a989fb1..9829c57 100644
--- a/pkg/frontend_server/lib/src/javascript_bundle.dart
+++ b/pkg/frontend_server/lib/src/javascript_bundle.dart
@@ -27,7 +27,6 @@
this._fileSystemScheme, this._packageConfig,
{this.useDebuggerModuleNames = false,
this.emitDebugMetadata = false,
- this.emitDebugSymbols = false,
this.soundNullSafety = false,
String moduleFormat})
: _moduleFormat = parseModuleFormat(moduleFormat ?? 'amd') {
@@ -64,7 +63,6 @@
final PackageConfig _packageConfig;
final bool useDebuggerModuleNames;
final bool emitDebugMetadata;
- final bool emitDebugSymbols;
final ModuleFormat _moduleFormat;
final bool soundNullSafety;
@@ -76,19 +74,16 @@
/// Compile each component into a single JavaScript module.
Future<Map<String, ProgramCompiler>> compile(
- ClassHierarchy classHierarchy,
- CoreTypes coreTypes,
- Set<Library> loadedLibraries,
- IOSink codeSink,
- IOSink manifestSink,
- IOSink sourceMapsSink,
- IOSink metadataSink,
- IOSink symbolsSink,
- ) async {
+ ClassHierarchy classHierarchy,
+ CoreTypes coreTypes,
+ Set<Library> loadedLibraries,
+ IOSink codeSink,
+ IOSink manifestSink,
+ IOSink sourceMapsSink,
+ IOSink metadataSink) async {
var codeOffset = 0;
var sourceMapOffset = 0;
var metadataOffset = 0;
- var symbolsOffset = 0;
final manifest = <String, Map<String, List<int>>>{};
final Set<Uri> visited = <Uri>{};
final Map<String, ProgramCompiler> kernel2JsCompilers = {};
@@ -140,7 +135,6 @@
sourceMap: true,
summarizeApi: false,
emitDebugMetadata: emitDebugMetadata,
- emitDebugSymbols: emitDebugSymbols,
moduleName: moduleName,
soundNullSafety: soundNullSafety,
),
@@ -151,6 +145,10 @@
final jsModule = compiler.emitModule(summaryComponent);
+ // TODO:(annagrin): create symbol tables and pass to expression compiler
+ // so it can map dart symbols to js symbols
+ // [issue 40273](https://github.com/dart-lang/sdk/issues/40273)
+
// Save program compiler to reuse for expression evaluation.
kernel2JsCompilers[moduleName] = compiler;
@@ -170,29 +168,22 @@
inlineSourceMap: true,
buildSourceMap: true,
emitDebugMetadata: emitDebugMetadata,
- emitDebugSymbols: emitDebugSymbols,
jsUrl: '$moduleUrl.lib.js',
mapUrl: '$moduleUrl.lib.js.map',
sourceMapBase: sourceMapBase,
customScheme: _fileSystemScheme,
- compiler: compiler,
component: summaryComponent,
);
final codeBytes = utf8.encode(code.code);
final sourceMapBytes = utf8.encode(json.encode(code.sourceMap));
final metadataBytes =
emitDebugMetadata ? utf8.encode(json.encode(code.metadata)) : null;
- final symbolsBytes =
- emitDebugSymbols ? utf8.encode(json.encode(code.symbols)) : null;
codeSink.add(codeBytes);
sourceMapsSink.add(sourceMapBytes);
if (emitDebugMetadata) {
metadataSink.add(metadataBytes);
}
- if (emitDebugSymbols) {
- symbolsSink.add(symbolsBytes);
- }
final String moduleKey = _moduleImportForSummary[moduleUri];
manifest[moduleKey] = {
'code': <int>[codeOffset, codeOffset += codeBytes.length],
@@ -205,11 +196,6 @@
metadataOffset,
metadataOffset += metadataBytes.length
],
- if (emitDebugSymbols)
- 'symbols': <int>[
- symbolsOffset,
- symbolsOffset += symbolsBytes.length,
- ],
};
}
manifestSink.add(utf8.encode(json.encode(manifest)));
diff --git a/pkg/frontend_server/test/frontend_server_test.dart b/pkg/frontend_server/test/frontend_server_test.dart
index 8205380..ee69ecb 100644
--- a/pkg/frontend_server/test/frontend_server_test.dart
+++ b/pkg/frontend_server/test/frontend_server_test.dart
@@ -1979,14 +1979,12 @@
var manifestFile = File('${dillFile.path}.json');
var sourceMapsFile = File('${dillFile.path}.map');
var metadataFile = File('${dillFile.path}.metadata');
- var symbolsFile = File('${dillFile.path}.symbols');
expect(dillFile.existsSync(), false);
expect(sourceFile.existsSync(), false);
expect(manifestFile.existsSync(), false);
expect(sourceMapsFile.existsSync(), false);
expect(metadataFile.existsSync(), false);
- expect(symbolsFile.existsSync(), false);
final List<String> args = <String>[
'--sdk-root=${sdkRoot.toFilePath()}',
@@ -1996,7 +1994,6 @@
'--target=dartdevc',
'--packages=${package_config.path}',
'--experimental-emit-debug-metadata',
- '--emit-debug-symbols',
];
final StreamController<List<int>> streamController =
@@ -2025,7 +2022,6 @@
expect(manifestFile.existsSync(), equals(true));
expect(sourceMapsFile.existsSync(), equals(true));
expect(metadataFile.existsSync(), equals(true));
- expect(symbolsFile.existsSync(), equals(true));
expect(result.filename, dillFile.path);
streamController.add('accept\n'.codeUnits);
outputParser.expectSources = false;
diff --git a/pkg/frontend_server/test/src/javascript_bundle_test.dart b/pkg/frontend_server/test/src/javascript_bundle_test.dart
index d927f82..898cbcc 100644
--- a/pkg/frontend_server/test/src/javascript_bundle_test.dart
+++ b/pkg/frontend_server/test/src/javascript_bundle_test.dart
@@ -111,19 +111,16 @@
final codeSink = _MemorySink();
final sourcemapSink = _MemorySink();
final metadataSink = _MemorySink();
- final symbolsSink = _MemorySink();
final coreTypes = CoreTypes(testComponent);
final compilers = await javaScriptBundler.compile(
- ClassHierarchy(testComponent, coreTypes),
- coreTypes,
- {},
- codeSink,
- manifestSink,
- sourcemapSink,
- metadataSink,
- symbolsSink,
- );
+ ClassHierarchy(testComponent, coreTypes),
+ coreTypes,
+ {},
+ codeSink,
+ manifestSink,
+ sourcemapSink,
+ metadataSink);
final Map manifest = json.decode(utf8.decode(manifestSink.buffer));
final String code = utf8.decode(codeSink.buffer);
@@ -165,19 +162,10 @@
final codeSink = _MemorySink();
final sourcemapSink = _MemorySink();
final metadataSink = _MemorySink();
- final symbolsSink = _MemorySink();
final coreTypes = CoreTypes(testComponent);
- await javaScriptBundler.compile(
- ClassHierarchy(testComponent, coreTypes),
- coreTypes,
- {},
- codeSink,
- manifestSink,
- sourcemapSink,
- metadataSink,
- symbolsSink,
- );
+ await javaScriptBundler.compile(ClassHierarchy(testComponent, coreTypes),
+ coreTypes, {}, codeSink, manifestSink, sourcemapSink, metadataSink);
final Map manifest = json.decode(utf8.decode(manifestSink.buffer));
final String code = utf8.decode(codeSink.buffer);
@@ -216,19 +204,10 @@
final codeSink = _MemorySink();
final sourcemapSink = _MemorySink();
final metadataSink = _MemorySink();
- final symbolsSink = _MemorySink();
final coreTypes = CoreTypes(testComponent);
- await javaScriptBundler.compile(
- ClassHierarchy(testComponent, coreTypes),
- coreTypes,
- {},
- codeSink,
- manifestSink,
- sourcemapSink,
- metadataSink,
- symbolsSink,
- );
+ await javaScriptBundler.compile(ClassHierarchy(testComponent, coreTypes),
+ coreTypes, {}, codeSink, manifestSink, sourcemapSink, metadataSink);
final Map manifest = json.decode(utf8.decode(manifestSink.buffer));
final String code = utf8.decode(codeSink.buffer);
@@ -277,19 +256,10 @@
final codeSink = _MemorySink();
final sourcemapSink = _MemorySink();
final metadataSink = _MemorySink();
- final symbolsSink = _MemorySink();
final coreTypes = CoreTypes(testComponent);
- javaScriptBundler.compile(
- ClassHierarchy(testComponent, coreTypes),
- coreTypes,
- {},
- codeSink,
- manifestSink,
- sourcemapSink,
- metadataSink,
- symbolsSink,
- );
+ javaScriptBundler.compile(ClassHierarchy(testComponent, coreTypes),
+ coreTypes, {}, codeSink, manifestSink, sourcemapSink, metadataSink);
final code = utf8.decode(codeSink.buffer);
final manifest = json.decode(utf8.decode(manifestSink.buffer));
diff --git a/runtime/vm/compiler/ffi/native_calling_convention_test.cc b/runtime/vm/compiler/ffi/native_calling_convention_test.cc
index e9308b9..e1fdfb0 100644
--- a/runtime/vm/compiler/ffi/native_calling_convention_test.cc
+++ b/runtime/vm/compiler/ffi/native_calling_convention_test.cc
@@ -584,6 +584,37 @@
#endif
}
+// MacOS arm64 alignment of 12-byte homogenous float structs.
+//
+// http://dartbug.com/46305
+//
+// See the *.expect in ./unit_tests for this behavior.
+UNIT_TEST_CASE_WITH_ZONE(NativeCallingConvention_struct12bytesFloatx6) {
+ const auto& float_type = *new (Z) NativePrimitiveType(kFloat);
+ const auto& int64_type = *new (Z) NativePrimitiveType(kInt64);
+
+ auto& member_types = *new (Z) NativeTypes(Z, 3);
+ member_types.Add(&float_type);
+ member_types.Add(&float_type);
+ member_types.Add(&float_type);
+ const auto& struct_type = NativeStructType::FromNativeTypes(Z, member_types);
+
+#if defined(TARGET_ARCH_ARM64) && \
+ (defined(TARGET_OS_MACOS) || defined(TARGET_OS_MACOS_IOS))
+ EXPECT_EQ(4, struct_type.AlignmentInBytesStack());
+#endif
+
+ auto& arguments = *new (Z) NativeTypes(Z, 6);
+ arguments.Add(&struct_type);
+ arguments.Add(&struct_type);
+ arguments.Add(&struct_type);
+ arguments.Add(&struct_type);
+ arguments.Add(&struct_type);
+ arguments.Add(&struct_type);
+
+ RunSignatureTest(Z, "struct12bytesFloatx6", arguments, int64_type);
+}
+
} // namespace ffi
} // namespace compiler
} // namespace dart
diff --git a/runtime/vm/compiler/ffi/native_type.cc b/runtime/vm/compiler/ffi/native_type.cc
index b78b206..686816c 100644
--- a/runtime/vm/compiler/ffi/native_type.cc
+++ b/runtime/vm/compiler/ffi/native_type.cc
@@ -174,9 +174,10 @@
// If this struct is passed on the stack, it should be aligned to the largest
// alignment of its members when passing those members on the stack.
intptr_t alignment_stack = kAtLeast1ByteAligned;
-#if defined(TARGET_OS_MACOS_IOS) && defined(TARGET_ARCH_ARM64)
- // On iOS64 stack values can be less aligned than wordSize, which deviates
- // from the arm64 ABI.
+#if (defined(TARGET_OS_MACOS_IOS) || defined(TARGET_OS_MACOS)) && \
+ defined(TARGET_ARCH_ARM64)
+ // On iOS64 and MacOS arm64 stack values can be less aligned than wordSize,
+ // which deviates from the arm64 ABI.
ASSERT(CallingConventions::kArgumentStackAlignment == kAlignedToValueSize);
// Because the arm64 ABI aligns primitives to word size on the stack, every
// struct will be automatically aligned to word size. iOS64 does not align
diff --git a/runtime/vm/compiler/ffi/unit_tests/floatx10/arm64_macos.expect b/runtime/vm/compiler/ffi/unit_tests/floatx10/arm64_macos.expect
index 8f237e3..0a25996 100644
--- a/runtime/vm/compiler/ffi/unit_tests/floatx10/arm64_macos.expect
+++ b/runtime/vm/compiler/ffi/unit_tests/floatx10/arm64_macos.expect
@@ -7,6 +7,6 @@
v6 float
v7 float
S+0 float
-S+8 float
+S+4 float
=>
v0 float
diff --git a/runtime/vm/compiler/ffi/unit_tests/int8x10/arm64_macos.expect b/runtime/vm/compiler/ffi/unit_tests/int8x10/arm64_macos.expect
index 04f72e5f..8efadc4 100644
--- a/runtime/vm/compiler/ffi/unit_tests/int8x10/arm64_macos.expect
+++ b/runtime/vm/compiler/ffi/unit_tests/int8x10/arm64_macos.expect
@@ -7,6 +7,6 @@
r6 int8
r7 int8
S+0 int8
-S+8 int8
+S+1 int8
=>
r0 int8
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm64_android.expect b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm64_android.expect
new file mode 100644
index 0000000..e14f6b1
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm64_android.expect
@@ -0,0 +1,8 @@
+M(v0 float, v1 float, v2 float) Struct(size: 12)
+M(v3 float, v4 float, v5 float) Struct(size: 12)
+S+0 Struct(size: 12)
+S+16 Struct(size: 12)
+S+32 Struct(size: 12)
+S+48 Struct(size: 12)
+=>
+r0 int64
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm64_ios.expect b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm64_ios.expect
new file mode 100644
index 0000000..1ea815b
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm64_ios.expect
@@ -0,0 +1,8 @@
+M(v0 float, v1 float, v2 float) Struct(size: 12)
+M(v3 float, v4 float, v5 float) Struct(size: 12)
+S+0 Struct(size: 12)
+S+12 Struct(size: 12)
+S+24 Struct(size: 12)
+S+36 Struct(size: 12)
+=>
+r0 int64
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm64_linux.expect b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm64_linux.expect
new file mode 100644
index 0000000..e14f6b1
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm64_linux.expect
@@ -0,0 +1,8 @@
+M(v0 float, v1 float, v2 float) Struct(size: 12)
+M(v3 float, v4 float, v5 float) Struct(size: 12)
+S+0 Struct(size: 12)
+S+16 Struct(size: 12)
+S+32 Struct(size: 12)
+S+48 Struct(size: 12)
+=>
+r0 int64
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm64_macos.expect b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm64_macos.expect
new file mode 100644
index 0000000..1ea815b
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm64_macos.expect
@@ -0,0 +1,8 @@
+M(v0 float, v1 float, v2 float) Struct(size: 12)
+M(v3 float, v4 float, v5 float) Struct(size: 12)
+S+0 Struct(size: 12)
+S+12 Struct(size: 12)
+S+24 Struct(size: 12)
+S+36 Struct(size: 12)
+=>
+r0 int64
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm_android.expect b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm_android.expect
new file mode 100644
index 0000000..3cd3492
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm_android.expect
@@ -0,0 +1,8 @@
+M(r0 int32, r1 int32, r2 int32) Struct(size: 12)
+M(r3 int32, S+0 int32, S+4 int32) Struct(size: 12)
+M(S+8 int32, S+12 int32, S+16 int32) Struct(size: 12)
+M(S+20 int32, S+24 int32, S+28 int32) Struct(size: 12)
+M(S+32 int32, S+36 int32, S+40 int32) Struct(size: 12)
+M(S+44 int32, S+48 int32, S+52 int32) Struct(size: 12)
+=>
+(r0, r1) int64
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm_ios.expect b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm_ios.expect
new file mode 100644
index 0000000..d5dfa4d
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm_ios.expect
@@ -0,0 +1,8 @@
+M(s0 float, s1 float, s2 float) Struct(size: 12)
+M(s3 float, s4 float, s5 float) Struct(size: 12)
+M(s6 float, s7 float, s8 float) Struct(size: 12)
+M(s9 float, s10 float, s11 float) Struct(size: 12)
+M(s12 float, s13 float, s14 float) Struct(size: 12)
+S+0 Struct(size: 12)
+=>
+(r0, r1) int64
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm_linux.expect b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm_linux.expect
new file mode 100644
index 0000000..d5dfa4d
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm_linux.expect
@@ -0,0 +1,8 @@
+M(s0 float, s1 float, s2 float) Struct(size: 12)
+M(s3 float, s4 float, s5 float) Struct(size: 12)
+M(s6 float, s7 float, s8 float) Struct(size: 12)
+M(s9 float, s10 float, s11 float) Struct(size: 12)
+M(s12 float, s13 float, s14 float) Struct(size: 12)
+S+0 Struct(size: 12)
+=>
+(r0, r1) int64
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/ia32_android.expect b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/ia32_android.expect
new file mode 100644
index 0000000..ca9d8e9
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/ia32_android.expect
@@ -0,0 +1,8 @@
+S+0 Struct(size: 12)
+S+12 Struct(size: 12)
+S+24 Struct(size: 12)
+S+36 Struct(size: 12)
+S+48 Struct(size: 12)
+S+60 Struct(size: 12)
+=>
+(eax, edx) int64
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/ia32_linux.expect b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/ia32_linux.expect
new file mode 100644
index 0000000..ca9d8e9
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/ia32_linux.expect
@@ -0,0 +1,8 @@
+S+0 Struct(size: 12)
+S+12 Struct(size: 12)
+S+24 Struct(size: 12)
+S+36 Struct(size: 12)
+S+48 Struct(size: 12)
+S+60 Struct(size: 12)
+=>
+(eax, edx) int64
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/ia32_win.expect b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/ia32_win.expect
new file mode 100644
index 0000000..ca9d8e9
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/ia32_win.expect
@@ -0,0 +1,8 @@
+S+0 Struct(size: 12)
+S+12 Struct(size: 12)
+S+24 Struct(size: 12)
+S+36 Struct(size: 12)
+S+48 Struct(size: 12)
+S+60 Struct(size: 12)
+=>
+(eax, edx) int64
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/x64_ios.expect b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/x64_ios.expect
new file mode 100644
index 0000000..c4a4cc2
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/x64_ios.expect
@@ -0,0 +1,8 @@
+M(xmm0 double, xmm1 double) Struct(size: 12)
+M(xmm2 double, xmm3 double) Struct(size: 12)
+M(xmm4 double, xmm5 double) Struct(size: 12)
+M(xmm6 double, xmm7 double) Struct(size: 12)
+S+0 Struct(size: 12)
+S+16 Struct(size: 12)
+=>
+rax int64
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/x64_linux.expect b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/x64_linux.expect
new file mode 100644
index 0000000..c4a4cc2
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/x64_linux.expect
@@ -0,0 +1,8 @@
+M(xmm0 double, xmm1 double) Struct(size: 12)
+M(xmm2 double, xmm3 double) Struct(size: 12)
+M(xmm4 double, xmm5 double) Struct(size: 12)
+M(xmm6 double, xmm7 double) Struct(size: 12)
+S+0 Struct(size: 12)
+S+16 Struct(size: 12)
+=>
+rax int64
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/x64_macos.expect b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/x64_macos.expect
new file mode 100644
index 0000000..c4a4cc2
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/x64_macos.expect
@@ -0,0 +1,8 @@
+M(xmm0 double, xmm1 double) Struct(size: 12)
+M(xmm2 double, xmm3 double) Struct(size: 12)
+M(xmm4 double, xmm5 double) Struct(size: 12)
+M(xmm6 double, xmm7 double) Struct(size: 12)
+S+0 Struct(size: 12)
+S+16 Struct(size: 12)
+=>
+rax int64
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/x64_win.expect b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/x64_win.expect
new file mode 100644
index 0000000..06b823f
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/x64_win.expect
@@ -0,0 +1,8 @@
+P(rcx int64) Struct(size: 12)
+P(rdx int64) Struct(size: 12)
+P(r8 int64) Struct(size: 12)
+P(r9 int64) Struct(size: 12)
+P(S+0 int64) Struct(size: 12)
+P(S+8 int64) Struct(size: 12)
+=>
+rax int64
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct16bytesHomogenousx10/arm64_macos.expect b/runtime/vm/compiler/ffi/unit_tests/struct16bytesHomogenousx10/arm64_macos.expect
index 123cea6..da95987 100644
--- a/runtime/vm/compiler/ffi/unit_tests/struct16bytesHomogenousx10/arm64_macos.expect
+++ b/runtime/vm/compiler/ffi/unit_tests/struct16bytesHomogenousx10/arm64_macos.expect
@@ -10,6 +10,6 @@
S+112 Struct(size: 16)
S+128 float
r0 int8
-S+136 Struct(size: 16)
+S+132 Struct(size: 16)
=>
M(v0 float, v1 float, v2 float, v3 float) Struct(size: 16)
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct_floatarray/arm64_macos.expect b/runtime/vm/compiler/ffi/unit_tests/struct_floatarray/arm64_macos.expect
index 728e016..21f9c56 100644
--- a/runtime/vm/compiler/ffi/unit_tests/struct_floatarray/arm64_macos.expect
+++ b/runtime/vm/compiler/ffi/unit_tests/struct_floatarray/arm64_macos.expect
@@ -1,3 +1,3 @@
-Struct(size: 16, field alignment: 4, stack alignment: 8, members: {
- 0: Array(element type: Struct(size: 8, field alignment: 4, stack alignment: 8, members: {0: Array(element type: float, length: 2)}), length: 2)
+Struct(size: 16, field alignment: 4, stack alignment: 4, members: {
+ 0: Array(element type: Struct(size: 8, field alignment: 4, stack alignment: 4, members: {0: Array(element type: float, length: 2)}), length: 2)
})
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct_floatx4/arm64_macos.expect b/runtime/vm/compiler/ffi/unit_tests/struct_floatx4/arm64_macos.expect
index c065867..a753409 100644
--- a/runtime/vm/compiler/ffi/unit_tests/struct_floatx4/arm64_macos.expect
+++ b/runtime/vm/compiler/ffi/unit_tests/struct_floatx4/arm64_macos.expect
@@ -1,4 +1,4 @@
-Struct(size: 16, field alignment: 4, stack alignment: 8, members: {
+Struct(size: 16, field alignment: 4, stack alignment: 4, members: {
0: float,
4: float,
8: float,
diff --git a/runtime/vm/constants_arm64.h b/runtime/vm/constants_arm64.h
index 28cbf1d..9b93a3a 100644
--- a/runtime/vm/constants_arm64.h
+++ b/runtime/vm/constants_arm64.h
@@ -142,7 +142,7 @@
const Register CALLEE_SAVED_TEMP = R19;
const Register CALLEE_SAVED_TEMP2 = R20;
const Register HEAP_BITS = R28; // write_barrier_mask << 32 | heap_base >> 32
-const Register NULL_REG = R22; // Caches NullObject() value.
+const Register NULL_REG = R22; // Caches NullObject() value.
// ABI for catch-clause entry point.
const Register kExceptionObjectReg = R0;
@@ -433,7 +433,7 @@
kAlignedToWordSize;
// How stack arguments are aligned.
-#if defined(TARGET_OS_MACOS_IOS)
+#if defined(TARGET_OS_MACOS_IOS) || defined(TARGET_OS_MACOS)
// > Function arguments may consume slots on the stack that are not multiples
// > of 8 bytes.
// https://developer.apple.com/documentation/xcode/writing_arm64_code_for_apple_platforms
diff --git a/runtime/vm/elf.cc b/runtime/vm/elf.cc
index 7f17df5..ab90490 100644
--- a/runtime/vm/elf.cc
+++ b/runtime/vm/elf.cc
@@ -14,6 +14,8 @@
namespace dart {
+#if defined(DART_PRECOMPILER)
+
// A wrapper around BaseWriteStream that provides methods useful for
// writing ELF files (e.g., using ELF definitions of data sizes).
class ElfWriteStream : public ValueObject {
@@ -1574,4 +1576,6 @@
}
}
+#endif // DART_PRECOMPILER
+
} // namespace dart
diff --git a/runtime/vm/elf.h b/runtime/vm/elf.h
index fb27dc2..9c7cbf5 100644
--- a/runtime/vm/elf.h
+++ b/runtime/vm/elf.h
@@ -13,6 +13,8 @@
namespace dart {
+#if defined(DART_PRECOMPILER)
+
class Dwarf;
class ElfWriteStream;
class Section;
@@ -149,6 +151,8 @@
intptr_t program_table_file_size_ = -1;
};
+#endif // DART_PRECOMPILER
+
} // namespace dart
#endif // RUNTIME_VM_ELF_H_
diff --git a/runtime/vm/image_snapshot.h b/runtime/vm/image_snapshot.h
index 42f96e9..df09407 100644
--- a/runtime/vm/image_snapshot.h
+++ b/runtime/vm/image_snapshot.h
@@ -27,6 +27,7 @@
// Forward declarations.
class Code;
class Dwarf;
+class Elf;
class Instructions;
class Object;
@@ -240,9 +241,13 @@
// Text sections contain objects (even in bare instructions mode) wrapped
// in an Image object, and for now we also align them to the same page
// size assumed by Elf objects.
+ static constexpr intptr_t kTextAlignment = 16 * KB;
+#if defined(DART_PRECOMPILER)
+ static_assert(kTextAlignment == Elf::kPageSize,
+ "Page alignment must be consistent with max object alignment");
static_assert(Elf::kPageSize >= kMaxObjectAlignment,
"Page alignment must be consistent with max object alignment");
- static constexpr intptr_t kTextAlignment = Elf::kPageSize;
+#endif
void ResetOffsets() {
next_data_offset_ = Image::kHeaderSize;
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index bb3fea0..183dabc 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -50,7 +50,6 @@
#include "vm/thread_interrupter.h"
#include "vm/thread_registry.h"
#include "vm/timeline.h"
-#include "vm/timeline_analysis.h"
#include "vm/visitor.h"
#if !defined(DART_PRECOMPILED_RUNTIME)
@@ -61,7 +60,6 @@
namespace dart {
DECLARE_FLAG(bool, print_metrics);
-DECLARE_FLAG(bool, timing);
DECLARE_FLAG(bool, trace_service);
DECLARE_FLAG(bool, warn_on_pause_with_no_debugger);
@@ -2416,19 +2414,6 @@
// Fail fast if anybody tries to post any more messages to this isolate.
delete message_handler();
set_message_handler(nullptr);
-#if defined(SUPPORT_TIMELINE)
- // Before analyzing the isolate's timeline blocks- reclaim all cached
- // blocks.
- Timeline::ReclaimCachedBlocksFromThreads();
-#endif
-
-// Dump all timing data for the isolate.
-#if defined(SUPPORT_TIMELINE) && !defined(PRODUCT)
- if (FLAG_timing) {
- TimelinePauseTrace tpt;
- tpt.Print();
- }
-#endif // !PRODUCT
#if !defined(PRODUCT)
if (FLAG_dump_megamorphic_stats) {
diff --git a/runtime/vm/timeline.cc b/runtime/vm/timeline.cc
index 5e18589..74d2ef4 100644
--- a/runtime/vm/timeline.cc
+++ b/runtime/vm/timeline.cc
@@ -32,14 +32,6 @@
false,
"Record the timeline to the platform's tracing service if there is one");
DEFINE_FLAG(bool, trace_timeline, false, "Trace timeline backend");
-DEFINE_FLAG(bool,
- trace_timeline_analysis,
- false,
- "Trace timeline analysis backend");
-DEFINE_FLAG(bool,
- timing,
- false,
- "Dump isolate timing information from timeline.");
DEFINE_FLAG(charp,
timeline_dir,
NULL,
@@ -102,7 +94,7 @@
static TimelineEventRecorder* CreateTimelineRecorder() {
// Some flags require that we use the endless recorder.
const bool use_endless_recorder =
- (FLAG_timeline_dir != NULL) || FLAG_timing || FLAG_complete_timeline;
+ (FLAG_timeline_dir != NULL) || FLAG_complete_timeline;
const bool use_startup_recorder = FLAG_startup_timeline;
const bool use_systrace_recorder = FLAG_systrace_timeline;
@@ -190,7 +182,7 @@
// Returns true if |streams| contains |stream| or "all". Not case sensitive.
static bool HasStream(MallocGrowableArray<char*>* streams, const char* stream) {
- if ((FLAG_timeline_dir != NULL) || FLAG_timing || FLAG_complete_timeline ||
+ if ((FLAG_timeline_dir != NULL) || FLAG_complete_timeline ||
FLAG_startup_timeline) {
return true;
}
diff --git a/runtime/vm/timeline_analysis.cc b/runtime/vm/timeline_analysis.cc
deleted file mode 100644
index 10e9c47..0000000
--- a/runtime/vm/timeline_analysis.cc
+++ /dev/null
@@ -1,577 +0,0 @@
-// Copyright (c) 2015, 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 "vm/timeline_analysis.h"
-
-#include "vm/flags.h"
-#include "vm/isolate.h"
-#include "vm/log.h"
-#include "vm/os_thread.h"
-
-namespace dart {
-
-#ifndef PRODUCT
-
-DECLARE_FLAG(bool, trace_timeline_analysis);
-DECLARE_FLAG(bool, timing);
-
-TimelineAnalysisThread::TimelineAnalysisThread(ThreadId id) : id_(id) {}
-
-TimelineAnalysisThread::~TimelineAnalysisThread() {}
-
-void TimelineAnalysisThread::AddBlock(TimelineEventBlock* block) {
- blocks_.Add(block);
-}
-
-static int CompareBlocksLowerTimeBound(TimelineEventBlock* const* a,
- TimelineEventBlock* const* b) {
- ASSERT(a != NULL);
- ASSERT(*a != NULL);
- ASSERT(b != NULL);
- ASSERT(*b != NULL);
- return (*a)->LowerTimeBound() - (*b)->LowerTimeBound();
-}
-
-void TimelineAnalysisThread::Finalize() {
- blocks_.Sort(CompareBlocksLowerTimeBound);
- if (FLAG_trace_timeline_analysis) {
- THR_Print("Thread %" Pd " has %" Pd " blocks\n",
- OSThread::ThreadIdToIntPtr(id_), blocks_.length());
- }
-}
-
-TimelineAnalysisThreadEventIterator::TimelineAnalysisThreadEventIterator(
- TimelineAnalysisThread* thread) {
- Reset(thread);
-}
-
-TimelineAnalysisThreadEventIterator::~TimelineAnalysisThreadEventIterator() {
- Reset(NULL);
-}
-
-void TimelineAnalysisThreadEventIterator::Reset(
- TimelineAnalysisThread* thread) {
- current_ = NULL;
- thread_ = thread;
- block_cursor_ = 0;
- event_cursor_ = 0;
- if (thread_ == NULL) {
- return;
- }
- if (thread_->NumBlocks() == 0) {
- return;
- }
- TimelineEventBlock* block = thread_->At(block_cursor_);
- ASSERT(!block->IsEmpty());
- current_ = block->At(event_cursor_++);
-}
-
-bool TimelineAnalysisThreadEventIterator::HasNext() const {
- return current_ != NULL;
-}
-
-TimelineEvent* TimelineAnalysisThreadEventIterator::Next() {
- ASSERT(current_ != NULL);
- TimelineEvent* r = current_;
- current_ = NULL;
-
- TimelineEventBlock* block = thread_->At(block_cursor_);
- if (event_cursor_ == block->length()) {
- // Reached the end of this block, move to the next.
- block_cursor_++;
- if (block_cursor_ == thread_->NumBlocks()) {
- // Exhausted our supply of blocks.
- return r;
- }
- // Grab next block.
- block = thread_->At(block_cursor_);
- event_cursor_ = 0;
- ASSERT(!block->IsEmpty());
- }
- current_ = block->At(event_cursor_++);
- return r;
-}
-
-TimelineAnalysis::TimelineAnalysis(Zone* zone,
- Isolate* isolate,
- TimelineEventRecorder* recorder)
- : zone_(zone),
- isolate_(isolate),
- recorder_(recorder),
- has_error_(false),
- error_msg_(NULL) {
- ASSERT(zone_ != NULL);
- ASSERT(isolate_ != NULL);
- ASSERT(recorder_ != NULL);
-}
-
-TimelineAnalysis::~TimelineAnalysis() {}
-
-void TimelineAnalysis::BuildThreads() {
- DiscoverThreads();
- FinalizeThreads();
-}
-
-TimelineAnalysisThread* TimelineAnalysis::GetThread(ThreadId tid) {
- // Linear lookup because we expect N (# of threads in an isolate) to be small.
- for (intptr_t i = 0; i < threads_.length(); i++) {
- TimelineAnalysisThread* thread = threads_.At(i);
- ASSERT(thread != NULL);
- if (thread->id() == tid) {
- return thread;
- }
- }
- return NULL;
-}
-
-TimelineAnalysisThread* TimelineAnalysis::GetOrAddThread(ThreadId tid) {
- TimelineAnalysisThread* thread = GetThread(tid);
- if (thread != NULL) {
- return thread;
- }
- // New thread.
- thread = new TimelineAnalysisThread(tid);
- threads_.Add(thread);
- return thread;
-}
-
-void TimelineAnalysis::DiscoverThreads() {
- TimelineEventBlockIterator it(recorder_);
- while (it.HasNext()) {
- TimelineEventBlock* block = it.Next();
- ASSERT(block != NULL);
- if (block->IsEmpty()) {
- // Skip empty blocks.
- continue;
- }
- if (!block->CheckBlock()) {
- if (FLAG_trace_timeline_analysis) {
- THR_Print("DiscoverThreads block %" Pd
- " "
- "violates invariants.\n",
- block->block_index());
- }
- SetError("Block %" Pd
- " violates invariants. See "
- "TimelineEventBlock::CheckBlock",
- block->block_index());
- return;
- }
- TimelineAnalysisThread* thread = GetOrAddThread(block->thread_id());
- ASSERT(thread != NULL);
- thread->AddBlock(block);
- }
-}
-
-void TimelineAnalysis::FinalizeThreads() {
- for (intptr_t i = 0; i < threads_.length(); i++) {
- TimelineAnalysisThread* thread = threads_.At(i);
- ASSERT(thread != NULL);
- thread->Finalize();
- }
-}
-
-void TimelineAnalysis::SetError(const char* format, ...) {
- ASSERT(!has_error_);
- ASSERT(error_msg_ == NULL);
- has_error_ = true;
- va_list args;
- va_start(args, format);
- error_msg_ = zone_->VPrint(format, args);
- ASSERT(error_msg_ != NULL);
- if (FLAG_trace_timeline_analysis) {
- OS::PrintErr("TimelineAnalysis error = %s\n", error_msg_);
- }
-}
-
-TimelineLabelPauseInfo::TimelineLabelPauseInfo(const char* name)
- : name_(name),
- inclusive_micros_(0),
- exclusive_micros_(0),
- max_inclusive_micros_(0),
- max_exclusive_micros_(0) {
- ASSERT(name_ != NULL);
-}
-
-void TimelineLabelPauseInfo::OnPush(int64_t micros, bool already_on_stack) {
- UpdateInclusiveMicros(micros, already_on_stack);
-}
-
-void TimelineLabelPauseInfo::OnPop(int64_t exclusive_micros) {
- UpdateExclusiveMicros(exclusive_micros);
-}
-
-void TimelineLabelPauseInfo::OnBeginPop(int64_t inclusive_micros,
- int64_t exclusive_micros,
- bool already_on_stack) {
- UpdateInclusiveMicros(inclusive_micros, already_on_stack);
- UpdateExclusiveMicros(exclusive_micros);
-}
-
-void TimelineLabelPauseInfo::UpdateInclusiveMicros(int64_t inclusive_micros,
- bool already_on_stack) {
- if (!already_on_stack) {
- // Only adjust inclusive counts if we aren't already on the stack.
- add_inclusive_micros(inclusive_micros);
- if (inclusive_micros > max_inclusive_micros_) {
- max_inclusive_micros_ = inclusive_micros;
- }
- }
-}
-
-void TimelineLabelPauseInfo::UpdateExclusiveMicros(int64_t exclusive_micros) {
- add_exclusive_micros(exclusive_micros);
- if (exclusive_micros > max_exclusive_micros_) {
- max_exclusive_micros_ = exclusive_micros;
- }
-}
-
-void TimelineLabelPauseInfo::Aggregate(
- const TimelineLabelPauseInfo* thread_pause_info) {
- ASSERT(thread_pause_info != NULL);
- inclusive_micros_ += thread_pause_info->inclusive_micros_;
- exclusive_micros_ += thread_pause_info->exclusive_micros_;
- if (max_inclusive_micros_ < thread_pause_info->max_inclusive_micros_) {
- max_inclusive_micros_ = thread_pause_info->max_inclusive_micros_;
- }
- if (max_exclusive_micros_ < thread_pause_info->max_exclusive_micros_) {
- max_exclusive_micros_ = thread_pause_info->max_exclusive_micros_;
- }
-}
-
-TimelinePauses::TimelinePauses(Zone* zone,
- Isolate* isolate,
- TimelineEventRecorder* recorder)
- : TimelineAnalysis(zone, isolate, recorder) {}
-
-void TimelinePauses::Setup() {
- BuildThreads();
-}
-
-void TimelinePauses::CalculatePauseTimesForThread(ThreadId tid) {
- if (has_error()) {
- return;
- }
- TimelineAnalysisThread* thread = GetThread(tid);
- if (thread == NULL) {
- SetError("Thread %" Pd " does not exist.", OSThread::ThreadIdToIntPtr(tid));
- return;
- }
- ProcessThread(thread);
-}
-
-TimelineLabelPauseInfo* TimelinePauses::GetLabelPauseInfo(
- const char* name) const {
- ASSERT(name != NULL);
- // Linear lookup because we expect N (# of labels in an isolate) to be small.
- for (intptr_t i = 0; i < labels_.length(); i++) {
- TimelineLabelPauseInfo* label = labels_.At(i);
- if (strcmp(label->name(), name) == 0) {
- return label;
- }
- }
- return NULL;
-}
-
-int64_t TimelinePauses::InclusiveTime(const char* name) const {
- TimelineLabelPauseInfo* pause_info = GetLabelPauseInfo(name);
- ASSERT(pause_info != NULL);
- return pause_info->inclusive_micros();
-}
-
-int64_t TimelinePauses::ExclusiveTime(const char* name) const {
- TimelineLabelPauseInfo* pause_info = GetLabelPauseInfo(name);
- ASSERT(pause_info != NULL);
- return pause_info->exclusive_micros();
-}
-
-int64_t TimelinePauses::MaxInclusiveTime(const char* name) const {
- TimelineLabelPauseInfo* pause_info = GetLabelPauseInfo(name);
- ASSERT(pause_info != NULL);
- return pause_info->max_inclusive_micros();
-}
-
-int64_t TimelinePauses::MaxExclusiveTime(const char* name) const {
- TimelineLabelPauseInfo* pause_info = GetLabelPauseInfo(name);
- ASSERT(pause_info != NULL);
- return pause_info->max_exclusive_micros();
-}
-
-void TimelinePauses::ProcessThread(TimelineAnalysisThread* thread) {
- ASSERT(thread != NULL);
- stack_.Clear();
- labels_.Clear();
-
- TimelineAnalysisThreadEventIterator it(thread);
- if (FLAG_trace_timeline_analysis) {
- THR_Print(">>> TimelinePauses::ProcessThread %" Pd "\n",
- OSThread::ThreadIdToIntPtr(thread->id()));
- }
- intptr_t event_count = 0;
- while (!has_error() && it.HasNext()) {
- TimelineEvent* event = it.Next();
- if (event->isolate_id() != isolate_->main_port()) {
- // Skip events that do not belong to the isolate.
- continue;
- }
- if (event->IsFinishedDuration()) {
- int64_t start = event->TimeOrigin();
- PopFinishedDurations(start);
- if (!CheckStack(event)) {
- SetError("Duration check fail.");
- return;
- }
- event_count++;
- Push(event);
- } else if (event->IsBeginOrEnd()) {
- event_count++;
- if (event->IsBegin()) {
- PopFinishedDurations(event->TimeOrigin());
- Push(event);
- } else {
- ASSERT(event->IsEnd());
- PopFinishedDurations(event->TimeOrigin());
- PopBegin(event->label(), event->TimeOrigin());
- }
- } else {
- // Skip other event kinds.
- }
- }
- // Pop remaining duration stack.
- PopFinishedDurations(kMaxInt64);
- if (FLAG_trace_timeline_analysis) {
- THR_Print("<<< TimelinePauses::ProcessThread %" Pd " had %" Pd " events\n",
- OSThread::ThreadIdToIntPtr(thread->id()), event_count);
- }
-}
-
-// Verify that |event| is contained within all parent events on the stack.
-bool TimelinePauses::CheckStack(TimelineEvent* event) {
- ASSERT(event != NULL);
- for (intptr_t i = 0; i < stack_.length(); i++) {
- const StackItem& slot = stack_.At(i);
- if (slot.event->IsDuration()) {
- if (!slot.event->DurationContains(event)) {
- return false;
- }
- } else {
- ASSERT(slot.event->IsBegin());
- if (slot.event->TimeOrigin() > event->TimeOrigin()) {
- return false;
- }
- }
- }
- return true;
-}
-
-void TimelinePauses::PopFinishedDurations(int64_t start) {
- while (stack_.length() > 0) {
- const StackItem& top = stack_.Last();
- if (top.event->IsDuration() && top.event->DurationFinishedBefore(start)) {
- top.pause_info->OnPop(top.exclusive_micros);
- // Top of stack completes before |start|.
- stack_.RemoveLast();
- if (FLAG_trace_timeline_analysis) {
- THR_Print("Popping %s (%" Pd64 " <= %" Pd64 ")\n", top.event->label(),
- top.event->TimeEnd(), start);
- }
- } else {
- return;
- }
- }
-}
-
-void TimelinePauses::PopBegin(const char* label, int64_t end) {
- if (stack_.length() == 0) {
- SetError("PopBegin(%s, ...) called with empty stack.", label);
- return;
- }
- ASSERT(stack_.length() > 0);
- const StackItem& top = stack_.Last();
- const char* top_label = top.event->label();
- const bool top_is_begin = top.event->IsBegin();
- const int64_t start = top.event->TimeOrigin();
- if (start > end) {
- SetError("Bad time stamps for PopBegin(%s, ...) %" Pd64 " > %" Pd64 "",
- label, start, end);
- return;
- }
- const int64_t duration = end - start;
- // Sanity checks.
- if (strcmp(top_label, label) != 0) {
- SetError("PopBegin(%s, ...) called with %s at the top of stack", label,
- top.event->label());
- return;
- }
- if (!top_is_begin) {
- SetError("kEnd event not paired with kBegin event for label %s", label);
- return;
- }
- // Pop this event.
- // Add duration to exclusive micros.
- if (FLAG_trace_timeline_analysis) {
- THR_Print("Popping %s (%" Pd64 ")\n", top.event->label(), duration);
- }
- const int64_t exclusive_micros = top.exclusive_micros + duration;
- stack_.RemoveLast();
- top.pause_info->OnBeginPop(duration, exclusive_micros,
- IsLabelOnStack(top_label));
- if (StackDepth() > 0) {
- StackItem& top = GetStackTop();
- // |top| is under the popped |event|'s shadow, adjust the exclusive micros.
- top.exclusive_micros -= duration;
- }
-}
-
-void TimelinePauses::Push(TimelineEvent* event) {
- TimelineLabelPauseInfo* pause_info = GetOrAddLabelPauseInfo(event->label());
- ASSERT(pause_info != NULL);
- // |pause_info| will be running for |event->TimeDuration()|.
- if (FLAG_trace_timeline_analysis) {
- THR_Print("Pushing %s %" Pd64 " us\n", pause_info->name(),
- event->TimeDuration());
- }
- if (event->IsDuration()) {
- pause_info->OnPush(event->TimeDuration(), IsLabelOnStack(event->label()));
- if (StackDepth() > 0) {
- StackItem& top = GetStackTop();
- // |top| is under |event|'s shadow, adjust the exclusive micros.
- top.exclusive_micros -= event->TimeDuration();
- }
- // Push onto the stack.
- StackItem item;
- item.event = event;
- item.pause_info = pause_info;
- item.exclusive_micros = event->TimeDuration();
- stack_.Add(item);
- } else {
- ASSERT(event->IsBegin());
- pause_info->OnPush(0, IsLabelOnStack(event->label()));
- // Push onto the stack.
- StackItem item;
- item.event = event;
- item.pause_info = pause_info;
- item.exclusive_micros = 0;
- stack_.Add(item);
- }
-}
-
-bool TimelinePauses::IsLabelOnStack(const char* label) const {
- ASSERT(label != NULL);
- for (intptr_t i = 0; i < stack_.length(); i++) {
- const StackItem& slot = stack_.At(i);
- if (strcmp(slot.event->label(), label) == 0) {
- return true;
- }
- }
- return false;
-}
-
-intptr_t TimelinePauses::StackDepth() const {
- return stack_.length();
-}
-
-TimelinePauses::StackItem& TimelinePauses::GetStackTop() {
- ASSERT(stack_.length() > 0);
- return stack_.Last();
-}
-
-TimelineLabelPauseInfo* TimelinePauses::GetOrAddLabelPauseInfo(
- const char* name) {
- ASSERT(name != NULL);
- TimelineLabelPauseInfo* pause_info = GetLabelPauseInfo(name);
- if (pause_info != NULL) {
- return pause_info;
- }
- // New label.
- pause_info = new TimelineLabelPauseInfo(name);
- labels_.Add(pause_info);
- return pause_info;
-}
-
-TimelinePauseTrace::TimelinePauseTrace() {}
-
-TimelinePauseTrace::~TimelinePauseTrace() {}
-
-void TimelinePauseTrace::Print() {
- Thread* thread = Thread::Current();
- ASSERT(thread != NULL);
- Isolate* isolate = thread->isolate();
- ASSERT(isolate != NULL);
- Zone* zone = thread->zone();
- ASSERT(zone != NULL);
- TimelineEventRecorder* recorder = Timeline::recorder();
- ASSERT(recorder != NULL);
- TimelinePauses pauses(zone, isolate, recorder);
- pauses.Setup();
-
- THR_Print("Timing for isolate (%" Pd64 ") '%s' (from %" Pd " threads)\n",
- static_cast<int64_t>(isolate->main_port()), isolate->name(),
- pauses.NumThreads());
- THR_Print("\n");
- for (intptr_t t_idx = 0; t_idx < pauses.NumThreads(); t_idx++) {
- TimelineAnalysisThread* tat = pauses.At(t_idx);
- ASSERT(tat != NULL);
- pauses.CalculatePauseTimesForThread(tat->id());
- THR_Print("Thread %" Pd " (%" Pd "):\n", t_idx,
- OSThread::ThreadIdToIntPtr(tat->id()));
- for (intptr_t j = 0; j < pauses.NumPauseInfos(); j++) {
- const TimelineLabelPauseInfo* pause_info = pauses.PauseInfoAt(j);
- ASSERT(pause_info != NULL);
- Aggregate(pause_info);
- PrintPauseInfo(pause_info);
- }
- THR_Print("\n");
- }
- THR_Print("Totals:\n");
- for (intptr_t i = 0; i < isolate_labels_.length(); i++) {
- TimelineLabelPauseInfo* pause_info = isolate_labels_.At(i);
- ASSERT(pause_info != NULL);
- PrintPauseInfo(pause_info);
- }
- THR_Print("\n");
-}
-
-TimelineLabelPauseInfo* TimelinePauseTrace::GetOrAddLabelPauseInfo(
- const char* name) {
- ASSERT(name != NULL);
- // Linear lookup because we expect N (# of labels in an isolate) to be small.
- for (intptr_t i = 0; i < isolate_labels_.length(); i++) {
- TimelineLabelPauseInfo* label = isolate_labels_.At(i);
- if (strcmp(label->name(), name) == 0) {
- return label;
- }
- }
- // New label.
- TimelineLabelPauseInfo* pause_info = new TimelineLabelPauseInfo(name);
- isolate_labels_.Add(pause_info);
- return pause_info;
-}
-
-void TimelinePauseTrace::Aggregate(
- const TimelineLabelPauseInfo* thread_pause_info) {
- ASSERT(thread_pause_info != NULL);
- TimelineLabelPauseInfo* isolate_pause_info =
- GetOrAddLabelPauseInfo(thread_pause_info->name());
- ASSERT(isolate_pause_info != NULL);
- isolate_pause_info->Aggregate(thread_pause_info);
-}
-
-void TimelinePauseTrace::PrintPauseInfo(
- const TimelineLabelPauseInfo* pause_info) {
- ASSERT(pause_info != NULL);
- THR_Print("%s : ", pause_info->name());
- THR_Print("%.3f ms total on stack; ",
- MicrosecondsToMilliseconds(pause_info->inclusive_micros()));
- THR_Print("%.3f ms total executing; ",
- MicrosecondsToMilliseconds(pause_info->exclusive_micros()));
- THR_Print("%.3f ms max on stack; ",
- MicrosecondsToMilliseconds(pause_info->max_inclusive_micros()));
- THR_Print("%.3f ms max executing.\n",
- MicrosecondsToMilliseconds(pause_info->max_exclusive_micros()));
-}
-
-#endif // !PRODUCT
-
-} // namespace dart
diff --git a/runtime/vm/timeline_analysis.h b/runtime/vm/timeline_analysis.h
deleted file mode 100644
index bb27436..0000000
--- a/runtime/vm/timeline_analysis.h
+++ /dev/null
@@ -1,206 +0,0 @@
-// Copyright (c) 2015, 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_VM_TIMELINE_ANALYSIS_H_
-#define RUNTIME_VM_TIMELINE_ANALYSIS_H_
-
-#include "vm/growable_array.h"
-#include "vm/timeline.h"
-
-namespace dart {
-
-class TimelineAnalysisThread : public ZoneAllocated {
- public:
- explicit TimelineAnalysisThread(ThreadId id);
- ~TimelineAnalysisThread();
-
- ThreadId id() const { return id_; }
-
- intptr_t NumBlocks() const { return blocks_.length(); }
-
- TimelineEventBlock* At(intptr_t i) const { return blocks_.At(i); }
-
- private:
- void AddBlock(TimelineEventBlock* block);
- void Finalize();
-
- const ThreadId id_;
- ZoneGrowableArray<TimelineEventBlock*> blocks_;
-
- friend class TimelineAnalysis;
-};
-
-class TimelineAnalysisThreadEventIterator : public ValueObject {
- public:
- explicit TimelineAnalysisThreadEventIterator(TimelineAnalysisThread* thread);
- ~TimelineAnalysisThreadEventIterator();
-
- void Reset(TimelineAnalysisThread* thread);
-
- bool HasNext() const;
-
- TimelineEvent* Next();
-
- private:
- TimelineAnalysisThread* thread_;
- TimelineEvent* current_;
- intptr_t block_cursor_;
- intptr_t event_cursor_;
-};
-
-// Base of all timeline analysis classes. Base functionality:
-// - discovery of all thread ids in a recording.
-// - collecting all ThreadEventBlocks by thread id.
-class TimelineAnalysis : public ValueObject {
- public:
- TimelineAnalysis(Zone* zone,
- Isolate* isolate,
- TimelineEventRecorder* recorder);
- ~TimelineAnalysis();
-
- void BuildThreads();
-
- intptr_t NumThreads() const { return threads_.length(); }
-
- TimelineAnalysisThread* At(intptr_t i) const { return threads_[i]; }
-
- TimelineAnalysisThread* GetThread(ThreadId tid);
-
- bool has_error() const { return has_error_; }
-
- const char* error_msg() const { return error_msg_; }
-
- protected:
- TimelineAnalysisThread* GetOrAddThread(ThreadId tid);
-
- void DiscoverThreads();
- void FinalizeThreads();
-
- void SetError(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
-
- Zone* zone_;
- Isolate* isolate_;
- TimelineEventRecorder* recorder_;
- bool has_error_;
- const char* error_msg_;
-
- ZoneGrowableArray<TimelineAnalysisThread*> threads_;
-};
-
-class TimelineLabelPauseInfo : public ZoneAllocated {
- public:
- explicit TimelineLabelPauseInfo(const char* name);
-
- const char* name() const { return name_; }
-
- int64_t inclusive_micros() const { return inclusive_micros_; }
-
- int64_t exclusive_micros() const { return exclusive_micros_; }
-
- int64_t max_inclusive_micros() const { return max_inclusive_micros_; }
-
- int64_t max_exclusive_micros() const { return max_exclusive_micros_; }
-
- private:
- // Adjusts |inclusive_micros_| and |exclusive_micros_| by |micros|.
- // Also, may adjust, max_inclusive_micros_.
- void OnPush(int64_t micros, bool already_on_stack);
-
- // Adjusts |exclusive_micros_| by |exclusive_micros|.
- // Also, may adjust |max_exclusive_micros_|.
- void OnPop(int64_t exclusive_micros);
-
- // Adjusts |inclusive_micros_| and |exclusive_micros_| by |micros|.
- // Also, may adjust, |max_inclusive_micros_|.
- void OnBeginPop(int64_t inclusive_micros,
- int64_t exclusive_micros,
- bool already_on_stack);
-
- void UpdateInclusiveMicros(int64_t inclusive_micros, bool already_on_stack);
- void UpdateExclusiveMicros(int64_t exclusive_micros);
-
- // Adjust inclusive micros.
- void add_inclusive_micros(int64_t delta_micros) {
- inclusive_micros_ += delta_micros;
- ASSERT(inclusive_micros_ >= 0);
- }
-
- // Adjust exclusive micros.
- void add_exclusive_micros(int64_t delta_micros) {
- exclusive_micros_ += delta_micros;
- ASSERT(exclusive_micros_ >= 0);
- }
-
- void Aggregate(const TimelineLabelPauseInfo* thread_pause_info);
-
- const char* name_;
- int64_t inclusive_micros_;
- int64_t exclusive_micros_;
- int64_t max_inclusive_micros_;
- int64_t max_exclusive_micros_;
-
- friend class TimelinePauses;
- friend class TimelinePauseTrace;
-};
-
-class TimelinePauses : public TimelineAnalysis {
- public:
- TimelinePauses(Zone* zone, Isolate* isolate, TimelineEventRecorder* recorder);
-
- void Setup();
-
- void CalculatePauseTimesForThread(ThreadId tid);
-
- TimelineLabelPauseInfo* GetLabelPauseInfo(const char* name) const;
-
- int64_t InclusiveTime(const char* name) const;
- int64_t ExclusiveTime(const char* name) const;
- int64_t MaxInclusiveTime(const char* name) const;
- int64_t MaxExclusiveTime(const char* name) const;
-
- intptr_t NumPauseInfos() const { return labels_.length(); }
-
- const TimelineLabelPauseInfo* PauseInfoAt(intptr_t i) const {
- return labels_.At(i);
- }
-
- private:
- struct StackItem {
- TimelineEvent* event;
- TimelineLabelPauseInfo* pause_info;
- int64_t exclusive_micros;
- };
-
- void ProcessThread(TimelineAnalysisThread* thread);
- bool CheckStack(TimelineEvent* event);
- void PopFinishedDurations(int64_t start);
- void PopBegin(const char* label, int64_t end);
- void Push(TimelineEvent* event);
- bool IsLabelOnStack(const char* label) const;
- intptr_t StackDepth() const;
- StackItem& GetStackTop();
- TimelineLabelPauseInfo* GetOrAddLabelPauseInfo(const char* name);
-
- ZoneGrowableArray<StackItem> stack_;
- ZoneGrowableArray<TimelineLabelPauseInfo*> labels_;
-};
-
-class TimelinePauseTrace : public ValueObject {
- public:
- TimelinePauseTrace();
- ~TimelinePauseTrace();
-
- void Print();
-
- private:
- TimelineLabelPauseInfo* GetOrAddLabelPauseInfo(const char* name);
- void Aggregate(const TimelineLabelPauseInfo* thread_pause_info);
- void PrintPauseInfo(const TimelineLabelPauseInfo* pause_info);
-
- ZoneGrowableArray<TimelineLabelPauseInfo*> isolate_labels_;
-};
-
-} // namespace dart
-
-#endif // RUNTIME_VM_TIMELINE_ANALYSIS_H_
diff --git a/runtime/vm/timeline_test.cc b/runtime/vm/timeline_test.cc
index ba04a0b..f171921 100644
--- a/runtime/vm/timeline_test.cc
+++ b/runtime/vm/timeline_test.cc
@@ -10,7 +10,6 @@
#include "vm/dart_api_state.h"
#include "vm/globals.h"
#include "vm/timeline.h"
-#include "vm/timeline_analysis.h"
#include "vm/unit_test.h"
namespace dart {
@@ -341,127 +340,6 @@
EXPECT_EQ(1, override.recorder()->CountFor(TimelineEvent::kAsyncEnd));
}
-static bool LabelMatch(TimelineEvent* event, const char* label) {
- ASSERT(event != NULL);
- return strcmp(event->label(), label) == 0;
-}
-
-TEST_CASE(TimelineAnalysis_ThreadBlockCount) {
- TimelineRecorderOverride<TimelineEventEndlessRecorder> override;
- ASSERT(Timeline::recorder() != NULL);
- // Blocks owned by thread "1".
- TimelineEventBlock* block_1_0 = Timeline::recorder()->GetNewBlock();
- TimelineTestHelper::SetBlockThread(block_1_0, 1);
- TimelineEventBlock* block_1_1 = Timeline::recorder()->GetNewBlock();
- TimelineTestHelper::SetBlockThread(block_1_1, 1);
- TimelineEventBlock* block_1_2 = Timeline::recorder()->GetNewBlock();
- TimelineTestHelper::SetBlockThread(block_1_2, 1);
- // Blocks owned by thread "2".
- TimelineEventBlock* block_2_0 = Timeline::recorder()->GetNewBlock();
- TimelineTestHelper::SetBlockThread(block_2_0, 2);
- // Blocks owned by thread "3".
- TimelineEventBlock* block_3_0 = Timeline::recorder()->GetNewBlock();
- TimelineTestHelper::SetBlockThread(block_3_0, 3);
- USE(block_3_0);
-
- // Add events to each block for thread 1.
- TimelineTestHelper::FakeThreadEvent(block_1_2, 1, "B1");
- TimelineTestHelper::FakeThreadEvent(block_1_2, 1, "B2");
- TimelineTestHelper::FakeThreadEvent(block_1_2, 1, "B3");
- // Sleep to ensure timestamps differ.
- OS::Sleep(32);
- TimelineTestHelper::FakeThreadEvent(block_1_0, 1, "A1");
- OS::Sleep(32);
- TimelineTestHelper::FakeThreadEvent(block_1_1, 1, "C1");
- TimelineTestHelper::FakeThreadEvent(block_1_1, 1, "C2");
- OS::Sleep(32);
-
- // Add events to each block for thread 2.
- TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "A");
- TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "B");
- TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "C");
- TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "D");
- TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "E");
- TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "F");
-
- Zone* zone = thread->zone();
- Isolate* isolate = thread->isolate();
-
- // Discover threads in Timeline::recorder().
- TimelineAnalysis ta(zone, isolate, Timeline::recorder());
- ta.BuildThreads();
- EXPECT(!ta.has_error());
- // block_3_0 is never used by a thread, so we only have two threads.
- EXPECT_EQ(2, ta.NumThreads());
-
- // Extract both threads.
- TimelineAnalysisThread* thread_1 =
- ta.GetThread(OSThread::ThreadIdFromIntPtr(1));
- TimelineAnalysisThread* thread_2 =
- ta.GetThread(OSThread::ThreadIdFromIntPtr(2));
- EXPECT_EQ(OSThread::ThreadIdFromIntPtr(1), thread_1->id());
- EXPECT_EQ(OSThread::ThreadIdFromIntPtr(2), thread_2->id());
-
- // Thread "1" should have three blocks.
- EXPECT_EQ(3, thread_1->NumBlocks());
-
- // Verify that blocks for thread "1" are sorted based on start time.
- EXPECT_EQ(thread_1->At(0), block_1_2);
- EXPECT_EQ(thread_1->At(1), block_1_0);
- EXPECT_EQ(thread_1->At(2), block_1_1);
-
- // Verify that block_1_2 has three events.
- EXPECT_EQ(3, block_1_2->length());
-
- // Verify that block_1_0 has one events.
- EXPECT_EQ(1, block_1_0->length());
-
- // Verify that block_1_1 has two events.
- EXPECT_EQ(2, block_1_1->length());
-
- // Thread '2" should have one block.'
- EXPECT_EQ(1, thread_2->NumBlocks());
- EXPECT_EQ(thread_2->At(0), block_2_0);
- // Verify that block_2_0 has six events.
- EXPECT_EQ(6, block_2_0->length());
-
- {
- TimelineAnalysisThreadEventIterator it(thread_1);
- // Six events spread across three blocks.
- EXPECT(it.HasNext());
- EXPECT(LabelMatch(it.Next(), "B1"));
- EXPECT(it.HasNext());
- EXPECT(LabelMatch(it.Next(), "B2"));
- EXPECT(it.HasNext());
- EXPECT(LabelMatch(it.Next(), "B3"));
- EXPECT(it.HasNext());
- EXPECT(LabelMatch(it.Next(), "A1"));
- EXPECT(it.HasNext());
- EXPECT(LabelMatch(it.Next(), "C1"));
- EXPECT(it.HasNext());
- EXPECT(LabelMatch(it.Next(), "C2"));
- EXPECT(!it.HasNext());
- }
-
- {
- TimelineAnalysisThreadEventIterator it(thread_2);
- // Six events spread across three blocks.
- EXPECT(it.HasNext());
- EXPECT(LabelMatch(it.Next(), "A"));
- EXPECT(it.HasNext());
- EXPECT(LabelMatch(it.Next(), "B"));
- EXPECT(it.HasNext());
- EXPECT(LabelMatch(it.Next(), "C"));
- EXPECT(it.HasNext());
- EXPECT(LabelMatch(it.Next(), "D"));
- EXPECT(it.HasNext());
- EXPECT(LabelMatch(it.Next(), "E"));
- EXPECT(it.HasNext());
- EXPECT(LabelMatch(it.Next(), "F"));
- EXPECT(!it.HasNext());
- }
-}
-
TEST_CASE(TimelineRingRecorderJSONOrder) {
TimelineStream stream("testStream", "testStream", true);
@@ -497,426 +375,6 @@
EXPECT(alpha < beta);
}
-TEST_CASE(TimelinePauses_Basic) {
- Zone* zone = thread->zone();
- Isolate* isolate = thread->isolate();
- OSThread* os_thread = thread->os_thread();
- ASSERT(os_thread != NULL);
- ThreadId tid = os_thread->trace_id();
-
- {
- TimelineRecorderOverride<TimelineEventEndlessRecorder> override;
- // Test case.
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "a", 0, 10);
- {
- TimelinePauses pauses(zone, isolate, Timeline::recorder());
- pauses.Setup();
- pauses.CalculatePauseTimesForThread(tid);
- EXPECT(!pauses.has_error());
- EXPECT_EQ(10, pauses.InclusiveTime("a"));
- EXPECT_EQ(10, pauses.ExclusiveTime("a"));
- EXPECT_EQ(10, pauses.MaxInclusiveTime("a"));
- EXPECT_EQ(10, pauses.MaxExclusiveTime("a"));
- }
- }
-
- {
- TimelineRecorderOverride<TimelineEventEndlessRecorder> override;
-
- // Test case.
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "a", 0, 10);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 0, 10);
- {
- TimelinePauses pauses(zone, isolate, Timeline::recorder());
- pauses.Setup();
- pauses.CalculatePauseTimesForThread(tid);
- EXPECT(!pauses.has_error());
- EXPECT_EQ(10, pauses.InclusiveTime("a"));
- EXPECT_EQ(0, pauses.ExclusiveTime("a"));
- EXPECT_EQ(10, pauses.MaxInclusiveTime("a"));
- EXPECT_EQ(0, pauses.MaxExclusiveTime("a"));
- EXPECT_EQ(10, pauses.InclusiveTime("b"));
- EXPECT_EQ(10, pauses.ExclusiveTime("b"));
- EXPECT_EQ(10, pauses.MaxInclusiveTime("b"));
- EXPECT_EQ(10, pauses.MaxExclusiveTime("b"));
- }
- }
-
- {
- TimelineRecorderOverride<TimelineEventEndlessRecorder> override;
-
- // Test case.
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "a", 0, 10);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 1, 8);
- {
- TimelinePauses pauses(zone, isolate, Timeline::recorder());
- pauses.Setup();
- pauses.CalculatePauseTimesForThread(tid);
- EXPECT(!pauses.has_error());
- EXPECT_EQ(10, pauses.InclusiveTime("a"));
- EXPECT_EQ(3, pauses.ExclusiveTime("a"));
- EXPECT_EQ(10, pauses.MaxInclusiveTime("a"));
- EXPECT_EQ(3, pauses.MaxExclusiveTime("a"));
- EXPECT_EQ(7, pauses.InclusiveTime("b"));
- EXPECT_EQ(7, pauses.ExclusiveTime("b"));
- EXPECT_EQ(7, pauses.MaxInclusiveTime("b"));
- EXPECT_EQ(7, pauses.MaxExclusiveTime("b"));
- }
- }
-
- {
- TimelineRecorderOverride<TimelineEventEndlessRecorder> override;
-
- // Test case.
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "a", 0, 10);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 0, 1);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 1, 2);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 2, 3);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 3, 4);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 4, 5);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 5, 6);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 6, 7);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 7, 8);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 8, 9);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 9, 10);
- {
- TimelinePauses pauses(zone, isolate, Timeline::recorder());
- pauses.Setup();
- pauses.CalculatePauseTimesForThread(tid);
- EXPECT(!pauses.has_error());
- EXPECT_EQ(10, pauses.InclusiveTime("a"));
- EXPECT_EQ(0, pauses.ExclusiveTime("a"));
- EXPECT_EQ(10, pauses.MaxInclusiveTime("a"));
- EXPECT_EQ(0, pauses.MaxExclusiveTime("a"));
- EXPECT_EQ(10, pauses.InclusiveTime("b"));
- EXPECT_EQ(10, pauses.ExclusiveTime("b"));
- EXPECT_EQ(1, pauses.MaxInclusiveTime("b"));
- EXPECT_EQ(1, pauses.MaxExclusiveTime("b"));
- }
- }
-
- {
- TimelineRecorderOverride<TimelineEventEndlessRecorder> override;
-
- // Test case.
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "a", 0, 10);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 0, 5);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "c", 1, 4);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "d", 5, 10);
-
- {
- TimelinePauses pauses(zone, isolate, Timeline::recorder());
- pauses.Setup();
- pauses.CalculatePauseTimesForThread(tid);
- EXPECT(!pauses.has_error());
- EXPECT_EQ(10, pauses.InclusiveTime("a"));
- EXPECT_EQ(0, pauses.ExclusiveTime("a"));
- EXPECT_EQ(10, pauses.MaxInclusiveTime("a"));
- EXPECT_EQ(0, pauses.MaxExclusiveTime("a"));
- EXPECT_EQ(5, pauses.InclusiveTime("b"));
- EXPECT_EQ(2, pauses.ExclusiveTime("b"));
- EXPECT_EQ(5, pauses.MaxInclusiveTime("b"));
- EXPECT_EQ(2, pauses.MaxExclusiveTime("b"));
- EXPECT_EQ(3, pauses.InclusiveTime("c"));
- EXPECT_EQ(3, pauses.ExclusiveTime("c"));
- EXPECT_EQ(3, pauses.MaxInclusiveTime("c"));
- EXPECT_EQ(3, pauses.MaxExclusiveTime("c"));
- EXPECT_EQ(5, pauses.InclusiveTime("d"));
- EXPECT_EQ(5, pauses.ExclusiveTime("d"));
- EXPECT_EQ(5, pauses.MaxInclusiveTime("d"));
- EXPECT_EQ(5, pauses.MaxExclusiveTime("d"));
- }
- }
-
- {
- TimelineRecorderOverride<TimelineEventEndlessRecorder> override;
-
- // Test case.
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "a", 0, 10);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 1, 9);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "c", 2, 8);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "d", 3, 7);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "e", 4, 6);
-
- {
- TimelinePauses pauses(zone, isolate, Timeline::recorder());
- pauses.Setup();
- pauses.CalculatePauseTimesForThread(tid);
- EXPECT(!pauses.has_error());
- EXPECT_EQ(10, pauses.InclusiveTime("a"));
- EXPECT_EQ(2, pauses.ExclusiveTime("a"));
- EXPECT_EQ(10, pauses.MaxInclusiveTime("a"));
- EXPECT_EQ(2, pauses.MaxExclusiveTime("a"));
- EXPECT_EQ(8, pauses.InclusiveTime("b"));
- EXPECT_EQ(2, pauses.ExclusiveTime("b"));
- EXPECT_EQ(8, pauses.MaxInclusiveTime("b"));
- EXPECT_EQ(2, pauses.MaxExclusiveTime("b"));
- EXPECT_EQ(6, pauses.InclusiveTime("c"));
- EXPECT_EQ(2, pauses.ExclusiveTime("c"));
- EXPECT_EQ(6, pauses.MaxInclusiveTime("c"));
- EXPECT_EQ(2, pauses.MaxExclusiveTime("c"));
- EXPECT_EQ(4, pauses.InclusiveTime("d"));
- EXPECT_EQ(2, pauses.ExclusiveTime("d"));
- EXPECT_EQ(4, pauses.MaxInclusiveTime("d"));
- EXPECT_EQ(2, pauses.MaxExclusiveTime("d"));
- EXPECT_EQ(2, pauses.InclusiveTime("e"));
- EXPECT_EQ(2, pauses.ExclusiveTime("e"));
- EXPECT_EQ(2, pauses.MaxInclusiveTime("e"));
- EXPECT_EQ(2, pauses.MaxExclusiveTime("e"));
- }
- }
-
- {
- TimelineRecorderOverride<TimelineEventEndlessRecorder> override;
-
- // Test case.
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "a", 0, 10);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "a", 1, 9);
-
- {
- TimelinePauses pauses(zone, isolate, Timeline::recorder());
- pauses.Setup();
- pauses.CalculatePauseTimesForThread(tid);
- EXPECT(!pauses.has_error());
- EXPECT_EQ(10, pauses.InclusiveTime("a"));
- EXPECT_EQ(10, pauses.ExclusiveTime("a"));
- EXPECT_EQ(10, pauses.MaxInclusiveTime("a"));
- EXPECT_EQ(8, pauses.MaxExclusiveTime("a"));
- }
- }
-}
-
-TEST_CASE(TimelinePauses_BeginEnd) {
- Zone* zone = thread->zone();
- Isolate* isolate = thread->isolate();
- OSThread* os_thread = thread->os_thread();
- ASSERT(os_thread != NULL);
- ThreadId tid = os_thread->trace_id();
-
- {
- TimelineRecorderOverride<TimelineEventEndlessRecorder> override;
-
- // Test case.
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "a", 0);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "a", 10);
-
- {
- TimelinePauses pauses(zone, isolate, Timeline::recorder());
- pauses.Setup();
- pauses.CalculatePauseTimesForThread(tid);
- EXPECT(!pauses.has_error());
- EXPECT_EQ(10, pauses.InclusiveTime("a"));
- EXPECT_EQ(10, pauses.ExclusiveTime("a"));
- EXPECT_EQ(10, pauses.MaxInclusiveTime("a"));
- EXPECT_EQ(10, pauses.MaxExclusiveTime("a"));
- }
- }
-
- {
- TimelineRecorderOverride<TimelineEventEndlessRecorder> override;
-
- // Test case.
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "a", 0);
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "b", 0);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "b", 10);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "a", 10);
-
- {
- TimelinePauses pauses(zone, isolate, Timeline::recorder());
- pauses.Setup();
- pauses.CalculatePauseTimesForThread(tid);
- EXPECT(!pauses.has_error());
- EXPECT_EQ(10, pauses.InclusiveTime("a"));
- EXPECT_EQ(0, pauses.ExclusiveTime("a"));
- EXPECT_EQ(10, pauses.MaxInclusiveTime("a"));
- EXPECT_EQ(0, pauses.MaxExclusiveTime("a"));
- EXPECT_EQ(10, pauses.InclusiveTime("b"));
- EXPECT_EQ(10, pauses.ExclusiveTime("b"));
- EXPECT_EQ(10, pauses.MaxInclusiveTime("b"));
- EXPECT_EQ(10, pauses.MaxExclusiveTime("b"));
- }
- }
-
- {
- TimelineRecorderOverride<TimelineEventEndlessRecorder> override;
-
- // Test case.
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "a", 0);
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "b", 1);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "b", 8);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "a", 10);
-
- {
- TimelinePauses pauses(zone, isolate, Timeline::recorder());
- pauses.Setup();
- pauses.CalculatePauseTimesForThread(tid);
- EXPECT(!pauses.has_error());
- EXPECT_EQ(10, pauses.InclusiveTime("a"));
- EXPECT_EQ(3, pauses.ExclusiveTime("a"));
- EXPECT_EQ(10, pauses.MaxInclusiveTime("a"));
- EXPECT_EQ(3, pauses.MaxExclusiveTime("a"));
- EXPECT_EQ(7, pauses.InclusiveTime("b"));
- EXPECT_EQ(7, pauses.ExclusiveTime("b"));
- EXPECT_EQ(7, pauses.MaxInclusiveTime("b"));
- EXPECT_EQ(7, pauses.MaxExclusiveTime("b"));
- }
- }
-
- {
- TimelineRecorderOverride<TimelineEventEndlessRecorder> override;
-
- // Test case.
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "a", 0);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 0, 1);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 1, 2);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 2, 3);
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "b", 3);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "b", 4);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 4, 5);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 5, 6);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 6, 7);
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "b", 7);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "b", 8);
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "b", 8);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "b", 9);
- TimelineTestHelper::FakeDuration(Timeline::recorder(), "b", 9, 10);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "a", 10);
-
- {
- TimelinePauses pauses(zone, isolate, Timeline::recorder());
- pauses.Setup();
- pauses.CalculatePauseTimesForThread(tid);
- EXPECT(!pauses.has_error());
- EXPECT_EQ(10, pauses.InclusiveTime("a"));
- EXPECT_EQ(0, pauses.ExclusiveTime("a"));
- EXPECT_EQ(10, pauses.MaxInclusiveTime("a"));
- EXPECT_EQ(0, pauses.MaxExclusiveTime("a"));
- EXPECT_EQ(10, pauses.InclusiveTime("b"));
- EXPECT_EQ(10, pauses.ExclusiveTime("b"));
- EXPECT_EQ(1, pauses.MaxInclusiveTime("b"));
- EXPECT_EQ(1, pauses.MaxExclusiveTime("b"));
- }
- }
-
- {
- TimelineRecorderOverride<TimelineEventEndlessRecorder> override;
-
- // Test case.
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "a", 0);
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "b", 0);
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "c", 1);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "c", 4);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "b", 5);
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "d", 5);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "d", 10);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "a", 10);
-
- {
- TimelinePauses pauses(zone, isolate, Timeline::recorder());
- pauses.Setup();
- pauses.CalculatePauseTimesForThread(tid);
- EXPECT(!pauses.has_error());
- EXPECT_EQ(10, pauses.InclusiveTime("a"));
- EXPECT_EQ(0, pauses.ExclusiveTime("a"));
- EXPECT_EQ(10, pauses.MaxInclusiveTime("a"));
- EXPECT_EQ(0, pauses.MaxExclusiveTime("a"));
- EXPECT_EQ(5, pauses.InclusiveTime("b"));
- EXPECT_EQ(2, pauses.ExclusiveTime("b"));
- EXPECT_EQ(5, pauses.MaxInclusiveTime("b"));
- EXPECT_EQ(2, pauses.MaxExclusiveTime("b"));
- EXPECT_EQ(3, pauses.InclusiveTime("c"));
- EXPECT_EQ(3, pauses.ExclusiveTime("c"));
- EXPECT_EQ(3, pauses.MaxInclusiveTime("c"));
- EXPECT_EQ(3, pauses.MaxExclusiveTime("c"));
- EXPECT_EQ(5, pauses.InclusiveTime("d"));
- EXPECT_EQ(5, pauses.ExclusiveTime("d"));
- EXPECT_EQ(5, pauses.MaxInclusiveTime("d"));
- EXPECT_EQ(5, pauses.MaxExclusiveTime("d"));
- }
- }
-
- {
- TimelineRecorderOverride<TimelineEventEndlessRecorder> override;
-
- // Test case.
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "a", 0);
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "b", 1);
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "c", 2);
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "d", 3);
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "e", 4);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "e", 6);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "d", 7);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "c", 8);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "b", 9);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "a", 10);
-
- {
- TimelinePauses pauses(zone, isolate, Timeline::recorder());
- pauses.Setup();
- pauses.CalculatePauseTimesForThread(tid);
- EXPECT(!pauses.has_error());
- EXPECT_EQ(10, pauses.InclusiveTime("a"));
- EXPECT_EQ(2, pauses.ExclusiveTime("a"));
- EXPECT_EQ(10, pauses.MaxInclusiveTime("a"));
- EXPECT_EQ(2, pauses.MaxExclusiveTime("a"));
- EXPECT_EQ(8, pauses.InclusiveTime("b"));
- EXPECT_EQ(2, pauses.ExclusiveTime("b"));
- EXPECT_EQ(8, pauses.MaxInclusiveTime("b"));
- EXPECT_EQ(2, pauses.MaxExclusiveTime("b"));
- EXPECT_EQ(6, pauses.InclusiveTime("c"));
- EXPECT_EQ(2, pauses.ExclusiveTime("c"));
- EXPECT_EQ(6, pauses.MaxInclusiveTime("c"));
- EXPECT_EQ(2, pauses.MaxExclusiveTime("c"));
- EXPECT_EQ(4, pauses.InclusiveTime("d"));
- EXPECT_EQ(2, pauses.ExclusiveTime("d"));
- EXPECT_EQ(4, pauses.MaxInclusiveTime("d"));
- EXPECT_EQ(2, pauses.MaxExclusiveTime("d"));
- EXPECT_EQ(2, pauses.InclusiveTime("e"));
- EXPECT_EQ(2, pauses.ExclusiveTime("e"));
- EXPECT_EQ(2, pauses.MaxInclusiveTime("e"));
- EXPECT_EQ(2, pauses.MaxExclusiveTime("e"));
- }
- }
-
- {
- TimelineRecorderOverride<TimelineEventEndlessRecorder> override;
-
- // Test case.
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "a", 0);
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "a", 1);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "a", 9);
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "a", 10);
-
- {
- TimelinePauses pauses(zone, isolate, Timeline::recorder());
- pauses.Setup();
- pauses.CalculatePauseTimesForThread(tid);
- EXPECT(!pauses.has_error());
- EXPECT_EQ(10, pauses.InclusiveTime("a"));
- EXPECT_EQ(10, pauses.ExclusiveTime("a"));
- EXPECT_EQ(10, pauses.MaxInclusiveTime("a"));
- EXPECT_EQ(8, pauses.MaxExclusiveTime("a"));
- }
- }
-
- {
- TimelineRecorderOverride<TimelineEventEndlessRecorder> override;
-
- // Test case.
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "a", 0);
- TimelineTestHelper::FakeBegin(Timeline::recorder(), "b", 1);
- // Pop "a" without popping "b" first.
- TimelineTestHelper::FakeEnd(Timeline::recorder(), "a", 10);
-
- {
- TimelinePauses pauses(zone, isolate, Timeline::recorder());
- pauses.Setup();
- pauses.CalculatePauseTimesForThread(tid);
- EXPECT(pauses.has_error());
- }
- }
-}
-
#endif // !PRODUCT
} // namespace dart
diff --git a/runtime/vm/vm_sources.gni b/runtime/vm/vm_sources.gni
index a2ed92d..2d68f1e 100644
--- a/runtime/vm/vm_sources.gni
+++ b/runtime/vm/vm_sources.gni
@@ -328,8 +328,6 @@
"thread_state.h",
"timeline.cc",
"timeline.h",
- "timeline_analysis.cc",
- "timeline_analysis.h",
"timeline_android.cc",
"timeline_fuchsia.cc",
"timeline_linux.cc",
diff --git a/tests/corelib/corelib.status b/tests/corelib/corelib.status
index d649a5d..97150c2 100644
--- a/tests/corelib/corelib.status
+++ b/tests/corelib/corelib.status
@@ -5,9 +5,17 @@
[ $compiler == dartdevk ]
regexp/lookbehind_test/01: Skip # Flaky in uncatchable way. Issue 36280
+[ $compiler == dartkp ]
+bigint_parse_radix_test: Slow, Pass # --no_intrinsify
+bigint_test/03: SkipSlow # --no_intrinsify
+bigint_test/15: SkipSlow # --no_intrinsify
+
[ $mode == debug ]
regexp/pcre_test: Slow, Pass # Issue 22008
+[ $system == android ]
+throw_half_surrogate_pair_test/*: Skip # Issue http://dartbug.com/42094
+
[ $arch == x64 && $system == windows ]
stopwatch_test: Skip # Flaky test due to expected performance behaviour.
@@ -30,6 +38,9 @@
[ $compiler == none && !$checked && ($runtime == dart_precompiled || $runtime == vm) ]
*: SkipByDesign
+[ $runtime != dart_precompiled && $runtime != vm ]
+reg_exp_receive_port_test: SkipByDesign # uses SendPort/ReceivePort
+
[ $runtime != none && ($compiler == dart2js || $compiler == dartdevc || $compiler == dartdevk) ]
int_parse_with_limited_ints_test: SkipByDesign # Requires fixed-size int64 support.
integer_arith_vm_test: SkipByDesign # Is a VM optimization test that requires int64 support.
@@ -47,22 +58,11 @@
uri_parse_test: Slow, Pass
uri_test: Slow, Pass
-[ $compiler == dartkp ]
-bigint_parse_radix_test: Slow, Pass # --no_intrinsify
-bigint_test/03: SkipSlow # --no_intrinsify
-bigint_test/15: SkipSlow # --no_intrinsify
-
[ $runtime == dart_precompiled || $runtime == vm ]
regexp/global_test: Skip # Issue 21709
regexp/pcre_test: Slow, Pass
-[ $runtime != vm ]
-reg_exp_receive_port_test : Skip # uses SendPort/ReceivePort
-
[ $hot_reload || $hot_reload_rollback ]
bigint_parse_radix_test: Skip # Issue 31659. Issue 34361.
bigint_test: Skip # Issue 31659
integer_parsed_mul_div_vm_test: Slow, Pass # Slow
-
-[ $system == android ]
-throw_half_surrogate_pair_test/* : Skip # Issue http://dartbug.com/42094
diff --git a/tests/corelib_2/corelib_2.status b/tests/corelib_2/corelib_2.status
index 5353258..726b58f 100644
--- a/tests/corelib_2/corelib_2.status
+++ b/tests/corelib_2/corelib_2.status
@@ -16,9 +16,6 @@
[ $runtime != none ]
string_runes_test: Skip # See breaking change #40674
-[ $runtime != vm ]
-reg_exp_receive_port_test: Skip # uses SendPort/ReceivePort
-
[ $system == android ]
throw_half_surrogate_pair_test/*: Skip # Issue http://dartbug.com/42094
@@ -44,6 +41,9 @@
[ $compiler == none && !$checked && ($runtime == dart_precompiled || $runtime == vm) ]
*: SkipByDesign
+[ $runtime != dart_precompiled && $runtime != vm ]
+reg_exp_receive_port_test: SkipByDesign # uses SendPort/ReceivePort
+
[ $runtime != none && ($compiler == dart2js || $compiler == dartdevc || $compiler == dartdevk) ]
int_parse_with_limited_ints_test: SkipByDesign # Requires fixed-size int64 support.
integer_arith_vm_test: SkipByDesign # Is a VM optimization test that requires int64 support.
diff --git a/tools/VERSION b/tools/VERSION
index 8d43d02..711c5dd 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 14
PATCH 0
-PRERELEASE 193
+PRERELEASE 194
PRERELEASE_PATCH 0
\ No newline at end of file
diff --git a/tools/bots/test_matrix.json b/tools/bots/test_matrix.json
index d310455..9f22437 100644
--- a/tools/bots/test_matrix.json
+++ b/tools/bots/test_matrix.json
@@ -533,7 +533,7 @@
"options": {
"use-sdk": true,
"dart2js-options": [
- "--no-legacy-javascript"
+ "--canary"
]
}
},
@@ -687,7 +687,7 @@
"builder-tag": "dart2js_modern",
"use-sdk": true,
"dart2js-options": [
- "--no-legacy-javascript"
+ "--canary"
]
}
},
@@ -2612,7 +2612,7 @@
]
},
{
- "name": "dart2js --no-legacy-javascript smoke tests",
+ "name": "dart2js --canary smoke tests",
"arguments": [
"-ndart2js-modern-linux-d8",
"--dart2js-batch",