Skip to content

Remove DiagnosticEngine #325

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

Merged
merged 1 commit into from
Oct 8, 2021

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Oct 6, 2021

Simplify SwiftSyntax by removing the DiagnosticEngine. Instead SyntaxParser just takes a lightweight callback to emit diagnostics.

rdar://83850489 [SR-15280]

@ahoppen ahoppen requested review from akyrtzi and allevato October 6, 2021 10:55
Simplify `SwiftSyntax` by removing the `DiagnosticEngine`. Instead `SyntaxParser` just takes a lightweight callback to emit diagnostics.

rdar://83850489 [SR-15280]
@ahoppen
Copy link
Member Author

ahoppen commented Oct 6, 2021

swiftlang/swift-stress-tester#166

@swift-ci Please test

@swiftlang swiftlang deleted a comment from swift-ci Oct 6, 2021
@swiftlang swiftlang deleted a comment from swift-ci Oct 6, 2021
@ahoppen
Copy link
Member Author

ahoppen commented Oct 6, 2021

Looks like CI didn’t pick up the stress tester PR. Let’s try again

swiftlang/swift-stress-tester#166

@swift-ci Please test macOS

Copy link
Member

@allevato allevato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@ahoppen ahoppen merged commit b8e4a69 into swiftlang:main Oct 8, 2021
@ahoppen ahoppen deleted the pr/remove-diagnosticengine branch October 8, 2021 08:36
allevato added a commit to allevato/swift-format that referenced this pull request Nov 4, 2021
This change addresses swiftlang/swift-syntax#309
and swiftlang/swift-syntax#325, which split
`SwiftSyntaxParser` into its own module and then removed the
`DiagnosticEngine` APIs (so only the `Diagnostic` type remains as
the way diagnostics from the parser are sent back to the caller).

Rather than remain coupled to swift-syntax's `Diagnostic` type,
this change creates a similar `Finding` type (and related types)
to describe the "lint findings" that tree-based rules, the
pretty-printer, and the whitespace linter encounter during
formatting/linting.

This `Finding` type is the currency type for these kinds of
findings/diagnostics emitted by the formatter API layer. The
`swift-format` frontend tool now adopts `DiagnosticsEngine` from
https://github.com/apple/swift-tools-support-core to manage and
print these, but other clients using the API could use something
different entirely. Since the usage of `TSC` is limited to the
executable, API users don't have to take on a large and mostly
unrelated dependency.

There are still some opportunities for renaming here --
mainly replacing instances of `diagnose` in the internal code
with `emitFinding` or something similar -- but I'll leave that
as future cleanup.
dylansturg pushed a commit to dylansturg/swift-format that referenced this pull request Apr 16, 2022
This change addresses swiftlang/swift-syntax#309
and swiftlang/swift-syntax#325, which split
`SwiftSyntaxParser` into its own module and then removed the
`DiagnosticEngine` APIs (so only the `Diagnostic` type remains as
the way diagnostics from the parser are sent back to the caller).

Rather than remain coupled to swift-syntax's `Diagnostic` type,
this change creates a similar `Finding` type (and related types)
to describe the "lint findings" that tree-based rules, the
pretty-printer, and the whitespace linter encounter during
formatting/linting.

This `Finding` type is the currency type for these kinds of
findings/diagnostics emitted by the formatter API layer. The
`swift-format` frontend tool now adopts `DiagnosticsEngine` from
https://github.com/apple/swift-tools-support-core to manage and
print these, but other clients using the API could use something
different entirely. Since the usage of `TSC` is limited to the
executable, API users don't have to take on a large and mostly
unrelated dependency.

There are still some opportunities for renaming here --
mainly replacing instances of `diagnose` in the internal code
with `emitFinding` or something similar -- but I'll leave that
as future cleanup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants