Commit Graph

3981 Commits

Author SHA1 Message Date
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
39c0afcff1 [Completion] Addd constructors from the completion cache back
31dee1ce1c refactored the completion
filter, accidentally dropping initializers when found from the cache.
Add these back in and also modify the existing test to load from the
cache as well.

Resolves rdar://107807707.
2023-04-09 09:34:51 -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
Ben Barham
8e6c9962d6 [AST] Do not copy SearchPathOptions in updateNonUserModule
`updateNonUserModule` was accidentally copying `SearchPathOptions`. Take
a reference to it instead. Also, since `addFile` is actually called many
times (once for every submodule, of which there are many), change
`isNonUserModule` to a request so that it's only calculated when needed.

Resolves rdar://107155587.
2023-03-24 17:05:57 -07:00
Alex Lorenz
c9beaf02e1 Merge pull request #64496 from hyp/eng/skip-inline-ns
[interop] do not print inline C++ namespaces when printing module int…
2023-03-21 11:11:46 -07:00
Alexis Laferrière
201c4b6205 Merge pull request #64486 from xymus/import-filter-refactor
[Sema] Intro common sets of import filters to simplify calls to `getImportedModules`
2023-03-21 11:10:50 -07:00
Alex Lorenz
259763c278 [interop] do not print inline C++ namespaces when printing module interface 2023-03-20 19:47:49 -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
6c5ac5179a Merge pull request #63490 from ahoppen/ahoppen/split-ideinspection
Split IDEInspectionCallbacks into CodeCompletionCallbacks and DoneParsingCallback
2023-03-20 09:20:30 -07:00
Alex Hoppen
e5c521c999 [CursorInfo] Fix issues found by the stress tester 2023-03-20 08:09:10 -07:00
Alex Hoppen
eb6729754d [IDE] Report ambiguous cursor info results 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
Slava Pestov
b6b51cf4cf AST: Checking of pack requirements 2023-03-17 22:18:55 -04:00
Slava Pestov
d27231a91c AST: Generalize Requirement::isSatisfied() to Requirement::checkRequirement() 2023-03-17 22:18:55 -04:00
Alexis Laferrière
205a2edf38 [Sema] Intro set of import filters for general use
Calling getImportedModules requires to list the desired kind of imports.
With the new kind of imports this has become cumbersome. Let's simplify
it by offering common sets of imports. Advanced call sites can still
list the desired imports explicitly.
2023-03-17 16:05:44 -07:00
Egor Zhdan
55a08bb2e5 Merge pull request #64453 from apple/egorzhdan/cxx-completion-unsafe
[cxx-interop] Do not auto-complete unsafe underscored methods, part 2
2023-03-17 22:05:39 +00:00
Egor Zhdan
9247d53082 [cxx-interop] Do not auto-complete unsafe underscored methods, part 2
Previous patch removed unsafe C++ methods from the module interface, but not from auto-completion results.

rdar://103252957
2023-03-17 18:04:22 +00: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
Ben Barham
eec2848508 [SourceKit] Stop using isSystemModule to represent "non-user" modules
Rather than using `ModuleDecl::isSystemModule()` to determine whether a
module is not a user module, instead check whether the module was
defined adjacent to the compiler or if it's part of the SDK.

If no SDK path was given, then `isSystemModule` is still used as a
fallback.

Resolves rdar://89253201.
2023-03-15 14:29:48 -07:00
Ben Barham
3e76a5edae [Refactoring] Allow expanding freestanding decl expansions 2023-03-09 10:11:11 -08: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
Ben Barham
4eb87bda74 Merge pull request #64197 from bnbarham/allow-at-or-pound
[CursorInfo] Handle @ and # position
2023-03-08 08:20:15 -08:00
Ben Barham
daa80bba4b [CursorInfo] Handle @ and # position
Allow clients to send the position of @ or #, rather than just the name.

Resolves rdar://106368511.
2023-03-07 18:00:15 -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
Hamish Knight
37b0a6074f [Sema] Introduce ExprPatternMatchRequest
This replaces `synthesizeTildeEqualsOperatorApplication`,
and synthesizes the match expression and var
on-demand.

Additionally, it pushes the lookup logic into
pre-checking.
2023-03-07 15:16:35 +00:00
Hamish Knight
54c2fbf6f3 [CS] NFC: Add Solution::getTargetFor 2023-03-07 15:16:34 +00:00
Hamish Knight
2976edbe20 [CS] Rename SolutionApplicationTarget -> SyntacticElementTarget 2023-03-06 20:54:06 +00:00
Doug Gregor
af3b41625f Make the interface type of a generic macro into a GenericFunctionType.
This correctly models their type in the type system, and fixes the
redeclaration issue reported in rdar://104183961.
2023-03-05 22:38:08 -08:00
Doug Gregor
7177a16c4c [Code completion] Provide attached macro names after @ 2023-03-04 21:42:36 -08:00
Doug Gregor
af6fe8b383 [Code completion] Don't include non-freestanding macros in results. 2023-03-03 21:39:38 -08:00
Alexis Laferrière
6980cf211b [Serialization] Intro package-only module wide information and serialize it 2023-03-03 11:43:20 -08:00
Alexis Laferrière
4330921806 [Sema] Remove ImportFilterKind::SPIAccessControl
That filter wasn't needed in practice, we can remove it.
2023-03-03 11:42:59 -08:00
Doug Gregor
b82a0f54cb Merge pull request #64052 from DougGregor/se-382-macro-decls 2023-03-03 06:22:16 -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
Ben Barham
bb7760b9e0 [Refactor] Allow expanding nested macros
This adds a new `primary_file` key, which defaults to `sourcefile`. For
nested expansions, `primary_file` should be set to the containing file
and `sourcefile` to the name of the macro expansion buffer.
2023-03-02 14:04:46 -08:00
Holly Borla
b78b6b9a77 Merge pull request #63991 from hborla/materialize-pack-from-tuple
[ConstraintSystem] Implement type checking for converting a tuple to a pack using the `.element` syntax.
2023-03-01 16:19:33 -08:00
Doug Gregor
bd35cdb865 Merge pull request #63985 from DougGregor/expression-macros-effects 2023-03-01 06:52:43 -08:00
Holly Borla
509188630b [ConstraintSystem] Implement type checking for converting a tuple to a
pack using the `.element` syntax.
2023-02-28 22:56:59 -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
47607f630c [IDE] Don't set LeaveClosureBodiesUnchecked for solver-based cursor info 2023-02-28 17:28:01 +01: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
Alex Hoppen
ababdcaa0d Merge pull request #63859 from ahoppen/ahoppen/typecontextinfo-solver-based
[IDE] Migrate TypeContextInfo to solver-based
2023-02-27 23:12:27 +01:00
Ben Barham
ba377d7fb4 Merge pull request #63765 from bnbarham/add-generated-name-to-expansions
[SourceKit] Add an optional path and name to refactoring edits
2023-02-23 09:15:58 -08:00
Alex Hoppen
39668a8ac8 [IDE] Migrate TypeContextInfo to solver-based 2023-02-23 14:14:09 +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
989b69fc1d [IDE] Add debug output if we use fallback type checking for code completion 2023-02-22 22:33:42 +01: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
Alex Hoppen
f4986f9b3e [CodeCompletion] Don't consider calls to initializers on metatypes in argument completion 2023-02-22 22:31:08 +01:00