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
sourceimpl 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 parallel_prime_caches<F>(
&self,
num_worker_threads: u8,
cb: F
) -> Cancellable<()> where
F: Fn(ParallelPrimeCachesProgress) + Sync + UnwindSafe,
sourcepub fn file_text(&self, file_id: FileId) -> Cancellable<Arc<String>>
pub fn file_text(&self, file_id: FileId) -> Cancellable<Arc<String>>
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_item_tree(&self, file_id: FileId) -> Cancellable<String>
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 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
) -> Cancellable<Option<SourceChange>>
pub fn on_char_typed(
&self,
position: FilePosition,
char_typed: char
) -> 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
) -> Cancellable<Vec<InlayHint>>
pub fn inlay_hints(
&self,
config: &InlayHintsConfig,
file_id: FileId
) -> Cancellable<Vec<InlayHint>>
Returns a list of the places in the file where type hints can be displayed.
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) -> Cancellable<Vec<NavigationTarget>>
pub fn symbol_search(&self, query: Query) -> 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 find_all_methods(&self, file_id: FileId) -> Cancellable<Vec<FileRange>>
pub fn find_all_methods(&self, file_id: FileId) -> Cancellable<Vec<FileRange>>
Finds all methods and free functions for the file. Does not return tests!
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
) -> Cancellable<Option<String>>
pub fn external_docs(
&self,
position: FilePosition
) -> Cancellable<Option<String>>
Return URL(s) for the documentation of the symbol under the cursor.
sourcepub fn call_info(&self, position: FilePosition) -> Cancellable<Option<CallInfo>>
pub fn call_info(&self, position: FilePosition) -> Cancellable<Option<CallInfo>>
Computes parameter information for the given call expression.
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 crate_for(&self, file_id: FileId) -> Cancellable<Vec<CrateId>>
pub fn crate_for(&self, file_id: FileId) -> Cancellable<Vec<CrateId>>
Returns crates this file belongs 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 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, file_id: FileId) -> Cancellable<Vec<HlRange>>
pub fn highlight(&self, 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, frange: FileRange) -> Cancellable<Vec<HlRange>>
pub fn highlight_range(&self, 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
) -> Cancellable<Option<Vec<CompletionItem>>>
pub fn completions(
&self,
config: &CompletionConfig,
position: FilePosition
) -> 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 diagnostics(
&self,
config: &DiagnosticsConfig,
resolve: AssistResolveStrategy,
file_id: FileId
) -> Cancellable<Vec<Diagnostic>>
pub fn diagnostics(
&self,
config: &DiagnosticsConfig,
resolve: AssistResolveStrategy,
file_id: FileId
) -> Cancellable<Vec<Diagnostic>>
Computes the set of 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>>
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Analysis
impl Send for Analysis
impl !Sync for Analysis
impl Unpin for Analysis
impl UnwindSafe for Analysis
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Cast for T
impl<T> Cast for T
fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U where
Self: CastTo<U>,
U: HasInterner,
fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U where
Self: CastTo<U>,
U: HasInterner,
Cast a value to type U
using CastTo
.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more