Commit Graph

1541 Commits

Author SHA1 Message Date
Alex Lorenz
3b143d7d4e [interop][sourcekit] report a module error for any unconditional module loading failure
This ensures that interface gen reports an error when importing a framework Swift module
that also imports the underlying C++ module into Swift, when interop is disabled, so that
we can retry the interface gen with interop enabled.
2023-03-30 18:39:59 -07:00
Ben Barham
33727d7178 Merge pull request #64737 from bnbarham/skip-generated-buffers
[SourceKit] Return the original location for decls within generated code
2023-03-30 18:19:37 -07:00
Ben Barham
b9810fb0a3 [SourceKit] Return the original location for decls within generated code
Pass back the original location (ie. where the macro was expanded, not
the location that the generated code would be inserted) for cursor info
and indexing. Also mark any declarations/references within generated
source as implicit.

Resolves rdar://107209132.
2023-03-30 11:20:33 -07:00
Rintaro Ishizaki
c9172d14bd Merge pull request #64655 from rintaro/sourcekit-single-pluginregistry
[SourceKit] Use a single PluginRegistry in multiple ASTContexts
2023-03-29 12:36:00 -07:00
Ben Barham
1c97cd0424 Merge pull request #64663 from bnbarham/refactor-refactoring-collection
[SourceKit] Refactor collection of available refactorings
2023-03-29 09:17:10 -07:00
Ben Barham
a1c8280d0f [SourceKit] Refactor collection of available refactorings
Update to have a single refactoring collection method for cursor
refactorings and another for ranges. The various functions were only
needed because of the extra availability information on renames, so just
give that to all refactorings.
2023-03-28 13:05:35 -07:00
QuietMisdreavus
d9c8dca5d1 [SymbolGraphGen] allow SourceKit to print declarations for private stdlib symbols (#64556)
Resolves rdar://103112656
Resolves #62457
2023-03-28 10:30:36 -06:00
Rintaro Ishizaki
a4d1fc6abe [SourceKit] Use a single PluginRegistry in multiple ASTContexts
Make a single 'PluginRegistry' and share it between SwiftASTManager,
IDEInspectionInstance, and CompileInstance. And inject the plugin
registry to ASTContext right after 'CompilerInstance.setup()'

That way, all sema-capable ASTContext in SourceKit share a single
PluginRegistry.
2023-03-27 14:59:08 -07:00
Alex Lorenz
4e14288bba Merge pull request #64523 from hyp/eng/libcxx-module-int
[interop][sourcekit] print submodules of CxxStdlib when printing out …
2023-03-25 15:06:19 -07:00
Alex Lorenz
772909e229 [interop][sourcekit] print submodules of CxxStdlib when printing out IDE interface of it 2023-03-24 09:30:59 -07:00
Ben Barham
323745dc5e Merge pull request #64456 from bnbarham/nested-cursor
[SourceKit] Update requests to handle locations within generated buffers
2023-03-24 09:25:16 -07:00
Ben Barham
b2b5b196ac [SourceKit] Update requests to handle locations within generated buffers
Update requests to handle being passed a separate `key.primary_file`
which specifies the file to use for building the AST. `key.sourcefile`
is then the file to find in `SourceManager`, which could be a generated
buffer.

Resolves rdar://106863186.
2023-03-23 15:56:15 -07:00
Alex Hoppen
edfd3fde38 Merge pull request #64506 from ahoppen/ahoppen/no-begin-end-completions
[IDE] Remove "Begin completions" and "End completions" from test cases
2023-03-22 17:21:37 -07:00
Alex Hoppen
32eff21977 [IDE] Remove "Begin completions" and "End completions" from test cases
These test lines weren't actually providing any value and were annoying to write. Let's jut remove them.
2023-03-22 09:07:17 -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
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
Ben Barham
fd84ae98c2 Merge pull request #64367 from bnbarham/system-to-sdk
[SourceKit] Stop using `isSystemModule` to represent "non-user" modules
2023-03-17 10:15:04 -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
Alex Lorenz
37d242c3c2 Merge pull request #64372 from hyp/eng/igen-cxx
[interop] SourceKit should retry generating module interface with C++…
2023-03-14 20:03:17 -07:00
Alex Lorenz
72050c5385 [interop] SourceKit should retry generating module interface with C++ interop enabled
Sometimes the request might not have it enabled explicitly
2023-03-14 15:23:56 -07:00
Ben Barham
277674a642 Merge pull request #64298 from bnbarham/fix-shorthand-rename
[SourceKit] Merge local refactoring implementations
2023-03-14 10:36:44 -07:00
Ben Barham
d2de8ed83c [SourceKit] Merge local refactoring implementations
Retrieving local rename ranges and the local rename refactoring both had
almost identical methods, except for the addition of retrieving the
outermost shadowed decl that was added a couple months back. Merge them.

Resolves rdar://106529370.
2023-03-13 15:36:47 -07:00
Alex Lorenz
a8b33a3dee [interop][sourcekit] interface generator should show unavailable C++ declarations 2023-03-13 13:25:47 -07:00
Ben Barham
f3a6ce144c Merge pull request #63906 from bnbarham/add-nested-expansion
[Refactor] Allow expanding nested macros
2023-03-02 20:43:35 -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
Ellie Shin
7d23db3646 Create PackageUnit class, and Package entries to DeclContext / ASTHierarchy
Previously enum AccessLimitKind was
added to distinguish access scopes b/t package and public while keeping
DeclContext null but it proved to be too limiting. This PR creates package specific entries for DeclContext and
ASTHierarchy. It create a new class PackageUnit that can be set as the parent DeclContext of ModuleDecl. This PR
contains addition of such entries but not the use of them; the actual use of them will be in the upcoming PRs.

Resolves rdar://106155600
2023-03-02 13:20:51 -08:00
Louis D'hauwe
40573adfce Merge pull request #63816 from apple/louisd/sourcekit-inactive-ranges-request
[SourceKit] Add "Active Regions" request
2023-03-02 08:07:45 -08:00
Louis D'hauwe
876682fb12 [SourceKit] Add "Active Regions" request
`source.request.activeregions` is a new request that reports all
`#if`, `#else` and `#elseif` decls in the response with an `is_active` flag.
This is mainly useful for a client to know which branches are active,
but for completeness sake, the active decls are also reported.

Note: it only reports the positions of the decls, not the entire ranges.
It's up to clients to map this to the syntactic structure of a tree.
Reporting the ranges of the decls could be confusing in the case
of nested `#if`s, where the ranges can overlap.
2023-03-01 14:13:58 -08:00
Doug Gregor
bd35cdb865 Merge pull request #63985 from DougGregor/expression-macros-effects 2023-03-01 06:52:43 -08:00
Doug Gregor
8f42a5d111 [SourceKit] Don't report DocInfo requests from other buffers 2023-02-28 20:30:51 -08:00
Doug Gregor
7a1c558899 Add more missing ASTWalker macro behavior entries 2023-02-28 19:13:02 -08:00
Joe Groff
6c192018db Merge pull request #63073 from jckarter/se-0377-finalize
Changes to implement the final approved SE-0377 behavior
2023-02-28 18:38:33 -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
QuietMisdreavus
164e93e0a7 Merge pull request #63726 from apple/QuietMisdreavus/skip-proto-impls
[SymbolGraphGen] add new flag to skip "protocol implementation" symbols

rdar://59899968
2023-02-28 10:50:01 -07:00
Joe Groff
1311df6544 AST: Combine various ownership TypeReprs into one OwnershipTypeRepr.
This lets us consolidate code paths that mostly run in parallel over the
existing InOutTypeRepr/SharedTypeRepr/OwnedTypeRepr family of types. This
patch by itself is NFC but makes it easier to introduce new spellings,
particularly the newly-official `borrowing` and `consuming` modifiers
that were approved in SE-0377.
2023-02-28 09:15:43 -08:00
Rintaro Ishizaki
4190cb7978 Merge pull request #63793 from rintaro/macro-plugin-executable
[Macros] Add executable plugin support
2023-02-23 14:02:33 -08: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
Rintaro Ishizaki
0e31393024 [Macros] Add executable plugin support
Executable compiler plugins are programs invoked by the host compiler
and communicate with the host with IPC via standard IO (stdin/stdout.)
Each message is serialized in JSON, prefixed with a header which is a
64bit little-endian integer indicating the size of the message.

* Basic/ExecuteWithPipe: External program invocation. Lik
  llvm::sys::ExecuteNoWait() but establishing pipes to the child's
  stdin/stdout
* Basic/Sandbox: Sandboxed execution helper. Create command line
  arguments to be executed in sandbox environment (similar to SwiftPM's
  pluging sandbox)
* AST/PluginRepository: ASTContext independent plugin manager
* ASTGen/PluginHost: Communication with the plugin. Messages are
  serialized by ASTGen/LLVMJSON

rdar://101508815
2023-02-22 10:22:14 -08:00
Victoria Mitchell
7ed30c92af refactor: stop populating SymbolGraphOptions at creation 2023-02-17 11:19:38 -07: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
Doug Gregor
d8e5cd91b4 Merge pull request #63625 from DougGregor/sourcekit-related-id-checker
Teach the related-id checker to ignore things from other buffers
2023-02-13 12:57:05 -08:00
Doug Gregor
a712c37c05 Teach the related-id checker to ignore things from other buffers 2023-02-13 10:13:39 -08:00
swift-ci
e80f571e71 Merge pull request #63608 from DougGregor/sourcekit-no-crash-macro-locations
Don't annotate entities not in the primary buffer
2023-02-13 00:07:40 -08:00
Doug Gregor
b87dfdf2ae Don't annotatae entities not in the primary buffer 2023-02-12 21:42:36 -08:00
swift-ci
f5488c5351 Merge pull request #63601 from DougGregor/sourcekit-macro-buffer-loc
[SourceKit] Disable optimization that's now incorrect with macros.
2023-02-12 04:04:31 -08:00
Ben Barham
e15ea7ae4d Merge pull request #63403 from bnbarham/so-much-re-index
[Index] Prevent re-indexing system modules repeatedly
2023-02-11 22:40:47 -08:00
Doug Gregor
642d0e9d36 [SourceKit] Disable optimization that's now incorrect with macros.
No test case at the moment, but it's pretty crashy here in practice :)
2023-02-11 19:56:07 -08:00