Commit Graph

895 Commits

Author SHA1 Message Date
swift-ci
0ccd741ed2 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-18 12:37:37 -07:00
Hamish Knight
a976af09ba [IDE] Ignore unresolved types in WithSolutionSpecificVarTypesRAII
Make sure we don't try to set an UnresolvedType as a VarDecl interface
type in WithSolutionSpecificVarTypesRAII.
2025-09-17 23:00:27 +01:00
Anthony Latsis
e1450e011e Manually merge remote-tracking branch 'origin/main' into rebranch
Conflicts:
*	utils/build_swift/build_swift/defaults.py
2025-09-04 14:07:50 +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
swift-ci
69e3469a9f Merge remote-tracking branch 'origin/main' into rebranch 2025-08-31 03:55:05 -07: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
swift-ci
9a46a42e72 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-28 11:35:27 -07: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
Anthony Latsis
c1d794364b Adjust code after changes to llvm::TrailingObjects API
See:
- https://github.com/llvm/llvm-project/pull/138970
- https://github.com/llvm/llvm-project/pull/144930
2025-07-19 01:48:18 +01:00
Anthony Latsis
5620abbad8 Bridging: Bridge swift::CharSourceRange directly 2025-07-15 21:34:48 +01:00
Anthony Latsis
b803861257 Bridging: Rename USED_IN_CPP_SOURCE and define it in Basic/SwiftBridging.h 2025-07-10 17:58:13 +01:00
Alex Hoppen
021cdd4416 Merge pull request #81975 from ahoppen/sema-annotate-source-range 2025-06-05 13:49:54 +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
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
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
f0c38616d0 [Completion] Handle unbound generics in typealiases
The underlying type for a typealias can be an unbound generic type,
replace these with the bound generic equivalent. This avoids crashing
when attempting to compute the type relation (in the future we'll
want to open these type parameters for the comparison).

rdar://147789214
2025-04-01 20:11:48 +01:00
Ahmed Mahmoud
673d6a1d9f [IDE] Rename CustomSyntaxAttributeKind to ParameterizedDeclAttributeKind 2025-03-13 02:19:17 +02:00
Tony Allevato
d94bd80c62 Add support for raw identifiers.
Raw identifiers are backtick-delimited identifiers that can contain any
non-identifier character other than the backtick itself, CR, LF, or other
non-printable ASCII code units, and which are also not composed entirely
of operator characters.
2025-03-11 17:18:43 -04:00
Hamish Knight
be0f6f9491 [Completion] NFC: Factor out getMemberBaseType() 2025-02-25 14:49:12 +00:00
Xi Ge
87877bd95f ABI checker: avoid diagnosing missing availability info for decls that are only explicitly available on visionOS
Resolves: rdar://145061506
2025-02-18 09:56:42 -08:00
Becca Royal-Gordon
01b8bbea89 Tie attributes to language features
The new `DECL_ATTR_FEATURE_REQUIREMENT` macro in DeclAttr.def can be used to declare that an attribute should only be available when a related language feature is enabled.

Effects:

• `#if hasAttribute(someAttr)` will return `false` unless the required feature is enabled.
• Code completion will not include the attribute unless the required feature is enabled.
• `TypeChecker::checkDeclAttributes()` diagnoses non-implicit uses of the attribute.

Add this mechanism and use it to tie @abi to the ABIAttribute feature. Also design tests for it.
2024-12-19 15:49:34 -08:00
Hamish Knight
c19d049493 [Completion] Fix invertible type completion
The previous logic for this was unused, replace
it with new logic that consults
InvertibleProtocols.def for the list of protocols
to suggest.

rdar://139212286
2024-11-19 12:12:21 +00:00
Hamish Knight
9ca1157a07 Add cache for USRBasedTypeContext::typeRelation
This brings the time taken for the cached completion:

```
import SwiftUI

Table(#^CC^#
```

down from ~400ms to ~190ms.
2024-10-31 15:42:30 +00:00
Hamish Knight
1a62f36a3a Eliminate recursion from USRBasedType::typeRelation
Use a worklist instead, and bump the size of the
inline set storage. This shaves ~30ms off the
time it takes to do this cached completion:

```
import SwiftUI

Table(#^CC^#
```
2024-10-31 15:42:30 +00:00
Hamish Knight
b840730958 [IDE] Pass LangOptions to ide::isSourceInputComplete
Ensure we account for things like the enablement
of bare slash regex literals.
2024-10-17 14:04:34 +01:00
Doug Gregor
49aa0e966f Ensure that SourceFiles always have a backing buffer in the SourceManager
The "buffer ID" in a SourceFile, which is used to find the source file's
contents in the SourceManager, has always been optional. However, the
effectively every SourceFile actually does have a buffer ID, and the
vast majority of accesses to this information dereference the optional
without checking.

