diff options
Diffstat (limited to 'crates/ide/src/lib.rs')
-rw-r--r-- | crates/ide/src/lib.rs | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index 6c94c26b5..b600178ee 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs | |||
@@ -22,6 +22,7 @@ mod markup; | |||
22 | mod prime_caches; | 22 | mod prime_caches; |
23 | mod display; | 23 | mod display; |
24 | 24 | ||
25 | mod annotations; | ||
25 | mod call_hierarchy; | 26 | mod call_hierarchy; |
26 | mod diagnostics; | 27 | mod diagnostics; |
27 | mod expand_macro; | 28 | mod expand_macro; |
@@ -63,9 +64,10 @@ use syntax::SourceFile; | |||
63 | use crate::display::ToNav; | 64 | use crate::display::ToNav; |
64 | 65 | ||
65 | pub use crate::{ | 66 | pub use crate::{ |
67 | annotations::{Annotation, AnnotationConfig, AnnotationKind}, | ||
66 | call_hierarchy::CallItem, | 68 | call_hierarchy::CallItem, |
67 | diagnostics::{Diagnostic, DiagnosticsConfig, Fix, Severity}, | 69 | diagnostics::{Diagnostic, DiagnosticsConfig, Fix, Severity}, |
68 | display::navigation_target::{NavigationTarget, SymbolKind}, | 70 | display::navigation_target::NavigationTarget, |
69 | expand_macro::ExpandedMacro, | 71 | expand_macro::ExpandedMacro, |
70 | file_structure::StructureNode, | 72 | file_structure::StructureNode, |
71 | folding_ranges::{Fold, FoldKind}, | 73 | folding_ranges::{Fold, FoldKind}, |
@@ -73,19 +75,19 @@ pub use crate::{ | |||
73 | inlay_hints::{InlayHint, InlayHintsConfig, InlayKind}, | 75 | inlay_hints::{InlayHint, InlayHintsConfig, InlayKind}, |
74 | markup::Markup, | 76 | markup::Markup, |
75 | prime_caches::PrimeCachesProgress, | 77 | prime_caches::PrimeCachesProgress, |
76 | references::{rename::RenameError, Declaration, ReferenceSearchResult}, | 78 | references::{rename::RenameError, ReferenceSearchResult}, |
77 | runnables::{Runnable, RunnableKind, TestId}, | 79 | runnables::{Runnable, RunnableKind, TestId}, |
78 | syntax_highlighting::{ | 80 | syntax_highlighting::{ |
79 | tags::{Highlight, HlMod, HlMods, HlPunct, HlTag}, | 81 | tags::{Highlight, HlMod, HlMods, HlPunct, HlTag}, |
80 | HlRange, | 82 | HlRange, |
81 | }, | 83 | }, |
82 | }; | 84 | }; |
83 | pub use assists::{Assist, AssistConfig, AssistId, AssistKind}; | 85 | pub use hir::{Documentation, Semantics}; |
84 | pub use completion::{ | 86 | pub use ide_assists::{Assist, AssistConfig, AssistId, AssistKind}; |
87 | pub use ide_completion::{ | ||
85 | CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, ImportEdit, | 88 | CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, ImportEdit, |
86 | InsertTextFormat, | 89 | InsertTextFormat, |
87 | }; | 90 | }; |
88 | pub use hir::{Documentation, Semantics}; | ||
89 | pub use ide_db::{ | 91 | pub use ide_db::{ |
90 | base_db::{ | 92 | base_db::{ |
91 | Canceled, Change, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, | 93 | Canceled, Change, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, |
@@ -93,13 +95,13 @@ pub use ide_db::{ | |||
93 | }, | 95 | }, |
94 | call_info::CallInfo, | 96 | call_info::CallInfo, |
95 | label::Label, | 97 | label::Label, |
96 | line_index::{LineCol, LineIndex}, | 98 | line_index::{LineCol, LineColUtf16, LineIndex}, |
97 | search::{FileReference, ReferenceAccess, ReferenceKind, SearchScope}, | 99 | search::{ReferenceAccess, SearchScope}, |
98 | source_change::{FileSystemEdit, SourceChange}, | 100 | source_change::{FileSystemEdit, SourceChange}, |
99 | symbol_index::Query, | 101 | symbol_index::Query, |
100 | RootDatabase, | 102 | RootDatabase, |
101 | }; | 103 | }; |
102 | pub use ssr::SsrError; | 104 | pub use ide_ssr::SsrError; |
103 | pub use syntax::{TextRange, TextSize}; | 105 | pub use syntax::{TextRange, TextSize}; |
104 | pub use text_edit::{Indel, TextEdit}; | 106 | pub use text_edit::{Indel, TextEdit}; |
105 | 107 | ||
@@ -369,9 +371,7 @@ impl Analysis { | |||
369 | position: FilePosition, | 371 | position: FilePosition, |
370 | search_scope: Option<SearchScope>, | 372 | search_scope: Option<SearchScope>, |
371 | ) -> Cancelable<Option<ReferenceSearchResult>> { | 373 | ) -> Cancelable<Option<ReferenceSearchResult>> { |
372 | self.with_db(|db| { | 374 | self.with_db(|db| references::find_all_refs(&Semantics::new(db), position, search_scope)) |
373 | references::find_all_refs(&Semantics::new(db), position, search_scope).map(|it| it.info) | ||
374 | }) | ||
375 | } | 375 | } |
376 | 376 | ||
377 | /// Finds all methods and free functions for the file. Does not return tests! | 377 | /// Finds all methods and free functions for the file. Does not return tests! |
@@ -468,7 +468,7 @@ impl Analysis { | |||
468 | config: &CompletionConfig, | 468 | config: &CompletionConfig, |
469 | position: FilePosition, | 469 | position: FilePosition, |
470 | ) -> Cancelable<Option<Vec<CompletionItem>>> { | 470 | ) -> Cancelable<Option<Vec<CompletionItem>>> { |
471 | self.with_db(|db| completion::completions(db, config, position).map(Into::into)) | 471 | self.with_db(|db| ide_completion::completions(db, config, position).map(Into::into)) |
472 | } | 472 | } |
473 | 473 | ||
474 | /// Resolves additional completion data at the position given. | 474 | /// Resolves additional completion data at the position given. |
@@ -478,15 +478,17 @@ impl Analysis { | |||
478 | position: FilePosition, | 478 | position: FilePosition, |
479 | full_import_path: &str, | 479 | full_import_path: &str, |
480 | imported_name: String, | 480 | imported_name: String, |
481 | import_for_trait_assoc_item: bool, | ||
481 | ) -> Cancelable<Vec<TextEdit>> { | 482 | ) -> Cancelable<Vec<TextEdit>> { |
482 | Ok(self | 483 | Ok(self |
483 | .with_db(|db| { | 484 | .with_db(|db| { |
484 | completion::resolve_completion_edits( | 485 | ide_completion::resolve_completion_edits( |
485 | db, | 486 | db, |
486 | config, | 487 | config, |
487 | position, | 488 | position, |
488 | full_import_path, | 489 | full_import_path, |
489 | imported_name, | 490 | imported_name, |
491 | import_for_trait_assoc_item, | ||
490 | ) | 492 | ) |
491 | })? | 493 | })? |
492 | .unwrap_or_default()) | 494 | .unwrap_or_default()) |
@@ -520,7 +522,7 @@ impl Analysis { | |||
520 | &self, | 522 | &self, |
521 | position: FilePosition, | 523 | position: FilePosition, |
522 | new_name: &str, | 524 | new_name: &str, |
523 | ) -> Cancelable<Result<RangeInfo<SourceChange>, RenameError>> { | 525 | ) -> Cancelable<Result<SourceChange, RenameError>> { |
524 | self.with_db(|db| references::rename::rename(db, position, new_name)) | 526 | self.with_db(|db| references::rename::rename(db, position, new_name)) |
525 | } | 527 | } |
526 | 528 | ||
@@ -547,14 +549,27 @@ impl Analysis { | |||
547 | selections: Vec<FileRange>, | 549 | selections: Vec<FileRange>, |
548 | ) -> Cancelable<Result<SourceChange, SsrError>> { | 550 | ) -> Cancelable<Result<SourceChange, SsrError>> { |
549 | self.with_db(|db| { | 551 | self.with_db(|db| { |
550 | let rule: ssr::SsrRule = query.parse()?; | 552 | let rule: ide_ssr::SsrRule = query.parse()?; |
551 | let mut match_finder = ssr::MatchFinder::in_context(db, resolve_context, selections); | 553 | let mut match_finder = |
554 | ide_ssr::MatchFinder::in_context(db, resolve_context, selections); | ||
552 | match_finder.add_rule(rule)?; | 555 | match_finder.add_rule(rule)?; |
553 | let edits = if parse_only { Default::default() } else { match_finder.edits() }; | 556 | let edits = if parse_only { Default::default() } else { match_finder.edits() }; |
554 | Ok(SourceChange::from(edits)) | 557 | Ok(SourceChange::from(edits)) |
555 | }) | 558 | }) |
556 | } | 559 | } |
557 | 560 | ||
561 | pub fn annotations( | ||
562 | &self, | ||
563 | file_id: FileId, | ||
564 | config: AnnotationConfig, | ||
565 | ) -> Cancelable<Vec<Annotation>> { | ||
566 | self.with_db(|db| annotations::annotations(db, file_id, config)) | ||
567 | } | ||
568 | |||
569 | pub fn resolve_annotation(&self, annotation: Annotation) -> Cancelable<Annotation> { | ||
570 | self.with_db(|db| annotations::resolve_annotation(db, annotation)) | ||
571 | } | ||
572 | |||
558 | /// Performs an operation on that may be Canceled. | 573 | /// Performs an operation on that may be Canceled. |
559 | fn with_db<F, T>(&self, f: F) -> Cancelable<T> | 574 | fn with_db<F, T>(&self, f: F) -> Cancelable<T> |
560 | where | 575 | where |