Commit Graph

3981 Commits

Author SHA1 Message Date
Alex Hoppen
90506909d3 Merge pull request #68603 from ahoppen/ahoppen/storage-attribute-completion
[CodeCompletion] Completion for `@storageRestrictions` attribute
2023-10-02 10:17:43 -07:00
Rintaro Ishizaki
8dbde04c61 Merge pull request #68408 from rintaro/fetch-content
[CMake] Replace early swift-syntax with FetchContent
2023-09-28 11:22:10 -07:00
Alex Hoppen
8550799eba [CodeCompletion] Call hasStorage instead of getImplInfo().hasStorage() to determine if a variable is stored
This uncovered a discrepancy between `getImplInfo().hasStorage()` and `hasStorage()`.
2023-09-27 11:19:21 -07:00
Alex Hoppen
ee85314e6f [CodeCompletion] Add completion for @storageRestrictions 2023-09-27 09:33:38 -07:00
Hamish Knight
c49d336b09 [IDE] Be a bit more explicit when matching locs for cursor info
Should be NFC, change the code to not rely on
`getLoc`, and instead explicitly match against
name locs where we can.
2023-09-22 21:13:54 +01:00
Rintaro Ishizaki
b0d323499d Merge pull request #67806 from rintaro/ide-completion-fakeannotation-rdar109062582
[CodeCompletion] Add fake type annotation to custom attributes
2023-09-19 15:05:33 -07:00
Alex Hoppen
a01feadcfa Merge pull request #68604 from ahoppen/ahoppen/split-try-solver-based
[CodeCompletion] Move implementation of solver-based completions to their own functions
2023-09-19 13:29:53 -07:00
Alex Hoppen
ebcdb6d008 [CodeCompletion] Suggest init as accessor
rdar://115500788
2023-09-18 17:35:54 -07:00
Alex Hoppen
927cf42ba6 [CodeCompletion] Move implementation of solver-based completions to their own functions
This has the benefit that in case of a code completion crash, we can see what kind of completion crashed without having to symbolicate the stack trace using LLDB.

It also made `trySolverCompletion` small enough that we can inline it into `doneParsing`, which makes debugging easier because you won’t accidentally step over the call to `trySolverCompletion`, which actually performs the completion.
2023-09-18 17:33:29 -07:00
Ben Barham
041691184c [CMake] Replace early swift-syntax with FetchContent
Use FetchContent to include swift-syntax directly in swift. This can be
thought of as an `add_subdirectory` for a directory outside the root.

The default build directory will be `_deps/swiftsyntax-subbuild/`, though
the modules and shared libraries will be built in `lib/swift/host` by
passing down `SWIFT_HOST_LIBRARIES_DEST_DIR` to avoid copying them as we
were doing previously.
2023-09-18 14:44:10 -07:00
Rintaro Ishizaki
fcaae5cc9b [CodeCompletion] Add fake type annotation to custom attributes
Macros and custom attribute types (i.e. `@resultBuilder`,
`@propertyWrapper`, and `@globalActor`) now have fake type
annotations. This would be useful to recognize which candidates are
actually usable in code completions after `@`.

rdar://109062582
2023-09-18 14:07:01 -07:00
Holly Borla
97f1e617fd [Concurrency] Replace ClosureActorIsolation with ActorIsolation throughout
the isolation query APIs.
2023-09-16 12:21:36 -07:00
Holly Borla
4b23564711 [Concurrency] Rename AbstractClosureExpr::getActorIsolation to
getClosureActorIsolation.

This is preparation for changing AbstractClosureExpr to store
ActorIsolation instead of ClosureActorIsolation, and convert to
ClosureActorIsolation when needed to allow incrementally updating
callers. This change is NFC.
2023-09-16 12:20:53 -07:00
Hamish Knight
febb019a86 Avoid storing a SourceManager on JSONFixitWriter
Switch to storing the necessary edit information
instead.
2023-09-15 18:27:49 +01:00
Holly Borla
e23e4c32f5 Merge pull request #68414 from hborla/nonisolated-init-hole
[Concurrency] Don't allow nonisolated initializers to introduce data races via superclass property observers.
2023-09-09 09:55:24 -07:00
Holly Borla
a6d078b820 [Concurrency] Use the 'nonisolated' terminology instead of 'independent'.
This commit is NFC; it's mostly renames.
2023-09-08 13:28:55 -07:00
Alex Hoppen
0e1cdb5d22 Merge pull request #68080 from ahoppen/ahoppen/delete-sanitize-expr
[CodeCompletion] Delete `SanitizeExpr`
2023-09-07 11:03:08 -07:00
Allan Shortlidge
5eebfc017a Merge pull request #68338 from tshortli/inherited-types-refactor
AST: Refactor representation of inherited types
2023-09-06 13:28:31 -07:00
Alex Hoppen
211171e89f [CodeCompletion] Delete ExprContextAnalyzer 2023-09-06 13:13:01 -07:00
Alex Hoppen
5aa725d5cc [CodeCompletion] Delete dead code 2023-09-06 13:13:01 -07:00
Alex Hoppen
acc6c10344 Merge pull request #68075 from ahoppen/ahoppen/labeled-trailing-closure-solver-based
[CodeCompletion] Migrate labeled trailing closure completions to solver-based
2023-09-06 13:10:56 -07:00
Allan Shortlidge
01ecd81950 AST: Introduce conveniences for inheritance clause source locations.
Replace the `front()` and `back()` accessors on `InheritedTypes` with dedicated
functions for accessing the start and end source locations of the inheritance
clause. NFC.
2023-09-06 10:41:57 -07:00
Allan Shortlidge
0dd8f4c492 AST: Introduce abstraction for extension/type decl inheritance clauses.
Wrap the `InheritedEntry` array available on both `ExtensionDecl` and
`TypeDecl` in a new `InheritedTypes` class. This class will provide shared
conveniences for working with inherited type clauses. NFC.
2023-09-06 10:41:57 -07:00
Hamish Knight
6ee44f09b4 Introduce then statements
These allow multi-statement `if`/`switch` expression
branches that can produce a value at the end by
saying `then <expr>`. This is gated behind
`-enable-experimental-feature ThenStatements`
pending evolution discussion.
2023-09-01 14:32:14 +01:00
Ben Barham
6894bd5d7b Merge pull request #68231 from bnbarham/fix-stack-use-after-free
[Completion] ~CCResultBuilder must be called after ~ExpectedTypeContext
2023-08-31 17:11:43 -07:00
Ben Barham
020f2b52b4 [Completion] ~ExpectedTypeContext must be called after ~CCResultBuilder
There's a subtle stack UAF here - `~CodeCompletionResultBuilder` would
be called *after* `~ExpectedTypeContext` as `ExpectedTypeContext` was
defined after `CodeCompletionResultBuilder`. Fix the order they're
created to prevent this.
2023-08-31 09:09:42 -07:00
Hamish Knight
7270f094ba Merge pull request #68210 from hamishknight/for-the-sake-of-argument 2023-08-31 15:05:00 +01:00
Hamish Knight
f6664f0244 [IDE] Simplify ModelASTWalker argument walking
Use `walkToArgumentPre` instead of stashing and
looking up argument parents.
2023-08-30 15:41:52 +01:00
Alex Hoppen
48ce1b37b1 [CodeCompletion] Delete LabeledTrailingClosure completion kind 2023-08-24 15:51:57 -07:00
Alex Hoppen
a1bfb510e1 [CodeCompletion] Migrate labeled trailing closure completions to solver-based
rdar://113472967
2023-08-24 15:41:36 -07:00
Alex Hoppen
72cadecf21 [CodeCompletion] Split result delivery into a result colleciton and consumer phase
This will allow us to run two different completion kinds and deliver results from both of them.

