Functions

The exported functions form a command/query split over a JuliaWorkspace: mutation functions change the workspace inputs, while query functions read derived results.

Constructing a workspace from disc

JuliaWorkspaces.workspace_from_foldersFunction
workspace_from_folders(workspace_folders::Vector{String}; dynamic=DynamicOff, symbolcache_download=false, symbolcache_upstream=DEFAULT_SYMBOLCACHE_UPSTREAM)

Create a new JuliaWorkspace and populate it by recursively reading every folder in workspace_folders from disc. This is the most convenient entry point for analysing a project that lives on the local file system.

Keyword arguments

  • dynamic::DynamicMode: Whether and how to run the out-of-process dynamic feature. See DynamicMode. Defaults to DynamicOff.
  • symbolcache_download::Bool: If true, allow downloading precomputed package symbol caches from symbolcache_upstream instead of indexing locally.
  • symbolcache_upstream::String: Upstream URL for symbol-cache downloads. Defaults to DEFAULT_SYMBOLCACHE_UPSTREAM.

Returns

source
JuliaWorkspaces.add_folder_from_disc!Function
add_folder_from_disc!(jw::JuliaWorkspace, path; ignore_io_errors=false)

Recursively read all relevant files under the local folder path from disc and add them to the workspace jw. Julia sources, Project.toml/Manifest.toml, and configuration files are picked up. The whole batch is added before a single reconciliation step runs, so this is more efficient than calling add_file! per file.

If ignore_io_errors is true, files that cannot be read are skipped instead of raising an error.

source
JuliaWorkspaces.add_file_from_disc!Function
add_file_from_disc!(jw::JuliaWorkspace, path)

Read the file at the local path from disc and add it to the workspace jw as a new file (see add_file!). The file content is read eagerly and the file's language is inferred from its extension.

Throws if a file with the same URI is already part of the workspace.

source
JuliaWorkspaces.update_file_from_disc!Function
update_file_from_disc!(jw::JuliaWorkspace, path)

Re-read the file at the local path from disc and update its content in the workspace jw (see update_file!). Use this to refresh a file whose on-disc content changed outside of the workspace.

Throws if no file with the corresponding URI is part of the workspace.

source

Mutating a workspace

JuliaWorkspaces.add_file!Function
add_file!(jw::JuliaWorkspace, file::TextFile)

Add a file to the workspace. If the file already exists as a regular file, it will throw an error. If the URI is currently tracked as an indirect file (reached via include from another file), it is promoted to a regular file and any existing lazy indirect content is cleared.

source
JuliaWorkspaces.remove_file!Function
remove_file!(jw::JuliaWorkspace, uri::URI)

Remove a file from the workspace. If the file does not exist, it will throw an error.

source
JuliaWorkspaces.set_active_project!Function
set_active_project!(jw::JuliaWorkspace, uri_or_nothing::Union{URI,Nothing})

Set the active project for the workspace. The active project serves as the fallback environment for files that are not inside any project folder and also as the fallback test project when determining test environments.

Pass nothing to clear the active project.

When the active project is outside the workspace folders, its Project.toml and Manifest.toml will be loaded lazily via the indirect file mechanism, which triggers the indirect_file_watch_callback so the host (e.g. the LS) can register file watchers for them.

source
JuliaWorkspaces.set_indirect_file_content!Function
set_indirect_file_content!(jw::JuliaWorkspace, uri::URI, file::Union{TextFile,Nothing})

Update the content of an indirect file (a file referenced via include from a regular file but not itself added as a regular file). Pass nothing if the file no longer exists on disc. This is intended to be called by the LS in response to file-watcher notifications.

source
JuliaWorkspaces.clear_indirect_file!Function
clear_indirect_file!(jw::JuliaWorkspace, uri::URI)

Drop tracking for an indirect file. Any cached lazy content is removed; if the include graph still references the URI, the next query will re-trigger the lazy disc read and the watcher callback.

source

Files and source text

JuliaWorkspaces.get_indirect_filesFunction
get_indirect_files(jw::JuliaWorkspace)

