Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use analyzer 5.12, fix uses of deprecated APIs. #1220

Merged
merged 2 commits into from
May 16, 2023
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
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);
}
scheglov marked this conversation as resolved.
Show resolved Hide resolved

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