Commit Graph

2331 Commits

Author SHA1 Message Date
Doug Gregor
7478df009d [CMake] Ensure that the SourceKit framework links Swift as needed 2022-10-07 15:47:29 -07:00
Doug Gregor
4da85ea091 Clean up build logic for ASTGen library.
Only introduce it and its dependency when the new Swift parser is being
built, and rely more on existing logic to make sure we get the right
build/link flags.
2022-10-07 10:19:05 -07:00
zoecarver
73a7c0ecc6 Apply Doug's review comments
(cherry picked from commit ddede209c7)
2022-10-07 10:18:40 -07:00
zoecarver
80200ec23a Add Swift-side infrastructure for ASTGen.
(cherry picked from commit 7bc67c9f12)
2022-10-07 10:18:40 -07:00
Alex Hoppen
0ab44d577d Merge pull request #61246 from skrtks/SourceKit_qualified_types
[SourceKit] add qualified types in type requests
2022-10-04 12:30:59 +02:00
Sam Kortekaas
1bd0d9753e [SourceKit] Add option for returning fully qualified types in variable type request 2022-09-29 09:32:09 +02:00
Doug Gregor
962e330e9a [CMake with Swift] Add toolchain lib path for stage != 0 bootstrapping builds.
Fixes a linker failure where we cannot find the compatibility libraries.
2022-09-27 14:40:21 -07:00
Sam Kortekaas
0efc3ea745 [SourceKit] Add option for returning fully qualified types in expression type request 2022-09-27 14:13:10 +02:00
Alex Hoppen
53901f5a22 [Build] Ensure that we link in SwiftSyntax and Swift for SourceKit
This applies the changes from c50b142a14 to AddSwiftSourceKit.cmake.
2022-09-26 17:19:26 +02:00
Rintaro Ishizaki
7ab18ff8ce Merge pull request #42545 from jsoref/spelling-sourcekit
Spelling sourcekit
2022-09-22 16:26:17 -07:00
Josh Soref
436484c8c8 Gardening: Fix spelling mistakes in */SourceKit
* about
* and
* answering
* because
* before
* cancellation
* clear
* comment
* complete
* corresponding
* cursor
* custom
* dependencies
* doesn't
* expression
* extension
* immediately
* implementation
* implicit
* innovation
* intentionally
* occasionally
* oldest
* parameter
* property
* response
* reuseastcontext
* snapshot
* sourcekit_swift_runtime_link_flags
* synchronously
* target
* that
* unlabeled
* usefulness
* work

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-09-21 02:03:25 -04:00
Max Obermeier
453fd2231b Allow for emission of swift.extension symbols for extensions to external types in swiftSymbolGraphGen (#59047)
This includes:
 - bumping the SWIFT_SYMBOLGRAPH_FORMAT_MINOR version
 - introduction of the "swift.extension" symbol and "extensionTo" relationship
 - adding support for ExtensionDecl to the Symbol class
 - adding a "typeKind" field to the symbol's extension mixin which indicates what kind
   of symbol was extended
 - intoduction of the -emit-extension-block-symbols flag, which enables the behavior
   outlined below
 - adaptions to SymbolGraphASTWalker that ensure a swift.extension symbol is emitted
   for each extension to a type that does not exist in the local symbol graph
 - adaptions to SymbolGraph and SymbolGraphASTWalker that ensure member and conformance
   relationships are correctly associated with the swift.extension symbol instead of
   the original type declaration's (extended nominal's) symbol where applicable
 - adaptions to SymbolGraphASTWalker that ensure swift.extension symbols are connected
   to their respective extended nominal's symbol using an extensionTo relationship

Testing:
- adds SymbolGraph tests that test behavior only relevant in
  -emit-extension-block-symbols mode
- adapts some SymbolGraph tests to additionally test similar behavior for
  extensions to external types in -emit-extension-block-symbols mode
- adapts some SymbolGraph tests to (additionally or exclusively) test the
  behavior with -emit-extension-block-symbols mode enabled

