-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge 95686e8 into dev
- Loading branch information
Showing
12 changed files
with
955 additions
and
87 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
pkg/analyzer/test/src/summary/macro/single/addClass_addMethod_addMethod.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) 2023, 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:_fe_analyzer_shared/src/macros/api.dart'; | ||
|
||
/*macro*/ class AddClassB implements ClassTypesMacro { | ||
const AddClassB(); | ||
|
||
@override | ||
buildTypesForClass(clazz, builder) async { | ||
// ignore: deprecated_member_use | ||
final identifier = await builder.resolveIdentifier( | ||
Uri.parse('package:test/a.dart'), | ||
'AddMethodFoo', | ||
); | ||
builder.declareType( | ||
'MyClass', | ||
DeclarationCode.fromParts([ | ||
'@', | ||
identifier, | ||
'()\nclass B {}\n', | ||
]), | ||
); | ||
} | ||
} | ||
|
||
/*macro*/ class AddMethodBar implements MethodDeclarationsMacro { | ||
const AddMethodBar(); | ||
|
||
@override | ||
buildDeclarationsForMethod(method, builder) async { | ||
builder.declareInType( | ||
DeclarationCode.fromString(' void bar() {}'), | ||
); | ||
} | ||
} | ||
|
||
/*macro*/ class AddMethodFoo implements ClassDeclarationsMacro { | ||
const AddMethodFoo(); | ||
|
||
@override | ||
buildDeclarationsForClass(clazz, builder) async { | ||
// ignore: deprecated_member_use | ||
final identifier = await builder.resolveIdentifier( | ||
Uri.parse('package:test/a.dart'), | ||
'AddMethodBar', | ||
); | ||
builder.declareInType( | ||
DeclarationCode.fromParts([ | ||
' @', | ||
identifier, | ||
'()\n void foo() {}', | ||
]), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.