Skip to content

Commit

Permalink
Use analyzer 5.12, fix uses of deprecated APIs. (#1220)
Browse files Browse the repository at this point in the history
* Use analyzer 5.12, fix uses of deprecated APIs.

* Use a change from flutter-style-experiment instead.
  • Loading branch information
scheglov authored May 16, 2023
1 parent 156f5c8 commit afb6bb4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
on other parameters (#1212).
* Don't split before `.` following a record literal (#1213).
* Don't force split on a line comment before a switch expression case (#1215).
* Require `package:analyzer` `^5.12.0`.

# 2.3.1

Expand Down
14 changes: 7 additions & 7 deletions lib/src/dart_formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ class DartFormatter {
var token = node.endToken.next!;
if (token.type != TokenType.CLOSE_CURLY_BRACKET) {
var stringSource = StringSource(text, source.uri);
var error = AnalysisError(
stringSource,
token.offset - inputOffset,
math.max(token.length, 1),
ParserErrorCode.UNEXPECTED_TOKEN,
[token.lexeme]);

var error = AnalysisError.tmp(
source: stringSource,
offset: token.offset - inputOffset,
length: math.max(token.length, 1),
errorCode: ParserErrorCode.UNEXPECTED_TOKEN,
arguments: [token.lexeme],
);
throw FormatterException([error]);
}
}
Expand Down
19 changes: 16 additions & 3 deletions lib/src/source_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1813,7 +1813,7 @@ class SourceVisitor extends ThrowingAstVisitor {
var hasInnerControlFlow = false;
for (var element in ifElements) {
_visitIfCondition(element.ifKeyword, element.leftParenthesis,
element.condition, element.caseClause, element.rightParenthesis);
element.expression, element.caseClause, element.rightParenthesis);

visitChild(element, element.thenElement);
if (element.thenElement.isControlFlowElement) {
Expand Down Expand Up @@ -1856,7 +1856,7 @@ class SourceVisitor extends ThrowingAstVisitor {

@override
void visitIfStatement(IfStatement node) {
_visitIfCondition(node.ifKeyword, node.leftParenthesis, node.condition,
_visitIfCondition(node.ifKeyword, node.leftParenthesis, node.expression,
node.caseClause, node.rightParenthesis);

void visitClause(Statement clause) {
Expand Down Expand Up @@ -2252,9 +2252,22 @@ class SourceVisitor extends ThrowingAstVisitor {

@override
void visitNamedType(NamedType node) {
visit(node.name);
var importPrefix = node.importPrefix;
if (importPrefix != null) {
builder.startSpan();

token(importPrefix.name);
soloZeroSplit();
token(importPrefix.period);
}

token(node.name2);
visit(node.typeArguments);
token(node.question);

if (importPrefix != null) {
builder.endSpan();
}
}

@override
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ environment:
sdk: ">=2.19.0 <3.0.0"

dependencies:
analyzer: ^5.7.0
analyzer: ^5.12.0
args: ">=1.0.0 <3.0.0"
path: ^1.0.0
pub_semver: ">=1.4.4 <3.0.0"
Expand Down

0 comments on commit afb6bb4

Please sign in to comment.