Skip to content

Commit

Permalink
Break up autofix/fixes.rs (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh authored Oct 17, 2022
1 parent 206e646 commit 583149a
Show file tree
Hide file tree
Showing 13 changed files with 400 additions and 384 deletions.
14 changes: 13 additions & 1 deletion src/ast/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use once_cell::sync::Lazy;
use regex::Regex;
use rustpython_ast::{Excepthandler, ExcepthandlerKind, Expr, ExprKind, StmtKind};
use rustpython_ast::{Excepthandler, ExcepthandlerKind, Expr, ExprKind, Location, StmtKind};

use crate::python::typing;

Expand Down Expand Up @@ -131,3 +131,15 @@ pub fn is_super_call_with_arguments(func: &Expr, args: &[Expr]) -> bool {
false
}
}

/// Convert a location within a file (relative to `base`) to an absolute position.
pub fn to_absolute(relative: &Location, base: &Location) -> Location {
if relative.row() == 1 {
Location::new(
relative.row() + base.row() - 1,
relative.column() + base.column() - 1,
)
} else {
Location::new(relative.row() + base.row() - 1, relative.column())
}
}
371 changes: 0 additions & 371 deletions src/autofix/fixes.rs

This file was deleted.

Loading

0 comments on commit 583149a

Please sign in to comment.