Commit Graph

4019 Commits

Author SHA1 Message Date
Hamish Knight
d3be024a54 [IDE] Introduce ReadyForTypeCheckingCallback
This avoids the layering violation of calling `bindExtensions` from
parser code.
2025-09-09 23:18:52 +01:00
Hamish Knight
92f2acaa67 [IDE] Remove redundant extension binding logic
I missed this in my previous patch that moved extension binding until
after we've mutated the AST for IDE inspection, this ad-hoc extension
binding logic is no longer necessary.
2025-09-09 23:18:52 +01:00
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
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
Hamish Knight
d7fea157a1 [IDE] Remove fallback type-checking logic
This should no longer be necessary, rip it out.
2025-08-30 14:08:42 +01: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
4f010f0fc7 Merge pull request #83646 from a7medev/refactor/extract-code-completion-string-builder
[IDE] [Signature Help] Extract primitive `CodeCompletionString` creation into `CodeCompletionStringBuilder`
2025-08-28 19:35:21 +01:00
Hamish Knight
0eae70cd84 Merge pull request #83961 from hamishknight/null-and-void
[IDE] Use `nullableTypesEqual` in `AfterPoundExprCompletion::sawSolutionImpl`
2025-08-28 13:06:53 +01:00
Hamish Knight
4aeb7e1b52 [IDE] Use nullableTypesEqual in AfterPoundExprCompletion::sawSolutionImpl
Avoid crashing if we can't compute the expected type.
2025-08-28 00:33:54 +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
Ahmed Mahmoud
ec1b146581 [IDE] Move CodeCompletionString building into CodeCompletionStringBuilder
[IDE] Move primitive completion function label into CodeCompletionStringBuilder

[IDE] NFC: Remove unneeded string builder methods on CodeCompletionResultBuilder

[IDE] Move addValueBaseName into CodeCompletionStringBuilder

[IDE] Make CodeCompletionResultBuilder a CodeCompletionStringBuilder

[IDE] Explicitly pass DeclContext in CodeCompletionStringBuilder

[IDE] Reduce includes in CodeCompletionStringBuilder.h
2025-08-27 00:40:20 +03:00
Hamish Knight
a63ab6d161 [Completion] Fall back to unqualified lookup on solver failure
Even if the solver fails we can still do an unqualified lookup without
a contextual type.
2025-08-25 11:13:40 +01:00
Hamish Knight
6b2b28ae81 Merge pull request #83565 from hamishknight/synth
[IDE] Use LookUpConformanceInModule for synthesized extension requirement substitution
2025-08-14 14:23:30 +01:00
Hamish Knight
5e27e83456 Merge pull request #83613 from hamishknight/next-step
[IDE] Perform extension binding after AST mutation
2025-08-13 22:37:56 +01:00
Hamish Knight
d4f2e2ba10 [IDE] Use getProtocolSubstitutions in SynthesizedExtensionAnalyzer
Get the substitution map from the conformance rather than building it
from the base type.
2025-08-13 21:19:07 +01:00
Hamish Knight
da0525a6d2 [IDE] Avoid building redundant substitution map
We only care about the case where we're substituting into a protocol
extension, otherwise the substitution map is an identity map.
2025-08-13 21:19:07 +01: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
Hamish Knight
831ed310a6 [IDE] Sink SubstitutionMap computation into handleRequirements
And check `is-><ProtocolType>` instead of `isExistentialType`. Should
be NFC.
2025-08-13 21:19:07 +01:00
Hamish Knight
8ccd658d9e [IDE] NFC: Remove redundant use of getInnermostDeclContext
An extension decl is its own inner DeclContext.
2025-08-13 21:19:07 +01:00
Hamish Knight
02d2b4aa46 [IDE] Use LookUpConformanceInModule for synthesized extension requirement substitution
The extension may have requirements stating new conformance requirements
that aren't present in the underlying substitution map for the
conforming type.

rdar://152164768
2025-08-13 21:19:07 +01:00
Anthony Latsis
26de61d826 [cmake] APIDigester, IDE: Specify Clang link dependencies
This way, CMake will propagate the interface compile definitions of the
Clang dependencies, which is important on Windows because Clang
visibility macro expansions, controlled by compile definitions, must
match between the Swift and Clang library.

See https://github.com/llvm/llvm-project/pull/108276/files#diff-4dd645a8b76bb3886a505258a8c2e598aeddea770e7b0a2b51689124a5ea6e9a.
2025-08-12 18:13:22 +01:00
Hamish Knight
deecd46e43 [IDE] Remove extension binding logic from typeCheckContextAt
Now that we correctly bind extensions after mutating the AST, this
is no longer necessary.
2025-08-10 23:49:03 +01:00
Hamish Knight
acf6375d46 Introduce BindExtensionsForIDEInspectionRequest
This allows us to lazily bind extensions after mutating the AST,
ensuring we don't prematurely kick the building of lookup tables.
2025-08-10 23:49:03 +01:00
Anthony Latsis
fec049e5e4 Address llvm::PointerUnion::{is,get} deprecations
These were deprecated in
https://github.com/llvm/llvm-project/pull/122623.
2025-07-29 18:37:48 +01:00
Hamish Knight
62f1303bca [IDE] Fix assertion failure in PostfixCompletionCallback::Result::tryMerge
Unfortunately due to pre-checking multiple times the recorded
application level can change. Just OR the bits together.
2025-07-18 11:00:37 +01:00
Hamish Knight
f49b7604ae [IDE] Refactor isUnappliedFunctionRef
Switch to using `hasAppliedSelf` to match the constraint system, and
flip the check to more accurately describe what we're checking which
is really "is application fully applied"?
2025-07-18 10:59:22 +01:00
Anthony Latsis
5620abbad8 Bridging: Bridge swift::CharSourceRange directly 2025-07-15 21:34:48 +01:00
Anthony Latsis
6eb5d7d857 Bridging: Bridge swift::SourceLoc directly 2025-07-15 21:33:06 +01:00
Hamish Knight
e631a37d0b [Completion] Avoid using unbound contextual type in argument completion
Match the logic in `getTypeForCompletion` and avoid using an unbound
generic type as the expected type for a completion.

rdar://155420395
2025-07-09 12:57:36 +01:00
Pavel Yaskevich
dab6f3d12e Merge pull request #82807 from xedin/se-0487-implementation-adjustments
[AST/Sema] SE-0487: Adjust implementation based on the LSG feedback
2025-07-08 00:03:36 -07:00
Pavel Yaskevich
43eec8fede [AST/Sema] SE-0487: Expand @nonexhaustive attribute to support warn argument
The spelling `@nonexhaustive(warn)` replaces `@preEnumExtensibility`
attriubte.
2025-07-04 10:20:25 -07:00
Hamish Knight
e7bf62dd81 [Completion] Map failable initializer result type into context
Make sure we don't pass an interface type to `setTypeContext`.

rdar://155038769
2025-07-04 13:55:40 +01:00
John McCall
5c20b19296 Introduce non-recursive print options and use them to handle IUO
printing more elegantly.

NFC intended.
2025-06-18 11:47:36 +09:00
Allan Shortlidge
2a11d03830 IDE: Resolve unused variable warnings in SourceEntityWalker.cpp. 2025-06-11 09:53:48 -07:00
John McCall
b3493bfa23 Prevent PrintOptions from being implicitly copied.
NFC *except* that I noticed a bug by inspection where we suppress
`@escaping` when print enum element types. Since this affects
recursive positions, we end up suppressing `@escaping` in places
we shouldn't. This is unlikely to affect much real code, but should
still obviously be fixed.

