aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cargo/config4
-rw-r--r--Cargo.lock8
-rw-r--r--README.md2
-rw-r--r--crates/gen_lsp_server/Cargo.toml2
-rw-r--r--crates/ra_hir/src/nameres/lower.rs1
-rw-r--r--crates/ra_lsp_server/Cargo.toml2
-rw-r--r--crates/ra_lsp_server/src/conv.rs2
-rw-r--r--crates/ra_syntax/src/lexer.rs18
-rw-r--r--crates/ra_syntax/src/lexer/strings.rs3
-rw-r--r--crates/ra_syntax/tests/data/lexer/0016_raw_ident.rs1
-rw-r--r--crates/ra_syntax/tests/data/lexer/0016_raw_ident.txt2
-rw-r--r--crates/ra_syntax/tests/data/parser/ok/0039_raw_fn_item.rs2
-rw-r--r--crates/ra_syntax/tests/data/parser/ok/0039_raw_fn_item.txt15
-rw-r--r--crates/ra_syntax/tests/data/parser/ok/0040_raw_struct_item_field.rs3
-rw-r--r--crates/ra_syntax/tests/data/parser/ok/0040_raw_struct_item_field.txt22
-rw-r--r--crates/ra_syntax/tests/data/parser/ok/0041_raw_keywords.rs1
-rw-r--r--crates/ra_syntax/tests/data/parser/ok/0041_raw_keywords.txt49
17 files changed, 119 insertions, 18 deletions
diff --git a/.cargo/config b/.cargo/config
index b9db30c96..3fba0f71d 100644
--- a/.cargo/config
+++ b/.cargo/config
@@ -1,8 +1,10 @@
1[alias] 1[alias]
2# Automatically generates the ast and syntax kinds files 2# Automatically generates the ast and syntax kinds files
3gen-syntax = "run --package tools --bin tools -- gen-syntax" 3gen-syntax = "run --package tools --bin tools -- gen-syntax"
4# Extracts the tests from 4# Extracts the tests from
5gen-tests = "run --package tools --bin tools -- gen-tests" 5gen-tests = "run --package tools --bin tools -- gen-tests"
6# Installs ra_lsp_server
7install-lsp = "install --path crates/ra_lsp_server --force"
6# Installs the visual studio code extension 8# Installs the visual studio code extension
7install-code = "run --package tools --bin tools -- install-code" 9install-code = "run --package tools --bin tools -- install-code"
8# Formats the full repository or installs the git hook to do it automatically. 10# Formats the full repository or installs the git hook to do it automatically.
diff --git a/Cargo.lock b/Cargo.lock
index f5f270e23..55ac3e7de 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -381,7 +381,7 @@ dependencies = [
381 "crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", 381 "crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
382 "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 382 "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
383 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 383 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
384 "lsp-types 0.54.0 (registry+https://github.com/rust-lang/crates.io-index)", 384 "lsp-types 0.55.0 (registry+https://github.com/rust-lang/crates.io-index)",
385 "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 385 "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)",
386 "serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", 386 "serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)",
387] 387]
@@ -507,7 +507,7 @@ dependencies = [
507 507
508[[package]] 508[[package]]
509name = "lsp-types" 509name = "lsp-types"
510version = "0.54.0" 510version = "0.55.0"
511source = "registry+https://github.com/rust-lang/crates.io-index" 511source = "registry+https://github.com/rust-lang/crates.io-index"
512dependencies = [ 512dependencies = [
513 "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", 513 "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -798,7 +798,7 @@ dependencies = [
798 "gen_lsp_server 0.1.0", 798 "gen_lsp_server 0.1.0",
799 "im 12.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 799 "im 12.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
800 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 800 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
801 "lsp-types 0.54.0 (registry+https://github.com/rust-lang/crates.io-index)", 801 "lsp-types 0.55.0 (registry+https://github.com/rust-lang/crates.io-index)",
802 "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", 802 "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
803 "ra_arena 0.1.0", 803 "ra_arena 0.1.0",
804 "ra_ide_api 0.1.0", 804 "ra_ide_api 0.1.0",
@@ -1645,7 +1645,7 @@ dependencies = [
1645"checksum linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70fb39025bc7cdd76305867c4eccf2f2dcf6e9a57f5b21a93e1c2d86cd03ec9e" 1645"checksum linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70fb39025bc7cdd76305867c4eccf2f2dcf6e9a57f5b21a93e1c2d86cd03ec9e"
1646"checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" 1646"checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c"
1647"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" 1647"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
1648"checksum lsp-types 0.54.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a252cc2be87d9329dd91c505a951996b3263582ba304870960faaae77b642183" 1648"checksum lsp-types 0.55.0 (registry+https://github.com/rust-lang/crates.io-index)" = "78455d7df2e41e103ccf893abdeb93981f0bbeb228884230e9fc5ff71546fd55"
1649"checksum maplit 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08cbb6b4fef96b6d77bfc40ec491b1690c779e77b05cd9f07f787ed376fd4c43" 1649"checksum maplit 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08cbb6b4fef96b6d77bfc40ec491b1690c779e77b05cd9f07f787ed376fd4c43"
1650"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" 1650"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
1651"checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8" 1651"checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8"
diff --git a/README.md b/README.md
index 8d4e32704..74f281ccb 100644
--- a/README.md
+++ b/README.md
@@ -29,6 +29,8 @@ $ cargo run --package ra_cli parse < crates/ra_syntax/src/lib.rs
29$ cargo run --package ra_cli symbols < crates/ra_syntax/src/lib.rs 29$ cargo run --package ra_cli symbols < crates/ra_syntax/src/lib.rs
30 30
31# install the language server 31# install the language server
32$ cargo install-lsp
33or
32$ cargo install --path crates/ra_lsp_server 34$ cargo install --path crates/ra_lsp_server
33``` 35```
34 36
diff --git a/crates/gen_lsp_server/Cargo.toml b/crates/gen_lsp_server/Cargo.toml
index 041151741..54a1d2901 100644
--- a/crates/gen_lsp_server/Cargo.toml
+++ b/crates/gen_lsp_server/Cargo.toml
@@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
8description = "Generic LSP server scaffold." 8description = "Generic LSP server scaffold."
9 9
10[dependencies] 10[dependencies]
11lsp-types = "0.54.0" 11lsp-types = "0.55.0"
12log = "0.4.3" 12log = "0.4.3"
13failure = "0.1.4" 13failure = "0.1.4"
14serde_json = "1.0.34" 14serde_json = "1.0.34"
diff --git a/crates/ra_hir/src/nameres/lower.rs b/crates/ra_hir/src/nameres/lower.rs
index 270f9ab03..4eea6ff1d 100644
--- a/crates/ra_hir/src/nameres/lower.rs
+++ b/crates/ra_hir/src/nameres/lower.rs
@@ -251,7 +251,6 @@ impl DefKind {
251 SyntaxKind::MODULE => PerNs::types(DefKind::Module), 251 SyntaxKind::MODULE => PerNs::types(DefKind::Module),
252 SyntaxKind::STRUCT_DEF => PerNs::both(DefKind::Struct, DefKind::StructCtor), 252 SyntaxKind::STRUCT_DEF => PerNs::both(DefKind::Struct, DefKind::StructCtor),
253 SyntaxKind::ENUM_DEF => PerNs::types(DefKind::Enum), 253 SyntaxKind::ENUM_DEF => PerNs::types(DefKind::Enum),
254 // These define items, but don't have their own DefKinds yet:
255 SyntaxKind::TRAIT_DEF => PerNs::types(DefKind::Trait), 254 SyntaxKind::TRAIT_DEF => PerNs::types(DefKind::Trait),
256 SyntaxKind::TYPE_DEF => PerNs::types(DefKind::Type), 255 SyntaxKind::TYPE_DEF => PerNs::types(DefKind::Type),
257 SyntaxKind::CONST_DEF => PerNs::values(DefKind::Const), 256 SyntaxKind::CONST_DEF => PerNs::values(DefKind::Const),
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml
index dd8543c56..160d2f672 100644
--- a/crates/ra_lsp_server/Cargo.toml
+++ b/crates/ra_lsp_server/Cargo.toml
@@ -16,7 +16,7 @@ crossbeam-channel = "0.3.5"
16flexi_logger = "0.10.0" 16flexi_logger = "0.10.0"
17log = "0.4.3" 17log = "0.4.3"
18url_serde = "0.2.0" 18url_serde = "0.2.0"
19lsp-types = "0.54.0" 19lsp-types = "0.55.0"
20walkdir = "2.2.7" 20walkdir = "2.2.7"
21im = "12.0.0" 21im = "12.0.0"
22cargo_metadata = "0.7.0" 22cargo_metadata = "0.7.0"
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs
index 6818acaf6..8c87f5195 100644
--- a/crates/ra_lsp_server/src/conv.rs
+++ b/crates/ra_lsp_server/src/conv.rs
@@ -390,7 +390,7 @@ pub fn to_location_link(
390 origin_selection_range: Some(target.range.conv_with(line_index)), 390 origin_selection_range: Some(target.range.conv_with(line_index)),
391 target_uri, 391 target_uri,
392 target_range, 392 target_range,
393 target_selection_range: Some(target_selection_range), 393 target_selection_range: target_selection_range,
394 }; 394 };
395 Ok(res) 395 Ok(res)
396} 396}
diff --git a/crates/ra_syntax/src/lexer.rs b/crates/ra_syntax/src/lexer.rs
index c6acd095e..f9362120e 100644
--- a/crates/ra_syntax/src/lexer.rs
+++ b/crates/ra_syntax/src/lexer.rs
@@ -190,17 +190,19 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind {
190} 190}
191 191
192fn scan_ident(c: char, ptr: &mut Ptr) -> SyntaxKind { 192fn scan_ident(c: char, ptr: &mut Ptr) -> SyntaxKind {
193 let is_single_letter = match ptr.current() { 193 let is_raw = match (c, ptr.current()) {
194 None => true, 194 ('r', Some('#')) => {
195 Some(c) if !is_ident_continue(c) => true, 195 ptr.bump();
196 true
197 }
198 ('_', Some(c)) if !is_ident_continue(c) => return UNDERSCORE,
196 _ => false, 199 _ => false,
197 }; 200 };
198 if is_single_letter {
199 return if c == '_' { UNDERSCORE } else { IDENT };
200 }
201 ptr.bump_while(is_ident_continue); 201 ptr.bump_while(is_ident_continue);
202 if let Some(kind) = SyntaxKind::from_keyword(ptr.current_token_text()) { 202 if !is_raw {
203 return kind; 203 if let Some(kind) = SyntaxKind::from_keyword(ptr.current_token_text()) {
204 return kind;
205 }
204 } 206 }
205 IDENT 207 IDENT
206} 208}
diff --git a/crates/ra_syntax/src/lexer/strings.rs b/crates/ra_syntax/src/lexer/strings.rs
index 0865b7f3b..5c1cf3e9c 100644
--- a/crates/ra_syntax/src/lexer/strings.rs
+++ b/crates/ra_syntax/src/lexer/strings.rs
@@ -5,7 +5,8 @@ use crate::lexer::ptr::Ptr;
5pub(crate) fn is_string_literal_start(c: char, c1: Option<char>, c2: Option<char>) -> bool { 5pub(crate) fn is_string_literal_start(c: char, c1: Option<char>, c2: Option<char>) -> bool {
6 match (c, c1, c2) { 6 match (c, c1, c2) {
7 ('r', Some('"'), _) 7 ('r', Some('"'), _)
8 | ('r', Some('#'), _) 8 | ('r', Some('#'), Some('"'))
9 | ('r', Some('#'), Some('#'))
9 | ('b', Some('"'), _) 10 | ('b', Some('"'), _)
10 | ('b', Some('\''), _) 11 | ('b', Some('\''), _)
11 | ('b', Some('r'), Some('"')) 12 | ('b', Some('r'), Some('"'))
diff --git a/crates/ra_syntax/tests/data/lexer/0016_raw_ident.rs b/crates/ra_syntax/tests/data/lexer/0016_raw_ident.rs
new file mode 100644
index 000000000..b40a1b6a2
--- /dev/null
+++ b/crates/ra_syntax/tests/data/lexer/0016_raw_ident.rs
@@ -0,0 +1 @@
r#raw_ident
diff --git a/crates/ra_syntax/tests/data/lexer/0016_raw_ident.txt b/crates/ra_syntax/tests/data/lexer/0016_raw_ident.txt
new file mode 100644
index 000000000..484689693
--- /dev/null
+++ b/crates/ra_syntax/tests/data/lexer/0016_raw_ident.txt
@@ -0,0 +1,2 @@
1IDENT 11 "r#raw_ident"
2WHITESPACE 1 "\n"
diff --git a/crates/ra_syntax/tests/data/parser/ok/0039_raw_fn_item.rs b/crates/ra_syntax/tests/data/parser/ok/0039_raw_fn_item.rs
new file mode 100644
index 000000000..8380d1e79
--- /dev/null
+++ b/crates/ra_syntax/tests/data/parser/ok/0039_raw_fn_item.rs
@@ -0,0 +1,2 @@
1fn r#foo() {
2}
diff --git a/crates/ra_syntax/tests/data/parser/ok/0039_raw_fn_item.txt b/crates/ra_syntax/tests/data/parser/ok/0039_raw_fn_item.txt
new file mode 100644
index 000000000..dcd055d86
--- /dev/null
+++ b/crates/ra_syntax/tests/data/parser/ok/0039_raw_fn_item.txt
@@ -0,0 +1,15 @@
1SOURCE_FILE@[0; 15)
2 FN_DEF@[0; 14)
3 FN_KW@[0; 2)
4 WHITESPACE@[2; 3)
5 NAME@[3; 8)
6 IDENT@[3; 8) "r#foo"
7 PARAM_LIST@[8; 10)
8 L_PAREN@[8; 9)
9 R_PAREN@[9; 10)
10 WHITESPACE@[10; 11)
11 BLOCK@[11; 14)
12 L_CURLY@[11; 12)
13 WHITESPACE@[12; 13)
14 R_CURLY@[13; 14)
15 WHITESPACE@[14; 15)
diff --git a/crates/ra_syntax/tests/data/parser/ok/0040_raw_struct_item_field.rs b/crates/ra_syntax/tests/data/parser/ok/0040_raw_struct_item_field.rs
new file mode 100644
index 000000000..098a60a72
--- /dev/null
+++ b/crates/ra_syntax/tests/data/parser/ok/0040_raw_struct_item_field.rs
@@ -0,0 +1,3 @@
1struct S {
2 r#foo: u32
3} \ No newline at end of file
diff --git a/crates/ra_syntax/tests/data/parser/ok/0040_raw_struct_item_field.txt b/crates/ra_syntax/tests/data/parser/ok/0040_raw_struct_item_field.txt
new file mode 100644
index 000000000..361e53152
--- /dev/null
+++ b/crates/ra_syntax/tests/data/parser/ok/0040_raw_struct_item_field.txt
@@ -0,0 +1,22 @@
1SOURCE_FILE@[0; 27)
2 STRUCT_DEF@[0; 27)
3 STRUCT_KW@[0; 6)
4 WHITESPACE@[6; 7)
5 NAME@[7; 8)
6 IDENT@[7; 8) "S"
7 WHITESPACE@[8; 9)
8 NAMED_FIELD_DEF_LIST@[9; 27)
9 L_CURLY@[9; 10)
10 WHITESPACE@[10; 15)
11 NAMED_FIELD_DEF@[15; 25)
12 NAME@[15; 20)
13 IDENT@[15; 20) "r#foo"
14 COLON@[20; 21)
15 WHITESPACE@[21; 22)
16 PATH_TYPE@[22; 25)
17 PATH@[22; 25)
18 PATH_SEGMENT@[22; 25)
19 NAME_REF@[22; 25)
20 IDENT@[22; 25) "u32"
21 WHITESPACE@[25; 26)
22 R_CURLY@[26; 27)
diff --git a/crates/ra_syntax/tests/data/parser/ok/0041_raw_keywords.rs b/crates/ra_syntax/tests/data/parser/ok/0041_raw_keywords.rs
new file mode 100644
index 000000000..d59a6d347
--- /dev/null
+++ b/crates/ra_syntax/tests/data/parser/ok/0041_raw_keywords.rs
@@ -0,0 +1 @@
fn foo() { let r#struct = 92; let r#trait = r#struct * 2; } \ No newline at end of file
diff --git a/crates/ra_syntax/tests/data/parser/ok/0041_raw_keywords.txt b/crates/ra_syntax/tests/data/parser/ok/0041_raw_keywords.txt
new file mode 100644
index 000000000..f03ed17f5
--- /dev/null
+++ b/crates/ra_syntax/tests/data/parser/ok/0041_raw_keywords.txt
@@ -0,0 +1,49 @@
1SOURCE_FILE@[0; 59)
2 FN_DEF@[0; 59)
3 FN_KW@[0; 2)
4 WHITESPACE@[2; 3)
5 NAME@[3; 6)
6 IDENT@[3; 6) "foo"
7 PARAM_LIST@[6; 8)
8 L_PAREN@[6; 7)
9 R_PAREN@[7; 8)
10 WHITESPACE@[8; 9)
11 BLOCK@[9; 59)
12 L_CURLY@[9; 10)
13 WHITESPACE@[10; 11)
14 LET_STMT@[11; 29)
15 LET_KW@[11; 14)
16 WHITESPACE@[14; 15)
17 BIND_PAT@[15; 23)
18 NAME@[15; 23)
19 IDENT@[15; 23) "r#struct"
20 WHITESPACE@[23; 24)
21 EQ@[24; 25)
22 WHITESPACE@[25; 26)
23 LITERAL@[26; 28)
24 INT_NUMBER@[26; 28) "92"
25 SEMI@[28; 29)
26 WHITESPACE@[29; 30)
27 LET_STMT@[30; 57)
28 LET_KW@[30; 33)
29 WHITESPACE@[33; 34)
30 BIND_PAT@[34; 41)
31 NAME@[34; 41)
32 IDENT@[34; 41) "r#trait"
33 WHITESPACE@[41; 42)
34 EQ@[42; 43)
35 WHITESPACE@[43; 44)
36 BIN_EXPR@[44; 56)
37 PATH_EXPR@[44; 52)
38 PATH@[44; 52)
39 PATH_SEGMENT@[44; 52)
40 NAME_REF@[44; 52)
41 IDENT@[44; 52) "r#struct"
42 WHITESPACE@[52; 53)
43 STAR@[53; 54)
44 WHITESPACE@[54; 55)
45 LITERAL@[55; 56)
46 INT_NUMBER@[55; 56) "2"
47 SEMI@[56; 57)
48 WHITESPACE@[57; 58)
49 R_CURLY@[58; 59)