Struct ide::Analysis

source ·
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

source

pub fn from_single_file(text: String) -> (Analysis, FileId)

source

pub fn status(&self, file_id: Option<FileId>) -> Cancellable<String>

Debug info about the current state of the analysis.

source

pub fn parallel_prime_caches<F>( &self, num_worker_threads: u8, cb: F ) -> Cancellable<()>

source

pub fn file_text(&self, file_id: FileId) -> Cancellable<Arc<str>>

Gets the text of the source file.

source

pub fn parse(&self, file_id: FileId) -> Cancellable<SourceFile>

Gets the syntax tree of the file.

source

pub fn is_library_file(&self, file_id: FileId) -> Cancellable<bool>

Returns true if this file belongs to an immutable library.

source

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.

source

pub fn extend_selection(&self, frange: FileRange) -> Cancellable<TextRange>

Selects the next syntactic nodes encompassing the range.

source

pub fn matching_brace( &self, position: FilePosition ) -> Cancellable<Option<TextSize>>

Returns position of the matching brace (all types of braces are supported).

source

pub fn syntax_tree( &self, file_id: FileId, text_range: Option<TextRange> ) -> Cancellable<String>

Returns a syntax tree represented as String, for debug purposes.

source

pub fn view_hir(&self, position: FilePosition) -> Cancellable<String>

source

pub fn view_mir(&self, position: FilePosition) -> Cancellable<String>

source

pub fn interpret_function(&self, position: FilePosition) -> Cancellable<String>

source

pub fn view_item_tree(&self, file_id: FileId) -> Cancellable<String>

source

pub fn discover_test_roots(&self) -> Cancellable<Vec<TestItem>>

source

pub fn discover_tests_in_crate_by_test_id( &self, crate_id: &str ) -> Cancellable<Vec<TestItem>>

source

pub fn discover_tests_in_crate( &self, crate_id: CrateId ) -> Cancellable<Vec<TestItem>>

source

pub fn view_crate_graph( &self, full: bool ) -> Cancellable<Result<String, String>>

Renders the crate graph to GraphViz “dot” syntax.

source

pub fn fetch_crates(&self) -> Cancellable<FxIndexSet<CrateInfo>>

source

pub fn expand_macro( &self, position: FilePosition ) -> Cancellable<Option<ExpandedMacro>>

source

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.

source

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).

source

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.

source

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.

source

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.

source

pub fn inlay_hints_resolve( &self, config: &InlayHintsConfig, file_id: FileId, position: TextSize, hash: u64 ) -> Cancellable<Option<InlayHint>>

source

pub fn folding_ranges(&self, file_id: FileId) -> Cancellable<Vec<Fold>>

Returns the set of folding ranges.

Fuzzy searches for a symbol.

source

pub fn goto_definition( &self, position: FilePosition ) -> Cancellable<Option<RangeInfo<Vec<NavigationTarget>>>>

Returns the definitions from the symbol at position.

source

pub fn goto_declaration( &self, position: FilePosition ) -> Cancellable<Option<RangeInfo<Vec<NavigationTarget>>>>

Returns the declaration from the symbol at position.

source

pub fn goto_implementation( &self, position: FilePosition ) -> Cancellable<Option<RangeInfo<Vec<NavigationTarget>>>>

Returns the impls from the symbol at position.

source

pub fn goto_type_definition( &self, position: FilePosition ) -> Cancellable<Option<RangeInfo<Vec<NavigationTarget>>>>

Returns the type definitions for the symbol at position.

source

pub fn find_all_refs( &self, position: FilePosition, search_scope: Option<SearchScope> ) -> Cancellable<Option<Vec<ReferenceSearchResult>>>

Finds all usages of the reference at point.

source

pub fn hover( &self, config: &HoverConfig, range: FileRange ) -> Cancellable<Option<RangeInfo<HoverResult>>>

Returns a short text describing element at position.

source

pub fn moniker( &self, position: FilePosition ) -> Cancellable<Option<RangeInfo<Vec<MonikerResult>>>>

Returns moniker of symbol at position.

source

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.
source

pub fn signature_help( &self, position: FilePosition ) -> Cancellable<Option<SignatureHelp>>

