Commit Graph

3981 Commits

Author SHA1 Message Date
Alex Hoppen
062eccbbbb [CodeCompletion] Hide underscored code completion results in argument completion 2023-02-22 22:31:08 +01:00
Alex Hoppen
24f64b8aea Merge pull request #63752 from ahoppen/ahoppen/property-wrapper-relationship
[IDE] Compute type relations for attributes for generic property wrapper types
2023-02-21 08:21:52 +01:00
Alex Hoppen
61e8882568 [IDE] Compute type relations for attributes for generic property wrapper types
The existing logic to check whether a type is a valid property wrapper only worked for nominal types, not generic types. Also consider generic types.
2023-02-17 19:32:39 +01:00
Ben Barham
9e40280bda Merge pull request #63738 from bnbarham/macros-everywhere
[AST] Allow ignoring macro expansions
2023-02-17 10:18:56 -08:00
Alex Hoppen
16af937919 Merge pull request #63515 from ahoppen/ahoppen/look-through-optional
[CodeCompletion] Look through optional when determining the function type of a called overload
2023-02-17 17:24:19 +01:00
Ben Barham
0c3f538822 [AST] Allow ignoring macro expansions
Various requests expect to be walking over the current source file.
While we could add checks to all these to skip decls outside of the
current buffer, it's a little nicer to handle this during the walk
instead.

Allow ignoring nodes that are from macro expansions and add that flag to
the various walks that expect it.

Also add a new `getOriginalAttrs` that filters out attributes in
generated source.
2023-02-16 18:04:56 -08:00
Holly Borla
60ae1b1fdf Merge pull request #63703 from hborla/resolve-macro-decl-context
[Macros] Don't invoke `ResolveMacroRequest` for the same custom attribute with different `DeclContext`s.
2023-02-16 08:08:53 -08:00
Holly Borla
85f2a1a234 [Macros] Factor calls to ResolveMacroRequest into Decl::getResolvedMacro.
This prevents call-sites from making the mistake of passing an incorrect
DeclContext to the request, which can cause re-typechecking issues.
2023-02-15 18:52:02 -08:00
Holly Borla
f1953f311f [Macros] Don't invoke ResolveMacroRequest for the same custom attribute with
different DeclContexts.
2023-02-15 14:58:24 -08:00
Alex Hoppen
f210a8e25f Merge pull request #63612 from ahoppen/ahoppen/resolved-cursor-info-by-reference
[SourceKit] Pass `ResolvedCursorInfo` as shared pointer instead of by value
2023-02-15 22:44:04 +01:00
Holly Borla
c33c925e81 [Macros] Remove the macro role argument to ResolveMacroRequest.
The macro role argument presented an opportunity for callers to accidentally
invoke this request twice for the same macro with slightly different macro
roles passed in, which resulted in re-typechecking the macro arguments.
Instead, derive the corresponding macro roles from the macro reference syntax.
2023-02-14 22:38:53 -08:00
Alex Hoppen
ee26b4b299 [SourceKit] Pass ResolvedCursorInfo as shared pointer instead of by value
This allows us to model the `ResolvedCursorInfo` types as a proper type hierarchy instead of having to store all values in the base `ResolvedCursorInfo` type.

