Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,17 @@ jobs:
strategy:
fail-fast: false
matrix:
sdk: [ 2.19.6, stable ]
sdk: [ stable ]
analyzer:
- ^5.13.0 # This should match the lower bound
- ^6.0.0
- ^7.0.0
exclude:
# Analyzer 6+ only resolves in Dart 3
- sdk: 2.19.6
analyzer: ^6.0.0
- ^8.0.0
- ^9.0.0
- ^10.0.0
# Analyzer 6+ does not resolve in Dart 2.
include:
- sdk: 2.19.6
analyzer: ^7.0.0
analyzer: ^5.13.0 # This should match the lower bound

steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# OverReact Changelog

## Unreleased
- Update analyzer dependency to `>=5.13.0 <11.0.0` (allow 8, 9, and 10)
- Remove dependency on `transformer_utils`

## 5.5.0
Expand Down
17 changes: 14 additions & 3 deletions lib/src/builder/parsing/ast_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,27 @@ extension TypeAnnotationNameHelper on TypeAnnotation {
/// Extension built on [NameHelper] to allow for easy access to the `name`
/// field of [Identifier]s.
extension TypeNameHelper on NamedType {
// Backwards compatibility for various analyzer versions that remove name/name2.
dynamic get name => this.name2; // Use `this.` to point to real impl if it exists, not extension.
dynamic get name2 => this.name; // Use `this.` to point to real impl if it exists, not extension.
dynamic get _name => name;
String get nameLexeme {
final name = this._name;
if (name is Identifier) return name.name;
if (name is Token) return name.lexeme;
if (name is String) return name;
throw UnimplementedError('Unexpected type for name: ${name.runtimeType}');
}

/// The type name without any namespace prefixes.
String get nameWithoutPrefix => name2.lexeme;
String get nameWithoutPrefix => nameLexeme;

/// The type name including the namespace prefix.
String get nameWithPrefix {
final prefix = importPrefix?.name.lexeme;
final name = name2.lexeme;
return [
if (prefix != null) prefix,
name,
nameLexeme,
].join('.');
}
}
Expand Down
14 changes: 4 additions & 10 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ environment:

dependencies:
collection: ^1.15.0
analyzer: '>=5.13.0 <8.0.0'
build: ^2.0.0
analyzer: '>=5.13.0 <11.0.0'
build: '>=2.0.0 <5.0.0'
dart_style: '>=2.0.0 <4.0.0'
js: ^0.6.1+1
logging: ^1.0.0
Expand All @@ -28,12 +28,11 @@ dependencies:
dev_dependencies:
args: ^2.4.2
benchmark_harness: ^2.2.1
build_resolvers: ^2.0.0
build_runner: ^2.0.0
build_test: '>=2.0.0 <4.0.0'
build_web_compilers: '>=3.2.6 <5.0.0'
dart_dev: ^4.0.1
dependency_validator: ^3.0.0
dart_dev: ^4.2.5
dependency_validator: '>=3.0.0 <6.0.0'
glob: ^2.0.1
io: ^1.0.0
react_testing_library: ^3.1.1
Expand All @@ -42,8 +41,3 @@ dev_dependencies:
workiva_analysis_options: ^1.4.0
yaml: ^3.1.0
mocktail: ^1.0.3

workiva:
core_checks:
version: 1
react_boilerplate: disabled
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ main() {

expect(parseAndGetSingleClassish('''
abstract class Foo implements Bar, Baz {}
''').interfaces.map((i) => i.name2.name), ['Bar', 'Baz']);
''').interfaces.map((i) => i.nameLexeme), ['Bar', 'Baz']);
});

test('withClause', () {
Expand Down Expand Up @@ -105,7 +105,7 @@ main() {

expect(parseAndGetSingleClassish('''
class Foo extends Bar {}
''').superclass?.name2.name, 'Bar');
''').superclass?.nameLexeme, 'Bar');
});

test('mixins', () {
Expand All @@ -115,13 +115,13 @@ main() {

expect(parseAndGetSingleClassish('''
class Foo extends Object with Bar, Baz {}
''').mixins.map((m) => m.name2.name), ['Bar', 'Baz']);
''').mixins.map((m) => m.nameLexeme), ['Bar', 'Baz']);
});

test('allSuperTypes', () {
expect(parseAndGetSingleClassish('''
class Foo extends Bar with Baz implements Qux {}
''').allSuperTypes.map((m) => m.name2.name), unorderedEquals(['Bar', 'Baz', 'Qux']));
''').allSuperTypes.map((m) => m.nameLexeme), unorderedEquals(['Bar', 'Baz', 'Qux']));
});
});
});
Expand All @@ -148,7 +148,7 @@ main() {

expect(parseAndGetSingleClassish('''
abstract class Foo = Object with Something implements Bar, Baz;
''').interfaces.map((i) => i.name2.name), ['Bar', 'Baz']);
''').interfaces.map((i) => i.nameLexeme), ['Bar', 'Baz']);
});

test('withClause', () {
Expand Down Expand Up @@ -180,19 +180,19 @@ main() {
test('superclass', () {
expect(parseAndGetSingleClassish('''
class Foo = Bar with Baz;
''').superclass?.name2.name, 'Bar');
''').superclass?.nameLexeme, 'Bar');
});

test('mixins', () {
expect(parseAndGetSingleClassish('''
class Foo = Object with Bar, Baz;
''').mixins.map((m) => m.name2.name), ['Bar', 'Baz']);
''').mixins.map((m) => m.nameLexeme), ['Bar', 'Baz']);
});

test('allSuperTypes', () {
expect(parseAndGetSingleClassish('''
class Foo = Bar with Baz implements Qux;
''').allSuperTypes.map((m) => m.name2.name), unorderedEquals(['Bar', 'Baz', 'Qux']));
''').allSuperTypes.map((m) => m.nameLexeme), unorderedEquals(['Bar', 'Baz', 'Qux']));
});
});
});
Expand Down Expand Up @@ -232,7 +232,7 @@ main() {

expect(parseAndGetSingleClassish('''
mixin Foo on Bar implements Baz {}
''').interfaces.map((i) => i.name2.name), unorderedEquals(['Bar', 'Baz']));
''').interfaces.map((i) => i.nameLexeme), unorderedEquals(['Bar', 'Baz']));
});

test('withClause', () {
Expand Down Expand Up @@ -268,7 +268,7 @@ main() {
test('allSuperTypes', () {
expect(parseAndGetSingleClassish('''
mixin Foo on Bar implements Baz {}
''').allSuperTypes.map((m) => m.name2.name), unorderedEquals(['Bar', 'Baz']));
''').allSuperTypes.map((m) => m.nameLexeme), unorderedEquals(['Bar', 'Baz']));
});
});
});
Expand Down