Return the set of URIs currently tracked as indirect files — i.e. files reached only via include(...) traversal that are not regular workspace files.

source
JuliaWorkspaces.is_indirect_fileFunction
is_indirect_file(jw::JuliaWorkspace, uri::URI)

Return true if uri is currently part of the include graph as an indirect file (i.e. reached only via include and not added as a regular file).

source
JuliaWorkspaces.position_atFunction
position_at(source_text::SourceText, x::Int) -> Position

Convert the 1-based byte offset x within source_text into a Position (a 1-based line number and a 1-based UTF-8 byte column).

source

Syntax trees

JuliaWorkspaces.get_julia_syntax_treeFunction
get_julia_syntax_tree(jw::JuliaWorkspace, uri::URI)

Get the syntax tree of a Julia file from the workspace.

Returns

  • The tuple (tree, diagnostics), where tree is the syntax tree and diagnostics is a vector of Diagnostic structs.
source

Diagnostics

JuliaWorkspaces.get_diagnosticFunction
get_diagnostic(jw::JuliaWorkspace, uri::URI)

Get the diagnostics of a file from the workspace.

Returns

  • A vector of Diagnostic structs.
source
JuliaWorkspaces.get_diagnostics_blockingFunction
get_diagnostics_blocking(jw::JuliaWorkspace; cancel_token::Union{CancellationTokens.CancellationToken,Nothing}=nothing)

Wait for the dynamic environment to finish loading, then return all diagnostics. This is useful for CLI tools that want the full, accurate set of diagnostics. If cancel_token is provided, throws CancellationTokens.OperationCanceledException when the token is cancelled.

source

Projects, packages and tests

The dynamic feature

JuliaWorkspaces.is_readyFunction
is_ready(jw::JuliaWorkspace)

Check whether the workspace's dynamic environment loading has completed. Returns true if no dynamic feature is configured, or if the environment has finished loading and no tasks are pending.

source
JuliaWorkspaces.wait_until_readyFunction
wait_until_ready(jw::JuliaWorkspace; cancel_token::Union{CancellationTokens.CancellationToken,Nothing}=nothing)

Block until the workspace's dynamic environment loading has completed. If cancel_token is provided, throws CancellationTokens.OperationCanceledException when the token is cancelled.

source
JuliaWorkspaces.get_update_channelFunction
get_update_channel(jw::JuliaWorkspace)

Return the Channel{Symbol} that receives notifications when dynamic data becomes available. Returns nothing if no dynamic feature is configured. Consumers can take! or wait on this channel to be notified of updates.

source

Language features

JuliaWorkspaces.get_hover_textFunction
get_hover_text(jw::JuliaWorkspace, uri::URI, index::Integer)

Return a Markdown documentation string for the expression at index (1-based Julia string index) in the file identified by uri, or nothing if there is no hover information for that position.

source
JuliaWorkspaces.get_doc_from_wordFunction
get_doc_from_word(jw::JuliaWorkspace, word::AbstractString)

Search all loaded symbol stores for symbols matching word (fuzzy match) and return their documentation as a single markdown string. Returns "No results found." when no matches are found.

source
JuliaWorkspaces.get_completionsFunction
get_completions(jw::JuliaWorkspace, uri::URI, index::Integer, completion_mode::Symbol=:import)

Return a CompletionResult with completion items at the given index (1-based Julia string index) in the file identified by uri.

completion_mode may be :import (default) or :qualify to control whether additional using statements are inserted for out-of-scope symbols.

source
JuliaWorkspaces.get_expr1Function
get_expr1(x, offset, pos=0)

Walk a CSTParser EXPR tree and return the leaf EXPR whose span covers offset (0-based byte offset). Returns nothing if no match is found.

source
JuliaWorkspaces.completion_typeFunction
completion_type(b) -> Union{Symbol,Missing}

Infer the type of a binding b as a Symbol suitable for display in hover and completion results, stripping a leading Core. qualifier. Returns missing when the type cannot be determined or b is not a StaticLint.Binding.

source
JuliaWorkspaces.get_typed_definitionFunction
get_typed_definition(b) -> Union{String,Symbol,Missing}