Bugfixes:
- fixes a bug where some conformsTo relationships implicated by the conformances
  declared on an extension to an external type were not emitted
  (see test/SymbolGraph/Relationships/ConformsTo/Indirect.swift)

Further changes:
- documents the strategy for naming and associating children declared in extensions
  to typealiases (see test/SymbolGraph/Relationships/MemberOf/Typealias.swift,
  test/SymbolGraph/Symbols/Names.swift)
2022-09-16 12:02:40 -06:00
Hamish Knight
4716f61fba [AST] Introduce explicit actions for ASTWalker
Replace the use of bool and pointer returns for
`walkToXXXPre`/`walkToXXXPost`, and instead use
explicit actions such as `Action::Continue(E)`,
`Action::SkipChildren(E)`, and `Action::Stop()`.
There are also conditional variants, e.g
`Action::SkipChildrenIf`, `Action::VisitChildrenIf`,
and `Action::StopIf`.

There is still more work that can be done here, in
particular:

- SourceEntityWalker still needs to be migrated.
- Some uses of `return false` in pre-visitation
methods can likely now be replaced by
`Action::Stop`.
- We still use bool and pointer returns internally
within the ASTWalker traversal, which could likely
be improved.

But I'm leaving those as future work for now as
this patch is already large enough.
2022-09-13 10:35:29 +01:00
Robert Widmann
18b79ffcfd Resolve a Layering Violation in libBasic
Basic should not be allowed to link Parse, yet it was doing so
to allow Version to provide a constructor that would conveniently
parse a StringRef. This entrypoint also emitted diagnostics, so it
pulled in libAST.