Computes parameter information at the given position.

source

pub fn call_hierarchy( &self, position: FilePosition ) -> Cancellable<Option<RangeInfo<Vec<NavigationTarget>>>>

Computes call hierarchy candidates for the given file position.

source

pub fn incoming_calls( &self, position: FilePosition ) -> Cancellable<Option<Vec<CallItem>>>

Computes incoming calls for the given file position.

source

pub fn outgoing_calls( &self, position: FilePosition ) -> Cancellable<Option<Vec<CallItem>>>

Computes outgoing calls for the given file position.

source

pub fn parent_module( &self, position: FilePosition ) -> Cancellable<Vec<NavigationTarget>>

Returns a mod name; declaration which created the current module.

source

pub fn crates_for(&self, file_id: FileId) -> Cancellable<Vec<CrateId>>

Returns crates this file belongs too.

source

pub fn transitive_rev_deps( &self, crate_id: CrateId ) -> Cancellable<Vec<CrateId>>

Returns crates this file belongs too.

source

pub fn relevant_crates_for(&self, file_id: FileId) -> Cancellable<Vec<CrateId>>

Returns crates this file might belong too.

source

pub fn crate_edition(&self, crate_id: CrateId) -> Cancellable<Edition>

Returns the edition of the given crate.

source

pub fn is_crate_no_std(&self, crate_id: CrateId) -> Cancellable<bool>

Returns true if this crate has no_std or no_core specified.

source

pub fn crate_root(&self, crate_id: CrateId) -> Cancellable<FileId>

Returns the root file of the given crate.

source

pub fn runnables(&self, file_id: FileId) -> Cancellable<Vec<Runnable>>

Returns the set of possible targets to run for the current file.

source

pub fn related_tests( &self, position: FilePosition, search_scope: Option<SearchScope> ) -> Cancellable<Vec<Runnable>>

Returns the set of tests for the given file position.

source

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.

source

pub fn highlight_range( &self, highlight_config: HighlightConfig, frange: FileRange ) -> Cancellable<Vec<HlRange>>

Computes syntax highlighting for the given file range.

source

pub fn highlight_as_html( &self, file_id: FileId, rainbow: bool ) -> Cancellable<String>

Computes syntax highlighting for the given file.

source

pub fn completions( &self, config: &CompletionConfig, position: FilePosition, trigger_character: Option<char> ) -> Cancellable<Option<Vec<CompletionItem>>>

Computes completions at the given position.

source

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.

source

pub fn diagnostics( &self, config: &DiagnosticsConfig, resolve: AssistResolveStrategy, file_id: FileId ) -> Cancellable<Vec<Diagnostic>>

Computes the set of diagnostics for the given file.

source

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

source

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.

source

pub fn prepare_rename( &self, position: FilePosition ) -> Cancellable<Result<RangeInfo<()>, RenameError>>

source

pub fn will_rename_file( &self, file_id: FileId, new_name_stem: &str ) -> Cancellable<Option<SourceChange>>

source

pub fn structural_search_replace( &self, query: &str, parse_only: bool, resolve_context: FilePosition, selections: Vec<FileRange> ) -> Cancellable<Result<SourceChange, SsrError>>

source

pub fn annotations( &self, config: &AnnotationConfig, file_id: FileId ) -> Cancellable<Vec<Annotation>>

source

pub fn resolve_annotation( &self, annotation: Annotation ) -> Cancellable<Annotation>

source

pub fn move_item( &self, range: FileRange, direction: Direction ) -> Cancellable<Option<TextEdit>>

source

pub fn get_recursive_memory_layout( &self, position: FilePosition ) -> Cancellable<Option<RecursiveMemoryLayout>>

Trait Implementations§

source§

impl Debug for Analysis

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Cast for T

§

fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U
where Self: CastTo<U>, U: HasInterner,

Cast a value to type U using CastTo.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoBox<dyn Any> for T
where T: Any,

§

fn into_box(self) -> Box<dyn Any>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Send> for T
where T: Any + Send,

§

fn into_box(self) -> Box<dyn Any + Send>

Convert self into the appropriate boxed form.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<'a, T> Captures<'a> for T
where T: ?Sized,