-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add macro metadata
dart_model
types and convert. (#118)
- Loading branch information
1 parent
a3ab801
commit 90d9129
Showing
13 changed files
with
4,705 additions
and
104 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
include: package:dart_flutter_team_lints/analysis_options.yaml |
Large diffs are not rendered by default.
Oops, something went wrong.
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,16 @@ | ||
sdk: | ||
# Only "pubspec" for when using SDK via a hash reference for latest | ||
# `_fe_analyzer_shared`. | ||
- pubspec | ||
|
||
stages: | ||
- analyze_and_format: | ||
- analyze: --fatal-infos . | ||
- format: | ||
sdk: | ||
- dev | ||
- unit_test: | ||
- test: --test-randomize-ordering-seed=random | ||
os: | ||
- linux | ||
- windows |
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,15 @@ | ||
name: _analyzer_cfe_macros | ||
publish-to: none | ||
description: Macro support for the analyzer and CFE. | ||
resolution: workspace | ||
|
||
environment: | ||
sdk: ^3.7.0-39.0.dev | ||
|
||
dependencies: | ||
_fe_analyzer_shared: any | ||
dart_model: any | ||
|
||
dev_dependencies: | ||
dart_flutter_team_lints: ^3.0.0 | ||
test: ^1.25.0 |
62 changes: 62 additions & 0 deletions
62
pkgs/_analyzer_cfe_macros/test/metadata_converter_test.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,62 @@ | ||
// 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_cfe_macros/metadata_converter.dart'; | ||
import 'package:_fe_analyzer_shared/src/metadata/ast.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
test('converts with unions', () { | ||
final invocation = MethodInvocation(DoubleLiteral('1.23'), 'round', [], []); | ||
|
||
expect(convert<Object>(invocation), <String, Object?>{ | ||
'receiver': { | ||
'type': 'DoubleLiteral', | ||
'value': {'text': '1.23'} | ||
}, | ||
'name': 'round', | ||
'typeArguments': [], | ||
'arguments': [], | ||
}); | ||
}); | ||
|
||
test('converts with enums', () { | ||
final expression = BinaryExpression( | ||
DoubleLiteral('1.23'), BinaryOperator.minus, DoubleLiteral('1.24')); | ||
|
||
expect(convert<Object>(expression), <String, Object?>{ | ||
'left': { | ||
'type': 'DoubleLiteral', | ||
'value': {'text': '1.23'} | ||
}, | ||
'operator': 'minus', | ||
'right': { | ||
'type': 'DoubleLiteral', | ||
'value': {'text': '1.24'} | ||
} | ||
}); | ||
}); | ||
|
||
test('converts with lists', () { | ||
final invocation = MethodInvocation(DoubleLiteral('1.23'), 'round', [], | ||
[PositionalArgument(IntegerLiteral('4'))]); | ||
|
||
expect(convert<Object>(invocation), <String, Object?>{ | ||
'receiver': { | ||
'type': 'DoubleLiteral', | ||
'value': {'text': '1.23'} | ||
}, | ||
'name': 'round', | ||
'typeArguments': [], | ||
'arguments': [ | ||
{ | ||
'expression': { | ||
'type': 'IntegerLiteral', | ||
'value': {'text': '4'} | ||
} | ||
} | ||
] | ||
}); | ||
}); | ||
} |
Oops, something went wrong.