Return a human-readable definition string for the binding b with its inferred type annotation inserted where possible (for example x::Int). Falls back to completion_type when b is not a StaticLint.Binding.

source
JuliaWorkspaces.get_definitionsFunction
get_definitions(jw::JuliaWorkspace, uri::URI, index::Integer)

Return a vector of DefinitionResult for the symbol at index (1-based Julia string index) in the file identified by uri.

source
JuliaWorkspaces.get_referencesFunction
get_references(jw::JuliaWorkspace, uri::URI, index::Integer)

Return a vector of ReferenceResult for all references to the symbol at index (1-based Julia string index) in the file identified by uri.

source
JuliaWorkspaces.get_rename_editsFunction
get_rename_edits(jw::JuliaWorkspace, uri::URI, index::Integer, new_name::String)

Return a vector of RenameEdit for renaming the symbol at index (1-based Julia string index) in uri to new_name.

source
JuliaWorkspaces.get_highlightsFunction
get_highlights(jw::JuliaWorkspace, uri::URI, index::Integer)

Return a vector of HighlightResult for highlighted occurrences of the symbol at index (1-based Julia string index) in the same file.

source
JuliaWorkspaces.can_renameFunction
can_rename(jw::JuliaWorkspace, uri::URI, index::Integer)

Check whether the symbol at index (1-based Julia string index) can be renamed. Returns a named tuple (; start::Position, stop::Position) describing the range of the renamable symbol (both positions use 1-based line and column), or nothing if the symbol cannot be renamed.

source
JuliaWorkspaces.get_signature_helpFunction
get_signature_help(jw::JuliaWorkspace, uri::URI, index::Integer)

Return a SignatureResult with signature information for the function call at index (1-based Julia string index) in the file identified by uri.

source
JuliaWorkspaces.get_document_symbolsFunction
get_document_symbols(jw::JuliaWorkspace, uri::URI)

Return a vector of DocumentSymbolResult representing the document outline for the file identified by uri. Each result has start_offset and end_offset as 0-based byte offsets, plus name, kind (LSP SymbolKind integer), and children.

source
JuliaWorkspaces.get_workspace_symbolsFunction
get_workspace_symbols(jw::JuliaWorkspace, query::String)

Search all files for top-level bindings whose name starts with query. Returns a vector of WorkspaceSymbolResult.

source
JuliaWorkspaces.get_selection_rangesFunction
get_selection_ranges(jw::JuliaWorkspace, uri::URI, indices::Vector{Int})

For each 1-based string index in indices, compute a nested selection range. Returns a vector of Union{Nothing, SelectionRangeResult}.

source
JuliaWorkspaces.get_current_block_rangeFunction
get_current_block_range(jw::JuliaWorkspace, uri::URI, index::Integer)

Find the current top-level block at index (1-based Julia string index). Returns a BlockRangeResult with 0-based byte offsets, or nothing.

source
JuliaWorkspaces.get_module_atFunction
get_module_at(jw::JuliaWorkspace, uri::URI, index::Integer)

Return the fully qualified module name at index (1-based Julia string index), or "Main" if no module scope is found.

source
JuliaWorkspaces.get_document_linksFunction
get_document_links(jw::JuliaWorkspace, uri::URI) → Vector{DocumentLinkResult}

Return clickable document links (string literals that resolve to files). Offsets in results are 0-based byte offsets for direct use with CST spans.

source
JuliaWorkspaces.get_inlay_hintsFunction
get_inlay_hints(jw::JuliaWorkspace, uri::URI, start_index::Integer, end_index::Integer, config::InlayHintConfig) → Vector{InlayHintResult}

Return inlay hints (parameter names, variable types) for the given range. start_index and end_index are 1-based Julia string indices.

source
JuliaWorkspaces.get_code_actionsFunction
get_code_actions(jw::JuliaWorkspace, uri::URI, index::Integer, diagnostic_messages::Vector{String}, workspace_folders::Vector{String}=String[]) → Vector{CodeActionInfo}

