From fa3c9ce3921b6a3f67222bf4f9b4efdf4f11c2a5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 8 Jan 2019 22:30:32 +0300 Subject: fix usages after rename --- crates/ra_analysis/Cargo.toml | 2 +- crates/ra_analysis/src/extend_selection.rs | 4 ++-- crates/ra_analysis/src/imp.rs | 4 ++-- crates/ra_analysis/src/lib.rs | 21 ++++++++++++--------- crates/ra_analysis/src/syntax_highlighting.rs | 7 +++---- crates/ra_cli/Cargo.toml | 2 +- crates/ra_cli/src/main.rs | 2 +- crates/ra_ide_api_light/Cargo.toml | 2 +- crates/ra_ide_api_light/src/lib.rs | 5 +++++ 9 files changed, 28 insertions(+), 21 deletions(-) (limited to 'crates') diff --git a/crates/ra_analysis/Cargo.toml b/crates/ra_analysis/Cargo.toml index 11c78ced8..3c0814279 100644 --- a/crates/ra_analysis/Cargo.toml +++ b/crates/ra_analysis/Cargo.toml @@ -16,7 +16,7 @@ parking_lot = "0.7.0" unicase = "2.2.0" ra_syntax = { path = "../ra_syntax" } -ra_editor = { path = "../ra_editor" } +ra_ide_api_light = { path = "../ra_ide_api_light" } ra_text_edit = { path = "../ra_text_edit" } ra_db = { path = "../ra_db" } hir = { path = "../ra_hir", package = "ra_hir" } diff --git a/crates/ra_analysis/src/extend_selection.rs b/crates/ra_analysis/src/extend_selection.rs index 3b130f966..c3c809c9f 100644 --- a/crates/ra_analysis/src/extend_selection.rs +++ b/crates/ra_analysis/src/extend_selection.rs @@ -14,7 +14,7 @@ pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRang if let Some(range) = extend_selection_in_macro(db, &source_file, frange) { return range; } - ra_editor::extend_selection(source_file.syntax(), frange.range).unwrap_or(frange.range) + ra_ide_api_light::extend_selection(source_file.syntax(), frange.range).unwrap_or(frange.range) } fn extend_selection_in_macro( @@ -25,7 +25,7 @@ fn extend_selection_in_macro( let macro_call = find_macro_call(source_file.syntax(), frange.range)?; let (off, exp) = hir::MacroDef::ast_expand(macro_call)?; let dst_range = exp.map_range_forward(frange.range - off)?; - let dst_range = ra_editor::extend_selection(&exp.syntax(), dst_range)?; + let dst_range = ra_ide_api_light::extend_selection(&exp.syntax(), dst_range)?; let src_range = exp.map_range_back(dst_range)? + off; Some(src_range) } diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 2b9963b3c..7c60ab7d6 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -6,7 +6,7 @@ use hir::{ self, Problem, source_binder, }; use ra_db::{FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase}; -use ra_editor::{self, assists, LocalEdit, Severity}; +use ra_ide_api_light::{self, assists, LocalEdit, Severity}; use ra_syntax::{ TextRange, AstNode, SourceFile, ast::{self, NameOwner}, @@ -194,7 +194,7 @@ impl db::RootDatabase { pub(crate) fn diagnostics(&self, file_id: FileId) -> Cancelable> { let syntax = self.source_file(file_id); - let mut res = ra_editor::diagnostics(&syntax) + let mut res = ra_ide_api_light::diagnostics(&syntax) .into_iter() .map(|d| Diagnostic { range: d.range, diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index 48df08416..183e36706 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs @@ -44,7 +44,7 @@ pub use crate::{ completion::{CompletionItem, CompletionItemKind, InsertText}, runnables::{Runnable, RunnableKind}, }; -pub use ra_editor::{ +pub use ra_ide_api_light::{ Fold, FoldKind, HighlightedRange, Severity, StructureNode, LineIndex, LineCol, translate_offset_with_edit, }; @@ -336,25 +336,28 @@ impl Analysis { /// Returns position of the mathcing brace (all types of braces are /// supported). pub fn matching_brace(&self, file: &SourceFile, offset: TextUnit) -> Option { - ra_editor::matching_brace(file, offset) + ra_ide_api_light::matching_brace(file, offset) } /// Returns a syntax tree represented as `String`, for debug purposes. // FIXME: use a better name here. pub fn syntax_tree(&self, file_id: FileId) -> String { let file = self.db.source_file(file_id); - ra_editor::syntax_tree(&file) + ra_ide_api_light::syntax_tree(&file) } /// Returns an edit to remove all newlines in the range, cleaning up minor /// stuff like trailing commas. pub fn join_lines(&self, frange: FileRange) -> SourceChange { let file = self.db.source_file(frange.file_id); - SourceChange::from_local_edit(frange.file_id, ra_editor::join_lines(&file, frange.range)) + SourceChange::from_local_edit( + 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 /// up minor stuff like continuing the comment. pub fn on_enter(&self, position: FilePosition) -> Option { let file = self.db.source_file(position.file_id); - let edit = ra_editor::on_enter(&file, position.offset)?; + let edit = ra_ide_api_light::on_enter(&file, position.offset)?; Some(SourceChange::from_local_edit(position.file_id, edit)) } /// Returns an edit which should be applied after `=` was typed. Primarily, @@ -362,25 +365,25 @@ impl Analysis { // FIXME: use a snippet completion instead of this hack here. pub fn on_eq_typed(&self, position: FilePosition) -> Option { let file = self.db.source_file(position.file_id); - let edit = ra_editor::on_eq_typed(&file, position.offset)?; + let edit = ra_ide_api_light::on_eq_typed(&file, position.offset)?; Some(SourceChange::from_local_edit(position.file_id, edit)) } /// Returns an edit which should be applied when a dot ('.') is typed on a blank line, indenting the line appropriately. pub fn on_dot_typed(&self, position: FilePosition) -> Option { let file = self.db.source_file(position.file_id); - let edit = ra_editor::on_dot_typed(&file, position.offset)?; + let edit = ra_ide_api_light::on_dot_typed(&file, position.offset)?; Some(SourceChange::from_local_edit(position.file_id, edit)) } /// Returns a tree representation of symbols in the file. Useful to draw a /// file outline. pub fn file_structure(&self, file_id: FileId) -> Vec { let file = self.db.source_file(file_id); - ra_editor::file_structure(&file) + ra_ide_api_light::file_structure(&file) } /// Returns the set of folding ranges. pub fn folding_ranges(&self, file_id: FileId) -> Vec { let file = self.db.source_file(file_id); - ra_editor::folding_ranges(&file) + ra_ide_api_light::folding_ranges(&file) } /// Fuzzy searches for a symbol. pub fn symbol_search(&self, query: Query) -> Cancelable> { diff --git a/crates/ra_analysis/src/syntax_highlighting.rs b/crates/ra_analysis/src/syntax_highlighting.rs index d2dc6cfbb..cb19e9515 100644 --- a/crates/ra_analysis/src/syntax_highlighting.rs +++ b/crates/ra_analysis/src/syntax_highlighting.rs @@ -1,22 +1,21 @@ use ra_syntax::{ast, AstNode,}; -use ra_editor::HighlightedRange; use ra_db::SyntaxDatabase; use crate::{ + FileId, Cancelable, HighlightedRange, db::RootDatabase, - FileId, Cancelable, }; pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Cancelable> { let source_file = db.source_file(file_id); - let mut res = ra_editor::highlight(source_file.syntax()); + let mut res = ra_ide_api_light::highlight(source_file.syntax()); for macro_call in source_file .syntax() .descendants() .filter_map(ast::MacroCall::cast) { if let Some((off, exp)) = hir::MacroDef::ast_expand(macro_call) { - let mapped_ranges = ra_editor::highlight(&exp.syntax()) + let mapped_ranges = ra_ide_api_light::highlight(&exp.syntax()) .into_iter() .filter_map(|r| { let mapped_range = exp.map_range_back(r.range)?; diff --git a/crates/ra_cli/Cargo.toml b/crates/ra_cli/Cargo.toml index 83f1d91e0..eb1722d5e 100644 --- a/crates/ra_cli/Cargo.toml +++ b/crates/ra_cli/Cargo.toml @@ -10,5 +10,5 @@ clap = "2.32.0" failure = "0.1.4" join_to_string = "0.1.1" ra_syntax = { path = "../ra_syntax" } -ra_editor = { path = "../ra_editor" } +ra_ide_api_light = { path = "../ra_ide_api_light" } tools = { path = "../tools" } diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs index 0d12f3a88..43fb2fc4c 100644 --- a/crates/ra_cli/src/main.rs +++ b/crates/ra_cli/src/main.rs @@ -2,7 +2,7 @@ use std::{fs, io::Read, path::Path, time::Instant}; use clap::{App, Arg, SubCommand}; use join_to_string::join; -use ra_editor::{extend_selection, file_structure, syntax_tree}; +use ra_ide_api_light::{extend_selection, file_structure, syntax_tree}; use ra_syntax::{SourceFile, TextRange, TreePtr, AstNode}; use tools::collect_tests; diff --git a/crates/ra_ide_api_light/Cargo.toml b/crates/ra_ide_api_light/Cargo.toml index a97d2308f..8c192fca6 100644 --- a/crates/ra_ide_api_light/Cargo.toml +++ b/crates/ra_ide_api_light/Cargo.toml @@ -1,6 +1,6 @@ [package] edition = "2018" -name = "ra_editor" +name = "ra_ide_api_light" version = "0.1.0" authors = ["Aleksey Kladov "] publish = false diff --git a/crates/ra_ide_api_light/src/lib.rs b/crates/ra_ide_api_light/src/lib.rs index 5a6af19b7..40638eda8 100644 --- a/crates/ra_ide_api_light/src/lib.rs +++ b/crates/ra_ide_api_light/src/lib.rs @@ -1,3 +1,8 @@ +//! This crate provides thouse IDE features which use only a single file. +//! +//! This usually means functions which take sytnax tree as an input and produce +//! an edit or some auxilarly info. + pub mod assists; mod extend_selection; mod folding_ranges; -- cgit v1.2.3