rdar://102853071
2023-02-14 22:40:45 +01:00
Alex Hoppen
754e9d7d54 [CodeCompletion] Fix issue when completing inside a switch in a closure 2023-02-14 09:40:56 +01:00
Alex Hoppen
ff7e11c83f [CodeComplete] Fix crash when completing in a string literal in a result builder 2023-02-14 09:40:56 +01:00
Alex Hoppen
9f4e1926b6 [CodeCompletion] Use type from solution to determine actor isolation 2023-02-14 09:40:56 +01:00
Alex Hoppen
26e237c4ae [CodeCompletion] Disallow void when code completion expr is a solution application target whose result is not unused
This happens if the code completion expression initializes a variable in a multi-statement closure that doesn’t have LeaveClosureBodiesUnchecked set.
2023-02-14 09:40:55 +01:00
Doug Gregor
96380624db [SourceKit] Implement macro expansion for (some) attached macros.
Extend the macro-expansion refactoring to work with member and
member-attribute attached macros. These expansions can return several
different changes, e.g., adding new members, sprinkling member
attributes around, and so on.
2023-02-11 11:23:28 -08:00
Alex Hoppen
fd039f4344 Merge pull request #62478 from ahoppen/ahoppen/solver-based-cursor-info
[CursorInfo] Implement a few expression references as solver-based
2023-02-10 16:49:37 +01:00
Doug Gregor
04eca73d60 [Macros] Stop parsing the ": <type>" syntax. We always require parameters 2023-02-09 22:11:23 -08:00
Alex Hoppen
a9cba5457c [CursorInfo] Fix a bug that caused solver-based cursor info to crash if invoked on a symbol from a different module 2023-02-09 23:29:07 +01:00
Alex Hoppen
e7ee839189 [CursorInfo] A few miscellaneous fixes to the AST-based cursor info and new test cases
In these cases the solver-based and AST-based cursor info differed in their results. Fix the AST-based cursor info to return the correct results and add test cases to make sure the solver-based implementation doesn’t regress them.
2023-02-09 23:29:07 +01:00
Alex Hoppen
5d986ecdc6 [CodeCompletion] Look through optional when determining the function type of a called overload
rdar://97339983
2023-02-08 17:30:02 +01:00
Alex Lorenz
1a763c0cbc Merge pull request #63336 from hyp/eng/emit-symbolic-interfaces
[interop] Emit symbolic interfaces while indexing
2023-02-07 20:24:36 -08:00
Alex Hoppen
6ee695a395 [CursorInfo] Implement a few expression references as solver-based
This implements cursor info resolving for a few expression types using the constraint system. This allows us to detect ambiguous results – we cannot deliver them yet but that will be done in a follow-up PR.
2023-02-07 10:42:00 +01:00
Alex Hoppen
a5f85ee10c [SourceKit] Make sure we reuse ASTContext in function bodies for solver-based cursor info
The main problem that prevented us from reusing the ASTContext was that we weren’t remapping the `LocToResolve` in the temporary buffer that only contains the re-parsed function back to the original buffer. Thus `NodeFinder` couldn’t find the node that we want to get cursor info for.

Getting AST reuse to work for top-level items is harder because it currently heavily relies on the `HasCodeCompletion` state being set on the parser result. I’ll try that in a follow-up PR.

rdar://103251263
2023-02-02 22:03:25 +01:00
Alex Hoppen
1ed94ff994 [SourceKit] Trigger generation of synthesized accessors in solver-based cursor info 2023-02-02 22:03:25 +01:00
Alex Hoppen
846a39d86b [IDE] Type check property wrappers so their USRs can be reported in cursor info 2023-02-02 22:03:25 +01:00
Alex Hoppen
e47aea448e [SourceKit] Disable completion-like cursor info for ParamDecls 2023-02-02 22:03:25 +01:00
John McCall
ea107ae025 Merge pull request #63324 from rjmccall/element-archetype-printing
Fix printing and implement parsing of opened element archetypes in SIL
2023-02-01 18:59:54 -05:00
John McCall
5dd6c4ee5f [NFC] Pass SIL-specific type resolution state abstractly into Sema
This is in preparation for parsing pack element archetypes.
2023-01-31 19:54:31 -05:00
Anthony Latsis
3302b27df8 Merge pull request #62775 from AnthonyLatsis/sugar-type-members-2
Parser: Support member types with non-identifier qualifiers
2023-02-01 02:07:12 +03:00
Alex Lorenz
a44a98bf64 [interop] clear importer decl when emitting symbolic interface
This ensures that our interface do not reference already instantiated and imported specializations.
2023-01-31 14:58:31 -08:00
Alex Lorenz
d4aa18ab9f [cxx-interop][index] emit symbolic interface files for C++ modules 2023-01-31 14:58:19 -08:00
Ben Barham
21f997c01a [IDE] Remove invalid assertions
The declaration and reference aren't necessarily the same type (eg. they
could be a function and a local). Thus they don't have to have the same
names, making the assertion invalid.

