aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vscode/launch.json25
-rw-r--r--crates/ra_hir_def/src/nameres/raw.rs32
-rw-r--r--crates/ra_hir_def/src/nameres/tests.rs9
3 files changed, 61 insertions, 5 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
index ca70fb209..3f74d7566 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -11,7 +11,7 @@
11 "configurations": [ 11 "configurations": [
12 { 12 {
13 // Used for testing the extension with the installed LSP server. 13 // Used for testing the extension with the installed LSP server.
14 "name": "Run Extension", 14 "name": "Run Installed Extension",
15 "type": "extensionHost", 15 "type": "extensionHost",
16 "request": "launch", 16 "request": "launch",
17 "runtimeExecutable": "${execPath}", 17 "runtimeExecutable": "${execPath}",
@@ -30,7 +30,7 @@
30 }, 30 },
31 { 31 {
32 // Used for testing the extension with a local build of the LSP server (in `target/debug`). 32 // Used for testing the extension with a local build of the LSP server (in `target/debug`).
33 "name": "Run Extension (Dev Server)", 33 "name": "Run Extension (Debug Build)",
34 "type": "extensionHost", 34 "type": "extensionHost",
35 "request": "launch", 35 "request": "launch",
36 "runtimeExecutable": "${execPath}", 36 "runtimeExecutable": "${execPath}",
@@ -50,6 +50,27 @@
50 } 50 }
51 }, 51 },
52 { 52 {
53 // Used for testing the extension with a local build of the LSP server (in `target/release`).
54 "name": "Run Extension (Release Build)",
55 "type": "extensionHost",
56 "request": "launch",
57 "runtimeExecutable": "${execPath}",
58 "args": [
59 "--disable-extensions",
60 "--extensionDevelopmentPath=${workspaceFolder}/editors/code"
61 ],
62 "outFiles": [
63 "${workspaceFolder}/editors/code/out/**/*.js"
64 ],
65 "preLaunchTask": "Build Extension",
66 "skipFiles": [
67 "<node_internals>/**/*.js"
68 ],
69 "env": {
70 "__RA_LSP_SERVER_DEBUG": "${workspaceFolder}/target/release/rust-analyzer"
71 }
72 },
73 {
53 // Used to attach LLDB to a running LSP server. 74 // Used to attach LLDB to a running LSP server.
54 // NOTE: Might require root permissions. For this run: 75 // NOTE: Might require root permissions. For this run:
55 // 76 //
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs
index afd538e4a..39b011ad7 100644
--- a/crates/ra_hir_def/src/nameres/raw.rs
+++ b/crates/ra_hir_def/src/nameres/raw.rs
@@ -266,8 +266,8 @@ impl RawItemsCollector {
266 self.add_macro(current_module, it); 266 self.add_macro(current_module, it);
267 return; 267 return;
268 } 268 }
269 ast::ModuleItem::ExternBlock(_) => { 269 ast::ModuleItem::ExternBlock(it) => {
270 // FIXME: add extern block 270 self.add_extern_block(current_module, it);
271 return; 271 return;
272 } 272 }
273 }; 273 };
@@ -278,6 +278,34 @@ impl RawItemsCollector {
278 } 278 }
279 } 279 }
280 280
281 fn add_extern_block(
282 &mut self,
283 current_module: Option<Idx<ModuleData>>,
284 block: ast::ExternBlock,
285 ) {
286 if let Some(items) = block.extern_item_list() {
287 for item in items.extern_items() {
288 let attrs = self.parse_attrs(&item);
289 let visibility =
290 RawVisibility::from_ast_with_hygiene(item.visibility(), &self.hygiene);
291 let (kind, name) = match item {
292 ast::ExternItem::FnDef(it) => {
293 (DefKind::Function(self.source_ast_id_map.ast_id(&it)), it.name())
294 }
295 ast::ExternItem::StaticDef(it) => {
296 (DefKind::Static(self.source_ast_id_map.ast_id(&it)), it.name())
297 }
298 };
299
300 if let Some(name) = name {
301 let name = name.as_name();
302 let def = self.raw_items.defs.alloc(DefData { name, kind, visibility });
303 self.push_item(current_module, attrs, RawItemKind::Def(def));
304 }
305 }
306 }
307 }
308
281 fn add_module(&mut self, current_module: Option<Idx<ModuleData>>, module: ast::Module) { 309 fn add_module(&mut self, current_module: Option<Idx<ModuleData>>, module: ast::Module) {
282 let name = match module.name() { 310 let name = match module.name() {
283 Some(it) => it.as_name(), 311 Some(it) => it.as_name(),
diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs
index 949ca7595..83120fa36 100644
--- a/crates/ra_hir_def/src/nameres/tests.rs
+++ b/crates/ra_hir_def/src/nameres/tests.rs
@@ -25,7 +25,7 @@ fn compute_crate_def_map(fixture: &str) -> Arc<CrateDefMap> {
25#[test] 25#[test]
26fn crate_def_map_smoke_test() { 26fn crate_def_map_smoke_test() {
27 let map = def_map( 27 let map = def_map(
28 " 28 r"
29 //- /lib.rs 29 //- /lib.rs
30 mod foo; 30 mod foo;
31 struct S; 31 struct S;
@@ -45,6 +45,11 @@ fn crate_def_map_smoke_test() {
45 } 45 }
46 46
47 enum E { V } 47 enum E { V }
48
49 extern {
50 static EXT: u8;
51 fn ext();
52 }
48 ", 53 ",
49 ); 54 );
50 assert_snapshot!(map, @r###" 55 assert_snapshot!(map, @r###"
@@ -61,7 +66,9 @@ fn crate_def_map_smoke_test() {
61 ⋮crate::foo::bar 66 ⋮crate::foo::bar
62 ⋮Baz: t v 67 ⋮Baz: t v
63 ⋮E: t 68 ⋮E: t
69 ⋮EXT: v
64 ⋮U: t v 70 ⋮U: t v
71 ⋮ext: v
65 "###) 72 "###)
66} 73}
67 74