pub struct Analysis { /* private fields */ }
Expand description
Analysis is a snapshot of a world state at a moment in time. It is the main
entry point for asking semantic information about the world. When the world
state is advanced using AnalysisHost::apply_change
method, all existing
Analysis
are canceled (most method return Err(Canceled)
).
Implementations§
source§impl Analysis
impl Analysis
pub fn from_single_file(text: String) -> (Analysis, FileId)
sourcepub fn status(&self, file_id: Option<FileId>) -> Cancellable<String>
pub fn status(&self, file_id: Option<FileId>) -> Cancellable<String>
Debug info about the current state of the analysis.
pub fn source_root_id(&self, file_id: FileId) -> Cancellable<SourceRootId>
pub fn is_local_source_root( &self, source_root_id: SourceRootId, ) -> Cancellable<bool>
pub fn parallel_prime_caches<F>( &self, num_worker_threads: usize, cb: F, ) -> Cancellable<()>
sourcepub fn file_text(&self, file_id: FileId) -> Cancellable<Arc<str>>
pub fn file_text(&self, file_id: FileId) -> Cancellable<Arc<str>>
Gets the text of the source file.
sourcepub fn parse(&self, file_id: FileId) -> Cancellable<SourceFile>
pub fn parse(&self, file_id: FileId) -> Cancellable<SourceFile>
Gets the syntax tree of the file.
sourcepub fn is_library_file(&self, file_id: FileId) -> Cancellable<bool>
pub fn is_library_file(&self, file_id: FileId) -> Cancellable<bool>
Returns true if this file belongs to an immutable library.
sourcepub fn file_line_index(&self, file_id: FileId) -> Cancellable<Arc<LineIndex>>
pub fn file_line_index(&self, file_id: FileId) -> Cancellable<Arc<LineIndex>>
Gets the file’s LineIndex
: data structure to convert between absolute
offsets and line/column representation.
sourcepub fn extend_selection(&self, frange: FileRange) -> Cancellable<TextRange>
pub fn extend_selection(&self, frange: FileRange) -> Cancellable<TextRange>
Selects the next syntactic nodes encompassing the range.
sourcepub fn matching_brace(
&self,
position: FilePosition,
) -> Cancellable<Option<TextSize>>
pub fn matching_brace( &self, position: FilePosition, ) -> Cancellable<Option<TextSize>>
Returns position of the matching brace (all types of braces are supported).
sourcepub fn syntax_tree(
&self,
file_id: FileId,
text_range: Option<TextRange>,
) -> Cancellable<String>
pub fn syntax_tree( &self, file_id: FileId, text_range: Option<TextRange>, ) -> Cancellable<String>
Returns a syntax tree represented as String
, for debug purposes.
pub fn view_hir(&self, position: FilePosition) -> Cancellable<String>
pub fn view_mir(&self, position: FilePosition) -> Cancellable<String>
pub fn interpret_function(&self, position: FilePosition) -> Cancellable<String>
pub fn view_item_tree(&self, file_id: FileId) -> Cancellable<String>
pub fn discover_test_roots(&self) -> Cancellable<Vec<TestItem>>
pub fn discover_tests_in_crate_by_test_id( &self, crate_id: &str, ) -> Cancellable<Vec<TestItem>>
pub fn discover_tests_in_crate( &self, crate_id: CrateId, ) -> Cancellable<Vec<TestItem>>
pub fn discover_tests_in_file( &self, file_id: FileId, ) -> Cancellable<Vec<TestItem>>
sourcepub fn view_crate_graph(
&self,
full: bool,
) -> Cancellable<Result<String, String>>
pub fn view_crate_graph( &self, full: bool, ) -> Cancellable<Result<String, String>>
Renders the crate graph to GraphViz “dot” syntax.
pub fn fetch_crates(&self) -> Cancellable<FxIndexSet<CrateInfo>>
pub fn expand_macro( &self, position: FilePosition, ) -> Cancellable<Option<ExpandedMacro>>
sourcepub fn join_lines(
&self,
config: &JoinLinesConfig,
frange: FileRange,
) -> Cancellable<TextEdit>
pub fn join_lines( &self, config: &JoinLinesConfig, frange: FileRange, ) -> Cancellable<TextEdit>
Returns an edit to remove all newlines in the range, cleaning up minor stuff like trailing commas.
sourcepub fn on_enter(&self, position: FilePosition) -> Cancellable<Option<TextEdit>>
pub fn on_enter(&self, position: FilePosition) -> Cancellable<Option<TextEdit>>
Returns an edit which should be applied when opening a new line, fixing
up minor stuff like continuing the comment.
The edit will be a snippet (with $0
).
sourcepub fn on_char_typed(
&self,
position: FilePosition,
char_typed: char,
autoclose: bool,
) -> Cancellable<Option<SourceChange>>
pub fn on_char_typed( &self, position: FilePosition, char_typed: char, autoclose: bool, ) -> Cancellable<Option<SourceChange>>
Returns an edit which should be applied after a character was typed.
This is useful for some on-the-fly fixups, like adding ;
to let =
automatically.
sourcepub fn file_structure(&self, file_id: FileId) -> Cancellable<Vec<StructureNode>>
pub fn file_structure(&self, file_id: FileId) -> Cancellable<Vec<StructureNode>>
Returns a tree representation of symbols in the file. Useful to draw a file outline.
sourcepub fn inlay_hints(
&self,
config: &InlayHintsConfig,
file_id: FileId,
range: Option<TextRange>,
) -> Cancellable<Vec<InlayHint>>
pub fn inlay_hints( &self, config: &InlayHintsConfig, file_id: FileId, range: Option<TextRange>, ) -> Cancellable<Vec<InlayHint>>
Returns a list of the places in the file where type hints can be displayed.
pub fn inlay_hints_resolve( &self, config: &InlayHintsConfig, file_id: FileId, resolve_range: TextRange, hash: u64, hasher: impl Fn(&InlayHint) -> u64 + Send + UnwindSafe, ) -> Cancellable<Option<InlayHint>>
sourcepub fn folding_ranges(&self, file_id: FileId) -> Cancellable<Vec<Fold>>
pub fn folding_ranges(&self, file_id: FileId) -> Cancellable<Vec<Fold>>
Returns the set of folding ranges.
sourcepub fn symbol_search(
&self,
query: Query,
limit: usize,
) -> Cancellable<Vec<NavigationTarget>>
pub fn symbol_search( &self, query: Query, limit: usize, ) -> Cancellable<Vec<NavigationTarget>>
Fuzzy searches for a symbol.
sourcepub fn goto_definition(
&self,
position: FilePosition,
) -> Cancellable<Option<RangeInfo<Vec<NavigationTarget>>>>
pub fn goto_definition( &self, position: FilePosition, ) -> Cancellable<Option<RangeInfo<Vec<NavigationTarget>>>>
Returns the definitions from the symbol at position
.
sourcepub fn goto_declaration(
&self,
position: FilePosition,
) -> Cancellable<Option<RangeInfo<Vec<NavigationTarget>>>>
pub fn goto_declaration( &self, position: FilePosition, ) -> Cancellable<Option<RangeInfo<Vec<NavigationTarget>>>>
Returns the declaration from the symbol at position
.
sourcepub fn goto_implementation(
&self,
position: FilePosition,
) -> Cancellable<Option<RangeInfo<Vec<NavigationTarget>>>>
pub fn goto_implementation( &self, position: FilePosition, ) -> Cancellable<Option<RangeInfo<Vec<NavigationTarget>>>>
Returns the impls from the symbol at position
.
sourcepub fn goto_type_definition(
&self,
position: FilePosition,
) -> Cancellable<Option<RangeInfo<Vec<NavigationTarget>>>>
pub fn goto_type_definition( &self, position: FilePosition, ) -> Cancellable<Option<RangeInfo<Vec<NavigationTarget>>>>
Returns the type definitions for the symbol at position
.
sourcepub fn find_all_refs(
&self,
position: FilePosition,
search_scope: Option<SearchScope>,
) -> Cancellable<Option<Vec<ReferenceSearchResult>>>
pub fn find_all_refs( &self, position: FilePosition, search_scope: Option<SearchScope>, ) -> Cancellable<Option<Vec<ReferenceSearchResult>>>
Finds all usages of the reference at point.
sourcepub fn hover(
&self,
config: &HoverConfig,
range: FileRange,
) -> Cancellable<Option<RangeInfo<HoverResult>>>
pub fn hover( &self, config: &HoverConfig, range: FileRange, ) -> Cancellable<Option<RangeInfo<HoverResult>>>
Returns a short text describing element at position.
sourcepub fn moniker(
&self,
position: FilePosition,
) -> Cancellable<Option<RangeInfo<Vec<MonikerResult>>>>
pub fn moniker( &self, position: FilePosition, ) -> Cancellable<Option<RangeInfo<Vec<MonikerResult>>>>
Returns moniker of symbol at position.
sourcepub fn external_docs(
&self,
position: FilePosition,
target_dir: Option<&str>,
sysroot: Option<&str>,
) -> Cancellable<DocumentationLinks>
pub fn external_docs( &self, position: FilePosition, target_dir: Option<&str>, sysroot: Option<&str>, ) -> Cancellable<DocumentationLinks>
Returns URL(s) for the documentation of the symbol under the cursor.
§Arguments
position
- Position in the file.target_dir
- Directory where the build output is storeda.
sourcepub fn signature_help(
&self,
position: FilePosition,
) -> Cancellable<Option<SignatureHelp>>
pub fn signature_help( &self, position: FilePosition, ) -> Cancellable<Option<SignatureHelp>>
Computes parameter information at the given position.
sourcepub fn call_hierarchy(
&self,
position: FilePosition,
) -> Cancellable<Option<RangeInfo<Vec<NavigationTarget>>>>
pub fn call_hierarchy( &self, position: FilePosition, ) -> Cancellable<Option<RangeInfo<Vec<NavigationTarget>>>>
Computes call hierarchy candidates for the given file position.
sourcepub fn incoming_calls(
&self,
position: FilePosition,
) -> Cancellable<Option<Vec<CallItem>>>
pub fn incoming_calls( &self, position: FilePosition, ) -> Cancellable<Option<Vec<CallItem>>>
Computes incoming calls for the given file position.
sourcepub fn outgoing_calls(
&self,
position: FilePosition,
) -> Cancellable<Option<Vec<CallItem>>>
pub fn outgoing_calls( &self, position: FilePosition, ) -> Cancellable<Option<Vec<CallItem>>>
Computes outgoing calls for the given file position.
sourcepub fn parent_module(
&self,
position: FilePosition,
) -> Cancellable<Vec<NavigationTarget>>
pub fn parent_module( &self, position: FilePosition, ) -> Cancellable<Vec<NavigationTarget>>
Returns a mod name;
declaration which created the current module.
sourcepub fn crates_for(&self, file_id: FileId) -> Cancellable<Vec<CrateId>>
pub fn crates_for(&self, file_id: FileId) -> Cancellable<Vec<CrateId>>
Returns crates this file belongs too.
sourcepub fn transitive_rev_deps(
&self,
crate_id: CrateId,
) -> Cancellable<Vec<CrateId>>
pub fn transitive_rev_deps( &self, crate_id: CrateId, ) -> Cancellable<Vec<CrateId>>
Returns crates this file belongs too.
sourcepub fn relevant_crates_for(&self, file_id: FileId) -> Cancellable<Vec<CrateId>>
pub fn relevant_crates_for(&self, file_id: FileId) -> Cancellable<Vec<CrateId>>
Returns crates this file might belong too.
sourcepub fn crate_edition(&self, crate_id: CrateId) -> Cancellable<Edition>
pub fn crate_edition(&self, crate_id: CrateId) -> Cancellable<Edition>
Returns the edition of the given crate.
sourcepub fn is_crate_no_std(&self, crate_id: CrateId) -> Cancellable<bool>
pub fn is_crate_no_std(&self, crate_id: CrateId) -> Cancellable<bool>
Returns true if this crate has no_std
or no_core
specified.
sourcepub fn crate_root(&self, crate_id: CrateId) -> Cancellable<FileId>
pub fn crate_root(&self, crate_id: CrateId) -> Cancellable<FileId>
Returns the root file of the given crate.
sourcepub fn runnables(&self, file_id: FileId) -> Cancellable<Vec<Runnable>>
pub fn runnables(&self, file_id: FileId) -> Cancellable<Vec<Runnable>>
Returns the set of possible targets to run for the current file.
Returns the set of tests for the given file position.
sourcepub fn highlight(
&self,
highlight_config: HighlightConfig,
file_id: FileId,
) -> Cancellable<Vec<HlRange>>
pub fn highlight( &self, highlight_config: HighlightConfig, file_id: FileId, ) -> Cancellable<Vec<HlRange>>
Computes syntax highlighting for the given file
Computes all ranges to highlight for a given item in a file.
sourcepub fn highlight_range(
&self,
highlight_config: HighlightConfig,
frange: FileRange,
) -> Cancellable<Vec<HlRange>>
pub fn highlight_range( &self, highlight_config: HighlightConfig, frange: FileRange, ) -> Cancellable<Vec<HlRange>>
Computes syntax highlighting for the given file range.
sourcepub fn highlight_as_html(
&self,
file_id: FileId,
rainbow: bool,
) -> Cancellable<String>
pub fn highlight_as_html( &self, file_id: FileId, rainbow: bool, ) -> Cancellable<String>
Computes syntax highlighting for the given file.
sourcepub fn completions(
&self,
config: &CompletionConfig,
position: FilePosition,
trigger_character: Option<char>,
) -> Cancellable<Option<Vec<CompletionItem>>>
pub fn completions( &self, config: &CompletionConfig, position: FilePosition, trigger_character: Option<char>, ) -> Cancellable<Option<Vec<CompletionItem>>>
Computes completions at the given position.
sourcepub fn resolve_completion_edits(
&self,
config: &CompletionConfig,
position: FilePosition,
imports: impl IntoIterator<Item = (String, String)> + UnwindSafe,
) -> Cancellable<Vec<TextEdit>>
pub fn resolve_completion_edits( &self, config: &CompletionConfig, position: FilePosition, imports: impl IntoIterator<Item = (String, String)> + UnwindSafe, ) -> Cancellable<Vec<TextEdit>>
Resolves additional completion data at the position given.
sourcepub fn syntax_diagnostics(
&self,
config: &DiagnosticsConfig,
file_id: FileId,
) -> Cancellable<Vec<Diagnostic>>
pub fn syntax_diagnostics( &self, config: &DiagnosticsConfig, file_id: FileId, ) -> Cancellable<Vec<Diagnostic>>
Computes the set of parser level diagnostics for the given file.
sourcepub fn semantic_diagnostics(
&self,
config: &DiagnosticsConfig,
resolve: AssistResolveStrategy,
file_id: FileId,
) -> Cancellable<Vec<Diagnostic>>
pub fn semantic_diagnostics( &self, config: &DiagnosticsConfig, resolve: AssistResolveStrategy, file_id: FileId, ) -> Cancellable<Vec<Diagnostic>>
Computes the set of semantic diagnostics for the given file.
sourcepub fn full_diagnostics(
&self,
config: &DiagnosticsConfig,
resolve: AssistResolveStrategy,
file_id: FileId,
) -> Cancellable<Vec<Diagnostic>>
pub fn full_diagnostics( &self, config: &DiagnosticsConfig, resolve: AssistResolveStrategy, file_id: FileId, ) -> Cancellable<Vec<Diagnostic>>
Computes the set of both syntax and semantic diagnostics for the given file.
sourcepub fn assists_with_fixes(
&self,
assist_config: &AssistConfig,
diagnostics_config: &DiagnosticsConfig,
resolve: AssistResolveStrategy,
frange: FileRange,
) -> Cancellable<Vec<Assist>>
pub fn assists_with_fixes( &self, assist_config: &AssistConfig, diagnostics_config: &DiagnosticsConfig, resolve: AssistResolveStrategy, frange: FileRange, ) -> Cancellable<Vec<Assist>>
Convenience function to return assists + quick fixes for diagnostics
sourcepub fn rename(
&self,
position: FilePosition,
new_name: &str,
) -> Cancellable<Result<SourceChange, RenameError>>
pub fn rename( &self, position: FilePosition, new_name: &str, ) -> Cancellable<Result<SourceChange, RenameError>>
Returns the edit required to rename reference at the position to the new name.
pub fn prepare_rename( &self, position: FilePosition, ) -> Cancellable<Result<RangeInfo<()>, RenameError>>
pub fn will_rename_file( &self, file_id: FileId, new_name_stem: &str, ) -> Cancellable<Option<SourceChange>>
pub fn structural_search_replace( &self, query: &str, parse_only: bool, resolve_context: FilePosition, selections: Vec<FileRange>, ) -> Cancellable<Result<SourceChange, SsrError>>
pub fn annotations( &self, config: &AnnotationConfig, file_id: FileId, ) -> Cancellable<Vec<Annotation>>
pub fn resolve_annotation( &self, annotation: Annotation, ) -> Cancellable<Annotation>
pub fn move_item( &self, range: FileRange, direction: Direction, ) -> Cancellable<Option<TextEdit>>
pub fn get_recursive_memory_layout( &self, position: FilePosition, ) -> Cancellable<Option<RecursiveMemoryLayout>>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Analysis
impl RefUnwindSafe for Analysis
impl Send for Analysis
impl !Sync for Analysis
impl Unpin for Analysis
impl UnwindSafe for Analysis
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Cast for T
impl<T> Cast for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more