Return the list of applicable code actions at index (1-based Julia string index). diagnostic_messages should contain the text of any diagnostics overlapping the cursor. workspace_folders is an optional list of workspace folder paths (used by license actions).

source
JuliaWorkspaces.execute_code_actionFunction
execute_code_action(jw::JuliaWorkspace, action_id::String, uri::URI, index::Integer, workspace_folders::Vector{String}=String[]) → Vector{WorkspaceFileEdit}

Execute the code action identified by action_id at index (1-based Julia string index). Returns a vector of workspace file edits. Each edit contains a URI and a vector of TextEditResults with 0-based byte offsets.

source
JuliaWorkspaces.get_format_editsFunction
get_format_edits(jw::JuliaWorkspace, uri::URI) → WorkspaceFileEdit

Format the entire document uri and return a WorkspaceFileEdit describing the edits required to apply the formatting. The formatting style and options are taken from the nearest juliaformat.toml configuration file (see derived_format_configuration); when no configuration is found the minimal JuliaFormatter style is used. A style of "runic" routes formatting through Runic.jl.

If the document is already correctly formatted the returned edit list is empty. Throws an error if formatting fails (for example because of a syntax error).

source
get_format_edits(jw::JuliaWorkspace, uri::URI, start_line::Integer, stop_line::Integer) → WorkspaceFileEdit

Format the whole-line range [start_line, stop_line] (1-based, inclusive) of the document uri and return a WorkspaceFileEdit. Configuration is resolved the same way as for full-document formatting.

If the targeted range is already correctly formatted the returned edit list is empty. Throws an error if formatting fails.

source

StaticLint and environment accessors

JuliaWorkspaces.get_legacy_cstFunction
get_legacy_cst(jw::JuliaWorkspace, uri::URI)

Get the CSTParser legacy syntax tree for a Julia file.

Returns

  • An EXPR (CSTParser expression tree).
source
JuliaWorkspaces.get_roots_for_uriFunction
get_roots_for_uri(jw::JuliaWorkspace, uri::URI)

Get all root files whose include tree contains the given URI.

Returns

  • A Set{URI} of root file URIs.
source
JuliaWorkspaces.get_best_root_for_uriFunction
get_best_root_for_uri(jw::JuliaWorkspace, uri::URI)

Get the single best root file for a given URI. Prefers package src/ roots over test roots when a file is reachable from multiple roots. Returns nothing if the URI is not part of any root's include tree.

Returns

  • A URI or nothing.
source
JuliaWorkspaces.get_static_lint_dataFunction
get_static_lint_data(jw::JuliaWorkspace, uri::URI)

Get the static lint analysis data for the best root containing uri. This includes the metadata dictionary, environment, and workspace packages needed by LS request handlers.

Returns

  • A named tuple (meta_dict, env, workspace_packages, root) or nothing if no root contains the URI.
    • meta_dict::Dict{UInt64, StaticLint.Meta} — maps EXPR object_id → metadata
    • env::StaticLint.ExternalEnv — resolved environment (symbols, methods, deps)
    • workspace_packages::Dict{String,Any} — deved packages available for import
    • root::URI — the root file that was used
source
JuliaWorkspaces.get_environmentFunction
get_environment(jw::JuliaWorkspace, uri::URI)

Get the resolved environment for the best root containing uri.

Returns

  • A StaticLint.ExternalEnv or nothing.
source
JuliaWorkspaces.get_expr_locationFunction
get_expr_location(jw::JuliaWorkspace, x::CSTParser.EXPR)

Given an EXPR node from a CST obtained via get_legacy_cst, return the URI and byte offset of x within its owning file.

Walks x.parent pointers up to the file-root EXPR, computes the byte offset by descending through the tree, then looks up the root's objectid in a Salsa-memoized expr→URI mapping.

Returns

  • (uri::URI, offset::Int) if the owning file is found
  • nothing if the EXPR cannot be mapped to a file
source

Private functions

JuliaWorkspaces.update_file!Function
update_file!(jw::JuliaWorkspace, file::TextFile)

Update a file in the workspace. If the file does not exist, it will throw an error.

source

URI helper functions (submodule URIs2)