Skip to content

Commit afb6bb4

Browse files
authored
Use analyzer 5.12, fix uses of deprecated APIs. (#1220)
* Use analyzer 5.12, fix uses of deprecated APIs. * Use a change from flutter-style-experiment instead.
1 parent 156f5c8 commit afb6bb4

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
on other parameters (#1212).
77
* Don't split before `.` following a record literal (#1213).
88
* Don't force split on a line comment before a switch expression case (#1215).
9+
* Require `package:analyzer` `^5.12.0`.
910

1011
# 2.3.1
1112

lib/src/dart_formatter.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ class DartFormatter {
153153
var token = node.endToken.next!;
154154
if (token.type != TokenType.CLOSE_CURLY_BRACKET) {
155155
var stringSource = StringSource(text, source.uri);
156-
var error = AnalysisError(
157-
stringSource,
158-
token.offset - inputOffset,
159-
math.max(token.length, 1),
160-
ParserErrorCode.UNEXPECTED_TOKEN,
161-
[token.lexeme]);
162-
156+
var error = AnalysisError.tmp(
157+
source: stringSource,
158+
offset: token.offset - inputOffset,
159+
length: math.max(token.length, 1),
160+
errorCode: ParserErrorCode.UNEXPECTED_TOKEN,
161+
arguments: [token.lexeme],
162+
);
163163
throw FormatterException([error]);
164164
}
165165
}

lib/src/source_visitor.dart

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,7 +1813,7 @@ class SourceVisitor extends ThrowingAstVisitor {
18131813
var hasInnerControlFlow = false;
18141814
for (var element in ifElements) {
18151815
_visitIfCondition(element.ifKeyword, element.leftParenthesis,
1816-
element.condition, element.caseClause, element.rightParenthesis);
1816+
element.expression, element.caseClause, element.rightParenthesis);
18171817

18181818
visitChild(element, element.thenElement);
18191819
if (element.thenElement.isControlFlowElement) {
@@ -1856,7 +1856,7 @@ class SourceVisitor extends ThrowingAstVisitor {
18561856

18571857
@override
18581858
void visitIfStatement(IfStatement node) {
1859-
_visitIfCondition(node.ifKeyword, node.leftParenthesis, node.condition,
1859+
_visitIfCondition(node.ifKeyword, node.leftParenthesis, node.expression,
18601860
node.caseClause, node.rightParenthesis);
18611861

18621862
void visitClause(Statement clause) {
@@ -2252,9 +2252,22 @@ class SourceVisitor extends ThrowingAstVisitor {
22522252

22532253
@override
22542254
void visitNamedType(NamedType node) {
2255-
visit(node.name);
2255+
var importPrefix = node.importPrefix;
2256+
if (importPrefix != null) {
2257+
builder.startSpan();
2258+
2259+
token(importPrefix.name);
2260+
soloZeroSplit();
2261+
token(importPrefix.period);
2262+
}
2263+
2264+
token(node.name2);
22562265
visit(node.typeArguments);
22572266
token(node.question);
2267+
2268+
if (importPrefix != null) {
2269+
builder.endSpan();
2270+
}
22582271
}
22592272

22602273
@override

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ environment:
99
sdk: ">=2.19.0 <3.0.0"
1010

1111
dependencies:
12-
analyzer: ^5.7.0
12+
analyzer: ^5.12.0
1313
args: ">=1.0.0 <3.0.0"
1414
path: ^1.0.0
1515
pub_semver: ">=1.4.4 <3.0.0"

0 commit comments

Comments
 (0)