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

[SR-15280] Remove DiagnosticsEngine and report diagnostics via a callback closure #394

Open
ahoppen opened this issue Oct 4, 2021 · 3 comments
Labels
bug

Comments

@ahoppen
Copy link
Collaborator

@ahoppen ahoppen commented Oct 4, 2021

Previous ID SR-15280
Radar rdar://83850489
Original Reporter @ahoppen
Type Bug
Additional Detail from JIRA
Votes 0
Component/s SwiftSyntax
Labels Bug
Assignee None
Priority Medium

md5: 5671cec3472131d2317036b28cf2d9f7

Issue Description:

As discussed here (apple/swift-format#268 (comment)

maybe the whole concept of a diagnostic engine/consumers shouldn't live in SwiftSyntax/SwiftSyntaxParser at all? If the parser is the only user of it, it could just take a callback function instead of a diagnostic engine reference, and pass its own lightweight Diagnostic value containing information relevant to a parse issue. Then, clients of SwiftSyntaxParser would translate those into whatever diagnostic engine they wanted to use (for example, swift-format could start using TSC instead).

@akyrtzi
Copy link
Member

@akyrtzi akyrtzi commented Oct 4, 2021

AFAICT \cc @allevato's suggestion is to remove 'DiagnosticsEngine' entirely, creating another module just for that type seems overkill.

@allevato
Copy link
Collaborator

@allevato allevato commented Oct 4, 2021

Right, AFAICT all SwiftSyntaxParser needs to be able to do is communicate the location, severity, and description of the diagnostics back to the caller; it doesn't need to worry about providing capabilities like JSON serialization or even printing them. So the reporting can be done with a lightweight Diagnostic value that's specific to SwiftSyntaxParser, and modifying the parser APIs to take a diagnostic callback function instead of the engine. Then, the user would forward those to a specific diagnostic engine implementation or something else entirely.

@ahoppen
Copy link
Collaborator Author

@ahoppen ahoppen commented Oct 5, 2021

Ah, sorry. I misunderstood you. Thanks for clarifying.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug
Projects
None yet
Development

No branches or pull requests

4 participants