]> git.lizzy.rs Git - rust.git/commitdiff
Merge #79
authorbors[bot] <bors[bot]@users.noreply.github.com>
Tue, 25 Sep 2018 11:43:48 +0000 (11:43 +0000)
committerbors[bot] <bors[bot]@users.noreply.github.com>
Tue, 25 Sep 2018 11:43:48 +0000 (11:43 +0000)
79: Implement Folding Ranges r=matklad a=kjeremy

Implements folding ranges for comments and imports.

Bumps LSP to 3.13

Co-authored-by: Jeremy A. Kolb <jkolb@ara.com>
Cargo.lock
crates/gen_lsp_server/Cargo.toml
crates/ra_analysis/src/lib.rs
crates/ra_editor/src/folding_ranges.rs [new file with mode: 0644]
crates/ra_editor/src/lib.rs
crates/ra_lsp_server/Cargo.toml
crates/ra_lsp_server/src/caps.rs
crates/ra_lsp_server/src/main_loop/handlers.rs
crates/ra_lsp_server/src/main_loop/mod.rs

index e51fd4a7aaddc3129f2d060e5bbac3862c51a2ab..815c97483ff9c2017631f5c81ca9e10131eb7d9f 100644 (file)
@@ -3,7 +3,7 @@ name = "aho-corasick"
 version = "0.6.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -11,7 +11,7 @@ name = "ansi_term"
 version = "0.11.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -29,7 +29,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
  "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -41,7 +41,7 @@ dependencies = [
  "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -81,7 +81,7 @@ dependencies = [
  "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_json 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_json 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -128,7 +128,7 @@ dependencies = [
 
 [[package]]
 name = "crossbeam-channel"
