Skip to content

Conversation

@elohmeier
Copy link

What does this PR do?

  • Adds rename support for YAML anchors/aliases, wiring LSP prepare/rename and updating references alongside the anchor definition.

What issues does this PR fix or reference?

  • n/a (new feature)

Is it tested? How?

  • npm test -- --grep "YAML Rename"
  • tested it manually with Neovim

@coveralls
Copy link

Coverage Status

coverage: 83.321% (-0.6%) from 83.961%
when pulling 80f74f1 on elohmeier:main
into 67ecad2 on redhat-developer:main.

@datho7561 datho7561 moved this to Pending review in Java Tooling Dec 1, 2025
@datho7561 datho7561 self-requested a review December 4, 2025 16:37
Copy link
Contributor

@datho7561 datho7561 left a comment

Choose a reason for hiding this comment

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

Very helpful as is, but I think it could be better.

}

doRename(document: TextDocument, params: RenameParams): WorkspaceEdit | null {
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently with this PR, it's possible to rename the anchor to a name that's invalid (for instance, add any of [, ], (, ), ,). For a list of what characters are valid for an anchor, here's what the specification says: https://yaml.org/spec/1.2.2/#rule-ns-anchor-char.

There's a way to reject these names. Are you interested in working on this? I think it's important to have, but it's a bit more work, and as it stands this PR is helpful as-is.

return null;
}

const normalizedNewName = this.normalizeName(params.newName);
Copy link
Contributor

Choose a reason for hiding this comment

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

This will remove the first * or & from the supplied new name. It seems (based on the spec) that anchors are allowed to contain them, even at the beginning. Given just the name and not the leading & or * is being replaced, is this necessary?

}
});

if (edits.length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should never happen, see line 58

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

Labels

None yet

Projects

Status: Pending review

Development

Successfully merging this pull request may close these issues.

3 participants