Also: Compute a unified type context for global lookup. Previously, we always used the expected type context of the last lookup. But really, we should be considering all possible types from all constraint system solutions when computing code completion results from the cache.
2023-08-24 15:41:36 -07:00
Alex Hoppen
4702f82914 [CodeCompletion] Check getContextualType in getTypeForCompletion 2023-08-24 08:48:36 -07:00
Alex Hoppen
5d201131c1 [CodeCompletion] Migrate yield completions to solver-based
We didn’t actually have any tests for this. Completions aren’t great here at the moment but since this is an underscored language feature it’s not that important at the moment.
2023-08-23 13:07:56 -07:00
Alex Hoppen
3670b16754 [CodeCompletion] Migrate completion of ReturnStmtExpr to solver-based 2023-08-23 13:07:56 -07:00
Pavel Yaskevich
0ab131c452 [Mangling] NFC: Remove mangling logic and Ha postfix used by @runtimeMetadata records 2023-08-15 12:17:31 -07:00
Alex Hoppen
bba2f476ab Merge pull request #67613 from barinsim/my-main
[SourceKit] Report cursor info information for literals
2023-08-08 20:54:00 -07:00
Simon Barinka
9342e78e3e [SourceKit] Fix support for interpolated strings 2023-08-08 23:36:16 +02:00
Slava Pestov
9ebb5f2e03 AST: Rename VarDecl::getType() to VarDecl::getTypeInContext()
This is a futile attempt to discourage future use of getType() by
giving it a "scary" name.

We want people to use getInterfaceType() like with the other decl kinds.
2023-08-04 14:19:25 -04:00
Hamish Knight
c0e2d5ecbb Merge pull request #67015 from skrtks/sk-fix-incorrect-optional-types 2023-08-03 19:44:29 +01:00
Hamish Knight
a5d9b13ef0 [CodeComplete] Avoid let/var completions in a few cases
Don't suggest `let` or `var` in e.g the sequence
expression of a `for` loop, or after a `return`.
We ought to do a better job of checking whether
we're in expression position before suggesting
these (as opposed to a pattern), but I'm leaving
that as future work for now.
2023-08-03 14:17:54 +01:00
Hamish Knight
bd0aff4dcd [CodeComplete] Query the Solution for contextual type
Instead of querying the ConstraintSystem, query the
Solution instead, as the ConstraintSystem is not
necessarily in the same state as when the solution
was produced.
2023-08-01 15:21:29 +01:00
Simon Barinka
e32a20a55c [SourceKit] Report init info instead of the type decl info
Addresses PR review comments.
2023-08-01 12:51:39 +02:00
Simon Barinka
fcd084f9dd [SourceKit] Report cursor info information for literals
Adds literals support for the CursorInfo request.
Previously CursorInfo just returned error for literals.
Implements issue #57725
2023-07-30 14:22:08 +02:00
Alex Hoppen
862e14e084 [CursorInfo] De-duplicate reported cursor info results
The constraint system might produce multiple solutions that all reference the same declaration. We should only report the declaration once in those cases instead of multiple times.

rdar://111814276
2023-07-27 16:48:28 -07:00
Sam Kortekaas
c210a08afb [SourceKit] Don't report types for implicit expressions
Fixes incorrectly reporting an optional type for an expression when the contextual type is optional.

fixes #66882
rdar://111462279
2023-07-25 10:12:14 +02: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
Evan Wilde
83b044f5fb Migrating LLVM API usage on main
This patch migrates the compiler off of the deprecated LLVM APIs where I
can.

 - APInt::getAllOnesValue -> APInt::getAllOnes
 - APInt::getNullValue -> APInt::getZero
 - APInt::isNullValue -> APInt::isZero
 - APInt::getMinSignedBits -> APInt::getSignificantBits
 - clang::Module::submodule_{begin,end} -> clang::Module::submodules
2023-07-13 11:22:35 -07:00
Alex Hoppen
597c0dc90a [SourceKit] Fix crash when completing a parameter of an unapplied instance member reference 2023-07-07 21:16:59 +02:00
Alex Hoppen
f2017b82ac [IDE] Don't fallback type check if the completion expression is inside a closure 2023-07-07 19:51:01 +02:00
Alex Hoppen
71937667f2 [IDE] Don’t return any result if the base expression’s type in postfix completion couldn’t be inferred 2023-07-07 19:51:01 +02:00