-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add GetSpanContents
engine call
#12439
Conversation
This allows plugins to view the source code of spans. Requested by @ayax79 for implementing `polars ls`.
.engine_state | ||
.get_span_contents(span) | ||
.to_vec() | ||
.into_spanned(self.call.head)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
into_spanned(self.call.head))
seems wrong to me, because we need to get content from given span
.
So I think this should be into_spanned(span)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I wasn't really sure which to choose... But if the value were going to be returned from the command, it would be better for it to be spanned from the command than from the span of the source code.
It doesn't matter so much for Rust because this span is actually not used in the API. I just didn't want to keep creating unspanned variants of EngineCallResponse
when there are perfectly usable Value
types.
Anyway, the reasoning is that the span refers to the source code, but the source code string originates from the command that produced it
While I see the need in the short term to get the existing command moved over to the plugin., I am a bit skeptical if "reflection-we-have-at-home" level introspection operations looking into the engine should be part of the plugin interface for stabilization. But we can refine that in the upcoming releases. |
I understand the reservation, but for the moment plugins have really no access to anything other than the spans that come from values. Would you rather see something that takes an entire value and just spits out some metadata about where it came from, including the source code information? This is already not perfect for |
I am fine with going ahead with this PR for now. Maybe we can come up with a list of metadata that a plugin is reasonably interested in about its custom values and provide the necessary interface for that. |
Let's move forward for now. Thanks! |
# Description This allows plugins to view the source code of spans. Requested by @ayax79 for implementing `polars ls`. Note that this won't really help you find the location of the span. I'm planning to add another engine call that will return information more similar to what shows up in the miette diagnostics, with filename / line number / some context, but I'll want to refactor some of the existing logic to make that happen, so it was easier to just do this first. I hope this is enough to at least have something somewhat useful show up for `polars ls`. # User-Facing Changes - Example plugin: added `example view span` command # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting - [ ] Add to plugin protocol reference
# Description This allows plugins to view the source code of spans. Requested by @ayax79 for implementing `polars ls`. Note that this won't really help you find the location of the span. I'm planning to add another engine call that will return information more similar to what shows up in the miette diagnostics, with filename / line number / some context, but I'll want to refactor some of the existing logic to make that happen, so it was easier to just do this first. I hope this is enough to at least have something somewhat useful show up for `polars ls`. # User-Facing Changes - Example plugin: added `example view span` command # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting - [ ] Add to plugin protocol reference
Description
This allows plugins to view the source code of spans.
Requested by @ayax79 for implementing
polars ls
. Note that this won't really help you find the location of the span. I'm planning to add another engine call that will return information more similar to what shows up in the miette diagnostics, with filename / line number / some context, but I'll want to refactor some of the existing logic to make that happen, so it was easier to just do this first. I hope this is enough to at least have something somewhat useful show up forpolars ls
.User-Facing Changes
example view span
commandTests + Formatting
toolkit fmt
toolkit clippy
toolkit test
toolkit test stdlib
After Submitting