Resolves #63262.
2023-01-27 21:24:25 -08:00
Anthony Latsis
8f3d48f223 CodeCompletion: Complete member types with non-identifier qualifiers 2023-01-26 21:10:39 +03:00
Pavel Yaskevich
7e0f02ac40 Merge pull request #62724 from valeriyvan/Formatting
Add check against NULL before dereferencing pointer
2023-01-26 00:24:47 -08:00
Valeriy Van
c5493d8b5d Move assert to CaptureListExpr::CaptureListExpr as suggested in review 2023-01-25 15:40:36 +02:00
Ben Barham
4cc7167b60 [Index] Handle shorthand if let/closure captures in local rename
Update rename to pull the outermost-declaration so that references are correctly found.

Rather than keeping suppressed locations in the current parent, keep
them for the whole index. Local rename starts the lookup from the
innermost context it can, which could be a closure. In that case there
is no parent decl on the stack and thus no where to store the locations
to suppress. We could have a specific store for this case, but there
shouldn't be that many of these and they're relatively cheap to store
anyway.

Resolves rdar://104568539.
2023-01-24 11:10:38 -08:00
Alex Hoppen
edbee9eef7 Merge pull request #63126 from poya/bug/62802
[IDE] Fix crash in common root search in REPL code completion
2023-01-21 12:56:00 +01:00
Ben Barham
721e3e9bec Merge pull request #63127 from bnbarham/fix-shadowed-decls
[Index] Resolve any shadowed references to the decl they shadow
2023-01-20 23:13:20 -08:00
Ben Barham
7b4ab8d0e6 [Index] Resolve any shadowed references to the decl they shadow
Skip the shadowing decl and instead reference the top-most shadowed decl
(ie. follow any shadowed decls up the chain).

Also fix `getShorthandShadows` missing references in `MemberDeclRefExpr`
by using `getReferencedDecl` instead of assuming it is a `DeclRefExpr`.

Resolves rdar://99730146, rdar://100006415, and rdar://103449038.
2023-01-20 14:34:10 -08:00
Martin Svensson
fd5c56ee59 [IDE] Fix crash in common root search in REPL code completion
Specify end of second range to std::mismatch (since C++14) to avoid
accidentally stepping outside that range. In this case fixes a crash when
trying to find a common prefix with an empty StringRef.

Also add early return if no common root can be found.

Fix for "REPL crashes during autocompletion" #62802
2023-01-20 13:25:24 +09:00
Ellie Shin
37af51dc4c Merge branch 'main' into es-pkg-acl 2023-01-19 16:18:17 -08:00
Ellie Shin
1c66d02f92 Add package access level to enum AccessLevel
Resolves rdar://104198440
2023-01-19 15:54:18 -08:00
Holly Borla
3f462f0f43 [Decl] Add MissingDecl to use for parser recovery. 2023-01-15 09:55:15 -08:00
Anthony Latsis
1bb407ac8c [NFC] AST: Rename ComponentIdentTypeReprIdentTypeRepr 2023-01-07 07:15:36 +03:00
Anthony Latsis
ad5d55c36e [NFC] AST: Rename IdentTypeReprDeclRefTypeRepr 2023-01-07 07:14:44 +03:00
Anthony Latsis
746c7aff7d [NFC] AST: Rename CompoundIdentTypeReprMemberTypeRepr 2023-01-07 07:14:41 +03:00
Anthony Latsis
2113e175f5 [NFC] AST: Remove IdentTypeRepr::ComponentRange 2023-01-07 07:11:30 +03:00
Doug Gregor
db801afbe9 Handle null macro references in the semantic annotator 2023-01-04 10:56:57 -08:00