Move join_lines to ra_ide_api

This commit is contained in:
Wilco Kusee 2019-03-21 19:51:42 +01:00
parent 6e324d38d6
commit 58e77660de
7 changed files with 10 additions and 13 deletions

1
Cargo.lock generated
View file

@ -1008,6 +1008,7 @@ dependencies = [
"proptest 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "proptest 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ra_assists 0.1.0", "ra_assists 0.1.0",
"ra_db 0.1.0", "ra_db 0.1.0",
"ra_fmt 0.1.0",
"ra_hir 0.1.0", "ra_hir 0.1.0",
"ra_ide_api_light 0.1.0", "ra_ide_api_light 0.1.0",
"ra_syntax 0.1.0", "ra_syntax 0.1.0",

View file

@ -23,6 +23,7 @@ ra_syntax = { path = "../ra_syntax" }
ra_ide_api_light = { path = "../ra_ide_api_light" } ra_ide_api_light = { path = "../ra_ide_api_light" }
ra_text_edit = { path = "../ra_text_edit" } ra_text_edit = { path = "../ra_text_edit" }
ra_db = { path = "../ra_db" } ra_db = { path = "../ra_db" }
ra_fmt = { path = "../ra_fmt" }
hir = { path = "../ra_hir", package = "ra_hir" } hir = { path = "../ra_hir", package = "ra_hir" }
test_utils = { path = "../test_utils" } test_utils = { path = "../test_utils" }
ra_assists = { path = "../ra_assists" } ra_assists = { path = "../ra_assists" }

View file

@ -9,9 +9,8 @@ use ra_syntax::{
use ra_fmt::{ use ra_fmt::{
compute_ws, extract_trivial_expression compute_ws, extract_trivial_expression
}; };
use crate::{ use ra_text_edit::TextEditBuilder;
LocalEdit, TextEditBuilder, use ra_ide_api_light::LocalEdit;
};
pub fn join_lines(file: &SourceFile, range: TextRange) -> LocalEdit { pub fn join_lines(file: &SourceFile, range: TextRange) -> LocalEdit {
let range = if range.is_empty() { let range = if range.is_empty() {

View file

@ -36,9 +36,12 @@ mod syntax_tree;
mod line_index; mod line_index;
mod folding_ranges; mod folding_ranges;
mod line_index_utils; mod line_index_utils;
mod join_lines;
#[cfg(test)] #[cfg(test)]
mod marks; mod marks;
#[cfg(test)]
mod test_utils;
use std::sync::Arc; use std::sync::Arc;
@ -276,10 +279,7 @@ impl Analysis {
/// stuff like trailing commas. /// stuff like trailing commas.
pub fn join_lines(&self, frange: FileRange) -> SourceChange { pub fn join_lines(&self, frange: FileRange) -> SourceChange {
let file = self.db.parse(frange.file_id); let file = self.db.parse(frange.file_id);
SourceChange::from_local_edit( SourceChange::from_local_edit(frange.file_id, join_lines::join_lines(&file, frange.range))
frange.file_id,
ra_ide_api_light::join_lines(&file, frange.range),
)
} }
/// Returns an edit which should be applied when opening a new line, fixing /// Returns an edit which should be applied when opening a new line, fixing

View file

@ -4,9 +4,6 @@
//! an edit or some auxiliary info. //! an edit or some auxiliary info.
mod structure; mod structure;
#[cfg(test)]
mod test_utils;
mod join_lines;
mod typing; mod typing;
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
@ -20,7 +17,6 @@ use ra_syntax::{
pub use crate::{ pub use crate::{
structure::{file_structure, StructureNode}, structure::{file_structure, StructureNode},
join_lines::join_lines,
typing::{on_enter, on_dot_typed, on_eq_typed}, typing::{on_enter, on_dot_typed, on_eq_typed},
}; };
@ -118,7 +114,7 @@ mod tests {
use ra_syntax::AstNode; use ra_syntax::AstNode;
use insta::assert_debug_snapshot_matches; use insta::assert_debug_snapshot_matches;
use crate::test_utils::{add_cursor, assert_eq_text, extract_offset}; use test_utils::{add_cursor, assert_eq_text, extract_offset};
use super::*; use super::*;

View file

@ -118,7 +118,7 @@ pub fn on_dot_typed(file: &SourceFile, dot_offset: TextUnit) -> Option<LocalEdit
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::test_utils::{add_cursor, assert_eq_text, extract_offset}; use test_utils::{add_cursor, assert_eq_text, extract_offset};
use super::*; use super::*;