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

Custom statement_range() LSP message #85

Merged
merged 3 commits into from
Sep 6, 2023

Conversation

DavisVaughan
Copy link
Contributor

@DavisVaughan DavisVaughan commented Sep 5, 2023

Joint with posit-dev/positron#1227 - see there for full details

goto_first_child_for_point() doesn't work as expected, see tree-sitter/tree-sitter#2012, so I'm using a Rust implementation of the patch they used in Emacs tree-sitter/tree-sitter#2012 (comment)

@DavisVaughan DavisVaughan marked this pull request as ready for review September 5, 2023 17:45
Comment on lines +52 to 53
#[macro_export]
macro_rules! backend_trace {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does it seem reasonable to do this? Is there anything else I need to do besides this tag?

Comment on lines +61 to +62
// TODO: Uncommenting this causes a compile error???
// backend_trace!(self, "statement_range(): No child associated with point.");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kevinushey I think we should talk about this and see if the backend_trace!() macro has a bug in it somehow

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems to work above; maybe the macro doesn't handle invocations lacking any arguments?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or perhaps it's because logging here requires a call to .await and that doesn't play nicely when you have treesitter nodes on the stack?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It has something to do with the latter. If i put the message before the creation of root then everything is fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2023-09-05 at 3 44 01 PM

The exact error is this horrible thing

Copy link
Contributor

Choose a reason for hiding this comment

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

That thing gives C++ template compilation errors a run for its money 💀

We could probably adjust the macro to either avoid the await, or spawn a separate execution context wherein it could be awaited safely and independently from the current call... not sure if you have any strong feelings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely no strong feelings

@DavisVaughan DavisVaughan changed the title Mostly working statement_range() implementation Custom statement_range() LSP message Sep 5, 2023
Copy link
Contributor

@kevinushey kevinushey left a comment

Choose a reason for hiding this comment

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

LGTM!

@DavisVaughan DavisVaughan merged commit 482e31a into main Sep 6, 2023
@DavisVaughan DavisVaughan deleted the feature/statement-range-provider branch September 6, 2023 13:56
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.

3 participants