aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-12-09 18:47:00 +0000
committerGitHub <[email protected]>2019-12-09 18:47:00 +0000
commit897b550049d8889804bb476e305427d07879cd63 (patch)
treeb972b060d4c23397bfa06466bd2261301e8228ec
parent442ab3a34dfaf41bc3852acb9db20e0687d20b0c (diff)
parentb683cbd93db65f5421ef9b7617a2abfe93928af0 (diff)
Merge #2513
2513: Report correct original range in goto_definition r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--crates/ra_ide/src/goto_definition.rs16
-rw-r--r--editors/code/src/config.ts5
-rw-r--r--editors/code/src/server.ts3
3 files changed, 14 insertions, 10 deletions
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs
index b93d6a931..cfe62037f 100644
--- a/crates/ra_ide/src/goto_definition.rs
+++ b/crates/ra_ide/src/goto_definition.rs
@@ -19,25 +19,23 @@ pub(crate) fn goto_definition(
19 position: FilePosition, 19 position: FilePosition,
20) -> Option<RangeInfo<Vec<NavigationTarget>>> { 20) -> Option<RangeInfo<Vec<NavigationTarget>>> {
21 let file = db.parse_or_expand(position.file_id.into())?; 21 let file = db.parse_or_expand(position.file_id.into())?;
22 let token = file.token_at_offset(position.offset).filter(|it| !it.kind().is_trivia()).next()?; 22 let original_token =
23 let token = descend_into_macros(db, position.file_id, token); 23 file.token_at_offset(position.offset).filter(|it| !it.kind().is_trivia()).next()?;
24 let token = descend_into_macros(db, position.file_id, original_token.clone());
24 25
25 let res = match_ast! { 26 let nav_targets = match_ast! {
26 match (token.value.parent()) { 27 match (token.value.parent()) {
27 ast::NameRef(name_ref) => { 28 ast::NameRef(name_ref) => {
28 let navs = reference_definition(db, token.with_value(&name_ref)).to_vec(); 29 reference_definition(db, token.with_value(&name_ref)).to_vec()
29 RangeInfo::new(name_ref.syntax().text_range(), navs.to_vec())
30 }, 30 },
31 ast::Name(name) => { 31 ast::Name(name) => {
32 let navs = name_definition(db, token.with_value(&name))?; 32 name_definition(db, token.with_value(&name))?
33 RangeInfo::new(name.syntax().text_range(), navs)
34
35 }, 33 },
36 _ => return None, 34 _ => return None,
37 } 35 }
38 }; 36 };
39 37
40 Some(res) 38 Some(RangeInfo::new(original_token.text_range(), nav_targets))
41} 39}
42 40
43#[derive(Debug)] 41#[derive(Debug)]
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index 95c3f42e5..fb9e55dd6 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -26,6 +26,8 @@ export class Config {
26 public excludeGlobs = []; 26 public excludeGlobs = [];
27 public useClientWatching = false; 27 public useClientWatching = false;
28 public featureFlags = {}; 28 public featureFlags = {};
29 // for internal use
30 public withSysroot: null | boolean = null;
29 public cargoWatchOptions: CargoWatchOptions = { 31 public cargoWatchOptions: CargoWatchOptions = {
30 enableOnStartup: 'ask', 32 enableOnStartup: 'ask',
31 trace: 'off', 33 trace: 'off',
@@ -148,5 +150,8 @@ export class Config {
148 if (config.has('featureFlags')) { 150 if (config.has('featureFlags')) {
149 this.featureFlags = config.get('featureFlags') || {}; 151 this.featureFlags = config.get('featureFlags') || {};
150 } 152 }
153 if (config.has('withSysroot')) {
154 this.withSysroot = config.get('withSysroot') || false;
155 }
151 } 156 }
152} 157}
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts
index b346c0828..e767b6f1b 100644
--- a/editors/code/src/server.ts
+++ b/editors/code/src/server.ts
@@ -57,7 +57,8 @@ export class Server {
57 maxInlayHintLength: Server.config.maxInlayHintLength, 57 maxInlayHintLength: Server.config.maxInlayHintLength,
58 excludeGlobs: Server.config.excludeGlobs, 58 excludeGlobs: Server.config.excludeGlobs,
59 useClientWatching: Server.config.useClientWatching, 59 useClientWatching: Server.config.useClientWatching,
60 featureFlags: Server.config.featureFlags 60 featureFlags: Server.config.featureFlags,
61 withSysroot: Server.config.withSysroot
61 }, 62 },
62 traceOutputChannel 63 traceOutputChannel
63 }; 64 };