Commit Graph

1606 Commits

Author SHA1 Message Date
Hamish Knight
4ce49bd4d2 [Parse] Sink registerParseRequestFunctions call into ParserUnit 2023-05-22 14:55:18 +01:00
Ben Barham
01086bc8b5 Merge pull request #65688 from bnbarham/swap-cursor-info-order
[CursorInfo] Prefer AST based results over solver based
2023-05-05 16:54:25 -07:00
Ben Barham
5beeca7cf1 [CursorInfo] Prefer AST based results over solver based
Solver based results are fast within a function, where the `ASTContext`
can be re-used. But it is significantly slower than the AST based
results when outside of a function. Instead of using solver based as the
primary results, only use them as a fallback for when AST based fails.

Resolves rdar://108930110.
2023-05-04 20:53:38 -07:00
Hamish Knight
62b021030f [SourceKit] Include generated macro buffers in diagnostic responses
Introduce a new key `generated_buffers`, which
stores an array of generated buffers. These
include the buffer text, as well as its original
location and any parent buffers.

While here, also fix rdar://107281079 such that
only apply the filename fallback logic to the
pretty-printed Decl case. We ought to remove this
fallback once the editor can handle it though.

rdar://107281079
rdar://107952288
2023-05-02 16:21:44 +01:00
Hamish Knight
f0d5456b33 NFC: Move some code around 2023-05-02 16:21:44 +01: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
Ben Barham
f7d1cc8426 [Completion] Add convertible type relation for attached macros
Resolves rdar://108678938.
2023-04-28 16:15:51 -07:00
Hamish Knight
b8ae0666ad Rename getBriefComment -> getSemanticBriefComment
Make it clear that we will walk the comment providing
decls if needed.
2023-04-26 12:38:38 +01:00
Rintaro Ishizaki
a551c01d6a [Macros] Track plugin dependencies
* Factor out ASTContext plugin loading to newly introduced 'PluginLoader'
* Insert 'DependencyTracker' to 'PluginLoader'
* Add dependencies right before loading the plugins

rdar://104938481
2023-04-25 10:50:32 -07:00
Alex Hoppen
aef35b917e [SourceKit] Expand editor placeholder to trailing closures inside a TryExpr
rdar://108391690
2023-04-21 17:21:50 -07:00
Rintaro Ishizaki
3517db4c3b [SourceKit] Pass 'swiftc' path to Driver when creating frontend args
Driver uses its path to derive the plugin paths (i.e.
'lib/swift/host/plugins' et al.) Previously it was a constant string
'swiftc' that caused SourceKit failed to find dylib plugins in the
toolchain. Since 'SwiftLangSupport' knows the swift-frontend path,
use it, but replacing the filename with 'swiftc', to derive the plugin
paths.

rdar://107849796
2023-04-12 09:53:43 -07:00
Ben Barham
e5dbe300e4 Merge pull request #64986 from bnbarham/macro-completion
[Completion] Only provide macro completions when they are valid
2023-04-08 11:08:42 -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
Alex Lorenz
00181138fd [interop] support 'default' mode for '-cxx-interoperability-mode' option
Default corresponds to the Swift language version used to compile the input. Swift-5.9 is still supported for now, but will be removed shortly
2023-04-04 15:35:48 -07:00
Alex Lorenz
932519145e Merge pull request #64776 from hyp/eng/uncond-fail-det
[interop][sourcekit] report a module error for any unconditional module loading failure
2023-03-31 10:33:13 -07:00
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