471: rename crates to match reality  r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2019-01-08 19:48:48 +00:00
commit 46f74e33ca
52 changed files with 135 additions and 107 deletions

View file

@ -15,7 +15,7 @@ More specifically, input data consists of a set of test files (`(PathBuf,
String)` pairs) and an information about project structure, the so called
`CrateGraph`. Crate graph specifies which files are crate roots, which cfg flags
are specified for each crate (TODO: actually implement this) and what are
dependencies between the crate. The analyzer keeps all these input data in
dependencies between the crates. The analyzer keeps all these input data in
memory and never does any IO. Because the input data is source code, which
typically measures in tens of megabytes at most, keeping all input data in
memory is OK.
@ -74,9 +74,9 @@ notes.
- `algo`: generic tree algorithms, including `walk` for O(1) stack
space tree traversal (this is cool) and `visit` for type-driven
visiting the nodes (this is double plus cool, if you understand how
`Visitor` works, you understand rust-analyzer).
`Visitor` works, you understand the design of syntax trees).
Test for ra_syntax are mostly data-driven: `tests/data/parser` contains a bunch of `.rs`
Tests for ra_syntax are mostly data-driven: `tests/data/parser` contains a bunch of `.rs`
(test vectors) and `.txt` files with corresponding syntax trees. During testing, we check
`.rs` against `.txt`. If the `.txt` file is missing, it is created (this is how you update
tests). Additionally, running `cargo gen-tests` will walk the grammar module and collect
@ -107,41 +107,46 @@ guessing a HIR for a particular source position.
Underneath, HIR works on top of salsa, using a `HirDatabase` trait.
### `crates/ra_analysis`
### `crates/ra_ide_api`
A stateful library for analyzing many Rust files as they change.
`AnalysisHost` is a mutable entity (clojure's atom) which holds the
current state, incorporates changes and handles out `Analysis` --- an
immutable and consistent snapshot of world state at a point in time, which
actually powers analysis.
A stateful library for analyzing many Rust files as they change. `AnalysisHost`
is a mutable entity (clojure's atom) which holds the current state, incorporates
changes and handles out `Analysis` --- an immutable and consistent snapshot of
world state at a point in time, which actually powers analysis.
One interesting aspect of analysis is its support for cancellation. When a change
is applied to `AnalysisHost`, first all currently active snapshots are
One interesting aspect of analysis is its support for cancellation. When a
change is applied to `AnalysisHost`, first all currently active snapshots are
cancelled. Only after all snapshots are dropped the change actually affects the
database.
### `crates/ra_lsp_server`
APIs in this crate are IDE centric: they take text offsets as input and produce
offsets and strings as output. This works on top of rich code model powered by
`hir`.
An LSP implementation which uses `ra_analysis` for managing state and
`ra_editor` for actually doing useful stuff.
### `crates/ra_ide_api_light`
See [#79](https://github.com/rust-analyzer/rust-analyzer/pull/79/) as an
example of PR which adds a new feature to `ra_editor` and exposes it
to `ra_lsp_server`.
All IDE features which can be implemented if you only have access to a single
file. `ra_ide_api_light` could be used to enhance editing of Rust code without
the need to fiddle with build-systems, file synchronization and such.
### `crates/ra_editor`
All IDE features which can be implemented if you only have access to a
single file. `ra_editor` could be used to enhance editing of Rust code
without the need to fiddle with build-systems, file
synchronization and such.
In a sense, `ra_editor` is just a bunch of pure functions which take a
In a sense, `ra_ide_api_light` is just a bunch of pure functions which take a
syntax tree as input.
The tests for `ra_editor` are `#[cfg(test)] mod tests` unit-tests spread
The tests for `ra_ide_api_light` are `#[cfg(test)] mod tests` unit-tests spread
throughout its modules.
### `crates/ra_lsp_server`
An LSP implementation which wraps `ra_ide_api` into a langauge server protocol.
### `crates/ra_vfs`
Although `hir` and `ra_ide_api` don't do any io, we need to be able to read
files from disk at the end of the day. This is what `ra_vfs` does. It also
manages overlays: "dirty" files in the editor, whose "true" contents is
different from data on disk.
### `crates/gen_lsp_server`
A language server scaffold, exposing a synchronous crossbeam-channel based API.

100
Cargo.lock generated
View file

@ -171,7 +171,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -548,7 +548,7 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -636,27 +636,6 @@ dependencies = [
"proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ra_analysis"
version = "0.1.0"
dependencies = [
"fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ra_db 0.1.0",
"ra_editor 0.1.0",
"ra_hir 0.1.0",
"ra_syntax 0.1.0",
"ra_text_edit 0.1.0",
"rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"salsa 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"test_utils 0.1.0",
"unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ra_arena"
version = "0.1.0"
@ -668,7 +647,7 @@ dependencies = [
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"join_to_string 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ra_editor 0.1.0",
"ra_ide_api_light 0.1.0",
"ra_syntax 0.1.0",
"tools 0.1.0",
]
@ -686,20 +665,6 @@ dependencies = [
"test_utils 0.1.0",
]
[[package]]
name = "ra_editor"
version = "0.1.0"
dependencies = [
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"join_to_string 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"proptest 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)",
"ra_syntax 0.1.0",
"ra_text_edit 0.1.0",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"superslice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"test_utils 0.1.0",
]
[[package]]
name = "ra_hir"
version = "0.1.0"
@ -718,6 +683,41 @@ dependencies = [
"test_utils 0.1.0",
]
[[package]]
name = "ra_ide_api"
version = "0.1.0"
dependencies = [
"fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ra_db 0.1.0",
"ra_hir 0.1.0",
"ra_ide_api_light 0.1.0",
"ra_syntax 0.1.0",
"ra_text_edit 0.1.0",
"rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"salsa 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"test_utils 0.1.0",
"unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ra_ide_api_light"
version = "0.1.0"
dependencies = [
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"join_to_string 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"proptest 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)",
"ra_syntax 0.1.0",
"ra_text_edit 0.1.0",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"superslice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"test_utils 0.1.0",
]
[[package]]
name = "ra_lsp_server"
version = "0.1.0"
@ -733,7 +733,7 @@ dependencies = [
"languageserver-types 0.53.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ra_analysis 0.1.0",
"ra_ide_api 0.1.0",
"ra_syntax 0.1.0",
"ra_text_edit 0.1.0",
"ra_vfs 0.1.0",
@ -806,7 +806,7 @@ dependencies = [
[[package]]
name = "rand"
version = "0.6.3"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -815,7 +815,7 @@ dependencies = [
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_os 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_os 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -861,13 +861,14 @@ dependencies = [
[[package]]
name = "rand_os"
version = "0.1.0"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -909,6 +910,14 @@ dependencies = [
"num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rdrand"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "redox_syscall"
version = "0.1.50"
@ -1164,7 +1173,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)",
"remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1551,17 +1560,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
"checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c"
"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c"
"checksum rand 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b65e163105a6284f841bd23100a015895f54340e88a5ffc9ca7b8b33827cfce0"
"checksum rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3906503e80ac6cbcacb2c2973fa8e473f24d7e2747c8c92bb230c2441cad96b5"
"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
"checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372"
"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db"
"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
"checksum rand_os 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de5ac4de1c2973e1391dc305cb0fbf8788cb58068e98255439b7485a77022273"
"checksum rand_os 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f46fbd5550acf75b0c2730f5dd1873751daf9beb8f11b44027778fae50d7feca"
"checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05"
"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
"checksum rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "373814f27745b2686b350dd261bfd24576a6fb0e2c5919b3a2b6005f820b0473"
"checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356"
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
"checksum redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)" = "52ee9a534dc1301776eff45b4fa92d2c39b1d8c3d3357e6eb593e0d795506fc2"
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
"checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f"

View file

@ -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" }

View file

@ -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;

View file

@ -1,4 +1,4 @@
//! ra_db defines basic database traits. Concrete DB is defined by ra_analysis.
//! ra_db defines basic database traits. Concrete DB is defined by ra_ide_api.
mod cancelation;
mod syntax_ptr;
mod input;

View file

@ -1,6 +1,6 @@
[package]
edition = "2018"
name = "ra_analysis"
name = "ra_ide_api"
version = "0.1.0"
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
@ -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" }

View file

@ -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)
}

View file

@ -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<Vec<Diagnostic>> {
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,

View file

@ -1,8 +1,14 @@
//! ra_analyzer crate provides "ide-centric" APIs for the rust-analyzer. What
//! powers this API are the `RootDatabase` struct, which defines a `salsa`
//! ra_ide_api crate provides "ide-centric" APIs for the rust-analyzer. That is,
//! it generally operates with files and text ranges, and returns results as
//! Strings, suitable for displaying to the human.
//!
//! What powers this API are the `RootDatabase` struct, which defines a `salsa`
//! database, and the `ra_hir` crate, where majority of the analysis happens.
//! However, IDE specific bits of the analysis (most notably completion) happen
//! in this crate.
//!
//! The sibling `ra_ide_api_light` handles thouse bits of IDE functionality
//! which are restricted to a single file and need only syntax.
macro_rules! ctry {
($expr:expr) => {
match $expr {
@ -44,7 +50,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 +342,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<TextUnit> {
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<SourceChange> {
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 +371,25 @@ impl Analysis {
// FIXME: use a snippet completion instead of this hack here.
pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> {
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<SourceChange> {
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<StructureNode> {
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<Fold> {
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<Vec<NavigationTarget>> {

View file

@ -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<Vec<HighlightedRange>> {
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)?;

View file

@ -3,7 +3,7 @@ mod runnables;
use ra_syntax::TextRange;
use test_utils::{assert_eq_dbg, assert_eq_text};
use ra_analysis::{
use ra_ide_api::{
mock_analysis::{analysis_and_position, single_file, single_file_with_position, MockAnalysis},
AnalysisChange, CrateGraph, FileId, Query
};

View file

@ -1,6 +1,6 @@
use test_utils::assert_eq_dbg;
use ra_analysis::mock_analysis::analysis_and_position;
use ra_ide_api::mock_analysis::analysis_and_position;
#[test]
fn test_runnables() {

View file

@ -1,6 +1,6 @@
[package]
edition = "2018"
name = "ra_editor"
name = "ra_ide_api_light"
version = "0.1.0"
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
publish = false

View file

@ -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;

View file

@ -29,7 +29,7 @@ parking_lot = "0.7.0"
thread_worker = { path = "../thread_worker" }
ra_syntax = { path = "../ra_syntax" }
ra_text_edit = { path = "../ra_text_edit" }
ra_analysis = { path = "../ra_analysis" }
ra_ide_api = { path = "../ra_ide_api" }
gen_lsp_server = { path = "../gen_lsp_server" }
ra_vfs = { path = "../ra_vfs" }

View file

@ -4,7 +4,7 @@ use languageserver_types::{
TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier,
WorkspaceEdit,
};
use ra_analysis::{
use ra_ide_api::{
CompletionItem, CompletionItemKind, FileId, FilePosition, FileRange, FileSystemEdit,
InsertText, NavigationTarget, SourceChange, SourceFileEdit,
LineCol, LineIndex, translate_offset_with_edit

View file

@ -10,7 +10,7 @@ use gen_lsp_server::{
handle_shutdown, ErrorCode, RawMessage, RawNotification, RawRequest, RawResponse,
};
use languageserver_types::NumberOrString;
use ra_analysis::{Canceled, FileId, LibraryData};
use ra_ide_api::{Canceled, FileId, LibraryData};
use ra_vfs::VfsTask;
use rayon;
use rustc_hash::FxHashSet;

View file

@ -8,7 +8,7 @@ use languageserver_types::{
ParameterInformation, ParameterLabel, Position, PrepareRenameResponse, Range, RenameParams,
SignatureInformation, SymbolInformation, TextDocumentIdentifier, TextEdit, WorkspaceEdit,
};
use ra_analysis::{
use ra_ide_api::{
FileId, FilePosition, FileRange, FoldKind, Query, RunnableKind, Severity, SourceChange,
};
use ra_syntax::{TextUnit, AstNode};
@ -736,7 +736,7 @@ fn highlight(world: &ServerWorld, file_id: FileId) -> Result<Vec<Decoration>> {
}
fn to_diagnostic_severity(severity: Severity) -> DiagnosticSeverity {
use ra_analysis::Severity::*;
use ra_ide_api::Severity::*;
match severity {
Error => DiagnosticSeverity::Error,

View file

@ -1,4 +1,4 @@
use ra_analysis::FileId;
use ra_ide_api::FileId;
use rustc_hash::FxHashSet;
pub struct Subscriptions {

View file

@ -1,10 +1,10 @@
use std::{
path::{PathBuf},
path::PathBuf,
sync::Arc,
};
use languageserver_types::Url;
use ra_analysis::{
use ra_ide_api::{
Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, LibraryData,
SourceRootId
};
@ -12,7 +12,7 @@ use ra_vfs::{Vfs, VfsChange, VfsFile, VfsRoot};
use rustc_hash::FxHashMap;
use relative_path::RelativePathBuf;
use parking_lot::RwLock;
use failure::{format_err};
use failure::format_err;
use crate::{
project_model::{CargoWorkspace, TargetKind},