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

how can i read source_back when call with_source_code before #406

Open
hardfist opened this issue Sep 26, 2024 · 1 comment
Open

how can i read source_back when call with_source_code before #406

hardfist opened this issue Sep 26, 2024 · 1 comment
Labels
question Further information is requested

Comments

@hardfist
Copy link

it's sometimes useful to get source_code as string back if we need to convert miette report to other diagnostic info like vscode lsp format, but it seems impossible to get it back, so it seems we need to wrap our own diagnostic to save source_code, but I'm not sure it's a good practice

struct MyDiagnostic {
   inner: Arc<miette::Report>,
   source_code: Arc<src>
}
@zkat
Copy link
Owner

zkat commented Sep 26, 2024

You should be able to downcast any Report into a dyn Diagnostic, and then call .source_code() on it, to get the source code, if available.

@zkat zkat added the question Further information is requested label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants