Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSP rename should collect non-LSP references before the rename and invoke handleElementRename() on them after successful rename #670

Closed
SCWells72 opened this issue Dec 6, 2024 · 4 comments
Assignees
Labels
bug Something isn't working rename
Milestone

Comments

@SCWells72
Copy link
Contributor

References can be added to LSP4IJ-managed files by non-LSP4IJ plugins, and those references need to know when a target has been renamed via LSP so they can be updated accordingly. I think all that's needed is to collect references to the pseudo-element that's being renamed before the LSP rename, and then on success, iterate through those references and invoke handleElementRename(newName) on each so that things are kept consistent.

@angelozerr
Copy link
Contributor

Have you a usecase which causes problem with rename?

@SCWells72
Copy link
Contributor Author

SCWells72 commented Dec 7, 2024

Have you a usecase which causes problem with rename?

Yes, absolutely. My own plugin adds references from HTML braced expressions to properties/methods of the associated JavaScript/TypeScript via a simple template binding syntax, e.g.,:

<record-edit-form
    record-id={recordId}
    onsubmit={handleSubmit}
    onerror={handleError}>
    ...
</record-edit-form>
export default class FormController {
    recordId: string;

    handleSubmit() {
        ...
    }


    handleError() {
        ...
    }
}

When, for example, recordId is renamed in the TypeScript file, all TypeScript/JavaScript references are properly updated, but the {recordId} reference in the HTML file is not resulting in an inconsistent state.

PsiReference#handleElementRename() exists explicitly to allow external references to respond to rename events accordingly. Those references just need to be included in the action since it's happening external to the IDE's own refactoring framework.

I'm happy to field this one if you'd like to assign it to me.

@angelozerr
Copy link
Contributor

I'm happy to field this one if you'd like to assign it to me.

Yes please. Thanks!

@angelozerr angelozerr added bug Something isn't working rename labels Dec 7, 2024
@SCWells72
Copy link
Contributor Author

See PR #674.

@angelozerr angelozerr added this to the 0.9.0 milestone Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rename
Projects
None yet
Development

No branches or pull requests

2 participants