Sink the version parser entrypoint down into Parse where it belongs
and point all the clients to the right place.
2022-09-09 00:21:30 -07:00
Doug Gregor
b247c6d9f3 Enable build of Swift Swift parser even when bootstrapping is OFF.
The Swift Swift parser doesn't require any bootstrapping, so allow it to
be built even when bootstrapping is off.
2022-09-07 17:52:21 -07:00
Ikko Ashimine
4458b4d382 [SourceKit] Fix typo in SwiftSourceDocInfo.cpp 2022-09-05 18:18:06 +09:00
Eric Miotto
b6878ce752 Link all compatibility libraries when cross compiling and bootstrapping (#60728)
Refactor the logic so to have a single target to reference the
compatibility libraries for the host, and use that when needed.

The main driver for this change is supporting the cross-compilation of
x86-64 on Apple Silicon.

Supports rdar://90307965
2022-08-31 02:18:19 -07:00
Alex Hoppen
c8a7e55f6a [SourceKit] Workaround a bug that parameterized protocols without 'any' cannot be mangled
`typealias` is currently allowed to refer to a protocol without the `any` keyword. This breaks mangling the typealias type into a USR will crash because parameterized protocols are expected to be `any` types.

Implement a SourceKit-specific minimal workaround for that problem by not computing USRs for parameterized protocols.

rdar://98623438
2022-08-26 19:08:06 +02:00
YOCKOW
d10381557b [NFC] Python Lint: Fix E275(missing whitespace after keyword) issues. 2022-08-21 16:07:07 +09:00
Alex Hoppen
e22e443596 [SourceKit] Re-enable cancellation of non-completion requests
This enables the ability to cancel requests, which aren’t code completion requests, again.

Previous crashes in SILGen are prevented by disabling cancellation during the SIL stages. Instead, we add dedicated cancellation checkpoints before and after SIL.

rdar://98390926
2022-08-16 16:02:23 +02:00
swift-ci
a760571edb Merge remote-tracking branch 'origin/main' into rebranch 2022-08-04 09:13:27 -07:00
Alex Hoppen
1e9eac6c64 [SourceKit] Don’t provide incorrect semantic highlighting of nil in case statements as enum decl element
If a 'nil' literal occurs in a swift-case statment, it gets replaced by a reference to 'Optional.none' in the AST. We want to continue highlighting 'nil' as a keyword and not as an enum element.

Resolves apple/sourcekit-lsp#599
rdar://97961865
2022-08-03 22:42:40 +02:00
swift-ci
06a98bfd8c Merge remote-tracking branch 'origin/main' into rebranch 2022-08-02 10:34:18 -07:00
Alex Hoppen
fa75cfba72 Merge pull request #60210 from ahoppen/pr/operator-syntax-kind
[SourceKit] Add an operator syntax kind
2022-08-02 19:33:36 +02:00
swift-ci
4696141e93 Merge remote-tracking branch 'origin/main' into rebranch 2022-08-01 23:34:05 -07:00
Alex Hoppen
daec367b46 [CodeCompletion] Don't recommend functions with async alternatives in async contexts
When an function has an async alternative, that should be preferred when we are completing in an async context. Thus, the sync method should be marked as not recommended if the current context can handle async methods.

rdar://88354910
2022-08-01 14:28:51 +02:00
swift-ci
7b04dceddc Merge remote-tracking branch 'origin/main' into rebranch 2022-08-01 01:34:04 -07:00
Alex Hoppen
a7dcd4604e [SourceKit] Add an operator syntax kind
This will allow us to do semantic highlighting for operators in SourceKit-LSP.
2022-07-25 07:19:49 +02:00
Alex Hoppen
1150e700a5 [CodeComplete] Store the compiler instace as a shared pointer in CompletionInstance 2022-07-21 18:29:34 +02:00
Alex Hoppen
dec32674ef [CodeCompletion] Compute InvalidAsyncContext warning when making a completion result contextual
Store whether a result is async in the `ContextFreeCodeCompletionResult` and determine whether an async method is used in a sync context when promoting the context free result to a contextual result.

rdar://78317170
2022-07-21 14:27:19 +02:00
Alex Hoppen
9fc850abed [CodeCompletion] Lazily compute contextual diagnostics 2022-07-21 14:19:48 +02:00
swift-ci
5cb01c1068 Merge remote-tracking branch 'origin/main' into rebranch 2022-06-13 10:33:38 -07:00
Michael Wyman
55b1444027 Fix assert triggering immediately in sourcekitd-repl.
PR #41550 changed from using `SmallVector::set_size` to `resize_for_overwrite` and `truncate`, but in `sourcekitd-repl` changing from `reserve` changed the size just prior to getting the `end()` of the output array, leading to retrieving the end of the resized array, rather than the array prior to resizing.

The conversion needs to begin at the original output's end, rather than the resized-to-reserve output size, otherwise the conversion triggers the asserts at lines 101 and 116 (with `res == targetExhausted`).
2022-05-19 17:17:09 -07:00
swift-ci
073f16a471 Merge remote-tracking branch 'origin/main' into rebranch 2022-05-19 00:33:46 -07:00
Alex Hoppen
025e919b84 Merge pull request #42258 from ahoppen/pr/no-deadlock-cancellation
[SourceKit] Resolve a nondeterministic deadlock in SourceKit while cancelling
2022-05-19 09:27:27 +02:00
swift-ci
f05ad9523d Merge remote-tracking branch 'origin/main' into rebranch 2022-05-13 23:54:07 -07:00
Alex Hoppen
727d3fec86 Merge pull request #58852 from ahoppen/pr/ubuntu-22-failure
[SourceKit] Pass the main swift executable path when constructing a compiler invocation
2022-05-14 08:36:35 +02:00
swift-ci
d8e8aaf3c5 Merge remote-tracking branch 'origin/main' into rebranch 2022-05-13 07:33:58 -07:00
Alex Hoppen
1843f22066 Merge pull request #58787 from ahoppen/pr/shorthand-closure-info
[CursorInfo] Report values shadowed using shorthand syntax as secondary results
2022-05-13 16:28:47 +02:00
Alex Hoppen
1525f6b982 [SourceKit] Pass the main swift executable path when constructing a compiler invocation
#58786 (rdar://93030932) was failing because the `swift-frontend` invocations passed a `swiftExecutablePath` to `Invocation.parseArgs`. This caused the `ClangImporter` instance to point to a `clang` binary next to the `swift-frontend` executable while SourceKit used PATH to find `clang`. The clang executable next to `swift-frontend` doesn’t actually exist because `clang` lives in `llvm-linux-aarch64/bin` and `swift-frontend` lives in `swift-linux-aarch64/bin`.
So some checks for a minimum clang verison failed for the normal build (because the executable doesn’t actually exists) while they pass during the SourceKit build (which used `clang` from `PATH`). This in turn caused the `outline-atomics` to be enabled to the SourceKit clang compiler arguments but not the clang compiler arguments for a normal build and thus resulted in two separate module cache directories (which includes the enabled features in the module directory hash).

To fix this issue, also set the swift executable path for compiler invocations created from SourceKit.

Fixes #58786 (rdar://93030932)
2022-05-13 09:05:38 +02:00
Ben Barham
8148c763cd Merge pull request #58847 from bnbarham/rebranch-test-fixes
[next] Fixes for various test failures on rebranch
2022-05-12 09:30:39 -07:00
Alex Hoppen
0c336882d6 Merge pull request #58681 from ahoppen/pr/guard-dependency-stamps
[SourceKit] Guard DependencyStamps with a lock
2022-05-12 08:11:48 +02:00
Ben Barham
a6a6ae456a [next] Use SmallString over reserved std::string
A `llvm::raw_string_ostream` is unbuffered, but calling `SetBufferSize`
adds a buffer. Since its destructor doesn't flush (as it assumes it is
unbuffered), this then asserts in the `llvm::raw_ostream` destructor.
Remove the `SetBufferSize` call (the string is the underlying buffer)
and also switch to using `llvm::SmallString` instead.

