Skip to content

Commit

Permalink
Update import_sort.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
a-frantz committed Jul 3, 2024
1 parent a961355 commit 7e1ab8c
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions wdl-lint/src/rules/import_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use wdl_ast::Diagnostic;
use wdl_ast::Diagnostics;
use wdl_ast::Span;
use wdl_ast::SyntaxKind;
use wdl_ast::SyntaxNode;
use wdl_ast::ToSpan;
use wdl_ast::VisitReason;
use wdl_ast::Visitor;
Expand Down Expand Up @@ -89,17 +88,11 @@ impl Visitor for ImportSortRule {
return;
}

let imports = doc
.syntax()
.children_with_tokens()
.filter(|c| c.kind() == SyntaxKind::ImportStatementNode)
.map(|c| c.into_node().unwrap());

let mut prev_import: Option<SyntaxNode> = None;
for import in imports {
let mut prev_import: Option<ImportStatement> = None;
for import in doc.ast().as_v1().unwrap().imports() {
if let Some(prev) = prev_import {
if import.text().to_string() < prev.text().to_string() {
state.add(import_not_sorted(import.text_range().to_span()));
if import.syntax().to_string() < prev.syntax().to_string() {
state.add(import_not_sorted(import.syntax().text_range().to_span()));
return; // Only report one sorting diagnostic at a time.
}
}
Expand Down

0 comments on commit 7e1ab8c

Please sign in to comment.