Commit Graph

895 Commits

Author SHA1 Message Date
Alex Hoppen
a139962622 Merge pull request #65720 from ahoppen/ahoppen/complete-parameter-pack-arg
[CodeCompletion] Fix a crash when completing an argument to a function taking a parameter pack
2023-05-08 10:51:37 -07:00
Alex Hoppen
6d8b1f42c7 [CodeCompletion] Fix a crash when completing an argument to a function taking a parameter pack
We previously asserted that for a call the function type had the same number of parameters as the declaration. But that’s not true for parameter packs anymore because the parameter pack will be exploded in the function type to account for passing multiple arguments to the pack.

To fix this, use `ConcreteDeclRef` instead of a `ValueDecl`, which has a substitution map and is able to account for the exploded parameter packs when accessed using `getParameterAt`.

rdar://100066716
2023-05-05 15:18:57 -07:00
Alex Hoppen
c140fe480c [CodeCompletion] Only show type annotations for macros that return non-void
Showing the type annotation only makes sense if they are not `Void`. That’s consistent with functions where we also don’t show a `Void` return type. Most importantly, we shouldn’t be showing a `Void` type annotation for attached macros.

rdar://108870970
2023-05-04 18:02:26 -07:00
Alex Hoppen
e4a0b9e8c5 Merge pull request #65521 from ahoppen/ahoppen/name-suggestions
[CodeComplete] Offer completions for the `names:` argument of a macro declaration
2023-05-01 20:05:58 -07:00
Ben Barham
3368e710a2 Merge pull request #65515 from bnbarham/add-attached-type-relation
[Completion] Add convertible type relation for attached macros
2023-05-01 09:52:04 -07:00
Alex Hoppen
1e505791e4 [CodeComplete] Offer completions for the names: argument of a macro declaration
When completing after `names:`, completion should offer the different ways you can specify the names, i.e. `arbitrary`, `named`, etc.

```
@freestanding(declaration, names: #^COMPLETE^#)
```

rdar://108535077
2023-04-28 17:20:45 -07:00
Alex Hoppen
053d215d55 Merge pull request #65427 from ahoppen/ahoppen/macro-attribute-completions
[CodeCompletion] Support completion for macro roles and the 'names:' argument label
2023-04-28 17:20:24 -07:00
Ben Barham
f7d1cc8426 [Completion] Add convertible type relation for attached macros
Resolves rdar://108678938.
2023-04-28 16:15:51 -07:00
Alex Hoppen
6098a3ca2b [CodeCompletion] Support completion for macro roles and the 'names:' argument label
rdar://108163121
2023-04-27 21:48:06 -07:00
Alex Hoppen
cb6304c350 Merge pull request #65428 from ahoppen/ahoppen/macro-keyword-completions
[CodeCompletion] Suggest freestanding after @
2023-04-27 18:21:59 -07:00
Alex Hoppen
d5e97501fa [CodeCompletion] Suggest freestanding after @
rdar://108163121
2023-04-25 18:06:47 -07:00
Alex Hoppen
8abe38f9e2 [Rename] Also syntactically rename a macro’s definition
Previously we were skipping the macro’s definition (i.e. the part after `=` in a macro declaration if it wasn’t type checked. Since syntactic rename doesn’t type-check anything, it was thus skippin the macro definition. Add a flag to `ASTWalker` that allows `NameMatcher` to opt-out of this behavior.
2023-04-24 13:33:57 -07:00
Rintaro Ishizaki
20a8441724 [CodeCompletion] Don't take opaque types subst map into account
for checking duplicated results from multiple type checker solutions.
e.g.

  protocol Proto {}
  struct Generic<T> {
    func retProto() -> some Proto
  }
  func foo() -> Generic<T1>
  func foo() -> Generic<T2>

  foo().<COMPLETION>

The return type of `Geric<T1>.retProto()` and `Geric<T2>.retProto()` is
different, but they both spelled 'some Proto'. So IDE consumers don't
care the difference.

rdar://107669173
2023-04-13 16:38:10 -07:00
Ben Barham
31dee1ce1c [Completion] Only provide macro completions when they are valid
Only return macros that are valid in their current position, ie. an
attached macro is not valid on a nominal.

Also return freestanding expression macros in code block item position
and handle the new freestanding code item macros.

Resolves rdar://105563583.
2023-04-07 18:43:06 -07:00
Ellie Shin
7c75733137 Add package in code completion override lookup 2023-03-28 17:30:32 -07:00
Alex Hoppen
2108d01e46 Merge pull request #63613 from ahoppen/ahoppen/ambiguous-cursor-info-results
[IDE] Report ambiguous cursor info results
2023-03-20 13:07:09 -07:00
Alex Hoppen
e5c521c999 [CursorInfo] Fix issues found by the stress tester 2023-03-20 08:09:10 -07:00
Alex Hoppen
05b59d1462 [IDE] Support reporting multiple cursor results
This hooks up the cursor info infrastructure to be able to pass through multiple, ambiguous results. There are still minor issues that cause solver-based cursor info to not actually report the ambiguous results but those will be fixed in a follow-up PR.
2023-03-20 08:09:10 -07:00
Alex Hoppen
8a2cd86deb Split IDEInspectionCallbacks into CodeCompletionCallbacks and DoneParsingCallback
Cursor info only cares about the `doneParsing` callback and not about all the `complete` functions that are now defined in `CodeCompletionCallbacks`. To make the design clearer, split `IDEInspectionCallbacks`.

rdar://105120332
2023-03-17 10:31:13 -07:00
Alex Hoppen
788c9f6fbf Merge pull request #63857 from ahoppen/ahoppen/solution-specific-var-types
[IDE] Set solution-specific variable types as interface types
2023-03-08 08:30:55 -08:00
Alex Hoppen
614679f73d [IDE] Set solution-specific variable types as interface types
Setting the interface type of a variable, just to reset it to a null type is actually really gross. But quite a few methods further down in the generation of code completion results (such as USR generation) need to get a variable’s type and passing them along in a separate map would be really invasive. So this seems like the least bad solution to me.
2023-03-07 17:48:41 -08:00
Doug Gregor
7177a16c4c [Code completion] Provide attached macro names after @ 2023-03-04 21:42:36 -08:00
Doug Gregor
7fc7040aad [Macros] Drop special code completions for built-in macros.
We don't need special completion logic for things like `#file` and
`#line` now that they are declared in the standard library. Drop it
and update tests.
2023-03-02 20:34:58 -08:00
Doug Gregor
7a1c558899 Add more missing ASTWalker macro behavior entries 2023-02-28 19:13:02 -08:00
Doug Gregor
200f2340d9 [Macros] Be deliberate about walking macro arguments vs. expansions
Provide ASTWalker with a customization point to specify whether to
check macro arguments (which are type checked but never emitted), the
macro expansion (which is the result of applying the macro and is
actually emitted into the source), or both. Provide answers for the
~115 different ASTWalker visitors throughout the code base.

Fixes rdar://104042945, which concerns checking of effects in
macro arguments---which we shouldn't do.
2023-02-28 17:48:23 -08:00
Alex Hoppen
0ed6deea9b Merge pull request #63712 from ahoppen/ahoppen/completion-misc
[CodeCompletion] Collection of minor changes to prepare migrating remaining completion kinds to solver-based
2023-02-28 16:02:58 +01:00
Ben Barham
f7aaf02065 [SourceKit] Add an optional path and name to refactoring edits
Add two new fields to refactoring edits:
  - A file path if the edit corresponds to a buffer other than the
    original file
  - A buffer name when the edit is actually source of generated buffer

Macro expansions allow the former as a macro could expand to member
attributes, which may eg. add accessors to each member. The attribute
itself is inside the expansion, but the edit is to the member in the
original source.

The latter will later allow clients to send requests with these names to
allow semantic functionality inside synthesized buffers.
2023-02-22 16:24:02 -08:00
Alex Hoppen
470dcde915 [CodeCompletion] Don't show call pattern completions for overridden functions 2023-02-22 22:33:42 +01:00
Alex Hoppen
390d7a6882 [CodeCompletion] Compute type relations for the function calls selected by ArgumentCompletion 2023-02-22 22:33:40 +01:00
Pavel Yaskevich
6b5f4494d8 Merge pull request #63744 from L-j-h-c/fix-typo-globally
[Gardening] Fix typos across docs and codebase
2023-02-17 12:26:01 -08: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
L-j-h-c
913dcd62b8 [Gardening] fix typos across docs and codebase
fix typos across docs and codebase
2023-02-17 23:55:16 +09: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
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
9f4e1926b6 [CodeCompletion] Use type from solution to determine actor isolation 2023-02-14 09:40:56 +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
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
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
d4aa18ab9f [cxx-interop][index] emit symbolic interface files for C++ modules 2023-01-31 14:58:19 -08:00
Anthony Latsis
8f3d48f223 CodeCompletion: Complete member types with non-identifier qualifiers 2023-01-26 21:10:39 +03: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
Doug Gregor
76e0d5e726 [Macro] API digester support for macro declarations 2023-01-02 21:22:05 -08:00
Alex Hoppen
fe2ae72ad2 [IDE] Rename CodeCompletion to IDEInspection in cases where the code path no longer exclusively applies to code completion
The code completio infrastructure is also being used for cursor info now, so it should no longer be called code completion.

rdar://103251187
2022-12-13 11:41:05 +01:00
Alex Hoppen
a8dd6819b5 [IDE] Implement completion-like cursor info for ValueDecls
This brings up the ability to compute cursor info results using the completion-like type checking paradigm, which an reuse ASTContexts and doesn’t need to type check the entire file.

For now, the new implementation only supports cursor info on `ValueDecl`s (not on references) because they were easiest to implement. More cursor info kinds are coming soon.

At the moment, we only run the new implementation in a verification mode: It is only invoked in assert toolchains and when run, we check that the results are equivalent to the old implementation. Once more cursor info kinds are implemented and if the SourceKit stress tester doesn’t find any verification issues, we can enable the new implementation, falling back to the old implementation if the new one didn’t produce any results.
2022-12-08 14:39:14 +01:00
Alex Hoppen
9481e86a38 [IDE] Make isDynamicRef take a getType function
This allows isDynamicRef to work with types from a constraint system solution
2022-12-05 23:52:05 +01:00
Alex Hoppen
1fb439382e [IDE] Move getSelectedOverloadInfo to be a function on Solution
We will need this for solver-based cursor info.
2022-12-05 23:52:04 +01:00
Alex Hoppen
8e857d55c3 Merge pull request #62292 from ahoppen/ahoppen/solver-based-cursor-info-prep
[SourceKit] Preparation for solver-based cursor info
2022-12-02 10:52:30 +01:00
Alex Hoppen
652686034c [IDE] Split ResolvedCursorInfo into subclasses
This way, each kind of `ResolvedCursorInfo` can define its own set of properties and it’s obvious which properties are used for which kind. Also switch to getters and setters because that makes it easier to search for usages of properties by looking at the call hierarchy of the getter / setter.
2022-12-01 12:11:39 +01:00