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: Simplify tests for renaming #7309

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

hunger
Copy link
Member

@hunger hunger commented Jan 9, 2025

Simplify the testing of the renaming and some more small patches that should be pretty uncontroversial.

let identifier = en.DeclaredIdentifier();
if identifier.text() == name {
result.push(identifier);
#[track_caller]
Copy link
Member

Choose a reason for hiding this comment

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

The function have many unwrap. It may be difficult to distinguish them if they are all reported at the location of the caller. But I guess this is not a problem in practice anyway as it is more important to know what fails rather than why

Copy link
Member Author

Choose a reason for hiding this comment

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

I found it more convenient this way: The test print the processed output and which file that was taken from already and it typically is pretty obvious what I mistyped with that visible :-)

let document = document_cache.get_document_by_path(document_path).unwrap();
let document = document.node.as_ref().unwrap();
let comment = document
.descendants_with_tokens()
Copy link
Member

Choose a reason for hiding this comment

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

What I'm usually doing in the other tests is to just call find() on the source string to get the offset, and then find the token from the offset

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeap, that makes sense :-) I'll change that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants