Skip to content

feat: extend ALS with symbol navigation, references, rename, and workspace symbols#2647

Draft
arikon wants to merge 17 commits intoansible:mainfrom
arikon:feat/als-document-symbol-provider
Draft

feat: extend ALS with symbol navigation, references, rename, and workspace symbols#2647
arikon wants to merge 17 commits intoansible:mainfrom
arikon:feat/als-document-symbol-provider

Conversation

@arikon
Copy link
Copy Markdown

@arikon arikon commented Mar 15, 2026

Summary

Extends the Ansible Language Server with comprehensive LSP navigation features built on a unified symbol infrastructure.

New LSP capabilities

  • Document Symbol — outline view and breadcrumbs for plays, tasks, blocks, roles, handlers
  • References — find all references for handlers (notify/name/listen), variables, file paths, roles
  • Rename — rename handlers with automatic notify/name/listen co-rename matrix
  • Workspace Symbol — fuzzy search across all open documents with caching
  • Symbol-based Hover — contextual hover info for handlers, variables, file paths, roles
  • Symbol-based Go to Definition — jump to handler definitions, variable declarations, included files, role directories

Infrastructure

  • ansibleSymbols.ts — unified symbol extraction engine supporting handlers, variables (vars, vars_prompt, vars_files, set_fact, register), file paths (include_tasks, template, copy), and roles
  • roleResolver.ts — role path resolution, argument_specs parsing, cross-file symbol search within role directories
  • ansibleConfig.ts — roles_paths support from ansible-config dump
  • Enhanced completion — dict-format vars support, role variable completion via roleResolver

Cleanup

  • Removed unused test fixtures (dynamic_inventory.py, new_ansible_config.cfg)
  • Added LSP support documentation

Wait-On: #2665

@arikon arikon requested review from a team as code owners March 15, 2026 06:49
Copilot AI review requested due to automatic review settings March 15, 2026 06:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@arikon arikon requested a review from Copilot March 15, 2026 06:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@arikon arikon requested a review from Copilot March 15, 2026 06:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

arikon and others added 12 commits March 17, 2026 12:58
Adds Document Symbol support to the Ansible Language Server,
enabling outline view and breadcrumbs in editors. Supports
plays, tasks, blocks, roles, and task sections (handlers,
pre_tasks, post_tasks). Falls back to flat SymbolInformation
when the client lacks hierarchical support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use node: protocol for fs and path imports in cli.ts
- Extract collectPlayChildren to reduce cognitive complexity
- Add tests for edge cases (nameless play/block, non-sequence YAML)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add tests for uncovered edge cases in documentSymbolProvider:
- Task fallback to "Task" when no name or module is present
- Play fallback to "Play" when hosts is absent
- Role with "name" key instead of "role" key

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix null type cast in processRootSequence return type
- Extract blockSectionKeys constant to eliminate regex duplication
- Rename getKeyRange to getSelectionRange for accurate semantics
- Add comment explaining single YAML document limitation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace all `{} as any` with typed emptyDocsLibrary mock
- Add null-case tests for non-symbol position and non-existent role

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add tests for handler, variable, filePath, and role definitions
- Add cross-file role definition tests
- Add null-case tests for definition provider
- Add dict-format vars completion test for Jinja2 brackets

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add unified symbol extraction (ansibleSymbols.ts) supporting handlers,
variables, file paths, and roles across playbooks and role directories.
Add role resolver (roleResolver.ts) for path resolution, argument_specs
parsing, and cross-file symbol search. Extend ansibleConfig with
roles_paths support. Include comprehensive test suites and fixtures.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wire up onReferences, onRenameRequest, onPrepareRename, and
onWorkspaceSymbol handlers in the language service. The rename
provider handles handler notify/name/listen co-rename matrix.
Workspace symbol provider supports fuzzy search with caching.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add symbol-based hover and go-to-definition for handlers, variables,
file paths, and roles. Extend completion to support dict-format vars
and role variables via roleResolver integration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove dynamic_inventory.py and new_ansible_config.cfg from completion
fixtures — no test references these files directly or indirectly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Document implemented and planned LSP features including completions,
hover, diagnostics, document symbols, references, rename, and
workspace symbols.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
arikon and others added 3 commits March 17, 2026 15:40
…esolver

Split ansibleSymbols.ts into focused modules (handlerSymbols, variableSymbols,
moduleSymbols, symbolDefinitions). Export shared patterns from ansible.ts,
add workspace symbol cache invalidation, fix nested /roles/ path resolution,
and add escapeRegex utility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…iders

Pass rolesPaths from AnsibleConfig to definition, hover, references,
rename, and workspace symbol providers so roles in DEFAULT_ROLES_PATH
are resolved correctly. Also fix getRoleContextFromUri to check
rolesPaths before /roles/ path fallback, supporting nested vendor roles.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unblock the LSP event loop by replacing heavy synchronous fs operations
(readFileSync, readdirSync) with their async equivalents from fs/promises.
Light single-syscall ops (existsSync, statSync, lstatSync, mkdirSync) are
intentionally kept synchronous. docsParser.ts is excluded (separate task).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants