Skip to content

Add usage-count CodeLens for variables and functions #180

Description

@julia-script

Summary

Add LSP CodeLens usage counts for local variables, parameters, functions, and other suitable declarations.

This builds on the workspace reference product in #179. Local declarations can use current per-module semantic occurrences; top-level declarations need complete source-root reference summaries.

Scope

  • Advertise and implement textDocument/codeLens.
  • Use canonical semantic identities rather than textual name counts.
  • Count local binding and parameter references from current module/function facts.
  • Count top-level function/declaration references across closed reverse-dependent modules through Index workspace references beyond the open-root import closure #179.
  • Support codeLens/resolve so expensive workspace counts can be deferred.
  • Keep lenses coherent with the accepted document and workspace revision.
  • Define and document:
    • whether import-clause occurrences count as usages;
    • whether declarations are excluded from counts;
    • whether zero-count lenses are hidden or displayed;
    • whether local and workspace counts are presented differently.

Acceptance criteria

  • A local variable and parameter lens reports the exact semantic reference count within its scope.
  • A top-level function lens includes uses from unopened source-root modules.
  • Shadowed or same-spelled declarations do not affect each other's counts.
  • The declaration occurrence itself is not accidentally counted as a reference.
  • Stale lens resolution does not combine current text with old reference summaries.
  • Lens ordering and titles are deterministic.
  • Large files and workspaces do not eagerly recompute every global count for every request.
  • Tests cover imports/aliases, first-class callable uses, direct calls, zero usages, unsaved buffers, and closed reverse dependents.

Dependency

Blocked by the workspace reference completeness and freshness semantics in #179.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Nice to haveblockedlspLanguage servernew featureNew functionality outside the current stable-release language surface

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions