Skip to content

Commit 9c456b0

Browse files
Merge pull request #997 from Workiva/upgrade-analyzer
FED-4405 Allow analyzer 8.x, 9.x, 10.x
2 parents 16b9057 + a605303 commit 9c456b0

5 files changed

Lines changed: 36 additions & 30 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,17 @@ jobs:
110110
strategy:
111111
fail-fast: false
112112
matrix:
113-
sdk: [ 2.19.6, stable ]
113+
sdk: [ stable ]
114114
analyzer:
115-
- ^5.13.0 # This should match the lower bound
116115
- ^6.0.0
117116
- ^7.0.0
118-
exclude:
119-
# Analyzer 6+ only resolves in Dart 3
120-
- sdk: 2.19.6
121-
analyzer: ^6.0.0
117+
- ^8.0.0
118+
- ^9.0.0
119+
- ^10.0.0
120+
# Analyzer 6+ does not resolve in Dart 2.
121+
include:
122122
- sdk: 2.19.6
123-
analyzer: ^7.0.0
123+
analyzer: ^5.13.0 # This should match the lower bound
124124

125125
steps:
126126
- uses: actions/checkout@v4

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# OverReact Changelog
22

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

67
## 5.5.0

lib/src/builder/parsing/ast_util.dart

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,27 @@ extension TypeAnnotationNameHelper on TypeAnnotation {
6868
/// Extension built on [NameHelper] to allow for easy access to the `name`
6969
/// field of [Identifier]s.
7070
extension TypeNameHelper on NamedType {
71+
// Backwards compatibility for various analyzer versions that remove name/name2.
72+
dynamic get name => this.name2; // Use `this.` to point to real impl if it exists, not extension.
73+
dynamic get name2 => this.name; // Use `this.` to point to real impl if it exists, not extension.
74+
dynamic get _name => name;
75+
String get nameLexeme {
76+
final name = this._name;
77+
if (name is Identifier) return name.name;
78+
if (name is Token) return name.lexeme;
79+
if (name is String) return name;
80+
throw UnimplementedError('Unexpected type for name: ${name.runtimeType}');
81+
}
82+
7183
/// The type name without any namespace prefixes.
72-
String get nameWithoutPrefix => name2.lexeme;
84+
String get nameWithoutPrefix => nameLexeme;
7385

7486
/// The type name including the namespace prefix.
7587
String get nameWithPrefix {
7688
final prefix = importPrefix?.name.lexeme;
77-
final name = name2.lexeme;
7889
return [
7990
if (prefix != null) prefix,
80-
name,
91+
nameLexeme,
8192
].join('.');
8293
}
8394
}

pubspec.yaml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ environment:
77

88
dependencies:
99
collection: ^1.15.0
10-
analyzer: '>=5.13.0 <8.0.0'
11-
build: ^2.0.0
10+
analyzer: '>=5.13.0 <11.0.0'
11+
build: '>=2.0.0 <5.0.0'
1212
dart_style: '>=2.0.0 <4.0.0'
1313
js: ^0.6.1+1
1414
logging: ^1.0.0
@@ -28,12 +28,11 @@ dependencies:
2828
dev_dependencies:
2929
args: ^2.4.2
3030
benchmark_harness: ^2.2.1
31-
build_resolvers: ^2.0.0
3231
build_runner: ^2.0.0
3332
build_test: '>=2.0.0 <4.0.0'
3433
build_web_compilers: '>=3.2.6 <5.0.0'
35-
dart_dev: ^4.0.1
36-
dependency_validator: ^3.0.0
34+
dart_dev: ^4.2.5
35+
dependency_validator: '>=3.0.0 <6.0.0'
3736
glob: ^2.0.1
3837
io: ^1.0.0
3938
react_testing_library: ^3.1.1
@@ -42,8 +41,3 @@ dev_dependencies:
4241
workiva_analysis_options: ^1.4.0
4342
yaml: ^3.1.0
4443
mocktail: ^1.0.3
45-
46-
workiva:
47-
core_checks:
48-
version: 1
49-
react_boilerplate: disabled

test/vm_tests/builder/parsing/ast_util/classish_declaration_test.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ main() {
6565

6666
expect(parseAndGetSingleClassish('''
6767
abstract class Foo implements Bar, Baz {}
68-
''').interfaces.map((i) => i.name2.name), ['Bar', 'Baz']);
68+
''').interfaces.map((i) => i.nameLexeme), ['Bar', 'Baz']);
6969
});
7070

7171
test('withClause', () {
@@ -105,7 +105,7 @@ main() {
105105

106106
expect(parseAndGetSingleClassish('''
107107
class Foo extends Bar {}
108-
''').superclass?.name2.name, 'Bar');
108+
''').superclass?.nameLexeme, 'Bar');
109109
});
110110

111111
test('mixins', () {
@@ -115,13 +115,13 @@ main() {
115115

116116
expect(parseAndGetSingleClassish('''
117117
class Foo extends Object with Bar, Baz {}
118-
''').mixins.map((m) => m.name2.name), ['Bar', 'Baz']);
118+
''').mixins.map((m) => m.nameLexeme), ['Bar', 'Baz']);
119119
});
120120

121121
test('allSuperTypes', () {
122122
expect(parseAndGetSingleClassish('''
123123
class Foo extends Bar with Baz implements Qux {}
124-
''').allSuperTypes.map((m) => m.name2.name), unorderedEquals(['Bar', 'Baz', 'Qux']));
124+
''').allSuperTypes.map((m) => m.nameLexeme), unorderedEquals(['Bar', 'Baz', 'Qux']));
125125
});
126126
});
127127
});
@@ -148,7 +148,7 @@ main() {
148148

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

154154
test('withClause', () {
@@ -180,19 +180,19 @@ main() {
180180
test('superclass', () {
181181
expect(parseAndGetSingleClassish('''
182182
class Foo = Bar with Baz;
183-
''').superclass?.name2.name, 'Bar');
183+
''').superclass?.nameLexeme, 'Bar');
184184
});
185185

186186
test('mixins', () {
187187
expect(parseAndGetSingleClassish('''
188188
class Foo = Object with Bar, Baz;
189-
''').mixins.map((m) => m.name2.name), ['Bar', 'Baz']);
189+
''').mixins.map((m) => m.nameLexeme), ['Bar', 'Baz']);
190190
});
191191

192192
test('allSuperTypes', () {
193193
expect(parseAndGetSingleClassish('''
194194
class Foo = Bar with Baz implements Qux;
195-
''').allSuperTypes.map((m) => m.name2.name), unorderedEquals(['Bar', 'Baz', 'Qux']));
195+
''').allSuperTypes.map((m) => m.nameLexeme), unorderedEquals(['Bar', 'Baz', 'Qux']));
196196
});
197197
});
198198
});
@@ -232,7 +232,7 @@ main() {
232232

233233
expect(parseAndGetSingleClassish('''
234234
mixin Foo on Bar implements Baz {}
235-
''').interfaces.map((i) => i.name2.name), unorderedEquals(['Bar', 'Baz']));
235+
''').interfaces.map((i) => i.nameLexeme), unorderedEquals(['Bar', 'Baz']));
236236
});
237237

238238
test('withClause', () {
@@ -268,7 +268,7 @@ main() {
268268
test('allSuperTypes', () {
269269
expect(parseAndGetSingleClassish('''
270270
mixin Foo on Bar implements Baz {}
271-
''').allSuperTypes.map((m) => m.name2.name), unorderedEquals(['Bar', 'Baz']));
271+
''').allSuperTypes.map((m) => m.nameLexeme), unorderedEquals(['Bar', 'Baz']));
272272
});
273273
});
274274
});

0 commit comments

Comments
 (0)