aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/completion/complete_dot.rs6
-rw-r--r--crates/ra_ide_api/src/db.rs1
-rw-r--r--crates/ra_ide_api/src/extend_selection.rs2
-rw-r--r--crates/ra_ide_api/src/lib.rs32
4 files changed, 19 insertions, 22 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs
index fb8b2fc88..32fd497be 100644
--- a/crates/ra_ide_api/src/completion/complete_dot.rs
+++ b/crates/ra_ide_api/src/completion/complete_dot.rs
@@ -25,7 +25,9 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) {
25fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) { 25fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) {
26 for receiver in receiver.autoderef(ctx.db) { 26 for receiver in receiver.autoderef(ctx.db) {
27 match receiver { 27 match receiver {
28 Ty::Adt { def_id, .. } => { 28 Ty::Adt {
29 def_id, ref substs, ..
30 } => {
29 match def_id.resolve(ctx.db) { 31 match def_id.resolve(ctx.db) {
30 Def::Struct(s) => { 32 Def::Struct(s) => {
31 for field in s.fields(ctx.db) { 33 for field in s.fields(ctx.db) {
@@ -35,7 +37,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty)
35 field.name().to_string(), 37 field.name().to_string(),
36 ) 38 )
37 .kind(CompletionItemKind::Field) 39 .kind(CompletionItemKind::Field)
38 .set_detail(field.ty(ctx.db).map(|ty| ty.to_string())) 40 .set_detail(field.ty(ctx.db).map(|ty| ty.subst(substs).to_string()))
39 .add_to(acc); 41 .add_to(acc);
40 } 42 }
41 } 43 }
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs
index c2978f909..a1b666899 100644
--- a/crates/ra_ide_api/src/db.rs
+++ b/crates/ra_ide_api/src/db.rs
@@ -129,6 +129,7 @@ salsa::database_storage! {
129 fn body_hir() for hir::db::BodyHirQuery; 129 fn body_hir() for hir::db::BodyHirQuery;
130 fn body_syntax_mapping() for hir::db::BodySyntaxMappingQuery; 130 fn body_syntax_mapping() for hir::db::BodySyntaxMappingQuery;
131 fn fn_signature() for hir::db::FnSignatureQuery; 131 fn fn_signature() for hir::db::FnSignatureQuery;
132 fn generic_params() for hir::db::GenericParamsQuery;
132 } 133 }
133 } 134 }
134} 135}
diff --git a/crates/ra_ide_api/src/extend_selection.rs b/crates/ra_ide_api/src/extend_selection.rs
index 9f0ab2f1c..718b4def5 100644
--- a/crates/ra_ide_api/src/extend_selection.rs
+++ b/crates/ra_ide_api/src/extend_selection.rs
@@ -51,7 +51,7 @@ mod tests {
51 } 51 }
52 ", 52 ",
53 ); 53 );
54 let r = analysis.extend_selection(frange); 54 let r = analysis.extend_selection(frange).unwrap();
55 assert_eq!(r, TextRange::from_to(51.into(), 56.into())); 55 assert_eq!(r, TextRange::from_to(51.into(), 56.into()));
56 } 56 }
57} 57}
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs
index fb0821ff6..a09a8f926 100644
--- a/crates/ra_ide_api/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -299,7 +299,7 @@ impl Analysis {
299 } 299 }
300 300
301 /// Gets the syntax tree of the file. 301 /// Gets the syntax tree of the file.
302 pub fn file_syntax(&self, file_id: FileId) -> TreeArc<SourceFile> { 302 pub fn parse(&self, file_id: FileId) -> TreeArc<SourceFile> {
303 self.db.source_file(file_id).clone() 303 self.db.source_file(file_id).clone()
304 } 304 }
305 305
@@ -310,14 +310,15 @@ impl Analysis {
310 } 310 }
311 311
312 /// Selects the next syntactic nodes encopasing the range. 312 /// Selects the next syntactic nodes encopasing the range.
313 pub fn extend_selection(&self, frange: FileRange) -> TextRange { 313 pub fn extend_selection(&self, frange: FileRange) -> Cancelable<TextRange> {
314 extend_selection::extend_selection(&self.db, frange) 314 self.with_db(|db| extend_selection::extend_selection(db, frange))
315 } 315 }
316 316
317 /// Returns position of the mathcing brace (all types of braces are 317 /// Returns position of the mathcing brace (all types of braces are
318 /// supported). 318 /// supported).
319 pub fn matching_brace(&self, file: &SourceFile, offset: TextUnit) -> Option<TextUnit> { 319 pub fn matching_brace(&self, position: FilePosition) -> Option<TextUnit> {
320 ra_ide_api_light::matching_brace(file, offset) 320 let file = self.db.source_file(position.file_id);
321 ra_ide_api_light::matching_brace(&file, position.offset)
321 } 322 }
322 323
323 /// Returns a syntax tree represented as `String`, for debug purposes. 324 /// Returns a syntax tree represented as `String`, for debug purposes.
@@ -388,8 +389,7 @@ impl Analysis {
388 &self, 389 &self,
389 position: FilePosition, 390 position: FilePosition,
390 ) -> Cancelable<Option<RangeInfo<Vec<NavigationTarget>>>> { 391 ) -> Cancelable<Option<RangeInfo<Vec<NavigationTarget>>>> {
391 self.db 392 self.with_db(|db| goto_definition::goto_definition(db, position))
392 .catch_canceled(|db| goto_definition::goto_definition(db, position))
393 } 393 }
394 394
395 /// Finds all usages of the reference at point. 395 /// Finds all usages of the reference at point.
@@ -404,8 +404,7 @@ impl Analysis {
404 404
405 /// Computes parameter information for the given call expression. 405 /// Computes parameter information for the given call expression.
406 pub fn call_info(&self, position: FilePosition) -> Cancelable<Option<CallInfo>> { 406 pub fn call_info(&self, position: FilePosition) -> Cancelable<Option<CallInfo>> {
407 self.db 407 self.with_db(|db| call_info::call_info(db, position))
408 .catch_canceled(|db| call_info::call_info(db, position))
409 } 408 }
410 409
411 /// Returns a `mod name;` declaration which created the current module. 410 /// Returns a `mod name;` declaration which created the current module.
@@ -420,33 +419,28 @@ impl Analysis {
420 419
421 /// Returns the root file of the given crate. 420 /// Returns the root file of the given crate.
422 pub fn crate_root(&self, crate_id: CrateId) -> Cancelable<FileId> { 421 pub fn crate_root(&self, crate_id: CrateId) -> Cancelable<FileId> {
423 Ok(self.db.crate_graph().crate_root(crate_id)) 422 self.with_db(|db| db.crate_graph().crate_root(crate_id))
424 } 423 }
425 424
426 /// Returns the set of possible targets to run for the current file. 425 /// Returns the set of possible targets to run for the current file.
427 pub fn runnables(&self, file_id: FileId) -> Cancelable<Vec<Runnable>> { 426 pub fn runnables(&self, file_id: FileId) -> Cancelable<Vec<Runnable>> {
428 self.db 427 self.with_db(|db| runnables::runnables(db, file_id))
429 .catch_canceled(|db| runnables::runnables(db, file_id))
430 } 428 }
431 429
432 /// Computes syntax highlighting for the given file. 430 /// Computes syntax highlighting for the given file.
433 pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> { 431 pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> {
434 self.db 432 self.with_db(|db| syntax_highlighting::highlight(db, file_id))
435 .catch_canceled(|db| syntax_highlighting::highlight(db, file_id))
436 } 433 }
437 434
438 /// Computes completions at the given position. 435 /// Computes completions at the given position.
439 pub fn completions(&self, position: FilePosition) -> Cancelable<Option<Vec<CompletionItem>>> { 436 pub fn completions(&self, position: FilePosition) -> Cancelable<Option<Vec<CompletionItem>>> {
440 let completions = self 437 self.with_db(|db| completion::completions(db, position).map(Into::into))
441 .db
442 .catch_canceled(|db| completion::completions(db, position))?;
443 Ok(completions.map(|it| it.into()))
444 } 438 }
445 439
446 /// Computes assists (aks code actons aka intentions) for the given 440 /// Computes assists (aks code actons aka intentions) for the given
447 /// position. 441 /// position.
448 pub fn assists(&self, frange: FileRange) -> Cancelable<Vec<SourceChange>> { 442 pub fn assists(&self, frange: FileRange) -> Cancelable<Vec<SourceChange>> {
449 Ok(self.db.assists(frange)) 443 self.with_db(|db| db.assists(frange))
450 } 444 }
451 445
452 /// Computes the set of diagnostics for the given file. 446 /// Computes the set of diagnostics for the given file.