-version = "0.2.5"
+version = "0.2.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "crossbeam-epoch 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -273,13 +273,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 name = "gen_lsp_server"
 version = "0.1.0"
 dependencies = [
- "crossbeam-channel 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "crossbeam-channel 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "languageserver-types 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "languageserver-types 0.51.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_json 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_json 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -339,7 +339,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "languageserver-types"
-version = "0.50.0"
+version = "0.51.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -347,7 +347,7 @@ dependencies = [
  "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_json 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_json 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -389,10 +389,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "memchr"
-version = "2.0.2"
+version = "2.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
+ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
+ "version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -401,7 +403,7 @@ version = "0.6.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -448,7 +450,7 @@ dependencies = [
 
 [[package]]
 name = "once_cell"
-version = "0.1.5"
+version = "0.1.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -480,7 +482,7 @@ dependencies = [
  "rand 0.5.5 (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.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -528,11 +530,11 @@ dependencies = [
 name = "ra_analysis"
 version = "0.1.0"
 dependencies = [
- "crossbeam-channel 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "crossbeam-channel 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "fst 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "im 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "once_cell 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "once_cell 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "ra_editor 0.1.0",
  "ra_syntax 0.1.0",
@@ -570,13 +572,13 @@ name = "ra_lsp_server"
 version = "0.1.0"
 dependencies = [
  "cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "crossbeam-channel 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "crossbeam-channel 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "drop_bomb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "flexi_logger 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "gen_lsp_server 0.1.0",
  "im 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "languageserver-types 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "languageserver-types 0.51.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "ra_analysis 0.1.0",
  "ra_editor 0.1.0",
@@ -585,7 +587,7 @@ dependencies = [
  "relative-path 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_json 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_json 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "smol_str 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "text_unit 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -614,7 +616,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -626,7 +628,7 @@ dependencies = [
  "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand_core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -674,7 +676,7 @@ version = "1.0.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -698,7 +700,7 @@ name = "remove_dir_all"
 version = "0.5.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -784,12 +786,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)",
  "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.5 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "serde_json"
-version = "1.0.27"
+version = "1.0.28"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -858,7 +860,7 @@ dependencies = [
 
 [[package]]
 name = "syn"
-version = "0.15.4"
+version = "0.15.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -908,7 +910,7 @@ dependencies = [
  "pest_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_json 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_json 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "unic-segment 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -964,7 +966,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
  "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -1120,13 +1122,13 @@ version = "2.2.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "same-file 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "winapi"
-version = "0.3.5"
+version = "0.3.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1143,7 +1145,7 @@ name = "winapi-util"
 version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -1167,7 +1169,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878"
 "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
 "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
-"checksum crossbeam-channel 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a5716fadb87a5633db34c5e83ee6e036e6edc229f8a6bfb7c7c84ed340ba95df"
+"checksum crossbeam-channel 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7b85741761b7f160bc5e7e0c14986ef685b7f8bf9b7ad081c60c604bb4649827"
 "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3"
 "checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150"
 "checksum crossbeam-epoch 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c90f1474584f38e270b5b613e898c8c328aa4f3dea85e0a27ac2e642f009416"
@@ -1192,13 +1194,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450"
 "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
 "checksum join_to_string 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7bddc885f3fd69dd4b5d747c2efe6dd2c36d795ea9938281ed50910e32c95e31"
-"checksum languageserver-types 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6866bed90d044147c6d71d3e4d31339e356164ab7b76b9fd13ccb1211528e166"
+"checksum languageserver-types 0.51.0 (registry+https://github.com/rust-lang/crates.io-index)" = "caecadd973c43c93f5ce96fa457da310113d867af28808a8ed74023e9887a39e"
 "checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7"
 "checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d"
 "checksum lock_api 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "949826a5ccf18c1b3a7c3d57692778d21768b79e46eb9dd07bfc4c2160036c54"
 "checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f"
 "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
-"checksum memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a3b4142ab8738a78c51896f704f83c11df047ff1bda9a92a661aa6361552d93d"
+"checksum memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b3629fe9fdbff6daa6c33b90f7c08355c1aca05a3d01fa8063b822fcf185f3b"
 "checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff"
 "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
 "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2"
@@ -1206,7 +1208,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
 "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
 "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30"
-"checksum once_cell 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "cecf059b719a56d137b66fadaee0781c08b1f61c040c36f5c6851d6769bab0af"
+"checksum once_cell 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d7ce3535d54560c937c1652ba4a0da66bfc63e0f8e07bed127483afb6e5ee925"
 "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37"
 "checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5"
 "checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c"
@@ -1238,7 +1240,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
 "checksum serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "84257ccd054dc351472528c8587b4de2dbf0dc0fe2e634030c1a90bfdacebaa9"
 "checksum serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "31569d901045afbff7a9479f793177fe9259819aff10ab4f89ef69bbc5f567fe"
-"checksum serde_json 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "59790990c5115d16027f00913e2e66de23a51f70422e549d2ad68c8c5f268f1c"
+"checksum serde_json 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "d30ec34ac923489285d24688c7a9c0898d16edff27fc1f1bd854edeff6ca3b7f"
 "checksum slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373"
 "checksum smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "153ffa32fd170e9944f7e0838edf824a754ec4c1fc64746fcc9fe1f8fa602e5d"
 "checksum smol_str 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "248055d41f4c53f8ee7048e8a578a5190d0cca306630718091e4d481735e44b9"
@@ -1247,7 +1249,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum superslice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b50b13d42370e0f5fc62eafdd5c2d20065eaf5458dab215ff3e20e63eea96b30"
 "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
 "checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741"
-"checksum syn 0.15.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9056ebe7f2d6a38bc63171816fd1d3430da5a43896de21676dc5c0a4b8274a11"
+"checksum syn 0.15.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5522da8e493dbd7703e88ec5518546ed45c30efa2699f291a7bd0a08fb0a6ab6"
 "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
 "checksum synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb9b7550d063ea184027c9b8c20ac167cd36d3e06b3a40bceb9d746dc1a7b7"
 "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
@@ -1279,7 +1281,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7716c242968ee87e5542f8021178248f267f295a5c4803beae8b8b7fd9bc6051"
 "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
 "checksum walkdir 2.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "af464bc7be7b785c7ac72e266a6b67c4c9070155606f51655a650a6686204e35"
-"checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd"
+"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
 "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
 "checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab"
 "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
index 4eb508fc030c6d98cbc1758ac5cb16ae74d8ea57..6580ba6e43d2f75bbf77c664e26b9ac8dbb74250 100644 (file)
@@ -4,7 +4,7 @@ version = "0.1.0"
 authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
 
 [dependencies]
-languageserver-types = "0.50.0"
+languageserver-types = "0.51.0"
 log = "0.4.3"
 
 failure = "0.1.2"
index 4da55ab269d6d11e5b43b5341eda1cacec394f0d..b4c7db476bccecde681ff8657543ec7a9ee57084 100644 (file)
@@ -34,6 +34,7 @@
 pub use ra_editor::{
     StructureNode, LineIndex, FileSymbol,
     Runnable, RunnableKind, HighlightedRange, CompletionItem,
+    Fold, FoldKind
 };
 pub use job::{JobToken, JobHandle};
 
@@ -224,6 +225,10 @@ pub fn assists(&self, file_id: FileId, range: TextRange) -> Vec<SourceChange> {
     pub fn diagnostics(&self, file_id: FileId) -> Vec<Diagnostic> {
         self.imp.diagnostics(file_id)
     }
+    pub fn folding_ranges(&self, file_id: FileId) -> Vec<Fold> {
+        let file = self.imp.file_syntax(file_id);
+        ra_editor::folding_ranges(&file)
+    }
 }
 
 #[derive(Debug)]
diff --git a/crates/ra_editor/src/folding_ranges.rs b/crates/ra_editor/src/folding_ranges.rs
new file mode 100644 (file)
index 0000000..817da28
--- /dev/null
@@ -0,0 +1,142 @@
+use std::collections::HashSet;
+
+use ra_syntax::{
+    File, TextRange, SyntaxNodeRef,
+    SyntaxKind,
+    algo::{walk, Direction, siblings},
+};
+
+#[derive(Debug, PartialEq, Eq)]
+pub enum FoldKind {
+    Comment,
+    Imports,
+}
+
+#[derive(Debug)]
+pub struct Fold {
+    pub range: TextRange,
+    pub kind: FoldKind,
+}
+
+pub fn folding_ranges(file: &File) -> Vec<Fold> {
+    let syntax = file.syntax();
+
+    let mut res = vec![];
+    let mut visited = HashSet::new();
+
+    for node in walk::preorder(syntax) {
+        if visited.contains(&node) {
+            continue;
+        }
+
+        let range_and_kind = match node.kind() {
+            SyntaxKind::COMMENT => (
+                contiguous_range_for(SyntaxKind::COMMENT, node, &mut visited),
+                Some(FoldKind::Comment),
+            ),
+            SyntaxKind::USE_ITEM => (
+                contiguous_range_for(SyntaxKind::USE_ITEM, node, &mut visited),
+                Some(FoldKind::Imports),
+            ),
+            _ => (None, None),
+        };
+
+        match range_and_kind {
+            (Some(range), Some(kind)) => {
+                res.push(Fold {
+                    range: range,
+                    kind: kind
+                });
+            }
+            _ => {}
+        }
+    }
+
+    res
+}
+
+fn contiguous_range_for<'a>(
+    kind: SyntaxKind,
+    node: SyntaxNodeRef<'a>,
+    visited: &mut HashSet<SyntaxNodeRef<'a>>,
+) -> Option<TextRange> {
+    visited.insert(node);
+
+    let left = node;
+    let mut right = node;
+    for node in siblings(node, Direction::Forward) {
+        visited.insert(node);
+        match node.kind() {
+            SyntaxKind::WHITESPACE if !node.leaf_text().unwrap().as_str().contains("\n\n") => (),
+            k => {
+                if k == kind {
+                    right = node
+                } else {
+                    break;
+                }
+            }
+        }
+    }
+    if left != right {
+        Some(TextRange::from_to(
+            left.range().start(),
+            right.range().end(),
+        ))
+    } else {
+        None
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn test_fold_comments() {
+        let text = r#"
+// Hello
+// this is a multiline
+// comment
+//
+
+// But this is not
+
+fn main() {
+    // We should
+    // also
+    // fold
+    // this one.
+}"#;
+
+        let file = File::parse(&text);
+        let folds = folding_ranges(&file);
+        assert_eq!(folds.len(), 2);
+        assert_eq!(folds[0].range.start(), 1.into());
+        assert_eq!(folds[0].range.end(), 46.into());
+        assert_eq!(folds[0].kind, FoldKind::Comment);
+
+        assert_eq!(folds[1].range.start(), 84.into());
+        assert_eq!(folds[1].range.end(), 137.into());
+        assert_eq!(folds[1].kind, FoldKind::Comment);
+    }
+
+    #[test]
+    fn test_fold_imports() {
+        let text = r#"
+use std::str;
+use std::vec;
+use std::io as iop;
+
+fn main() {
+}"#;
+
+        let file = File::parse(&text);
+        let folds = folding_ranges(&file);
+        assert_eq!(folds.len(), 1);
+        assert_eq!(folds[0].range.start(), 1.into());
+        assert_eq!(folds[0].range.end(), 48.into());
+        assert_eq!(folds[0].kind, FoldKind::Imports);
+    }
+
+
+}
\ No newline at end of file
index 78ed34c7c113a8fcdcc628835d7a713e5542e68f..de929d73a6f90cf7e5060dee2b790cb66add54b8 100644 (file)
@@ -10,6 +10,7 @@
 mod symbols;
 mod line_index;
 mod edit;
+mod folding_ranges;
 mod code_actions;
 mod typing;
 mod completion;
@@ -36,6 +37,7 @@
     },
     typing::{join_lines, on_eq_typed},
     completion::{scope_completion, CompletionItem},
+    folding_ranges::{Fold, FoldKind, folding_ranges}
 };
 
 #[derive(Debug)]
index b851f70e1e2325a89104096f1578f6f73f5885d8..32463e499f32f4c864a6f98db131687f5adb5881 100644 (file)
@@ -15,7 +15,7 @@ crossbeam-channel = "0.2.4"
 flexi_logger = "0.9.1"
 log = "0.4.3"
 url_serde = "0.2.0"
-languageserver-types = "0.50.0"
+languageserver-types = "0.51.0"
 walkdir = "2.2.0"
 im = "12.0.0"
 cargo_metadata = "0.6.0"
index 7456aea8a21b514c386cf5b5368b0af2a5baa7ec..3c628f29c58c2ad500b8fbd5b96cbb550e19bb7a 100644 (file)
@@ -1,5 +1,7 @@
 use languageserver_types::{
     ServerCapabilities,
+    CodeActionProviderCapability,
+    FoldingRangeProviderCapability,
     TextDocumentSyncCapability,
     TextDocumentSyncOptions,
     TextDocumentSyncKind,
@@ -32,7 +34,7 @@ pub fn server_capabilities() -> ServerCapabilities {
         document_highlight_provider: None,
         document_symbol_provider: Some(true),
         workspace_symbol_provider: Some(true),
-        code_action_provider: Some(true),
+        code_action_provider: Some(CodeActionProviderCapability::Simple(true)),
         code_lens_provider: None,
         document_formatting_provider: None,
         document_range_formatting_provider: None,
@@ -40,10 +42,12 @@ pub fn server_capabilities() -> ServerCapabilities {
             first_trigger_character: "=".to_string(),
             more_trigger_character: None,
         }),
+        folding_range_provider: Some(FoldingRangeProviderCapability::Simple(true)),
         rename_provider: None,
         color_provider: None,
         execute_command_provider: Some(ExecuteCommandOptions {
             commands: vec!["apply_code_action".to_string()],
         }),
+        workspace: None,
     }
 }
index b2ebc9cdc33184365da531c946f5ba69558b6c3e..51061543c29b4fb0a50670561bb447c7f630c907 100644 (file)
@@ -1,15 +1,16 @@
-use std::collections::HashMap;
+use std::collections::{HashMap};
 
 use languageserver_types::{
     Diagnostic, DiagnosticSeverity, DocumentSymbol,
-    Command, TextDocumentIdentifier,
+    CodeActionResponse, Command, TextDocumentIdentifier,
     SymbolInformation, Position, Location, TextEdit,
     CompletionItem, InsertTextFormat, CompletionItemKind,
+    FoldingRange, FoldingRangeParams, FoldingRangeKind
 };
 use serde_json::to_value;
-use ra_analysis::{Query, FileId, RunnableKind, JobToken};
+use ra_analysis::{Query, FileId, RunnableKind, JobToken, FoldKind};
 use ra_syntax::{
-    text_utils::contains_offset_nonstrict,
+    text_utils::contains_offset_nonstrict
 };
 
 use ::{
@@ -177,6 +178,7 @@ fn exec_query(world: &ServerWorld, query: Query, token: &JobToken) -> Result<Vec
                     world, &line_index
                 )?,
                 container_name: None,
+                deprecated: None,
             };
             res.push(info);
         };
@@ -365,11 +367,41 @@ pub fn handle_completion(
     Ok(Some(req::CompletionResponse::Array(items)))
 }
 
+pub fn handle_folding_range(
+    world: ServerWorld,
+    params: FoldingRangeParams,
+    _token: JobToken,
+) -> Result<Option<Vec<FoldingRange>>> {
+    let file_id = params.text_document.try_conv_with(&world)?;
+    let line_index = world.analysis().file_line_index(file_id);
+
+    let res = Some(world.analysis()
+        .folding_ranges(file_id)
+        .into_iter()
+        .map(|fold| {
+            let kind = match fold.kind {
+                FoldKind::Comment => FoldingRangeKind::Comment,
+                FoldKind::Imports => FoldingRangeKind::Imports
+            };
+            let range = fold.range.conv_with(&line_index);
+            FoldingRange {
+                start_line: range.start.line,
+                start_character: Some(range.start.character),
+                end_line: range.end.line,
+                end_character: Some(range.start.character),
+                kind: Some(kind)
+            }
+        })
+        .collect());
+
+    Ok(res)
+}
+
 pub fn handle_code_action(
     world: ServerWorld,
     params: req::CodeActionParams,
     _token: JobToken,
-) -> Result<Option<Vec<Command>>> {
+) -> Result<Option<CodeActionResponse>> {
     let file_id = params.text_document.try_conv_with(&world)?;
     let line_index = world.analysis().file_line_index(file_id);
     let range = params.range.conv_with(&line_index);
@@ -392,7 +424,7 @@ pub fn handle_code_action(
         res.push(cmd);
     }
 
-    Ok(Some(res))
+    Ok(Some(CodeActionResponse::Commands(res)))
 }
 
 pub fn publish_diagnostics(
index 2b2279e977a144d8176a421f5ece1b77ac95606d..abc58b70ec807bffe0185c670337fbcaca2a6005 100644 (file)
@@ -253,6 +253,7 @@ fn on_request(
         .on::<req::DecorationsRequest>(handlers::handle_decorations)?
         .on::<req::Completion>(handlers::handle_completion)?
         .on::<req::CodeActionRequest>(handlers::handle_code_action)?
+        .on::<req::FoldingRangeRequest>(handlers::handle_folding_range)?
         .finish();
     match req {
         Ok((id, handle)) => {