Skip to content

[M10 correctness] Implement project-wide semantic rename #73

Description

@Teakowa

Parent: #27

Depends on: #72

Goal

Make rename operate on Wright's project-wide semantic identity and produce validated multi-source edits, instead of rewriting only the requesting document buffer.

Context

Cross-file definition/references now preserve source identity, but rename still validates and rewrites only the current document text and the LSP adapter returns edits only for the requesting URI. This does not satisfy M10's multi-file/project correctness contract when a declaration/definition and its references span multiple .opy sources.

Scope

  • Resolve the semantic symbol at the requested position and collect project-wide declaration/definition/reference targets using Wright's existing semantic/project model.
  • Produce source-aware edits for every affected source. The edit contract should carry enough identity to apply edits safely, including source identity, range/replacement, and appropriate version/source preconditions.
  • Reuse M9 safe-edit validation where possible; extend the shared edit contract rather than creating an LSP-only rename engine.
  • Prefer open unsaved document overlays over filesystem content when validating affected sources.
  • Reject rename explicitly when semantic identity, collision safety, source state, or validation cannot be established.
  • Map the editor-neutral multi-source result to a correct LSP WorkspaceEdit.

Non-goals

  • Building a general refactoring framework.
  • Adding extract/inline/code-action features.
  • Guessing rename targets through plain textual replacement when semantic identity is unresolved.
  • Expanding the .opy language surface.

Acceptance criteria

  • A symbol declared/defined in an included file and referenced in another file can be renamed from either the declaration/definition or a call/reference site.
  • The resulting edits cover every semantically affected source and do not modify unrelated same-spelled identifiers.
  • LSP returns a valid multi-document WorkspaceEdit for cross-file rename.
  • Applying all returned edits yields source that passes Wright's existing validation pipeline.
  • Open unsaved overlays participate in rename and take precedence over filesystem content.
  • Stale versions/source identities cause an explicit refusal rather than silently applying edits to newer content.
  • Collision/namespace-boundary cases have focused tests.
  • Single-file rename remains supported and uses the same underlying editor-neutral contract.

Planning notes

Do not begin by broadening the M9 safe-edit API speculatively. First use the source-aware diagnostic/project ownership work from #72 and extend only the minimum shared edit contract needed for verified cross-file rename.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions