Repository: rust-analyzer/rust-analyzer
Pull request #471 (2019-01-08 19:48:24)

rename crates to match reality 


Patch:
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index 277b29c122..9c404f4c3d 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -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`
-
-An LSP implementation which uses `ra_analysis` for managing state and
-`ra_editor` for actually doing useful stuff.
-
-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`.
+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`.
 
-### `crates/ra_editor`
+### `crates/ra_ide_api_light`
 
-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.
+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.
 
-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.
diff --git a/Cargo.lock b/Cargo.lock
index f1d8e5462c..354cc138b9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -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",
 ]
@@ -687,35 +666,56 @@ dependencies = [
 ]
 
 [[package]]
-name = "ra_editor"
+name = "ra_hir"
 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)",
+ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "flexi_logger 0.10.4 (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_arena 0.1.0",
+ "ra_db 0.1.0",
  "ra_syntax 0.1.0",
- "ra_text_edit 0.1.0",
+ "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)",
- "superslice 0.1.0 (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",
 ]
 
 [[package]]
-name = "ra_hir"
+name = "ra_ide_api"
 version = "0.1.0"
 dependencies = [
- "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "flexi_logger 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "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_arena 0.1.0",
  "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]]
@@ -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"
diff --git a/crates/ra_cli/Cargo.toml b/crates/ra_cli/Cargo.toml
index 83f1d91e0b..eb1722d5e7 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 0d12f3a88a..43fb2fc4ce 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_db/src/lib.rs b/crates/ra_db/src/lib.rs
index f56f70983a..e680d9fc37 100644
--- a/crates/ra_db/src/lib.rs
+++ b/crates/ra_db/src/lib.rs
@@ -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;
diff --git a/crates/ra_analysis/Cargo.toml b/crates/ra_ide_api/Cargo.toml
similarity index 87%
rename from crates/ra_analysis/Cargo.toml
rename to crates/ra_ide_api/Cargo.toml
index 11c78ced82..d42a664b65 100644
--- a/crates/ra_analysis/Cargo.toml
+++ b/crates/ra_ide_api/Cargo.toml
@@ -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" }
diff --git a/crates/ra_analysis/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs
similarity index 100%
rename from crates/ra_analysis/src/call_info.rs
rename to crates/ra_ide_api/src/call_info.rs
diff --git a/crates/ra_analysis/src/completion.rs b/crates/ra_ide_api/src/completion.rs
similarity index 100%
rename from crates/ra_analysis/src/completion.rs
rename to crates/ra_ide_api/src/completion.rs
diff --git a/crates/ra_analysis/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs
similarity index 100%
rename from crates/ra_analysis/src/completion/complete_dot.rs
rename to crates/ra_ide_api/src/completion/complete_dot.rs
diff --git a/crates/ra_analysis/src/completion/complete_fn_param.rs b/crates/ra_ide_api/src/completion/complete_fn_param.rs
similarity index 100%
rename from crates/ra_analysis/src/completion/complete_fn_param.rs
rename to crates/ra_ide_api/src/completion/complete_fn_param.rs
diff --git a/crates/ra_analysis/src/completion/complete_keyword.rs b/crates/ra_ide_api/src/completion/complete_keyword.rs
similarity index 100%
rename from crates/ra_analysis/src/completion/complete_keyword.rs
rename to crates/ra_ide_api/src/completion/complete_keyword.rs
diff --git a/crates/ra_analysis/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs
similarity index 100%
rename from crates/ra_analysis/src/completion/complete_path.rs
rename to crates/ra_ide_api/src/completion/complete_path.rs
diff --git a/crates/ra_analysis/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs
similarity index 100%
rename from crates/ra_analysis/src/completion/complete_scope.rs
rename to crates/ra_ide_api/src/completion/complete_scope.rs
diff --git a/crates/ra_analysis/src/completion/complete_snippet.rs b/crates/ra_ide_api/src/completion/complete_snippet.rs
similarity index 100%
rename from crates/ra_analysis/src/completion/complete_snippet.rs
rename to crates/ra_ide_api/src/completion/complete_snippet.rs
diff --git a/crates/ra_analysis/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs
similarity index 100%
rename from crates/ra_analysis/src/completion/completion_context.rs
rename to crates/ra_ide_api/src/completion/completion_context.rs
diff --git a/crates/ra_analysis/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs
similarity index 100%
rename from crates/ra_analysis/src/completion/completion_item.rs
rename to crates/ra_ide_api/src/completion/completion_item.rs
diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_ide_api/src/db.rs
similarity index 100%
rename from crates/ra_analysis/src/db.rs
rename to crates/ra_ide_api/src/db.rs
diff --git a/crates/ra_analysis/src/extend_selection.rs b/crates/ra_ide_api/src/extend_selection.rs
similarity index 88%
rename from crates/ra_analysis/src/extend_selection.rs
rename to crates/ra_ide_api/src/extend_selection.rs
index 3b130f9664..c3c809c9fe 100644
--- a/crates/ra_analysis/src/extend_selection.rs
+++ b/crates/ra_ide_api/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/goto_defenition.rs b/crates/ra_ide_api/src/goto_defenition.rs
similarity index 100%
rename from crates/ra_analysis/src/goto_defenition.rs
rename to crates/ra_ide_api/src/goto_defenition.rs
diff --git a/crates/ra_analysis/src/hover.rs b/crates/ra_ide_api/src/hover.rs
similarity index 100%
rename from crates/ra_analysis/src/hover.rs
rename to crates/ra_ide_api/src/hover.rs
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_ide_api/src/imp.rs
similarity index 98%
rename from crates/ra_analysis/src/imp.rs
rename to crates/ra_ide_api/src/imp.rs
index 2b9963b3c2..7c60ab7d6f 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_ide_api/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<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,
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_ide_api/src/lib.rs
similarity index 93%
rename from crates/ra_analysis/src/lib.rs
rename to crates/ra_ide_api/src/lib.rs
index 48df08416b..7e9ca20341 100644
--- a/crates/ra_analysis/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -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>> {
diff --git a/crates/ra_analysis/src/mock_analysis.rs b/crates/ra_ide_api/src/mock_analysis.rs
similarity index 100%
rename from crates/ra_analysis/src/mock_analysis.rs
rename to crates/ra_ide_api/src/mock_analysis.rs
diff --git a/crates/ra_analysis/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs
similarity index 100%
rename from crates/ra_analysis/src/runnables.rs
rename to crates/ra_ide_api/src/runnables.rs
diff --git a/crates/ra_analysis/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs
similarity index 100%
rename from crates/ra_analysis/src/symbol_index.rs
rename to crates/ra_ide_api/src/symbol_index.rs
diff --git a/crates/ra_analysis/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs
similarity index 94%
rename from crates/ra_analysis/src/syntax_highlighting.rs
rename to crates/ra_ide_api/src/syntax_highlighting.rs
index d2dc6cfbb9..cb19e9515a 100644
--- a/crates/ra_analysis/src/syntax_highlighting.rs
+++ b/crates/ra_ide_api/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<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)?;
diff --git a/crates/ra_editor/Cargo.toml b/crates/ra_ide_api_light/Cargo.toml
similarity index 93%
rename from crates/ra_editor/Cargo.toml
rename to crates/ra_ide_api_light/Cargo.toml
index a97d2308f2..8c192fca6c 100644
--- a/crates/ra_editor/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 <aleksey.kladov@gmail.com>"]
 publish = false
diff --git a/crates/ra_editor/src/assists.rs b/crates/ra_ide_api_light/src/assists.rs
similarity index 100%
rename from crates/ra_editor/src/assists.rs
rename to crates/ra_ide_api_light/src/assists.rs
diff --git a/crates/ra_editor/src/assists/add_derive.rs b/crates/ra_ide_api_light/src/assists/add_derive.rs
similarity index 100%
rename from crates/ra_editor/src/assists/add_derive.rs
rename to crates/ra_ide_api_light/src/assists/add_derive.rs
diff --git a/crates/ra_editor/src/assists/add_impl.rs b/crates/ra_ide_api_light/src/assists/add_impl.rs
similarity index 100%
rename from crates/ra_editor/src/assists/add_impl.rs
rename to crates/ra_ide_api_light/src/assists/add_impl.rs
diff --git a/crates/ra_editor/src/assists/change_visibility.rs b/crates/ra_ide_api_light/src/assists/change_visibility.rs
similarity index 100%
rename from crates/ra_editor/src/assists/change_visibility.rs
rename to crates/ra_ide_api_light/src/assists/change_visibility.rs
diff --git a/crates/ra_editor/src/assists/flip_comma.rs b/crates/ra_ide_api_light/src/assists/flip_comma.rs
similarity index 100%
rename from crates/ra_editor/src/assists/flip_comma.rs
rename to crates/ra_ide_api_light/src/assists/flip_comma.rs
diff --git a/crates/ra_editor/src/assists/introduce_variable.rs b/crates/ra_ide_api_light/src/assists/introduce_variable.rs
similarity index 100%
rename from crates/ra_editor/src/assists/introduce_variable.rs
rename to crates/ra_ide_api_light/src/assists/introduce_variable.rs
diff --git a/crates/ra_editor/src/assists/replace_if_let_with_match.rs b/crates/ra_ide_api_light/src/assists/replace_if_let_with_match.rs
similarity index 100%
rename from crates/ra_editor/src/assists/replace_if_let_with_match.rs
rename to crates/ra_ide_api_light/src/assists/replace_if_let_with_match.rs
diff --git a/crates/ra_editor/src/assists/split_import.rs b/crates/ra_ide_api_light/src/assists/split_import.rs
similarity index 100%
rename from crates/ra_editor/src/assists/split_import.rs
rename to crates/ra_ide_api_light/src/assists/split_import.rs
diff --git a/crates/ra_editor/src/diagnostics.rs b/crates/ra_ide_api_light/src/diagnostics.rs
similarity index 100%
rename from crates/ra_editor/src/diagnostics.rs
rename to crates/ra_ide_api_light/src/diagnostics.rs
diff --git a/crates/ra_editor/src/extend_selection.rs b/crates/ra_ide_api_light/src/extend_selection.rs
similarity index 100%
rename from crates/ra_editor/src/extend_selection.rs
rename to crates/ra_ide_api_light/src/extend_selection.rs
diff --git a/crates/ra_editor/src/folding_ranges.rs b/crates/ra_ide_api_light/src/folding_ranges.rs
similarity index 100%
rename from crates/ra_editor/src/folding_ranges.rs
rename to crates/ra_ide_api_light/src/folding_ranges.rs
diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_ide_api_light/src/lib.rs
similarity index 96%
rename from crates/ra_editor/src/lib.rs
rename to crates/ra_ide_api_light/src/lib.rs
index 5a6af19b7c..40638eda8e 100644
--- a/crates/ra_editor/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;
diff --git a/crates/ra_editor/src/line_index.rs b/crates/ra_ide_api_light/src/line_index.rs
similarity index 100%
rename from crates/ra_editor/src/line_index.rs
rename to crates/ra_ide_api_light/src/line_index.rs
diff --git a/crates/ra_editor/src/line_index_utils.rs b/crates/ra_ide_api_light/src/line_index_utils.rs
similarity index 100%
rename from crates/ra_editor/src/line_index_utils.rs
rename to crates/ra_ide_api_light/src/line_index_utils.rs
diff --git a/crates/ra_editor/src/structure.rs b/crates/ra_ide_api_light/src/structure.rs
similarity index 100%
rename from crates/ra_editor/src/structure.rs
rename to crates/ra_ide_api_light/src/structure.rs
diff --git a/crates/ra_editor/src/test_utils.rs b/crates/ra_ide_api_light/src/test_utils.rs
similarity index 100%
rename from crates/ra_editor/src/test_utils.rs
rename to crates/ra_ide_api_light/src/test_utils.rs
diff --git a/crates/ra_editor/src/typing.rs b/crates/ra_ide_api_light/src/typing.rs
similarity index 100%
rename from crates/ra_editor/src/typing.rs
rename to crates/ra_ide_api_light/src/typing.rs
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml
index b9fd61105c..296fae34f9 100644
--- a/crates/ra_lsp_server/Cargo.toml
+++ b/crates/ra_lsp_server/Cargo.toml
@@ -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" }
 
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs
index b3f8c83ccd..5c8b3c194b 100644
--- a/crates/ra_lsp_server/src/conv.rs
+++ b/crates/ra_lsp_server/src/conv.rs
@@ -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
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index 2dc1be26aa..96923fac77 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -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;
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index b7777bfc39..a653c5ada0 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -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,
diff --git a/crates/ra_lsp_server/src/main_loop/subscriptions.rs b/crates/ra_lsp_server/src/main_loop/subscriptions.rs
index 03f41e8705..a83e015573 100644
--- a/crates/ra_lsp_server/src/main_loop/subscriptions.rs
+++ b/crates/ra_lsp_server/src/main_loop/subscriptions.rs
@@ -1,4 +1,4 @@
-use ra_analysis::FileId;
+use ra_ide_api::FileId;
 use rustc_hash::FxHashSet;
 
 pub struct Subscriptions {
diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs
index ebf2b15ccd..76c76766d3 100644
--- a/crates/ra_lsp_server/src/server_world.rs
+++ b/crates/ra_lsp_server/src/server_world.rs
@@ -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},


Test patch:
diff --git a/crates/ra_analysis/tests/test/main.rs b/crates/ra_ide_api/tests/test/main.rs
similarity index 99%
rename from crates/ra_analysis/tests/test/main.rs
rename to crates/ra_ide_api/tests/test/main.rs
index 2c0735cb50..d1dc07e5b5 100644
--- a/crates/ra_analysis/tests/test/main.rs
+++ b/crates/ra_ide_api/tests/test/main.rs
@@ -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
 };
diff --git a/crates/ra_analysis/tests/test/runnables.rs b/crates/ra_ide_api/tests/test/runnables.rs
similarity index 97%
rename from crates/ra_analysis/tests/test/runnables.rs
rename to crates/ra_ide_api/tests/test/runnables.rs
index e6e0afbc31..da8d5e0d5d 100644
--- a/crates/ra_analysis/tests/test/runnables.rs
+++ b/crates/ra_ide_api/tests/test/runnables.rs
@@ -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() {