blob: 2b798c2c983e9eaaedb7820019325a013b2e89ba [file] [log] [blame]
// Copyright (c) 2024, 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/element.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../../dart/resolution/node_text_expectations.dart';
import '../elements_base.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(MetadataElementTest_keepLinking);
defineReflectiveTests(MetadataElementTest_fromBytes);
defineReflectiveTests(UpdateNodeTextExpectations);
});
}
abstract class MetadataElementTest extends ElementsBaseTest {
test_annotationArgument_recordLiteral() async {
var library = await buildLibrary('''
@A((2, a: 3))
class C {}
class A {
const A(o);
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class C @20
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @0
name: SimpleIdentifier
token: A @1
staticElement: <testLibraryFragment>::@class::A
staticType: null
arguments: ArgumentList
leftParenthesis: ( @2
arguments
RecordLiteral
leftParenthesis: ( @3
fields
IntegerLiteral
literal: 2 @4
staticType: int
NamedExpression
name: Label
label: SimpleIdentifier
token: a @7
staticElement: <null>
staticType: null
colon: : @8
expression: IntegerLiteral
literal: 3 @10
staticType: int
rightParenthesis: ) @11
staticType: (int, {int a})
rightParenthesis: ) @12
element: <testLibraryFragment>::@class::A::@constructor::new
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
class A @31
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
constructors
const @43
reference: <testLibraryFragment>::@class::A::@constructor::new
enclosingElement: <testLibraryFragment>::@class::A
parameters
requiredPositional o @45
type: dynamic
''');
}
test_annotationArgument_recordLiteral_withConst() async {
var library = await buildLibrary('''
@A(const ('',))
class C {}
class A {
const A(o);
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class C @22
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @0
name: SimpleIdentifier
token: A @1
staticElement: <testLibraryFragment>::@class::A
staticType: null
arguments: ArgumentList
leftParenthesis: ( @2
arguments
RecordLiteral
constKeyword: const @3
leftParenthesis: ( @9
fields
SimpleStringLiteral
literal: '' @10
rightParenthesis: ) @13
staticType: (String,)
rightParenthesis: ) @14
element: <testLibraryFragment>::@class::A::@constructor::new
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
class A @33
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
constructors
const @45
reference: <testLibraryFragment>::@class::A::@constructor::new
enclosingElement: <testLibraryFragment>::@class::A
parameters
requiredPositional o @47
type: dynamic
''');
}
test_invalid_annotation_prefixed_constructor() async {
addSource('$testPackageLibPath/a.dart', r'''
class A {
const A.named();
}
''');
var library = await buildLibrary('''
import "a.dart" as a;
@a.A.named
class C {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
libraryImports
package:test/a.dart as a @19
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
prefixes
a @19
reference: <testLibraryFragment>::@prefix::a
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
libraryImports
package:test/a.dart as a @19
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
libraryImportPrefixes
a @19
reference: <testLibraryFragment>::@prefix::a
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
classes
class C @39
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @22
name: PrefixedIdentifier
prefix: SimpleIdentifier
token: a @23
staticElement: <testLibraryFragment>::@prefix::a
staticType: null
period: . @24
identifier: SimpleIdentifier
token: A @25
staticElement: package:test/a.dart::<fragment>::@class::A
staticType: null
staticElement: package:test/a.dart::<fragment>::@class::A
staticType: null
period: . @26
constructorName: SimpleIdentifier
token: named @27
staticElement: package:test/a.dart::<fragment>::@class::A::@constructor::named
staticType: null
element: package:test/a.dart::<fragment>::@class::A::@constructor::named
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
''');
}
test_invalid_annotation_unprefixed_constructor() async {
addSource('$testPackageLibPath/a.dart', r'''
class A {
const A.named();
}
''');
var library = await buildLibrary('''
import "a.dart";
@A.named
class C {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
libraryImports
package:test/a.dart
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
libraryImports
package:test/a.dart
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
classes
class C @32
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @17
name: PrefixedIdentifier
prefix: SimpleIdentifier
token: A @18
staticElement: package:test/a.dart::<fragment>::@class::A
staticType: null
period: . @19
identifier: SimpleIdentifier
token: named @20
staticElement: package:test/a.dart::<fragment>::@class::A::@constructor::named
staticType: null
staticElement: package:test/a.dart::<fragment>::@class::A::@constructor::named
staticType: null
element: package:test/a.dart::<fragment>::@class::A::@constructor::named
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
''');
}
test_metadata_augmentation_class() async {
newFile('$testPackageLibPath/a.dart', r'''
augment library 'test.dart';
@deprecated
class A {}
''');
var library = await buildLibrary('''
import augment 'a.dart';
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
augmentationImports
package:test/a.dart
enclosingElement: <testLibrary>
reference: <testLibrary>::@augmentation::package:test/a.dart
definingUnit: <testLibrary>::@fragment::package:test/a.dart
units
<testLibraryFragment>
enclosingElement: <testLibrary>
<testLibrary>::@fragment::package:test/a.dart
enclosingElement: <testLibrary>::@augmentation::package:test/a.dart
enclosingElement3: <testLibraryFragment>
classes
class A @47
reference: <testLibrary>::@fragment::package:test/a.dart::@class::A
enclosingElement: <testLibrary>::@fragment::package:test/a.dart
metadata
Annotation
atSign: @ @29
name: SimpleIdentifier
token: deprecated @30
staticElement: dart:core::<fragment>::@getter::deprecated
staticType: null
element: dart:core::<fragment>::@getter::deprecated
constructors
synthetic @-1
reference: <testLibrary>::@fragment::package:test/a.dart::@class::A::@constructor::new
enclosingElement: <testLibrary>::@fragment::package:test/a.dart::@class::A
''');
}
test_metadata_augmentation_exportLibrary() async {
newFile('$testPackageLibPath/a.dart', r'''
augment library 'test.dart';
@deprecated
export 'dart:math';
''');
var library = await buildLibrary('''
import augment 'a.dart';
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
augmentationImports
package:test/a.dart
enclosingElement: <testLibrary>
reference: <testLibrary>::@augmentation::package:test/a.dart
libraryExports
dart:math
enclosingElement: <testLibrary>
enclosingElement3: <testLibrary>::@fragment::package:test/a.dart
metadata
Annotation
atSign: @ @29
name: SimpleIdentifier
token: deprecated @30
staticElement: dart:core::<fragment>::@getter::deprecated
staticType: null
element: dart:core::<fragment>::@getter::deprecated
definingUnit: <testLibrary>::@fragment::package:test/a.dart
units
<testLibraryFragment>
enclosingElement: <testLibrary>
<testLibrary>::@fragment::package:test/a.dart
enclosingElement: <testLibrary>::@augmentation::package:test/a.dart
enclosingElement3: <testLibraryFragment>
libraryExports
dart:math
enclosingElement: <testLibrary>
enclosingElement3: <testLibrary>::@fragment::package:test/a.dart
metadata
Annotation
atSign: @ @29
name: SimpleIdentifier
token: deprecated @30
staticElement: dart:core::<fragment>::@getter::deprecated
staticType: null
element: dart:core::<fragment>::@getter::deprecated
''');
}
test_metadata_augmentation_importAugmentation() async {
newFile('$testPackageLibPath/a.dart', r'''
augment library 'b.dart';
''');
newFile('$testPackageLibPath/b.dart', r'''
augment library 'test.dart';
@deprecated
import augment 'a.dart';
''');
var library = await buildLibrary('''
import augment 'b.dart';
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
augmentationImports
package:test/b.dart
enclosingElement: <testLibrary>
reference: <testLibrary>::@augmentation::package:test/b.dart
definingUnit: <testLibrary>::@fragment::package:test/b.dart
augmentationImports
package:test/a.dart
enclosingElement: <testLibrary>::@augmentation::package:test/b.dart
metadata
Annotation
atSign: @ @29
name: SimpleIdentifier
token: deprecated @30
staticElement: dart:core::<fragment>::@getter::deprecated
staticType: null
element: dart:core::<fragment>::@getter::deprecated
reference: <testLibrary>::@augmentation::package:test/a.dart
definingUnit: <testLibrary>::@fragment::package:test/a.dart
units
<testLibraryFragment>
enclosingElement: <testLibrary>
<testLibrary>::@fragment::package:test/b.dart
enclosingElement: <testLibrary>::@augmentation::package:test/b.dart
enclosingElement3: <testLibraryFragment>
<testLibrary>::@fragment::package:test/a.dart
enclosingElement: <testLibrary>::@augmentation::package:test/a.dart
enclosingElement3: <testLibrary>::@fragment::package:test/b.dart
''');
}
test_metadata_augmentation_importLibrary() async {
newFile('$testPackageLibPath/a.dart', r'''
augment library 'test.dart';
@deprecated
import 'dart:math';
''');
var library = await buildLibrary('''
import augment 'a.dart';
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
augmentationImports
package:test/a.dart
enclosingElement: <testLibrary>
reference: <testLibrary>::@augmentation::package:test/a.dart
libraryImports
dart:math
enclosingElement: <testLibrary>
enclosingElement3: <testLibrary>::@fragment::package:test/a.dart
metadata
Annotation
atSign: @ @29
name: SimpleIdentifier
token: deprecated @30
staticElement: dart:core::<fragment>::@getter::deprecated
staticType: null
element: dart:core::<fragment>::@getter::deprecated
definingUnit: <testLibrary>::@fragment::package:test/a.dart
units
<testLibraryFragment>
enclosingElement: <testLibrary>
<testLibrary>::@fragment::package:test/a.dart
enclosingElement: <testLibrary>::@augmentation::package:test/a.dart
enclosingElement3: <testLibraryFragment>
libraryImports
dart:math
enclosingElement: <testLibrary>
enclosingElement3: <testLibrary>::@fragment::package:test/a.dart
metadata
Annotation
atSign: @ @29
name: SimpleIdentifier
token: deprecated @30
staticElement: dart:core::<fragment>::@getter::deprecated
staticType: null
element: dart:core::<fragment>::@getter::deprecated
''');
}
test_metadata_class_field_first() async {
var library = await buildLibrary(r'''
const a = 0;
class C {
@a
int x = 0;
}
''');
// Check metadata without asking any other properties.
var x = _elementOfDefiningUnit(library, ['@class', 'C', '@field', 'x'])
as FieldElement;
expect(x.metadata, hasLength(1));
// Check details.
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class C @19
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
fields
x @34
reference: <testLibraryFragment>::@class::C::@field::x
enclosingElement: <testLibraryFragment>::@class::C
metadata
Annotation
atSign: @ @25
name: SimpleIdentifier
token: a @26
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
type: int
shouldUseTypeForInitializerInference: true
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
accessors
synthetic get x @-1
reference: <testLibraryFragment>::@class::C::@getter::x
enclosingElement: <testLibraryFragment>::@class::C
returnType: int
synthetic set x= @-1
reference: <testLibraryFragment>::@class::C::@setter::x
enclosingElement: <testLibraryFragment>::@class::C
parameters
requiredPositional _x @-1
type: int
returnType: void
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 0 @10
staticType: int
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: int
''');
}
test_metadata_class_scope() async {
var library = await buildLibrary(r'''
const foo = 0;
@foo
class C<@foo T> {
static const foo = 1;
@foo
void bar() {}
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class C @27
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @16
name: SimpleIdentifier
token: foo @17
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
typeParameters
covariant T @34
defaultType: dynamic
metadata
Annotation
atSign: @ @29
name: SimpleIdentifier
token: foo @30
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
fields
static const foo @54
reference: <testLibraryFragment>::@class::C::@field::foo
enclosingElement: <testLibraryFragment>::@class::C
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 1 @60
staticType: int
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
accessors
synthetic static get foo @-1
reference: <testLibraryFragment>::@class::C::@getter::foo
enclosingElement: <testLibraryFragment>::@class::C
returnType: int
methods
bar @77
reference: <testLibraryFragment>::@class::C::@method::bar
enclosingElement: <testLibraryFragment>::@class::C
metadata
Annotation
atSign: @ @65
name: SimpleIdentifier
token: foo @66
staticElement: <testLibraryFragment>::@class::C::@getter::foo
staticType: null
element: <testLibraryFragment>::@class::C::@getter::foo
returnType: void
topLevelVariables
static const foo @6
reference: <testLibraryFragment>::@topLevelVariable::foo
enclosingElement: <testLibraryFragment>
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 0 @12
staticType: int
accessors
synthetic static get foo @-1
reference: <testLibraryFragment>::@getter::foo
enclosingElement: <testLibraryFragment>
returnType: int
''');
}
test_metadata_classDeclaration() async {
var library = await buildLibrary(r'''
const a = null;
const b = null;
@a
@b
class C {}''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class C @44
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @32
name: SimpleIdentifier
token: a @33
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
Annotation
atSign: @ @35
name: SimpleIdentifier
token: b @36
staticElement: <testLibraryFragment>::@getter::b
staticType: null
element: <testLibraryFragment>::@getter::b
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
static const b @22
reference: <testLibraryFragment>::@topLevelVariable::b
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @26
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
synthetic static get b @-1
reference: <testLibraryFragment>::@getter::b
enclosingElement: <testLibraryFragment>
returnType: dynamic
''');
}
test_metadata_classTypeAlias() async {
var library = await buildLibrary(
'const a = null; @a class C = D with E; class D {} class E {}');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class alias C @25
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @16
name: SimpleIdentifier
token: a @17
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
supertype: D
mixins
E
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
constantInitializers
SuperConstructorInvocation
superKeyword: super @0
argumentList: ArgumentList
leftParenthesis: ( @0
rightParenthesis: ) @0
staticElement: <testLibraryFragment>::@class::D::@constructor::new
superConstructor: <testLibraryFragment>::@class::D::@constructor::new
class D @45
reference: <testLibraryFragment>::@class::D
enclosingElement: <testLibraryFragment>
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::D::@constructor::new
enclosingElement: <testLibraryFragment>::@class::D
class E @56
reference: <testLibraryFragment>::@class::E
enclosingElement: <testLibraryFragment>
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::E::@constructor::new
enclosingElement: <testLibraryFragment>::@class::E
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
''');
}
test_metadata_constructor_call_named() async {
var library = await buildLibrary('''
class A {
const A.named(int _);
}
@A.named(0)
class C {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class A @6
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
constructors
const named @20
reference: <testLibraryFragment>::@class::A::@constructor::named
enclosingElement: <testLibraryFragment>::@class::A
periodOffset: 19
nameEnd: 25
parameters
requiredPositional _ @30
type: int
class C @54
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @36
name: PrefixedIdentifier
prefix: SimpleIdentifier
token: A @37
staticElement: <testLibraryFragment>::@class::A
staticType: null
period: . @38
identifier: SimpleIdentifier
token: named @39
staticElement: <testLibraryFragment>::@class::A::@constructor::named
staticType: null
staticElement: <testLibraryFragment>::@class::A::@constructor::named
staticType: null
arguments: ArgumentList
leftParenthesis: ( @44
arguments
IntegerLiteral
literal: 0 @45
staticType: int
rightParenthesis: ) @46
element: <testLibraryFragment>::@class::A::@constructor::named
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
''');
}
test_metadata_constructor_call_named_generic_inference() async {
var library = await buildLibrary('''
class A<T> {
const A.named(T _);
}
@A.named(0)
class C {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class A @6
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
typeParameters
covariant T @8
defaultType: dynamic
constructors
const named @23
reference: <testLibraryFragment>::@class::A::@constructor::named
enclosingElement: <testLibraryFragment>::@class::A
periodOffset: 22
nameEnd: 28
parameters
requiredPositional _ @31
type: T
class C @56
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @38
name: PrefixedIdentifier
prefix: SimpleIdentifier
token: A @39
staticElement: <testLibraryFragment>::@class::A
staticType: null
period: . @40
identifier: SimpleIdentifier
token: named @41
staticElement: ConstructorMember
base: <testLibraryFragment>::@class::A::@constructor::named
substitution: {T: int}
staticType: null
staticElement: ConstructorMember
base: <testLibraryFragment>::@class::A::@constructor::named
substitution: {T: int}
staticType: null
arguments: ArgumentList
leftParenthesis: ( @46
arguments
IntegerLiteral
literal: 0 @47
staticType: int
rightParenthesis: ) @48
element: ConstructorMember
base: <testLibraryFragment>::@class::A::@constructor::named
substitution: {T: int}
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
''');
}
test_metadata_constructor_call_named_generic_typeArguments() async {
var library = await buildLibrary('''
class A<T> {
const A.named();
}
@A<int>.named()
class C {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class A @6
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
typeParameters
covariant T @8
defaultType: dynamic
constructors
const named @23
reference: <testLibraryFragment>::@class::A::@constructor::named
enclosingElement: <testLibraryFragment>::@class::A
periodOffset: 22
nameEnd: 28
class C @57
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @35
name: SimpleIdentifier
token: A @36
staticElement: <testLibraryFragment>::@class::A
staticType: null
typeArguments: TypeArgumentList
leftBracket: < @37
arguments
NamedType
name: int @38
element: dart:core::<fragment>::@class::int
type: int
rightBracket: > @41
period: . @42
constructorName: SimpleIdentifier
token: named @43
staticElement: ConstructorMember
base: <testLibraryFragment>::@class::A::@constructor::named
substitution: {T: int}
staticType: null
arguments: ArgumentList
leftParenthesis: ( @48
rightParenthesis: ) @49
element: ConstructorMember
base: <testLibraryFragment>::@class::A::@constructor::named
substitution: {T: int}
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
''');
}
test_metadata_constructor_call_named_generic_typeArguments_disabledGenericMetadata() async {
var library = await buildLibrary('''
class A<T> {
const A.named();
}
@A<int>.named()
class C {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class A @6
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
typeParameters
covariant T @8
defaultType: dynamic
constructors
const named @23
reference: <testLibraryFragment>::@class::A::@constructor::named
enclosingElement: <testLibraryFragment>::@class::A
periodOffset: 22
nameEnd: 28
class C @57
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @35
name: SimpleIdentifier
token: A @36
staticElement: <testLibraryFragment>::@class::A
staticType: null
typeArguments: TypeArgumentList
leftBracket: < @37
arguments
NamedType
name: int @38
element: dart:core::<fragment>::@class::int
type: int
rightBracket: > @41
period: . @42
constructorName: SimpleIdentifier
token: named @43
staticElement: ConstructorMember
base: <testLibraryFragment>::@class::A::@constructor::named
substitution: {T: int}
staticType: null
arguments: ArgumentList
leftParenthesis: ( @48
rightParenthesis: ) @49
element: ConstructorMember
base: <testLibraryFragment>::@class::A::@constructor::named
substitution: {T: int}
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
''');
}
test_metadata_constructor_call_named_prefixed() async {
addSource('$testPackageLibPath/foo.dart', '''
class A {
const A.named(int _);
}
''');
var library = await buildLibrary('''
import 'foo.dart' as foo;
@foo.A.named(0)
class C {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
libraryImports
package:test/foo.dart as foo @21
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
prefixes
foo @21
reference: <testLibraryFragment>::@prefix::foo
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
libraryImports
package:test/foo.dart as foo @21
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
libraryImportPrefixes
foo @21
reference: <testLibraryFragment>::@prefix::foo
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
classes
class C @48
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @26
name: PrefixedIdentifier
prefix: SimpleIdentifier
token: foo @27
staticElement: <testLibraryFragment>::@prefix::foo
staticType: null
period: . @30
identifier: SimpleIdentifier
token: A @31
staticElement: package:test/foo.dart::<fragment>::@class::A
staticType: null
staticElement: package:test/foo.dart::<fragment>::@class::A
staticType: null
period: . @32
constructorName: SimpleIdentifier
token: named @33
staticElement: package:test/foo.dart::<fragment>::@class::A::@constructor::named
staticType: null
arguments: ArgumentList
leftParenthesis: ( @38
arguments
IntegerLiteral
literal: 0 @39
staticType: int
rightParenthesis: ) @40
element: package:test/foo.dart::<fragment>::@class::A::@constructor::named
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
''');
}
test_metadata_constructor_call_named_prefixed_generic_inference() async {
addSource('$testPackageLibPath/foo.dart', '''
class A<T> {
const A.named(T _);
}
''');
var library = await buildLibrary('''
import "foo.dart" as foo;
@foo.A.named(0)
class C {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
libraryImports
package:test/foo.dart as foo @21
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
prefixes
foo @21
reference: <testLibraryFragment>::@prefix::foo
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
libraryImports
package:test/foo.dart as foo @21
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
libraryImportPrefixes
foo @21
reference: <testLibraryFragment>::@prefix::foo
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
classes
class C @48
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @26
name: PrefixedIdentifier
prefix: SimpleIdentifier
token: foo @27
staticElement: <testLibraryFragment>::@prefix::foo
staticType: null
period: . @30
identifier: SimpleIdentifier
token: A @31
staticElement: package:test/foo.dart::<fragment>::@class::A
staticType: null
staticElement: package:test/foo.dart::<fragment>::@class::A
staticType: null
period: . @32
constructorName: SimpleIdentifier
token: named @33
staticElement: ConstructorMember
base: package:test/foo.dart::<fragment>::@class::A::@constructor::named
substitution: {T: int}
staticType: null
arguments: ArgumentList
leftParenthesis: ( @38
arguments
IntegerLiteral
literal: 0 @39
staticType: int
rightParenthesis: ) @40
element: ConstructorMember
base: package:test/foo.dart::<fragment>::@class::A::@constructor::named
substitution: {T: int}
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
''');
}
test_metadata_constructor_call_named_prefixed_generic_typeArguments() async {
addSource('$testPackageLibPath/foo.dart', '''
class A<T> {
const A.named();
}
''');
var library = await buildLibrary('''
import "foo.dart" as foo;
@foo.A<int>.named()
class C {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
libraryImports
package:test/foo.dart as foo @21
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
prefixes
foo @21
reference: <testLibraryFragment>::@prefix::foo
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
libraryImports
package:test/foo.dart as foo @21
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
libraryImportPrefixes
foo @21
reference: <testLibraryFragment>::@prefix::foo
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
classes
class C @52
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @26
name: PrefixedIdentifier
prefix: SimpleIdentifier
token: foo @27
staticElement: <testLibraryFragment>::@prefix::foo
staticType: null
period: . @30
identifier: SimpleIdentifier
token: A @31
staticElement: package:test/foo.dart::<fragment>::@class::A
staticType: null
staticElement: package:test/foo.dart::<fragment>::@class::A
staticType: null
typeArguments: TypeArgumentList
leftBracket: < @32
arguments
NamedType
name: int @33
element: dart:core::<fragment>::@class::int
type: int
rightBracket: > @36
period: . @37
constructorName: SimpleIdentifier
token: named @38
staticElement: ConstructorMember
base: package:test/foo.dart::<fragment>::@class::A::@constructor::named
substitution: {T: int}
staticType: null
arguments: ArgumentList
leftParenthesis: ( @43
rightParenthesis: ) @44
element: ConstructorMember
base: package:test/foo.dart::<fragment>::@class::A::@constructor::named
substitution: {T: int}
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
''');
}
test_metadata_constructor_call_named_synthetic_ofClassAlias_generic() async {
var library = await buildLibrary('''
class A {
const A.named();
}
mixin B {}
class C<T> = A with B;
@C.named()
class D {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class A @6
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
constructors
const named @20
reference: <testLibraryFragment>::@class::A::@constructor::named
enclosingElement: <testLibraryFragment>::@class::A
periodOffset: 19
nameEnd: 25
class alias C @50
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
typeParameters
covariant T @52
defaultType: dynamic
supertype: A
mixins
B
constructors
synthetic const named @-1
reference: <testLibraryFragment>::@class::C::@constructor::named
enclosingElement: <testLibraryFragment>::@class::C
constantInitializers
SuperConstructorInvocation
superKeyword: super @0
period: . @0
constructorName: SimpleIdentifier
token: named @-1
staticElement: <testLibraryFragment>::@class::A::@constructor::named
staticType: null
argumentList: ArgumentList
leftParenthesis: ( @0
rightParenthesis: ) @0
staticElement: <testLibraryFragment>::@class::A::@constructor::named
superConstructor: <testLibraryFragment>::@class::A::@constructor::named
class D @85
reference: <testLibraryFragment>::@class::D
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @68
name: PrefixedIdentifier
prefix: SimpleIdentifier
token: C @69
staticElement: <testLibraryFragment>::@class::C
staticType: null
period: . @70
identifier: SimpleIdentifier
token: named @71
staticElement: ConstructorMember
base: <testLibraryFragment>::@class::C::@constructor::named
substitution: {T: dynamic}
staticType: null
staticElement: ConstructorMember
base: <testLibraryFragment>::@class::C::@constructor::named
substitution: {T: dynamic}
staticType: null
arguments: ArgumentList
leftParenthesis: ( @76
rightParenthesis: ) @77
element: ConstructorMember
base: <testLibraryFragment>::@class::C::@constructor::named
substitution: {T: dynamic}
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::D::@constructor::new
enclosingElement: <testLibraryFragment>::@class::D
mixins
mixin B @38
reference: <testLibraryFragment>::@mixin::B
enclosingElement: <testLibraryFragment>
superclassConstraints
Object
''');
}
test_metadata_constructor_call_unnamed() async {
var library = await buildLibrary('''
class A {
const A(int _);
}
@A(0)
class C {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class A @6
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
constructors
const @18
reference: <testLibraryFragment>::@class::A::@constructor::new
enclosingElement: <testLibraryFragment>::@class::A
parameters
requiredPositional _ @24
type: int
class C @42
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @30
name: SimpleIdentifier
token: A @31
staticElement: <testLibraryFragment>::@class::A
staticType: null
arguments: ArgumentList
leftParenthesis: ( @32
arguments
IntegerLiteral
literal: 0 @33
staticType: int
rightParenthesis: ) @34
element: <testLibraryFragment>::@class::A::@constructor::new
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
''');
}
test_metadata_constructor_call_unnamed_generic_inference() async {
var library = await buildLibrary('''
class A<T> {
const A(T _);
}
@A(0)
class C {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class A @6
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
typeParameters
covariant T @8
defaultType: dynamic
constructors
const @21
reference: <testLibraryFragment>::@class::A::@constructor::new
enclosingElement: <testLibraryFragment>::@class::A
parameters
requiredPositional _ @25
type: T
class C @44
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @32
name: SimpleIdentifier
token: A @33
staticElement: <testLibraryFragment>::@class::A
staticType: null
arguments: ArgumentList
leftParenthesis: ( @34
arguments
IntegerLiteral
literal: 0 @35
staticType: int
rightParenthesis: ) @36
element: ConstructorMember
base: <testLibraryFragment>::@class::A::@constructor::new
substitution: {T: int}
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
''');
}
test_metadata_constructor_call_unnamed_generic_typeArguments() async {
var library = await buildLibrary('''
class A<T> {
const A();
}
@A<int>()
class C {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class A @6
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
typeParameters
covariant T @8
defaultType: dynamic
constructors
const @21
reference: <testLibraryFragment>::@class::A::@constructor::new
enclosingElement: <testLibraryFragment>::@class::A
class C @45
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @29
name: SimpleIdentifier
token: A @30
staticElement: <testLibraryFragment>::@class::A
staticType: null
typeArguments: TypeArgumentList
leftBracket: < @31
arguments
NamedType
name: int @32
element: dart:core::<fragment>::@class::int
type: int
rightBracket: > @35
arguments: ArgumentList
leftParenthesis: ( @36
rightParenthesis: ) @37
element: ConstructorMember
base: <testLibraryFragment>::@class::A::@constructor::new
substitution: {T: int}
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
''');
}
test_metadata_constructor_call_unnamed_prefixed() async {
addSource('$testPackageLibPath/foo.dart', 'class A { const A(_); }');
var library =
await buildLibrary('import "foo.dart" as foo; @foo.A(0) class C {}');
checkElementText(library, r'''
library
reference: <testLibrary>
libraryImports
package:test/foo.dart as foo @21
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
prefixes
foo @21
reference: <testLibraryFragment>::@prefix::foo
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
libraryImports
package:test/foo.dart as foo @21
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
libraryImportPrefixes
foo @21
reference: <testLibraryFragment>::@prefix::foo
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
classes
class C @42
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @26
name: PrefixedIdentifier
prefix: SimpleIdentifier
token: foo @27
staticElement: <testLibraryFragment>::@prefix::foo
staticType: null
period: . @30
identifier: SimpleIdentifier
token: A @31
staticElement: package:test/foo.dart::<fragment>::@class::A
staticType: null
staticElement: package:test/foo.dart::<fragment>::@class::A
staticType: null
arguments: ArgumentList
leftParenthesis: ( @32
arguments
IntegerLiteral
literal: 0 @33
staticType: int
rightParenthesis: ) @34
element: package:test/foo.dart::<fragment>::@class::A::@constructor::new
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
''');
}
test_metadata_constructor_call_unnamed_prefixed_generic_inference() async {
addSource('$testPackageLibPath/foo.dart', '''
class A<T> {
const A(T _);
}
''');
var library = await buildLibrary('''
import "foo.dart" as foo;
@foo.A(0)
class C {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
libraryImports
package:test/foo.dart as foo @21
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
prefixes
foo @21
reference: <testLibraryFragment>::@prefix::foo
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
libraryImports
package:test/foo.dart as foo @21
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
libraryImportPrefixes
foo @21
reference: <testLibraryFragment>::@prefix::foo
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
classes
class C @42
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @26
name: PrefixedIdentifier
prefix: SimpleIdentifier
token: foo @27
staticElement: <testLibraryFragment>::@prefix::foo
staticType: null
period: . @30
identifier: SimpleIdentifier
token: A @31
staticElement: package:test/foo.dart::<fragment>::@class::A
staticType: null
staticElement: package:test/foo.dart::<fragment>::@class::A
staticType: null
arguments: ArgumentList
leftParenthesis: ( @32
arguments
IntegerLiteral
literal: 0 @33
staticType: int
rightParenthesis: ) @34
element: ConstructorMember
base: package:test/foo.dart::<fragment>::@class::A::@constructor::new
substitution: {T: int}
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
''');
}
test_metadata_constructor_call_unnamed_prefixed_generic_typeArguments() async {
addSource('$testPackageLibPath/foo.dart', '''
class A<T> {
const A();
}
''');
var library = await buildLibrary('''
import "foo.dart" as foo;
@foo.A<int>()
class C {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
libraryImports
package:test/foo.dart as foo @21
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
prefixes
foo @21
reference: <testLibraryFragment>::@prefix::foo
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
libraryImports
package:test/foo.dart as foo @21
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
libraryImportPrefixes
foo @21
reference: <testLibraryFragment>::@prefix::foo
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
classes
class C @46
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @26
name: PrefixedIdentifier
prefix: SimpleIdentifier
token: foo @27
staticElement: <testLibraryFragment>::@prefix::foo
staticType: null
period: . @30
identifier: SimpleIdentifier
token: A @31
staticElement: package:test/foo.dart::<fragment>::@class::A
staticType: null
staticElement: package:test/foo.dart::<fragment>::@class::A
staticType: null
typeArguments: TypeArgumentList
leftBracket: < @32
arguments
NamedType
name: int @33
element: dart:core::<fragment>::@class::int
type: int
rightBracket: > @36
arguments: ArgumentList
leftParenthesis: ( @37
rightParenthesis: ) @38
element: ConstructorMember
base: package:test/foo.dart::<fragment>::@class::A::@constructor::new
substitution: {T: int}
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
''');
}
test_metadata_constructor_call_unnamed_synthetic_ofClassAlias_generic() async {
var library = await buildLibrary('''
class A {
const A();
}
mixin B {}
class C<T> = A with B;
@C()
class D {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class A @6
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
constructors
const @18
reference: <testLibraryFragment>::@class::A::@constructor::new
enclosingElement: <testLibraryFragment>::@class::A
class alias C @44
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
typeParameters
covariant T @46
defaultType: dynamic
supertype: A
mixins
B
constructors
synthetic const @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
constantInitializers
SuperConstructorInvocation
superKeyword: super @0
argumentList: ArgumentList
leftParenthesis: ( @0
rightParenthesis: ) @0
staticElement: <testLibraryFragment>::@class::A::@constructor::new
superConstructor: <testLibraryFragment>::@class::A::@constructor::new
class D @73
reference: <testLibraryFragment>::@class::D
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @62
name: SimpleIdentifier
token: C @63
staticElement: <testLibraryFragment>::@class::C
staticType: null
arguments: ArgumentList
leftParenthesis: ( @64
rightParenthesis: ) @65
element: ConstructorMember
base: <testLibraryFragment>::@class::C::@constructor::new
substitution: {T: dynamic}
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::D::@constructor::new
enclosingElement: <testLibraryFragment>::@class::D
mixins
mixin B @32
reference: <testLibraryFragment>::@mixin::B
enclosingElement: <testLibraryFragment>
superclassConstraints
Object
''');
}
test_metadata_constructor_call_with_args() async {
var library =
await buildLibrary('class A { const A(x); } @A(null) class C {}');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class A @6
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
constructors
const @16
reference: <testLibraryFragment>::@class::A::@constructor::new
enclosingElement: <testLibraryFragment>::@class::A
parameters
requiredPositional x @18
type: dynamic
class C @39
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @24
name: SimpleIdentifier
token: A @25
staticElement: <testLibraryFragment>::@class::A
staticType: null
arguments: ArgumentList
leftParenthesis: ( @26
arguments
NullLiteral
literal: null @27
staticType: Null
rightParenthesis: ) @31
element: <testLibraryFragment>::@class::A::@constructor::new
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
''');
}
test_metadata_constructorDeclaration_named() async {
var library =
await buildLibrary('const a = null; class C { @a C.named(); }');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class C @22
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
constructors
named @31
reference: <testLibraryFragment>::@class::C::@constructor::named
enclosingElement: <testLibraryFragment>::@class::C
metadata
Annotation
atSign: @ @26
name: SimpleIdentifier
token: a @27
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
periodOffset: 30
nameEnd: 36
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
''');
}
test_metadata_constructorDeclaration_unnamed() async {
var library = await buildLibrary('const a = null; class C { @a C(); }');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class C @22
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
constructors
@29
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
metadata
Annotation
atSign: @ @26
name: SimpleIdentifier
token: a @27
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
''');
}
test_metadata_exportDirective() async {
addSource('$testPackageLibPath/foo.dart', '');
var library = await buildLibrary('@a export "foo.dart"; const a = null;');
checkElementText(library, r'''
library
reference: <testLibrary>
metadata
Annotation
atSign: @ @0
name: SimpleIdentifier
token: a @1
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
libraryExports
package:test/foo.dart
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
metadata
Annotation
atSign: @ @0
name: SimpleIdentifier
token: a @1
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
libraryExports
package:test/foo.dart
enclosingElement: <testLibrary>
enclosingElement3: <testLibraryFragment>
metadata
Annotation
atSign: @ @0
name: SimpleIdentifier
token: a @1
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
topLevelVariables
static const a @28
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @32
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
''');
}
test_metadata_fieldDeclaration() async {
var library = await buildLibrary('const a = null; class C { @a int x; }');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class C @22
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
fields
x @33
reference: <testLibraryFragment>::@class::C::@field::x
enclosingElement: <testLibraryFragment>::@class::C
metadata
Annotation
atSign: @ @26
name: SimpleIdentifier
token: a @27
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
type: int
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
accessors
synthetic get x @-1
reference: <testLibraryFragment>::@class::C::@getter::x
enclosingElement: <testLibraryFragment>::@class::C
returnType: int
synthetic set x= @-1
reference: <testLibraryFragment>::@class::C::@setter::x
enclosingElement: <testLibraryFragment>::@class::C
parameters
requiredPositional _x @-1
type: int
returnType: void
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
''');
}
test_metadata_fieldFormalParameter() async {
var library = await buildLibrary('''
const a = null;
class C {
var x;
C(@a this.x);
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class C @22
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
fields
x @32
reference: <testLibraryFragment>::@class::C::@field::x
enclosingElement: <testLibraryFragment>::@class::C
type: dynamic
constructors
@37
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
parameters
requiredPositional final this.x @47
type: dynamic
metadata
Annotation
atSign: @ @39
name: SimpleIdentifier
token: a @40
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
field: <testLibraryFragment>::@class::C::@field::x
accessors
synthetic get x @-1
reference: <testLibraryFragment>::@class::C::@getter::x
enclosingElement: <testLibraryFragment>::@class::C
returnType: dynamic
synthetic set x= @-1
reference: <testLibraryFragment>::@class::C::@setter::x
enclosingElement: <testLibraryFragment>::@class::C
parameters
requiredPositional _x @-1
type: dynamic
returnType: void
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
''');
}
test_metadata_fieldFormalParameter_withDefault() async {
var library = await buildLibrary(
'const a = null; class C { var x; C([@a this.x = null]); }');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class C @22
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
fields
x @30
reference: <testLibraryFragment>::@class::C::@field::x
enclosingElement: <testLibraryFragment>::@class::C
type: dynamic
constructors
@33
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
parameters
optionalPositional default final this.x @44
type: dynamic
metadata
Annotation
atSign: @ @36
name: SimpleIdentifier
token: a @37
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
constantInitializer
NullLiteral
literal: null @48
staticType: Null
field: <testLibraryFragment>::@class::C::@field::x
accessors
synthetic get x @-1
reference: <testLibraryFragment>::@class::C::@getter::x
enclosingElement: <testLibraryFragment>::@class::C
returnType: dynamic
synthetic set x= @-1
reference: <testLibraryFragment>::@class::C::@setter::x
enclosingElement: <testLibraryFragment>::@class::C
parameters
requiredPositional _x @-1
type: dynamic
returnType: void
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
''');
}
test_metadata_functionDeclaration_function() async {
var library = await buildLibrary('''
const a = null;
@a
f() {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
functions
f @19
reference: <testLibraryFragment>::@function::f
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @16
name: SimpleIdentifier
token: a @17
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
returnType: dynamic
''');
}
test_metadata_functionDeclaration_getter() async {
var library = await buildLibrary('const a = null; @a get f => null;');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
synthetic static f @-1
reference: <testLibraryFragment>::@topLevelVariable::f
enclosingElement: <testLibraryFragment>
type: dynamic
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
static get f @23
reference: <testLibraryFragment>::@getter::f
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @16
name: SimpleIdentifier
token: a @17
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
returnType: dynamic
''');
}
test_metadata_functionDeclaration_setter() async {
var library = await buildLibrary('const a = null; @a set f(value) {}');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
synthetic static f @-1
reference: <testLibraryFragment>::@topLevelVariable::f
enclosingElement: <testLibraryFragment>
type: dynamic
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
static set f= @23
reference: <testLibraryFragment>::@setter::f
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @16
name: SimpleIdentifier
token: a @17
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
parameters
requiredPositional value @25
type: dynamic
returnType: void
''');
}
test_metadata_functionTypeAlias() async {
var library = await buildLibrary('const a = null; @a typedef F();');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
typeAliases
functionTypeAliasBased F @27
reference: <testLibraryFragment>::@typeAlias::F
metadata
Annotation
atSign: @ @16
name: SimpleIdentifier
token: a @17
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
aliasedType: dynamic Function()
aliasedElement: GenericFunctionTypeElement
returnType: dynamic
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
''');
}
test_metadata_functionTypedFormalParameter() async {
var library = await buildLibrary('const a = null; f(@a g()) {}');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
functions
f @16
reference: <testLibraryFragment>::@function::f
enclosingElement: <testLibraryFragment>
parameters
requiredPositional g @21
type: dynamic Function()
metadata
Annotation
atSign: @ @18
name: SimpleIdentifier
token: a @19
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
returnType: dynamic
''');
}
test_metadata_functionTypedFormalParameter_withDefault() async {
var library = await buildLibrary('const a = null; f([@a g() = null]) {}');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
functions
f @16
reference: <testLibraryFragment>::@function::f
enclosingElement: <testLibraryFragment>
parameters
optionalPositional default g @22
type: dynamic Function()
metadata
Annotation
atSign: @ @19
name: SimpleIdentifier
token: a @20
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
constantInitializer
NullLiteral
literal: null @28
staticType: null
returnType: dynamic
''');
}
test_metadata_genericTypeAlias() async {
var library = await buildLibrary(r'''
const a = null;
const b = null;
@a
@b
typedef F = void Function();''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
typeAliases
F @46
reference: <testLibraryFragment>::@typeAlias::F
metadata
Annotation
atSign: @ @32
name: SimpleIdentifier
token: a @33
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
Annotation
atSign: @ @35
name: SimpleIdentifier
token: b @36
staticElement: <testLibraryFragment>::@getter::b
staticType: null
element: <testLibraryFragment>::@getter::b
aliasedType: void Function()
aliasedElement: GenericFunctionTypeElement
returnType: void
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
static const b @22
reference: <testLibraryFragment>::@topLevelVariable::b
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @26
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
synthetic static get b @-1
reference: <testLibraryFragment>::@getter::b
enclosingElement: <testLibraryFragment>
returnType: dynamic
''');
}
test_metadata_inAliasedElement_formalParameter() async {
var library = await buildLibrary('''
const a = 42;
typedef F = void Function(@a int first)
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
typeAliases
F @22
reference: <testLibraryFragment>::@typeAlias::F
aliasedType: void Function(int)
aliasedElement: GenericFunctionTypeElement
parameters
requiredPositional first @47
type: int
metadata
Annotation
atSign: @ @40
name: SimpleIdentifier
token: a @41
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
returnType: void
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 42 @10
staticType: int
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: int
''');
}
test_metadata_inAliasedElement_formalParameter2() async {
var library = await buildLibrary('''
const a = 42;
typedef F = void Function(int foo(@a int bar))
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
typeAliases
F @22
reference: <testLibraryFragment>::@typeAlias::F
aliasedType: void Function(int Function(int))
aliasedElement: GenericFunctionTypeElement
parameters
requiredPositional foo @44
type: int Function(int)
parameters
requiredPositional bar @55
type: int
metadata
Annotation
atSign: @ @48
name: SimpleIdentifier
token: a @49
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
returnType: void
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 42 @10
staticType: int
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: int
''');
}
test_metadata_inAliasedElement_typeParameter() async {
var library = await buildLibrary('''
const a = 42;
typedef F = void Function<@a T>(int first)
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
typeAliases
F @22
reference: <testLibraryFragment>::@typeAlias::F
aliasedType: void Function<T>(int)
aliasedElement: GenericFunctionTypeElement
typeParameters
covariant T @43
metadata
Annotation
atSign: @ @40
name: SimpleIdentifier
token: a @41
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
parameters
requiredPositional first @50
type: int
returnType: void
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 42 @10
staticType: int
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: int
''');
}
test_metadata_invalid_classDeclaration() async {
var library = await buildLibrary('f(_) {} @f(42) class C {}');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class C @21
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @8
name: SimpleIdentifier
token: f @9
staticElement: <testLibraryFragment>::@function::f
staticType: null
arguments: ArgumentList
leftParenthesis: ( @10
arguments
IntegerLiteral
literal: 42 @11
staticType: int
rightParenthesis: ) @13
element: <testLibraryFragment>::@function::f
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
functions
f @0
reference: <testLibraryFragment>::@function::f
enclosingElement: <testLibraryFragment>
parameters
requiredPositional _ @2
type: dynamic
returnType: dynamic
''');
}
test_metadata_library_importAugmentation_augmentation() async {
newFile('$testPackageLibPath/a.dart', r'''
augment library 'test.dart';
''');
var library = await buildLibrary('''
@deprecated
import augment 'a.dart';
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
augmentationImports
package:test/a.dart
enclosingElement: <testLibrary>
metadata
Annotation
atSign: @ @0
name: SimpleIdentifier
token: deprecated @1
staticElement: dart:core::<fragment>::@getter::deprecated
staticType: null
element: dart:core::<fragment>::@getter::deprecated
reference: <testLibrary>::@augmentation::package:test/a.dart
definingUnit: <testLibrary>::@fragment::package:test/a.dart
units
<testLibraryFragment>
enclosingElement: <testLibrary>
<testLibrary>::@fragment::package:test/a.dart
enclosingElement: <testLibrary>::@augmentation::package:test/a.dart
enclosingElement3: <testLibraryFragment>
''');
}
/// Even though the target is not an augmentation, metadata is available.
test_metadata_library_importAugmentation_notAugmentation_library() async {
var library = await buildLibrary('''
@deprecated
import augment 'dart:math';
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
augmentationImports
source 'dart:math'
enclosingElement: <testLibrary>
metadata
Annotation
atSign: @ @0
name: SimpleIdentifier
token: deprecated @1
staticElement: dart:core::<fragment>::@getter::deprecated
staticType: null
element: dart:core::<fragment>::@getter::deprecated
units
<testLibraryFragment>
enclosingElement: <testLibrary>
''');
}
test_metadata_libraryDirective() async {
var library = await buildLibrary('@a library L; const a = null;');
checkElementText(library, r'''
library
name: L
nameOffset: 11
reference: <testLibrary>
metadata
Annotation
atSign: @ @0
name: SimpleIdentifier
token: a @1
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
topLevelVariables
static const a @20
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @24
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
''');
}
test_metadata_methodDeclaration_getter() async {
var library =
await buildLibrary('const a = null; class C { @a get m => null; }');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class C @22
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
fields
synthetic m @-1
reference: <testLibraryFragment>::@class::C::@field::m
enclosingElement: <testLibraryFragment>::@class::C
type: dynamic
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
accessors
get m @33
reference: <testLibraryFragment>::@class::C::@getter::m
enclosingElement: <testLibraryFragment>::@class::C
metadata
Annotation
atSign: @ @26
name: SimpleIdentifier
token: a @27
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
returnType: dynamic
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
''');
}
test_metadata_methodDeclaration_method() async {
var library = await buildLibrary(r'''
const a = null;
const b = null;
class C {
@a
@b
m() {}
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class C @38
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
methods
m @54
reference: <testLibraryFragment>::@class::C::@method::m
enclosingElement: <testLibraryFragment>::@class::C
metadata
Annotation
atSign: @ @44
name: SimpleIdentifier
token: a @45
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
Annotation
atSign: @ @49
name: SimpleIdentifier
token: b @50
staticElement: <testLibraryFragment>::@getter::b
staticType: null
element: <testLibraryFragment>::@getter::b
returnType: dynamic
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
static const b @22
reference: <testLibraryFragment>::@topLevelVariable::b
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @26
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
synthetic static get b @-1
reference: <testLibraryFragment>::@getter::b
enclosingElement: <testLibraryFragment>
returnType: dynamic
''');
}
test_metadata_methodDeclaration_method_mixin() async {
var library = await buildLibrary(r'''
const a = null;
const b = null;
mixin M {
@a
@b
m() {}
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
mixins
mixin M @38
reference: <testLibraryFragment>::@mixin::M
enclosingElement: <testLibraryFragment>
superclassConstraints
Object
methods
m @54
reference: <testLibraryFragment>::@mixin::M::@method::m
enclosingElement: <testLibraryFragment>::@mixin::M
metadata
Annotation
atSign: @ @44
name: SimpleIdentifier
token: a @45
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
Annotation
atSign: @ @49
name: SimpleIdentifier
token: b @50
staticElement: <testLibraryFragment>::@getter::b
staticType: null
element: <testLibraryFragment>::@getter::b
returnType: dynamic
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
static const b @22
reference: <testLibraryFragment>::@topLevelVariable::b
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @26
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
synthetic static get b @-1
reference: <testLibraryFragment>::@getter::b
enclosingElement: <testLibraryFragment>
returnType: dynamic
''');
}
test_metadata_methodDeclaration_setter() async {
var library = await buildLibrary('''
const a = null;
class C {
@a
set m(value) {}
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class C @22
reference: <testLibraryFragment>::@class::C
enclosingElement: <testLibraryFragment>
fields
synthetic m @-1
reference: <testLibraryFragment>::@class::C::@field::m
enclosingElement: <testLibraryFragment>::@class::C
type: dynamic
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::C::@constructor::new
enclosingElement: <testLibraryFragment>::@class::C
accessors
set m= @37
reference: <testLibraryFragment>::@class::C::@setter::m
enclosingElement: <testLibraryFragment>::@class::C
metadata
Annotation
atSign: @ @28
name: SimpleIdentifier
token: a @29
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
parameters
requiredPositional value @39
type: dynamic
returnType: void
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
''');
}
test_metadata_mixin_scope() async {
var library = await buildLibrary(r'''
const foo = 0;
@foo
mixin M<@foo T> {
static const foo = 1;
@foo
void bar() {}
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
mixins
mixin M @27
reference: <testLibraryFragment>::@mixin::M
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @16
name: SimpleIdentifier
token: foo @17
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
typeParameters
covariant T @34
defaultType: dynamic
metadata
Annotation
atSign: @ @29
name: SimpleIdentifier
token: foo @30
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
superclassConstraints
Object
fields
static const foo @54
reference: <testLibraryFragment>::@mixin::M::@field::foo
enclosingElement: <testLibraryFragment>::@mixin::M
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 1 @60
staticType: int
accessors
synthetic static get foo @-1
reference: <testLibraryFragment>::@mixin::M::@getter::foo
enclosingElement: <testLibraryFragment>::@mixin::M
returnType: int
methods
bar @77
reference: <testLibraryFragment>::@mixin::M::@method::bar
enclosingElement: <testLibraryFragment>::@mixin::M
metadata
Annotation
atSign: @ @65
name: SimpleIdentifier
token: foo @66
staticElement: <testLibraryFragment>::@mixin::M::@getter::foo
staticType: null
element: <testLibraryFragment>::@mixin::M::@getter::foo
returnType: void
topLevelVariables
static const foo @6
reference: <testLibraryFragment>::@topLevelVariable::foo
enclosingElement: <testLibraryFragment>
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 0 @12
staticType: int
accessors
synthetic static get foo @-1
reference: <testLibraryFragment>::@getter::foo
enclosingElement: <testLibraryFragment>
returnType: int
''');
}
test_metadata_mixinDeclaration() async {
var library = await buildLibrary(r'''
const a = null;
const b = null;
@a
@b
mixin M {}''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
mixins
mixin M @44
reference: <testLibraryFragment>::@mixin::M
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @32
name: SimpleIdentifier
token: a @33
staticElement: <testLibraryFragment>::@getter::a
staticType: null
element: <testLibraryFragment>::@getter::a
Annotation
atSign: @ @35
name: SimpleIdentifier
token: b @36
staticElement: <testLibraryFragment>::@getter::b
staticType: null
element: <testLibraryFragment>::@getter::b
superclassConstraints
Object
topLevelVariables
static const a @6
reference: <testLibraryFragment>::@topLevelVariable::a
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @10
staticType: Null
static const b @22
reference: <testLibraryFragment>::@topLevelVariable::b
enclosingElement: <testLibraryFragment>
type: dynamic
shouldUseTypeForInitializerInference: false
constantInitializer
NullLiteral
literal: null @26
staticType: Null
accessors
synthetic static get a @-1
reference: <testLibraryFragment>::@getter::a
enclosingElement: <testLibraryFragment>
returnType: dynamic
synthetic static get b @-1
reference: <testLibraryFragment>::@getter::b
enclosingElement: <testLibraryFragment>
returnType: dynamic
''');
}
test_metadata_offsets_onClass() async {
var library = await buildLibrary(r'''
const foo = 0;
@foo
class A<@foo T> {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class A @27
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @16
name: SimpleIdentifier
token: foo @17
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
typeParameters
covariant T @34
defaultType: dynamic
metadata
Annotation
atSign: @ @29
name: SimpleIdentifier
token: foo @30
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::A::@constructor::new
enclosingElement: <testLibraryFragment>::@class::A
topLevelVariables
static const foo @6
reference: <testLibraryFragment>::@topLevelVariable::foo
enclosingElement: <testLibraryFragment>
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 0 @12
staticType: int
accessors
synthetic static get foo @-1
reference: <testLibraryFragment>::@getter::foo
enclosingElement: <testLibraryFragment>
returnType: int
''');
}
test_metadata_offsets_onClassConstructor() async {
var library = await buildLibrary(r'''
const foo = 0;
class A {
@foo
A(@foo int a);
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class A @22
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
constructors
@35
reference: <testLibraryFragment>::@class::A::@constructor::new
enclosingElement: <testLibraryFragment>::@class::A
metadata
Annotation
atSign: @ @28
name: SimpleIdentifier
token: foo @29
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
parameters
requiredPositional a @46
type: int
metadata
Annotation
atSign: @ @37
name: SimpleIdentifier
token: foo @38
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
topLevelVariables
static const foo @6
reference: <testLibraryFragment>::@topLevelVariable::foo
enclosingElement: <testLibraryFragment>
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 0 @12
staticType: int
accessors
synthetic static get foo @-1
reference: <testLibraryFragment>::@getter::foo
enclosingElement: <testLibraryFragment>
returnType: int
''');
}
test_metadata_offsets_onClassGetter() async {
var library = await buildLibrary(r'''
const foo = 0;
class A {
@foo
int get getter => 0;
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class A @22
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
fields
synthetic getter @-1
reference: <testLibraryFragment>::@class::A::@field::getter
enclosingElement: <testLibraryFragment>::@class::A
type: int
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::A::@constructor::new
enclosingElement: <testLibraryFragment>::@class::A
accessors
get getter @43
reference: <testLibraryFragment>::@class::A::@getter::getter
enclosingElement: <testLibraryFragment>::@class::A
metadata
Annotation
atSign: @ @28
name: SimpleIdentifier
token: foo @29
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
returnType: int
topLevelVariables
static const foo @6
reference: <testLibraryFragment>::@topLevelVariable::foo
enclosingElement: <testLibraryFragment>
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 0 @12
staticType: int
accessors
synthetic static get foo @-1
reference: <testLibraryFragment>::@getter::foo
enclosingElement: <testLibraryFragment>
returnType: int
''');
}
test_metadata_offsets_onClassMethod() async {
var library = await buildLibrary(r'''
const foo = 0;
class A {
@foo
void method<@foo T>(@foo int a) {}
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class A @22
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::A::@constructor::new
enclosingElement: <testLibraryFragment>::@class::A
methods
method @40
reference: <testLibraryFragment>::@class::A::@method::method
enclosingElement: <testLibraryFragment>::@class::A
metadata
Annotation
atSign: @ @28
name: SimpleIdentifier
token: foo @29
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
typeParameters
covariant T @52
defaultType: dynamic
metadata
Annotation
atSign: @ @47
name: SimpleIdentifier
token: foo @48
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
parameters
requiredPositional a @64
type: int
metadata
Annotation
atSign: @ @55
name: SimpleIdentifier
token: foo @56
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
returnType: void
topLevelVariables
static const foo @6
reference: <testLibraryFragment>::@topLevelVariable::foo
enclosingElement: <testLibraryFragment>
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 0 @12
staticType: int
accessors
synthetic static get foo @-1
reference: <testLibraryFragment>::@getter::foo
enclosingElement: <testLibraryFragment>
returnType: int
''');
}
test_metadata_offsets_onClassSetter() async {
var library = await buildLibrary(r'''
const foo = 0;
class A {
@foo
set setter(@foo int a) {}
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class A @22
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
fields
synthetic setter @-1
reference: <testLibraryFragment>::@class::A::@field::setter
enclosingElement: <testLibraryFragment>::@class::A
type: int
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::A::@constructor::new
enclosingElement: <testLibraryFragment>::@class::A
accessors
set setter= @39
reference: <testLibraryFragment>::@class::A::@setter::setter
enclosingElement: <testLibraryFragment>::@class::A
metadata
Annotation
atSign: @ @28
name: SimpleIdentifier
token: foo @29
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
parameters
requiredPositional a @55
type: int
metadata
Annotation
atSign: @ @46
name: SimpleIdentifier
token: foo @47
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
returnType: void
topLevelVariables
static const foo @6
reference: <testLibraryFragment>::@topLevelVariable::foo
enclosingElement: <testLibraryFragment>
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 0 @12
staticType: int
accessors
synthetic static get foo @-1
reference: <testLibraryFragment>::@getter::foo
enclosingElement: <testLibraryFragment>
returnType: int
''');
}
test_metadata_offsets_onClassTypeAlias() async {
var library = await buildLibrary(r'''
const foo = 0;
class A {}
mixin M {}
@foo
class B<@foo T> = A with M;
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class A @22
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::A::@constructor::new
enclosingElement: <testLibraryFragment>::@class::A
class alias B @50
reference: <testLibraryFragment>::@class::B
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @39
name: SimpleIdentifier
token: foo @40
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
typeParameters
covariant T @57
defaultType: dynamic
metadata
Annotation
atSign: @ @52
name: SimpleIdentifier
token: foo @53
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
supertype: A
mixins
M
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::B::@constructor::new
enclosingElement: <testLibraryFragment>::@class::B
constantInitializers
SuperConstructorInvocation
superKeyword: super @0
argumentList: ArgumentList
leftParenthesis: ( @0
rightParenthesis: ) @0
staticElement: <testLibraryFragment>::@class::A::@constructor::new
superConstructor: <testLibraryFragment>::@class::A::@constructor::new
mixins
mixin M @33
reference: <testLibraryFragment>::@mixin::M
enclosingElement: <testLibraryFragment>
superclassConstraints
Object
topLevelVariables
static const foo @6
reference: <testLibraryFragment>::@topLevelVariable::foo
enclosingElement: <testLibraryFragment>
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 0 @12
staticType: int
accessors
synthetic static get foo @-1
reference: <testLibraryFragment>::@getter::foo
enclosingElement: <testLibraryFragment>
returnType: int
''');
}
test_metadata_offsets_onEnum() async {
var library = await buildLibrary(r'''
const foo = 0;
@foo
enum E {
@foo e1,
e2,
@foo e3,
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
enums
enum E @26
reference: <testLibraryFragment>::@enum::E
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @16
name: SimpleIdentifier
token: foo @17
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
supertype: Enum
fields
static const enumConstant e1 @37
reference: <testLibraryFragment>::@enum::E::@field::e1
enclosingElement: <testLibraryFragment>::@enum::E
metadata
Annotation
atSign: @ @32
name: SimpleIdentifier
token: foo @33
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
type: E
shouldUseTypeForInitializerInference: false
constantInitializer
InstanceCreationExpression
constructorName: ConstructorName
type: NamedType
name: E @-1
element: <testLibraryFragment>::@enum::E
type: E
staticElement: <testLibraryFragment>::@enum::E::@constructor::new
argumentList: ArgumentList
leftParenthesis: ( @0
rightParenthesis: ) @0
staticType: E
static const enumConstant e2 @43
reference: <testLibraryFragment>::@enum::E::@field::e2
enclosingElement: <testLibraryFragment>::@enum::E
type: E
shouldUseTypeForInitializerInference: false
constantInitializer
InstanceCreationExpression
constructorName: ConstructorName
type: NamedType
name: E @-1
element: <testLibraryFragment>::@enum::E
type: E
staticElement: <testLibraryFragment>::@enum::E::@constructor::new
argumentList: ArgumentList
leftParenthesis: ( @0
rightParenthesis: ) @0
staticType: E
static const enumConstant e3 @54
reference: <testLibraryFragment>::@enum::E::@field::e3
enclosingElement: <testLibraryFragment>::@enum::E
metadata
Annotation
atSign: @ @49
name: SimpleIdentifier
token: foo @50
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
type: E
shouldUseTypeForInitializerInference: false
constantInitializer
InstanceCreationExpression
constructorName: ConstructorName
type: NamedType
name: E @-1
element: <testLibraryFragment>::@enum::E
type: E
staticElement: <testLibraryFragment>::@enum::E::@constructor::new
argumentList: ArgumentList
leftParenthesis: ( @0
rightParenthesis: ) @0
staticType: E
synthetic static const values @-1
reference: <testLibraryFragment>::@enum::E::@field::values
enclosingElement: <testLibraryFragment>::@enum::E
type: List<E>
constantInitializer
ListLiteral
leftBracket: [ @0
elements
SimpleIdentifier
token: e1 @-1
staticElement: <testLibraryFragment>::@enum::E::@getter::e1
staticType: E
SimpleIdentifier
token: e2 @-1
staticElement: <testLibraryFragment>::@enum::E::@getter::e2
staticType: E
SimpleIdentifier
token: e3 @-1
staticElement: <testLibraryFragment>::@enum::E::@getter::e3
staticType: E
rightBracket: ] @0
staticType: List<E>
constructors
synthetic const @-1
reference: <testLibraryFragment>::@enum::E::@constructor::new
enclosingElement: <testLibraryFragment>::@enum::E
accessors
synthetic static get e1 @-1
reference: <testLibraryFragment>::@enum::E::@getter::e1
enclosingElement: <testLibraryFragment>::@enum::E
returnType: E
synthetic static get e2 @-1
reference: <testLibraryFragment>::@enum::E::@getter::e2
enclosingElement: <testLibraryFragment>::@enum::E
returnType: E
synthetic static get e3 @-1
reference: <testLibraryFragment>::@enum::E::@getter::e3
enclosingElement: <testLibraryFragment>::@enum::E
returnType: E
synthetic static get values @-1
reference: <testLibraryFragment>::@enum::E::@getter::values
enclosingElement: <testLibraryFragment>::@enum::E
returnType: List<E>
topLevelVariables
static const foo @6
reference: <testLibraryFragment>::@topLevelVariable::foo
enclosingElement: <testLibraryFragment>
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 0 @12
staticType: int
accessors
synthetic static get foo @-1
reference: <testLibraryFragment>::@getter::foo
enclosingElement: <testLibraryFragment>
returnType: int
''');
}
test_metadata_offsets_onExtension() async {
var library = await buildLibrary(r'''
const foo = 0;
@foo
extension E<@foo T> on List<T> {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
extensions
E @31
reference: <testLibraryFragment>::@extension::E
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @16
name: SimpleIdentifier
token: foo @17
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
typeParameters
covariant T @38
defaultType: dynamic
metadata
Annotation
atSign: @ @33
name: SimpleIdentifier
token: foo @34
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
extendedType: List<T>
topLevelVariables
static const foo @6
reference: <testLibraryFragment>::@topLevelVariable::foo
enclosingElement: <testLibraryFragment>
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 0 @12
staticType: int
accessors
synthetic static get foo @-1
reference: <testLibraryFragment>::@getter::foo
enclosingElement: <testLibraryFragment>
returnType: int
''');
}
test_metadata_offsets_onFieldDeclaration() async {
var library = await buildLibrary(r'''
const foo = 0;
class A {
@foo
static isStatic = 1;
@foo
static const isStaticConst = 2;
@foo
var isInstance = 3;
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
classes
class A @22
reference: <testLibraryFragment>::@class::A
enclosingElement: <testLibraryFragment>
fields
static isStatic @42
reference: <testLibraryFragment>::@class::A::@field::isStatic
enclosingElement: <testLibraryFragment>::@class::A
metadata
Annotation
atSign: @ @28
name: SimpleIdentifier
token: foo @29
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
type: int
shouldUseTypeForInitializerInference: false
static const isStaticConst @79
reference: <testLibraryFragment>::@class::A::@field::isStaticConst
enclosingElement: <testLibraryFragment>::@class::A
metadata
Annotation
atSign: @ @59
name: SimpleIdentifier
token: foo @60
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 2 @95
staticType: int
isInstance @112
reference: <testLibraryFragment>::@class::A::@field::isInstance
enclosingElement: <testLibraryFragment>::@class::A
metadata
Annotation
atSign: @ @101
name: SimpleIdentifier
token: foo @102
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
type: int
shouldUseTypeForInitializerInference: false
constructors
synthetic @-1
reference: <testLibraryFragment>::@class::A::@constructor::new
enclosingElement: <testLibraryFragment>::@class::A
accessors
synthetic static get isStatic @-1
reference: <testLibraryFragment>::@class::A::@getter::isStatic
enclosingElement: <testLibraryFragment>::@class::A
returnType: int
synthetic static set isStatic= @-1
reference: <testLibraryFragment>::@class::A::@setter::isStatic
enclosingElement: <testLibraryFragment>::@class::A
parameters
requiredPositional _isStatic @-1
type: int
returnType: void
synthetic static get isStaticConst @-1
reference: <testLibraryFragment>::@class::A::@getter::isStaticConst
enclosingElement: <testLibraryFragment>::@class::A
returnType: int
synthetic get isInstance @-1
reference: <testLibraryFragment>::@class::A::@getter::isInstance
enclosingElement: <testLibraryFragment>::@class::A
returnType: int
synthetic set isInstance= @-1
reference: <testLibraryFragment>::@class::A::@setter::isInstance
enclosingElement: <testLibraryFragment>::@class::A
parameters
requiredPositional _isInstance @-1
type: int
returnType: void
topLevelVariables
static const foo @6
reference: <testLibraryFragment>::@topLevelVariable::foo
enclosingElement: <testLibraryFragment>
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 0 @12
staticType: int
accessors
synthetic static get foo @-1
reference: <testLibraryFragment>::@getter::foo
enclosingElement: <testLibraryFragment>
returnType: int
''');
}
test_metadata_offsets_onLibrary() async {
var library = await buildLibrary('''
/// Some documentation.
@foo
library my.lib;
const foo = 0;
''');
checkElementText(library, r'''
library
name: my.lib
nameOffset: 37
reference: <testLibrary>
documentationComment: /// Some documentation.
metadata
Annotation
atSign: @ @24
name: SimpleIdentifier
token: foo @25
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
topLevelVariables
static const foo @52
reference: <testLibraryFragment>::@topLevelVariable::foo
enclosingElement: <testLibraryFragment>
type: int
shouldUseTypeForInitializerInference: false
constantInitializer
IntegerLiteral
literal: 0 @58
staticType: int
accessors
synthetic static get foo @-1
reference: <testLibraryFragment>::@getter::foo
enclosingElement: <testLibraryFragment>
returnType: int
''');
}
test_metadata_offsets_onMixin() async {
var library = await buildLibrary(r'''
const foo = 0;
@foo
mixin A<@foo T> {}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
definingUnit: <testLibraryFragment>
units
<testLibraryFragment>
enclosingElement: <testLibrary>
mixins
mixin A @27
reference: <testLibraryFragment>::@mixin::A
enclosingElement: <testLibraryFragment>
metadata
Annotation
atSign: @ @16
name: SimpleIdentifier
token: foo @17
staticElement: <testLibraryFragment>::@getter::foo
staticType: null
element: <testLibraryFragment>::@getter::foo
ty