Commit Graph

2158 Commits

Author SHA1 Message Date
Ahmed Elrefaey
9d1436c1c8 [IDE] [Signature Help] Add basic signature help request to SourceKit (#83378) 2025-09-04 10:09:02 +01:00
Ahmed Elrefaey
1bc96857a8 Merge pull request #82464 from a7medev/feat/full-documentation-in-code-completion
[IDE] Add full documentation to code completion result
2025-09-04 10:06:21 +01:00
Mishal Shah
c75932b89f Merge pull request #83748 from swiftlang/bump-version-6.3
Bump the Swift version to 6.3
2025-09-03 21:18:05 -07:00
Hamish Knight
0c3be92c10 Merge pull request #83652 from a7medev/feat/generalize-erase-archetypes
[IDE] Erase archetypes without declaration generic signature
2025-09-01 11:01:54 +01:00
Owen Voorhees
57062d85ae Merge pull request #84031 from owenv/owenv/sourcekit-remarks 2025-08-31 09:47:02 -07:00
Owen Voorhees
593346ab0d Include remarks in SourceKit diagnostics responses 2025-08-30 22:17:00 -07:00
Ahmed Mahmoud
491b3a0fbc [IDE] Erase archetypes with no declaration generic signature
This generalization enables curried functions with generic parameters coming from the initial declaration to be printed with the archetype's upperbound rather than '_' unresolved type.

As an added benefit, T.self and T.Type for generic parameters now get shown as the upperbound of the generic parameter provided
2025-08-29 13:39:58 +03:00
Hamish Knight
44ba366759 Merge pull request #83662 from hamishknight/unqualified-fallback
[Completion] Fall back to unqualified lookup on solver failure
2025-08-28 20:39:11 +01:00
Hamish Knight
7e22297b71 [AST] Walk ErrorExpr's original expr in ASTWalker
We set an original expression on ErrorExpr for cases where we have
something semantically invalid that doesn't fit into the AST, but is
still something that the user has explicitly written. For example
this is how we represent unresolved dots without member names (`x.`).
We still want to type-check the underlying expression though since
it can provide useful diagnostics and allows semantic functionality
such as completion and cursor info to work correctly.

rdar://130771574
2025-08-27 15:27:06 +01:00
Hamish Knight
a3edf17b24 [SourceKit] Fix assertion failure in sortTopN
With the unqualified fallback we start to hit this assertion for
`return nil` in failable intializers. We ought to be able to just
skip over literal buckets though.
2025-08-25 11:13:40 +01:00
Mishal Shah
63ef5a0cc7 Bump the Swift version to 6.3 2025-08-14 23:06:49 -07:00
Hamish Knight
e1e0f72288 [IDE] Avoid redundant worklist visitor
This is unnecessary since the local conformances for a protocol
can only contain self-conformances, which we don't want to visit
anyway. This can just be a straightforward loop over the local
conformances.
2025-08-13 21:19:07 +01:00
Erik Eckstein
e28125b106 stdlib: specialize OptionSet.insert for FixedWidthInteger raw-values
This lets the generated code boil down to a single or-instruction.

rdar://157958188
2025-08-12 08:05:49 +02:00
Hamish Knight
87f9820c85 [AST] Visit TypeValueExpr's TypeRepr in ASTWalker
Ensure that we walk the TypeRepr to ensure that both cursor info and
indexing pick up on the reference to the generic parameter.

rdar://145509737
2025-07-16 21:19:15 +01:00
Rintaro Ishizaki
dfacf99526 [Test] Fix test failure caused by invalid iOS version for availability
'20.0' is not a valid version number for iOS

rdar://155463166
2025-07-14 10:13:14 -07:00
Hamish Knight
4064ad19e6 Merge pull request #82966 from hamishknight/len-check
[Refactoring] Handle argument count mismatches in `renameLabelsLenient`
2025-07-11 10:09:56 +01:00
Hamish Knight
6a63f307aa [Refactoring] Handle argument count mismatches in renameLabelsLenient
Make sure we bail if we don't have enough labels in the old name when
matching against a found reference.

rdar://155549979
2025-07-10 21:33:42 +01:00
Hamish Knight
9e16906c53 [test] Add test case for raw identifier semantic tokens
rdar://152273926
2025-07-10 15:43:08 +01:00
Doug Gregor
5900c8a9e3 Update tests for Span back-deployment 2025-07-07 22:57:44 -07:00
Hamish Knight
55ef1bcaf0 [SourceKit] Print backticks if needed in printDisplayName
Ensure we print raw identifier names with backticks for e.g the
document structure request.

rdar://152524780
2025-06-25 15:15:17 +01:00
John Hui
44aba1382d [SourceKit] Support location info for macro-expanded Clang imports
Currently, when we jump-to-definition for decls that are macro-expanded
from Clang imported decls (e.g., safe overloads generated by
@_SwiftifyImport), setLocationInfo() emits a bongus location pointing to
a generated buffer, leading the IDE to try to jump to a file that does
not exist.

The root cause here is that setLocationInfo() calls getOriginalRange()
(earlier, getOriginalLocation()), which was not written to account for
such cases where a macro is generated from another generated buffer
whose kind is 'AttributeFromClang'.

This patch fixes setLocationInfo() with some refactoring:

-   getOriginalRange() is inlined into setLocationInfo(), so that the
    generated buffer-handling logic is localized to that function. This
    includes how it handles buffers generated for ReplacedFunctionBody.

-   getOriginalLocation() is used in a couple of other places that only
    care about macros expanded from the same buffer (so other generated
    buffers not not relevant). This "macro-chasing" logic is simplified
    and moved from ModuleDecl::getOriginalRange() to a free-standing
    function, getMacroUnexpandedRange() (there is no reason for it to be
    a method of ModuleDecl).

-   GeneratedSourceInfo now carries an extra ClangNode field, which is
    populated by getClangSwiftAttrSourceFile() when constructing
    a generated buffer for an 'AttributeFromClang'. This could probably
    be union'ed with one or more of the other fields in the future.

rdar://151020332
2025-06-12 18:22:06 -07:00
Anthony Latsis
d0b00504d8 Merge pull request #81426 from AnthonyLatsis/quercus-ilex
[test] Fix misspelled FileCheck directives
2025-05-30 17:54:28 +01:00
Anthony Latsis
0a1b8b0d50 [test] Fix misspelled FileCheck directives 2025-05-29 15:09:36 +01:00
Hamish Knight
f6c73cd178 [SourceKit] Properly handle cursor info range for macro expansions
Make `getOriginalLocation` work with source ranges, and adjust the
cursor info logic to map the range into the original buffer. This
fixes the case where we were using bogus range lengths for macro
expansion decls.

rdar://151411756
2025-05-28 18:51:40 +01:00
Henrik G. Olsson
0f312adb92 [Swiftify] Always annotate overloads with @_disfavoredOverload (#81579)
Previously we would only add @_disfavoredOverload if the only type
changed was the return type, because in any other case it is unambiguous
which overload to call. However it is still ambiguous when storing the
function as a value rather than calling the function, unless explicit
type annotations are used.

To avoid breaking any existing code, this patch adds
@_disfavoredOverload to every overload generated by @_SwiftifyImport.

rdar://151206394
2025-05-23 21:21:49 -07:00
Hamish Knight
7522a3ea5b [SourceKit] Handle CustomAttrs arguments for placeholder expansion
Introduce a new ASTWalker option for walking CustomAttrs and use it
for the placeholder scanner to ensure we can expand placeholders in
attribute arguments.
2025-05-21 18:06:54 +01:00
Hamish Knight
60952784fc [SourceKit] Handle macro arguments in placeholder expansion
Allow macro argument placeholders to expand into trailing closures.

rdar://150550747
2025-05-21 18:06:54 +01:00
Ben Barham
7e63d08300 Merge pull request #81582 from bnbarham/remove-sk-diag-path
[SourceKit] Remove diagnostics path calculation
2025-05-20 11:17:01 -07:00
Henrik G. Olsson
6534b9b14f [Swiftify] Copy doc comment from clang node (#81584)
Swift nodes imported from clang don't have doc comments carried over,
but IDEs are clever enough to fetch the comments from the associated
clang node. The swift node in the macro expansion from _SwiftifyImport
doesn't have a clang node directly associated with it however.

This patch adds the same comment from the clang node to the
_SwiftifyImport macro invocation node. Since the macro has access to
this node, it can easily copy over its leading trivia.

For now the comment is not altered at all, meaning @param still remains
even if the parmeter is removed.

rdar://151346977
2025-05-20 08:06:20 -07:00
Ben Barham
381684a389 [SourceKit] Remove diagnostics path calculation
The diagnostic group documentation now point to the swift.org URL rather
than the toolchain path, so it no longer needs to be passed all the way
through sourcekitd.

Resolves rdar://151500502.
2025-05-16 17:58:16 -07:00
Hamish Knight
6eb76dfd15 [Driver] Avoid using response files for SourceKit
We only care about the frontend arguments here, creating a response
file is unnecessary.

rdar://98880399
2025-05-16 15:35:15 +01:00
Hamish Knight
b53c411655 [Frontend] Avoid storing StringRef values in ModuleAliasMap
Previously we would insert StringRefs that reference the keys in the
map, but that breaks if the invocation ever gets copied. Switch to
`std::string`.

rdar://148130166
2025-05-09 19:49:50 +01:00
Ben Barham
0bf1c1f3e1 Merge pull request #80958 from bnbarham/merge-modules
Merge exported modules with the same public name in generated interface
2025-05-05 13:49:12 -07:00
Erik Eckstein
08ce2f00f2 embedded: avoid false error "Deinit of non-copyable type not visible in the current module" in SourceKit
As SourceKit explicitly disables WMO, silence the diagnostic in this case (but leave it enabled for explicit non-WMO builds otherwise).

rdar://150596807
2025-05-05 09:19:08 +02:00
Ben Barham
ddddc667c8 Merge exported modules with the same public name in generated interface
If a module has the same `public-module-name` as the module being
generated and its import is exported, merge it into the same generated
interface.

Fix various always-imported modules from being printed while here and
update all the tests that checked for them.

Resolves rdar://137887712.
2025-05-02 10:59:15 -07:00
Hamish Knight
54e0607091 [Sema] Add missing null check for Type
`getType` here can return a null type if the queried expression isn't
part of the solution, which can currently happen for code completion.
I'm working on a more principled fix for this, but until then this is
a low-risk fix that will unblock the stress tester and can be
cherry-picked to 6.2.

rdar://149759542
2025-04-23 12:58:28 +01:00
Doug Gregor
851950562d Update test 2025-04-14 23:44:16 -07:00
Egor Zhdan
119eeec9df [cxx-interop] Add a test for interface generation of a module requiring C++20
rdar://148840350
2025-04-11 15:09:30 +01:00
Hamish Knight
aaeb38d7f4 [Macros] Expand extension macros at the top-level
Ensure we always expand extension macros after the top-level decl
for the given attached decl. This ensures correct unqualified lookup
behavior, and bans macro implementations from extending the
unqualified name (they're expected to use `providingExtensionsOf`
instead, which uses the qualified name).

rdar://148119538
2025-03-28 21:35:59 +00:00
Rintaro Ishizaki
002d7d7cdf [Parse/AST] Remove PoundDiagnosticDecl
There is no reson to make a AST node for '#error' and '#warning'
directives. Parser knows the diagnostics should be emitted or not.
2025-03-07 21:48:01 -08:00
Hamish Knight
f524691cdf [IDE] Avoid inferring container type for implicit expressions
For e.g implicit `buildExpression` calls, we have a location that
matches the argument, but we don't want to consider the result
builder type as the container type.
2025-02-28 21:00:12 +00:00
Hamish Knight
b52d154be4 Merge pull request #78855 from hamishknight/elemental
[Mangler] Handle local archetypes in `getDeclTypeForMangling`
2025-02-27 18:19:32 +00:00
Hamish Knight
35f79e4c07 Merge pull request #79585 from hamishknight/leaps-and-bounds
[Completion] Remove uses of unbounded generic types
2025-02-27 12:38:51 +00:00
Allan Shortlidge
332d770a5c IDE: Stop requiring availability platforms to be classified as keywords. 2025-02-26 18:02:00 -08:00
Hamish Knight
994848f6e5 [Mangler] Handle local archetypes in getDeclTypeForMangling
Element archetypes can occur here when mangling the USR for local
variables for e.g SourceKit cursor info, as well as for regular
compilation for things like lazy variables.

Update `getDeclTypeForMangling` to map local archetypes out of
context, using both the captured generic environments and the
archetypes present in the type. More work is needed to support lazy
variable though (now it crashes in SILGen).

This patch doesn't handle mangling standalone element archetypes for
e.g `printTypeUSR`, ideally we'd fix the clients there to not pass
local archetypes.

rdar://143077965
2025-02-26 11:51:20 +00:00
Hamish Knight
0fc825b6fb [Completion] Remove uses of unbounded generic types
Ensure we always produce bounded generic type annotations and
contextual types.
2025-02-25 14:49:12 +00:00
Rintaro Ishizaki
635494df39 [Parse] Adjust assertions for ParsingFlags::PoundIfAllActive mode
In this mode, multiple #if clauses are active. For now, just use the
first clause as the result.
2025-02-06 12:07:04 -08:00
Rintaro Ishizaki
694e815f07 [Parser] Include all AST nodes from every #if region in ParserUnit
'ParserUnit' is used for analyzing syntax structures _mainly_ in
SourceKit.

Since we removed IfConfigDecl from AST, ParserUnit didn't
inclue any AST in #if ... #endif regions even for active region because
it used to consider all inactive. Instead, consider every region
"active" and include all the AST nodes.

rdar://117387631
2025-02-03 16:22:11 -08:00
QuietMisdreavus
ab26b8b9d7 add support to getTopLevelDecls for clang submodules (#76401)
rdar://126031510
2025-01-30 09:39:58 -07:00
Rintaro Ishizaki
37a2748e0d [ASTPrinter] Print SPI by default
`PrintOptions.InterfaceContentKind` was not initialized. Set it to
`InteraceMode::Private` by default, so SPI declarations and their `@_spi`
attribues are printed. This basically restores the behavior before
aba3b6c24e , and is align with
`AccessFilter` being `AccessLevel::Private` by default.

rdar://131726756
2025-01-22 21:37:54 -08:00