Struct Analyzer

Source
pub struct Analyzer<Context> { /* private fields */ }
Expand description

Represents a Workflow Description Language (WDL) document analyzer.

By default, analysis parses documents, performs validation checks, resolves imports, and performs type checking.

Each analysis operation is processed in order of request; however, the individual parsing, resolution, and analysis of documents is performed across a thread pool.

Note that dropping the analyzer is a blocking operation as it will wait for the queue thread to join.

The type parameter is the context type passed to the progress callback.

Implementations§

Source§

impl<Context> Analyzer<Context>
where Context: Send + Clone + 'static,

Source

pub fn new<Progress, Return>(config: Config, progress: Progress) -> Self
where Progress: Fn(Context, ProgressKind, usize, usize) -> Return + Send + 'static, Return: Future<Output = ()>,

Constructs a new analyzer with the given config.

The provided progress callback will be invoked during analysis.

The analyzer will use a default validator for validation.

The analyzer must be constructed from the context of a Tokio runtime.

Source

pub fn new_with_validator<Progress, Return, Validator>( config: Config, progress: Progress, validator: Validator, ) -> Self
where Progress: Fn(Context, ProgressKind, usize, usize) -> Return + Send + 'static, Return: Future<Output = ()>, Validator: Fn() -> Validator + Send + Sync + 'static,

Constructs a new analyzer with the given config and validator function.

The provided progress callback will be invoked during analysis.

This validator function will be called once per worker thread to initialize a thread-local validator.

The analyzer must be constructed from the context of a Tokio runtime.

Source

pub async fn add_document(&self, uri: Url) -> Result<()>

Adds a document to the analyzer. Document can be a local file or a URL.

Returns an error if the document could not be added.

Source

pub async fn add_directory(&self, path: impl AsRef<Path>) -> Result<()>

Adds a directory to the analyzer. It will recursively search for WDL documents in the supplied directory.

Returns an error if there was a problem discovering documents for the specified path.

Source

pub async fn remove_documents(&self, documents: Vec<Url>) -> Result<()>

Removes the specified documents from the analyzer.

If a specified URI is a prefix (i.e. directory) of documents known to the analyzer, those documents will be removed.

Documents are only removed when not referenced from importing documents.

Source

pub fn notify_incremental_change( &self, document: Url, change: IncrementalChange, ) -> Result<()>

Notifies the analyzer that a document has an incremental change.

Changes to documents that aren’t known to the analyzer are ignored.

Source

pub fn notify_change(&self, document: Url, discard_pending: bool) -> Result<()>

Notifies the analyzer that a document has fully changed and should be fetched again.

Changes to documents that aren’t known to the analyzer are ignored.

If discard_pending is true, then any pending incremental changes are discarded; otherwise, the full change is ignored if there are pending incremental changes.

Source

pub async fn analyze_document( &self, context: Context, document: Url, ) -> Result<Vec<AnalysisResult>>

Analyzes a specific document.

The provided context is passed to the progress callback.

If the document is up-to-date and was previously analyzed, the current analysis result is returned.

Returns an analysis result for each document that was analyzed.

Source

pub async fn analyze(&self, context: Context) -> Result<Vec<AnalysisResult>>

Performs analysis of all documents.

The provided context is passed to the progress callback.

If a document is up-to-date and was previously analyzed, the current analysis result is returned.

Returns an analysis result for each document that was analyzed.

Source

pub async fn format_document( &self, document: Url, ) -> Result<Option<(u32, u32, String)>>

Formats a document.

Source

pub async fn goto_definition( &self, document: Url, position: SourcePosition, encoding: SourcePositionEncoding, ) -> Result<Option<GotoDefinitionResponse>>

Performs a “goto definition” for a symbol at the current position.

Source

pub async fn find_all_references( &self, document: Url, position: SourcePosition, encoding: SourcePositionEncoding, include_declaration: bool, ) -> Result<Vec<Location>>

Performs a find references for a symbol across all the documents.

Source

pub async fn completion( &self, context: Context, document: Url, position: SourcePosition, encoding: SourcePositionEncoding, ) -> Result<Option<CompletionResponse>>

Performs a auto-completion for a symbol.

Source

pub async fn hover( &self, document: Url, position: SourcePosition, encoding: SourcePositionEncoding, ) -> Result<Option<Hover>>

Performs a hover for a symbol at a given position in a document.

Source

pub async fn rename( &self, document: Url, position: SourcePosition, encoding: SourcePositionEncoding, new_name: String, ) -> Result<Option<WorkspaceEdit>>

Renames a symbol at a given position across the workspace.

Source

pub async fn semantic_tokens( &self, document: Url, ) -> Result<Option<SemanticTokensResult>>

Gets semantic tokens for a document

Trait Implementations§

Source§

impl<Context: Debug> Debug for Analyzer<Context>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Analyzer<()>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<C> Drop for Analyzer<C>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<Context> Freeze for Analyzer<Context>

§

impl<Context> !RefUnwindSafe for Analyzer<Context>

§

impl<Context> Send for Analyzer<Context>
where Context: Send,

§

impl<Context> Sync for Analyzer<Context>
where Context: Send,

§

impl<Context> Unpin for Analyzer<Context>

§

impl<Context> !UnwindSafe for Analyzer<Context>

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

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>,

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,