The new design is a little sketchy in that we're using `const` to
prevent direct use (and allow initialization of `const &` parameters)
but still relying on modification of the actual object.  Essentially,
we are treating the `const`-ness of the reference as a promise to leave
the original value in the object after computation rather than a
guarantee of not modifying the object. This is okay --- a temporary
bound to a `const` reference is still a non-`const` object formally
and can be modified without invoking UB --- but makes me a little
uncomfortable.
2025-06-05 12:52:01 -04:00
Alex Hoppen
062aaaad53 Merge pull request #81981 from ahoppen/getexpandedattrs
[IDE] Use `getExpandedAttrs` instead of `getSemanticAttrs` to get custom attributes of a declaration
2025-06-05 14:32:56 +02:00
Alex Hoppen
021cdd4416 Merge pull request #81975 from ahoppen/sema-annotate-source-range 2025-06-05 13:49:54 +02:00
Alex Hoppen
0ad799d133 [IDE] Use getExpandedAttrs instead of getSemanticAttrs to get custom attributes of a declaration
`getSemanticAttrs` runs a couple queries that we don’t actually need to run to get all the custom attributes, such as getting the actor isolation of the declaration. Running these things can amount to 5%-7% of the index-while-building overhead. Just running `getExpandedAttrs` should be sufficient here.
2025-06-04 18:28:17 +02:00
Alex Hoppen
c6c40de73d [IDE] Pass a SourceRange instead of a CharSourceRange in SemaAnnotator::passReference
Most `SemaAnnotator`s don’t actually care about the char source range. Instead, they only care about the start location of the reference, which is also included in `SourceRange`. Computing a `CharSourceRange` from a `SourceRange` is kind of expensive because it needs to start a new lexer.

To avoid this overhead, pass `SourceRange` to `SemaAnnotator::passReference` and related functions and let the clients compute the `CharSourceRange` when needed.

This reduces the overhead of index-while-building by about 10%.
2025-06-04 18:01:47 +02:00
Pavel Yaskevich
21ec5924f7 [AST] NFC: Capitalize UsingSpecifier::nonisolated for consistency 2025-05-31 10:49:50 -07:00
Pavel Yaskevich
816ea9fda6 [CodeCompletion] Implement completions in using declaration's specifier position 2025-05-30 00:39:06 -07:00
Hamish Knight
52d8b36af4 [Completion] Suggest trivial trailing closures for macros
Follow the same logic as function decl completion and suggest a
trailing closure for trivial cases.

rdar://150550747
2025-05-22 11:16:10 +01:00
Hamish Knight
352caa4ddc [Completion] NFC: Factor out addMacroCallArguments 2025-05-21 18:06:54 +01:00
Pavel Yaskevich
04d46760bb [AST] Extend @_inheritActorContext attribute to support optional always modifier
By default (currently) the closure passed to a parameter with `@_inheritActorContext`
would only inherit isolation from `nonisolated`, global actor isolated or actor
context when "self" is captured by the closure. `always` changes this behavior to
always inherit actor isolation from context regardless of whether it's captured
or not.
2025-05-14 20:07:57 -07:00
Hamish Knight
839e20b8ca [Completion] Assert we have a type in getClosureActorIsolation
Previously we could end up in cases where we pick the wrong
DeclContext in `TypeCheckASTNodeAtLocRequest` since we previously
weren't checking source ranges, which could result in skipping the
type-checking of an outer closure. Now that we correctly pick the
DeclContext, we should no longer hit that case, so we should be able
to fall into `getTypeForCompletion` and assert that the solution has
a type. Also while here let's upgrade that assert to a
`CONDITIONAL_ASSERT`.
2025-05-14 11:15:42 +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
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
Egor Zhdan
b51cfa5c76 [cxx-interop] Remove symbolic import mode
Importing C++ class templates in symbolic mode has proven to be problematic in interaction with other compiler features, and it isn't used widely. This change removes the feature.

rdar://150528798
2025-05-02 18:43:09 +01:00