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

Emit serialized diagnostics in JSON #73423

Open
award999 opened this issue May 3, 2024 · 1 comment
Open

Emit serialized diagnostics in JSON #73423

award999 opened this issue May 3, 2024 · 1 comment
Labels
feature A feature request or implementation triage needed This issue needs more specific labels

Comments

@award999
Copy link

award999 commented May 3, 2024

Motivation

The vscode-swift extension has been parsing diagnostics from stdout. This is output as a flat list. Whereas when sourcekit-lsp sends diagnostics, it will provide nested diagnostics for related information, and suggest quick fixes. There is the serialized diagnostics emitted to -serialize-diagnostics-path, but this is written in bitstream format which would be harder to deserialize in JS/TS.

Proposed solution

It would be amazing if swift could emit a serialized JSON file that would be a lot easier for us the consume in typescript. Ideally (1) we know the nested structure of diagnostics and (2) it seems like tsc knows about the available fixits so would be great to have those

Alternatives considered

No response

Additional information

No response

@award999 award999 added feature A feature request or implementation triage needed This issue needs more specific labels labels May 3, 2024
@Pulkit1822
Copy link

@award999 ,to generate a JSON file from Swift diagnostics, I would first emit serialized diagnostics in JSON format from the Swift compiler to make it easier to consume in TypeScript, ideally containing the nested structure of diagnostics and information about available quick fixes; then use a library like swift-json-gen to generate JSON encoders and decoders based on Swift struct definitions, allowing me to parse JSON into immutable Swift structs and encode structs back to JSON; next, I would leverage the Diagnostics framework to easily share diagnostic information with users, supporting logging simple string messages, errors, and generating directory tree reports, while also providing custom insights based on the diagnostics; starting with iOS 15 and macOS 12, I would take advantage of the fact that apps that generate crash reports store the data as JSON in files with an .ips or .ips64 extension, which can be interpreted to diagnose problems; and finally, I would use the Codable protocol in Swift to load and decode specific kinds of data from JSON files, creating extensions on Bundle to load JSON files and decode them into Swift structs.
I would like to work on the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A feature request or implementation triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

2 participants