Commit Graph

11 Commits

Author SHA1 Message Date
Doug Gregor
235242e8b3 [Diagnostics] Use the swift-syntax formatting for invalid source locations, too
The diagnostics formatter from swift-syntax previously only handled
fully-formed diagnostics anchored at a particular syntax node.
Therefore, the compiler would fall back to the existing LLVM-based
diagnostic formatter for diagnostics that had no source location.

Adopt new API in the swift-syntax diagnostics formatter that renders a
diagnostic message without requiring source location information, so
that we consistently use the swift-syntax formatter when it is
selected (which is the default).
2025-04-18 15:36:43 -07:00
Doug Gregor
e88f8995e1 [Diagnostics] Eliminate educational notes in favor of diagnostic groups
We've been converging the implementations of educational notes and
diagnostic groups, where both provide category information in
diagnostics (e.g., `[#StrictMemorySafety]`) and corresponding
short-form documentation files. The diagnostic group model is more
useful in a few ways:

* It provides warnings-as-errors control for warnings in the group
* It is easier to associate a diagnostic with a group with
GROUPED_ERROR/GROUPED_WARNING than it is to have a separate diagnostic
ID -> mapping.
* It is easier to see our progress on diagnostic-group coverage
* It provides an easy name to use for diagnostic purposes.

Collapse the educational-notes infrastructure into diagnostic groups,
migrating all of the existing educational notes into new groups.
Simplify the code paths that dealt with multiple educational notes to
have a single, possibly-missing "category documentation URL", which is
how we're treating this.
2025-03-29 15:40:35 -07:00
Doug Gregor
74fb36f9bc Translate Fix-Its from the C++ diagnostics into swift-syntax diagnostics
The swift-syntax diagnostic formatter doesn't actually print Fix-Its,
but at least they're available now.
2025-03-28 13:20:57 -07:00
Pavel Yaskevich
ac91d39a95 [DiagnosticBridge] NFC: Refactor addQueuedDiagnostic to use BridgedCharSourceRange for diagnostic highlights 2025-03-19 10:18:09 -07:00
Pavel Yaskevich
49f254f9f1 [DiagnosticBridge] NFC: Refactor addQueuedDiagnostic to use BridgedSourceLoc to diagnostic location 2025-03-19 09:54:41 -07:00
Pavel Yaskevich
2ee821164d [DiagnosticBridge] NFC: Refactor addQueuedDiagnostic to use BridgedStringRef instead of plain pointers 2025-03-19 09:54:36 -07:00
Doug Gregor
29b4f3ddbd [Diagnostics] Print category footnotes at the end of translation
When printing diagnostics, category names are printed as [#<category-name>]
at the end of a diagnostic. For all of the category names that are mentioned
in this manner, print "footnotes" at the end of compilation providing
documentation references to each category, e.g.,

    [#deprecated]: <http://example.com/deprecated>
    [#StrictMemorySafety]: <http://example.com/memory-safety>

Right now, these point into the markdown files in the installed toolchain,
same as the URLs behind references. That is subject to change in the future.
2025-03-09 14:36:51 -07:00
Pavel Yaskevich
8a0dc2b4a8 [DiagnosticBridge] Make sure that diagnostic queues up its child notes
`DiagnosticEngine` has an API that allows to attach notes to a "primary"
diagnostic (an error or a warning). This works well with old formatting
(`llvm`) but `swift` formatter doesn't display attached notes which makes
some diagnostics very hard to work with i.e. `invalid_redecl`.
2025-03-06 15:23:45 -08:00
Doug Gregor
6f6b8dd071 [Diagnostics] Provide category name + documentation path
Bridge the category name and educational note computed for the Swift
compiler's diagnostics to the newly-introduced category field for
the swift-syntax diagnostics. This lets the swift-syntax renderer
introduce the category name and (optionally) link to the
documentation.
2025-03-03 22:49:33 -08:00
Rintaro Ishizaki
e566a746c8 [ASTGen] Support macro expanded buffer
* Make ExportedSourceFile hold any Syntax as the root node
* Move `ExportedSourceFileRequest::evaluate()` to `ParseRequests.cpp`
* Pass  the decl context and `GeneatedSourceFileInfo::Kind` to
  `swift_ASTGen_parseSourceFile()` to customize the parsing
* Make `ExportedSourceFile` to hold an arbitrary Syntax node
* Move round-trip checking into `ExportedSourceFileRequest::evaluate()`
* Split `parseSourceFileViaASTGen` completely from C++ parsing logic
  (in `ParseSourceFileRequest::evaluate()`)
* Remove 'ParserDiagnostics' experimental feature: Now that we have
  ParserASTGen mode which includes the swift-syntax parser diagnostics.
2024-11-05 11:00:33 -08:00
Steven Wu
8ff3b05766 [NFC] Factor out DiagnosticBridge between swift-syntax
Refactor out the code that handles printing diagnostics from
swift-syntax.
2024-07-08 16:15:44 -07:00