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>
impl<Context> Analyzer<Context>
Sourcepub fn new<Progress, Return>(config: Config, progress: Progress) -> Self
pub fn new<Progress, Return>(config: Config, progress: Progress) -> Self
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.
Sourcepub fn new_with_resolution<Progress, Return>(
config: Config,
resolution: ResolutionContext,
progress: Progress,
) -> Self
pub fn new_with_resolution<Progress, Return>( config: Config, resolution: ResolutionContext, progress: Progress, ) -> Self
Constructs a new analyzer with the given config and resolution context.
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.
Sourcepub fn new_with_validator<Progress, Return, Validator>(
config: Config,
progress: Progress,
validator: Validator,
) -> Self
pub fn new_with_validator<Progress, Return, Validator>( config: Config, progress: Progress, validator: Validator, ) -> Self
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.
Sourcepub fn new_with_validator_and_resolution<Progress, Return, Validator>(
config: Config,
resolution: ResolutionContext,
progress: Progress,
validator: Validator,
) -> Self
pub fn new_with_validator_and_resolution<Progress, Return, Validator>( config: Config, resolution: ResolutionContext, progress: Progress, validator: Validator, ) -> Self
Constructs a new analyzer with the given config, resolution context, 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.
Sourcepub async fn swap_validator<Validator>(
&self,
validator: Validator,
) -> Result<()>
pub async fn swap_validator<Validator>( &self, validator: Validator, ) -> Result<()>
Replace the current validator function.
This will mark all documents for re-analysis.
Sourcepub async fn add_document(&self, uri: Url) -> Result<()>
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.
Sourcepub async fn add_directory(&self, path: impl Into<PathBuf>) -> Result<()>
pub async fn add_directory(&self, path: impl Into<PathBuf>) -> 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.
Sourcepub async fn unroot_documents(&self, documents: Vec<Url>) -> Result<()>
pub async fn unroot_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.
To forcefully delete the documents from the graph, use
Self::delete_documents().
Sourcepub async fn delete_documents(&self, documents: Vec<Url>) -> Result<()>
pub async fn delete_documents(&self, documents: Vec<Url>) -> Result<()>
Deletes the specified documents from the analyzer.
This differs from Self::unroot_documents(), as a deletion will occur
even if the document(s) are referenced in other documents.
Sourcepub fn notify_incremental_change(
&self,
document: Url,
change: IncrementalChange,
) -> Result<()>
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.
Sourcepub fn notify_change(&self, document: Url, discard_pending: bool) -> Result<()>
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.
Sourcepub async fn analyze_document(
&self,
context: Context,
document: Url,
) -> Result<Vec<AnalysisResult>>
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.
Sourcepub async fn analyze(&self, context: Context) -> Result<Vec<AnalysisResult>>
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.
Sourcepub async fn call_hierarchy(
&self,
document: Url,
position: SourcePosition,
encoding: SourcePositionEncoding,
) -> Result<Option<Vec<CallHierarchyItem>>>
pub async fn call_hierarchy( &self, document: Url, position: SourcePosition, encoding: SourcePositionEncoding, ) -> Result<Option<Vec<CallHierarchyItem>>>
Get the call hierarchy for the symbol at the current position.
Sourcepub async fn format_document(
&self,
document: Url,
) -> Result<Option<(u32, u32, String)>>
pub async fn format_document( &self, document: Url, ) -> Result<Option<(u32, u32, String)>>
Formats a document.
Sourcepub async fn folding_range(
&self,
document: Url,
) -> Result<Option<Vec<FoldingRange>>>
pub async fn folding_range( &self, document: Url, ) -> Result<Option<Vec<FoldingRange>>>
Get all folding ranges in a document.
Sourcepub async fn goto_definition(
&self,
document: Url,
position: SourcePosition,
encoding: SourcePositionEncoding,
) -> Result<Option<GotoDefinitionResponse>>
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.
Sourcepub async fn find_all_references(
&self,
document: Url,
position: SourcePosition,
encoding: SourcePositionEncoding,
include_declaration: bool,
) -> Result<Vec<Location>>
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.
Sourcepub async fn code_lens(&self, document: Url) -> Result<Option<Vec<CodeLens>>>
pub async fn code_lens(&self, document: Url) -> Result<Option<Vec<CodeLens>>>
Get all code lenses in a document.
Sourcepub async fn completion(
&self,
context: Context,
document: Url,
position: SourcePosition,
encoding: SourcePositionEncoding,
) -> Result<Option<CompletionResponse>>
pub async fn completion( &self, context: Context, document: Url, position: SourcePosition, encoding: SourcePositionEncoding, ) -> Result<Option<CompletionResponse>>
Performs a auto-completion for a symbol.
Sourcepub async fn hover(
&self,
document: Url,
position: SourcePosition,
encoding: SourcePositionEncoding,
) -> Result<Option<Hover>>
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.
Sourcepub async fn rename(
&self,
document: Url,
position: SourcePosition,
encoding: SourcePositionEncoding,
new_name: String,
) -> Result<Option<WorkspaceEdit>>
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.
Sourcepub async fn semantic_tokens(
&self,
document: Url,
) -> Result<Option<SemanticTokensResult>>
pub async fn semantic_tokens( &self, document: Url, ) -> Result<Option<SemanticTokensResult>>
Gets semantic tokens for a document
Sourcepub async fn document_symbol(
&self,
document: Url,
) -> Result<Option<DocumentSymbolResponse>>
pub async fn document_symbol( &self, document: Url, ) -> Result<Option<DocumentSymbolResponse>>
Gets document symbols for a document.
Sourcepub async fn workspace_symbol(
&self,
query: String,
) -> Result<Option<Vec<SymbolInformation>>>
pub async fn workspace_symbol( &self, query: String, ) -> Result<Option<Vec<SymbolInformation>>>
Gets document symbols for the workspace.
Sourcepub async fn incoming_calls(
&self,
document: Url,
position: SourcePosition,
encoding: SourcePositionEncoding,
) -> Result<Option<Vec<CallHierarchyIncomingCall>>>
pub async fn incoming_calls( &self, document: Url, position: SourcePosition, encoding: SourcePositionEncoding, ) -> Result<Option<Vec<CallHierarchyIncomingCall>>>
Get the incoming calls for the symbol at the current position.
Sourcepub async fn outgoing_calls(
&self,
document: Url,
position: SourcePosition,
encoding: SourcePositionEncoding,
) -> Result<Option<Vec<CallHierarchyOutgoingCall>>>
pub async fn outgoing_calls( &self, document: Url, position: SourcePosition, encoding: SourcePositionEncoding, ) -> Result<Option<Vec<CallHierarchyOutgoingCall>>>
Get the outgoing calls for the symbol at the current position.
Sourcepub async fn signature_help(
&self,
document: Url,
position: SourcePosition,
encoding: SourcePositionEncoding,
) -> Result<Option<SignatureHelp>>
pub async fn signature_help( &self, document: Url, position: SourcePosition, encoding: SourcePositionEncoding, ) -> Result<Option<SignatureHelp>>
Gets signature help for a function call at a given position.
Trait Implementations§
Auto Trait Implementations§
impl<Context> !RefUnwindSafe for Analyzer<Context>
impl<Context> !UnwindSafe for Analyzer<Context>
impl<Context> Freeze 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> UnsafeUnpin for Analyzer<Context>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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