Commit Graph

24 Commits

Author SHA1 Message Date
Allan Shortlidge
9b7c531fd8 AST/IDE/Sema: Remove unnecessary AvailabilityInference.h includes.
NFC.
2025-10-24 16:14:49 -07:00
Anthony Latsis
77e673a723 DiagnosticEngine: Print the ID of the wrapped, not wrapper, diagnostic 2025-03-25 02:25:39 +00:00
Allan Shortlidge
0bf464b272 AST: Return optional AvailabilityRange from SemanticAvailableAttr queries.
Introduction, deprecation, and obsoleteion ranges should only be returned by
the accessors on `SemanticAvailableAttr` when the attribute actually has an
affect on the corresponding kind of availability.
2025-03-06 13:02:19 -08:00
Allan Shortlidge
437382507e IDE: Update diagnostics to take AvailabilityRange instead of VersionTuple. 2025-03-04 19:41:04 -08:00
Allan Shortlidge
c89df2fc38 AST/Sema: Adopt AvailabilityDomain arguments in more diagnostics.
Update explicit unavailability and deprecation diagnostics to take
`AvailabiiltyDomain` instead of a platform string.
2025-02-28 13:57:00 -08:00
Allan Shortlidge
9edd9eed9e AST: Finish adopting SemanticAvailableAttr in AvailabilityInference utilities. 2025-01-08 08:17:27 -08:00
Allan Shortlidge
51ae094a09 CodeCompletion: Adopt SemanticAvailableAttr. 2025-01-07 07:31:13 -08:00
Allan Shortlidge
d0f63a0753 AST: Split Availability.h into multiple headers.
Put AvailabilityRange into its own header with very few dependencies so that it
can be included freely in other headers that need to use it as a complete type.

NFC.
2025-01-03 18:36:04 -08:00
Allan Shortlidge
055a9ecd07 AST: Return a SemanticAvailableAttr from Decl::getDeprecatedAttr(). 2024-12-19 17:22:51 -08:00
Doug Gregor
867cf285ba Merge pull request #77928 from DmT021/wp/error-wrapped-in-warn
Add DiagGroupID to Diagnostic
2024-12-04 13:11:00 -08:00
Dmitrii Galimzianov
d56b7df8a9 Add DiagGroupID to Diagnostic
This change addresses the following issue: when an error is being wrapped in a warning, the diagnostic message will use the wrapper's `DiagGroupID` as the warning's name. However, we want to retain the original error's group for use. For example, in Swift 5, async_unavailable_decl is wrapped in error_in_future_swift_version. When we print a diagnostic of this kind, we want to keep the `DiagGroupID` of `async_unavailable_decl`, not that of `error_in_future_swift_version`.
To achieve this, we add `DiagGroupID` to the `Diagnostic` class. When an active diagnostic is wrapped in DiagnosticEngine, we retain the original `DiagGroupID`.

For illustration purposes, this change also introduces a new group: `DeclarationUnavailableFromAsynchronousContext`.

With this change, we produce errors and warnings of this kind with messages like the following:

```
global function 'fNoAsync' is unavailable from asynchronous contexts [DeclarationUnavailableFromAsynchronousContext]
global function 'fNoAsync' is unavailable from asynchronous contexts; this is an error in the Swift 6 language mode [DeclarationUnavailableFromAsynchronousContext]
```
2024-12-03 20:12:11 +01:00
Allan Shortlidge
c5398e17d3 AST: Introduce Decl::getDeprecatedAttr().
It replaces `DeclAttr::getDeprecated()` as the designated way to query for the
attribute that makes a decl deprecated.
2024-12-02 07:35:58 -08:00
Dmitrii Galimzianov
a8b71ea97f Add -print-diagnostic-groups flag
This change adds the `-print-diagnostic-groups` flag as described by SE-0443.
2024-09-11 13:34:42 +02:00
Rintaro Ishizaki
79a7410206 [CodeCompletion] Remove CrossActorReference diagnostics too
Same for 'async in non-concurrency' context
2024-05-15 15:10:03 -07:00
Rintaro Ishizaki
9a6770e770 [CodeCompletion] Remove warning for 'async in non-concurrency context'
This warnings don't give much benefits for developers. Code completion
UI tends to show them unusable. But usually, developers can modify the
context to accept async calls, e.g. by wrapping it with `Task { }`

rdar://126737530
2024-05-15 12:55:05 -07:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Becca Royal-Gordon
325ab9118e [NFC] Adopt new features in availability diagnostics
Allows the removal of a helper function.
2023-07-19 13:08:12 -07:00
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Alex Hoppen
daec367b46 [CodeCompletion] Don't recommend functions with async alternatives in async contexts
When an function has an async alternative, that should be preferred when we are completing in an async context. Thus, the sync method should be marked as not recommended if the current context can handle async methods.

rdar://88354910
2022-08-01 14:28:51 +02:00
Alex Hoppen
9fc850abed [CodeCompletion] Lazily compute contextual diagnostics 2022-07-21 14:19:48 +02:00
Alex Hoppen
fd72674a57 [Code Completion] Split code completion results into context free part that can be cached and contextual part displayed to the user
This allows makes the distinction between cachable and non-cachable properties cleaner and allows us to more easily compute contextual information (like type relations) for cached items later.
2022-01-27 10:40:47 +01:00
Alex Hoppen
bad96793f8 [Code Completion] Extract NotRecommendedReason and CodeCompletionResultKind to top-level types
Preliminary work to split `CodeCompletionResult` into a context-free and contextual part.
2022-01-20 16:26:30 +01:00
Rintaro Ishizaki
df2b9715ba [CodeCompletion] Add "soft deprected" diagnostics for code completion
'available(..., deprecated: <version>)'. If the version is larger than the
current active version, the declaration is "soft deprecated". Emit a
relevant diagnostics for those items. If the version is equal to or
larger than '100000.0', it means the distant future without specifying
the version.

rdar://76122625
2021-08-10 17:11:14 -07:00
Rintaro Ishizaki
ed1db1bed2 [CodeCompletion] Explain why results aren't recommended
* Implement 'getDiagnosticSeverity()' and 'getDiagnosticMessage()' on
  'CodeCompletionResult'
* Differentiate 'RedundantImportIndirect' from 'RedundantImport'
* Make non-Sendable check respects '-warn-concurrency'

rdar://76129658
2021-08-10 17:11:14 -07:00