Update the handful of call sites that provided `nullopt` as the buffer
ID to provide a proper buffer instead. These were mostly unit tests
and testing programs, with a few places that passed a never-empty
optional through to the SourceFile constructor.

Then, remove optionality from the representation and accessors. It is
now the case that every SourceFile has a buffer ID, simplying a bunch
of code.
2024-09-16 21:46:42 -07:00
Doug Gregor
4c4a70f042 Remove unused shouldWalkInactiveConfigRegion 2024-09-16 16:30:57 -07:00
Hamish Knight
ec597c82fa [Completion] Only complete @unchecked et al in inheritance clauses
Add a case for completing type attributes in
inheritance clause position, and limit the
completion of `@unchecked`, `@preconcurrency`, and
`@retroactive` to that case.
2024-07-03 11:41:58 +01:00
Hamish Knight
0f30a1ab35 [Completion] Handle body macro attribute completion
Add support for function-attached macros, and
complete body and preamble macros in those
positions.

rdar://130740590
2024-07-02 09:44:32 +01:00
Hamish Knight
94ed2418f4 [Completion] Complete .isolation for @isolated(any) functions
This was added in SE-0431.

rdar://124615036
2024-07-01 12:49:52 +01:00
Hamish Knight
1f83e66a3e [Completion] NFC: Factor out addBuiltinMemberRef 2024-07-01 12:49:52 +01:00
Hamish Knight
b8b6395635 Merge pull request #74331 from hamishknight/keyword-completion
[Completion] Completions for `inout`, `borrowing`, `consuming`, `isolated`, `consume`, and `copy`
2024-06-18 21:00:54 +01:00
Alex Hoppen
f5d15f4f60 Merge pull request #74241 from ahoppen/enum-case-rename
Fix renaming enum case parameters with unnamed associated arguments
2024-06-12 14:46:46 -07:00
Hamish Knight
af0062725e [Completion] Complete ownership specifiers in parameters
Complete ownership specifiers such as `consuming`,
`borrowing`, and `inout` in parameter type
position. While here, also complete `isolated`.

rdar://127261573
2024-06-12 13:36:07 +01:00
Alex Hoppen
155773c38e Fix renaming enum case parameters with unnamed associated arguments
We treated enum case parameters the same way as function parameters and weren’t considering that they can be unlabeled. That caused us to insert eg. `_ ` in front of the case’s type, producing `case myCase(_ String)`, which is invalid. When we are inside an enum case parameter and the parameter label is empty, treat it the same as a function call, which will leave the label untouched if it isn’t modified and insert a label including a colon if a new label is introduced.

https://github.com/apple/sourcekit-lsp/issues/1228
2024-06-11 19:18:59 -07:00
Hamish Knight
30af99e47e [Completion] Better handle merging of lookup base types
For unresolved member completion, we were preferring
the more general type, when we ought to be preferring
the more specific type. Additionally, for both
unresolved member and postfix completion we were
opening archetypes, which doesn't work as expected
since we don't compare requirements. Factor out
the logic that deals with merging base types for
lookup, and have it prefer either the subtype, or
the optional type in the case of optional promotion.

rdar://126168123
2024-06-07 10:04:31 +01: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
39d633f5a8 [CodeCompletion] Remove unused 'isAsync' flag from CodeCompletionResult 2024-05-15 13:43:19 -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
Alex Hoppen
ef3e1c1d4f [SourceKit] Allow generation of cursor info for declarations from solutions that haven’t aren’t applied to the AST ye
This has two benefits:
1. We can now report ambiguous variable types
2. We are more robust in the generation of results for declarations inside closures. If the closure has an error, we won’t apply the solution to the AST and thus any cursor info that tried to get types out of the AST would fail.

rdar://123845208
2024-03-20 14:52:39 +01:00
Alex Hoppen
aa955655ab Merge pull request #72048 from Jamezzzb/#56350
#56350 - Give Identifier a hasUnderscoredNaming() helper
2024-03-04 20:13:01 -08:00
James Brown
2c281208de 56350 - Give Identifier a hasUnderscoredNaming() helper and in the places currently using str().startsWith, change it to use the new helper. 2024-03-04 19:34:11 -05:00
Alex Hoppen
63aeedecbd [SourceKit] Only report textual results inside comments and strings from syntactic rename ranges 2024-02-29 15:37:29 -08:00
Ben Barham
1306f2b32a Merge pull request #71863 from bnbarham/remove-makearrayref
Use the new template deduction guides rather than `makeArrayRef`
2024-02-25 21:06:51 -08:00
Alex Hoppen
873ed19786 [SourceKit] Add the raw doc comment to the cursor info response
SourceKit-LSP currently parses the XML comment to generate Markdown again but round-tripping a (probably markdown) doc comment to XML to Markdown is lossy in many cases and unnecessary work. Include the comment as it is spelled in source in the cursor info response so that sourcekit-lsp can display it.

Part of rdar://120685874
2024-02-24 08:41:08 -08:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00