This fixes a crash in `SourceKit/SyntaxTree/basic.swift` and
`SourceKit/SyntaxTree/pound_if.swift`, which are presumably the only two
tests that actually use this.
2022-05-11 17:06:29 -07:00
Alex Hoppen
2b364930fc [CursorInfo] Report values shadowed using shorthand syntax as secondary results
When a variable is re-declared using shorthand syntax (`[foo]` closure capture or `if let foo {`), the user doesn’t perceive this as a new variable declaration. Thus, we should return the original declaration as a secondary result.

rdar://91311033
rdar://75455650
2022-05-11 08:05:26 +02:00
Alex Hoppen
bbd2848723 Merge pull request #58684 from ahoppen/pr/related-idents
[SourceKit] In related identes, report underlying var of closure capture and shorthand if let binding
2022-05-09 16:56:15 +02:00
Alex Hoppen
d0d3d42967 [SourceKit] In related identes, report underlying var of shorthand if let binding 2022-05-06 10:10:10 +02:00
Alex Hoppen
64e27a270e [SoruceKit] Add the underlying variable to related identifiers for a captured variable
Previously, the related idents request wouldn’t look through caputred variables like `[foo]`. Change the logic to consider the captured variable as well as the variable that’s implicitly declared for use inside the closure.

rdar://81628899
2022-05-06 10:10:10 +02:00
Alex Hoppen
351770c2c3 [SourceKit] Guard DependencyStamps with a lock
We might run into situations where `matchesSourceState` reads `DependencyStamps` while they are being written in `buildASTUnit`, causing a crash.

Guard `DependencyStamps` by a mutex to avoid this problem. We don’t need to provide any ordering guarantees about whether `DependencyStamps` have been computed in are accessed because we already assume that the dependencies shouldn't change (much) in the time between an `ASTBuildOperation` is created and until it produced an AST.

rdar://92748564
2022-05-05 10:49:32 +02:00
Mishal Shah
d292a852d8 Merge pull request #40188 from apple/QuietMisdreavus/cmark
use swift-cmark/gfm instead of /main
2022-05-02 10:20:23 -07:00
Rintaro Ishizaki
30a53fed05 Merge pull request #42583 from rintaro/regex_diagnostics
[SwiftCompiler/Regex] Use bridged DiagnosticEngine for error reporting
2022-04-25 08:26:38 -07:00