-
Notifications
You must be signed in to change notification settings - Fork 322
buck2_error -> lsp diagnostics #1152
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
Open
cormacrelf
wants to merge
25
commits into
facebook:main
Choose a base branch
from
cormacrelf:buck2-error-lsp-diagnostics
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
1d26b23
Follow #{track_caller] to something that likely meant to use it
cormacrelf b7c3b48
Ignore target/ folder for OSS buck2 developers
cormacrelf d6b44d0
Document why not to use EvalMessage::from_any_error
cormacrelf 8e1e05d
Add note about unlikely wanted behaviour
cormacrelf 7f6e105
Always attach StarlarkContext
cormacrelf 2e497be
Store a real CallStack in StarlarkContext
cormacrelf ee8b40c
Add a missing enum value to match starlark_syntax::ErrorKind
cormacrelf 3676039
Document recover_crate_error
cormacrelf ccd8ebc
Rename error_with_starlark_context to inject_starlark_context
cormacrelf d4747e6
Fix a misplaced backtick
cormacrelf 824ebbd
Add buck2_error::Error::find_starlark_context for tests
cormacrelf 11cbcb4
Make StarlarkContext replace the root error, at format time
cormacrelf 1b0c4c7
Update out-of-date doc strings on buck2_error::ErrorKind
cormacrelf 5d7853c
impl Debug for ContextValue
cormacrelf c11eca4
Find relevant spans for lsp file in call stacks as well as directly a…
cormacrelf fb14575
Add show_span_in_buck_output flag on StarlarkContext
cormacrelf 77e2c47
Add a function to create_starlark_context
cormacrelf 4d88c85
Test for formatting starlark errors via buck
cormacrelf 6f03ee0
buck2_error::Error::into_lsp_diagnostic
cormacrelf 12bb357
Integrate buck2_error::Error::into_lsp_diagnostic with LSP
cormacrelf 30db68b
Add test_recover_starlark_span_through_context
cormacrelf 149ad42
Add starlark span to 'From load at BUCK:4'
cormacrelf 6b440bf
Add starlark span to invalid load errors
cormacrelf f44bb75
Add a test for create_starlark_context
cormacrelf 16d5bb0
Preserve error messages when we concatenate starlark call stacks
cormacrelf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -52,9 +52,14 @@ pub struct Error(pub(crate) Arc<ErrorKind>); | |||
| /// Right now, this type can represent an error root, together with a stack of context information. | ||||
| #[derive(allocative::Allocative)] | ||||
| pub(crate) enum ErrorKind { | ||||
| /// The originating error, before context is added | ||||
| Root(Box<ErrorRoot>), | ||||
| /// For now we use untyped context to maximize compatibility with anyhow. | ||||
| /// The output of [`e.context(...)`][Error::context]; recursively contains Error. | ||||
| /// There is eventually a [Self::Root] at the bottom. | ||||
| WithContext(ContextValue, Error), | ||||
| /// The output of [`e.mark_emitted()`][Error::mark_emitted]; recursively contains Error. | ||||
| /// There is eventually a [Self::Root] at the bottom. | ||||
| /// | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
| /// Indicates that the error has been emitted, ie shown to the user. | ||||
| // This `Arc` should ideally be a `Box`. However, that doesn't work right now because of the | ||||
| // implementation of `into_anyhow_for_format`. | ||||
|
|
@@ -262,6 +267,16 @@ impl Error { | |||
| }) | ||||
| } | ||||
|
|
||||
| /// Useful to check if StarlarkContext got injected properly | ||||
| #[cfg(test)] | ||||
| #[allow(unused)] | ||||
| pub(crate) fn find_starlark_context(&self) -> Option<&StarlarkContext> { | ||||
| self.iter_context().find_map(|kind| match kind { | ||||
| ContextValue::StarlarkError(sc) => Some(sc), | ||||
| _ => None, | ||||
| }) | ||||
| } | ||||
|
|
||||
| pub fn string_tags(&self) -> Vec<String> { | ||||
| let mut tags: Vec<String> = self | ||||
| .iter_context() | ||||
|
|
||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.