Commit Graph

2340 Commits

Author SHA1 Message Date
swift-ci
ba0c98ff08 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-21 22:33:02 -08:00
Rintaro Ishizaki
473ecd8c80 Merge pull request #40645 from rintaro/sourcekit-compilerserver
[SourceKit] Add a request to generate object files in SourceKit
2021-12-21 22:29:11 -08:00
Rintaro Ishizaki
7c92a8e555 [SourceKit] Add a request to generate object files in SourceKit
Add 'request.compile'
2021-12-21 14:35:38 -08:00
swift-ci
f25c7addf6 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-21 09:53:19 -08:00
Rintaro Ishizaki
2795a19ed6 Merge pull request #40163 from rintaro/ide-completion-enumbitfield
NFC: [CodeCompletion] Use enums in bit fields as-is
2021-12-21 09:40:00 -08:00
Alex Hoppen
c1542bf80e [SourceKit] Guard static assert by _MSC_VER 2021-12-21 11:56:03 +01:00
swift-ci
41ef4e8c9d Merge remote-tracking branch 'origin/main' into rebranch 2021-12-20 09:15:08 -08:00
Alex Hoppen
669e3f34a6 Merge pull request #40155 from ahoppen/pr/improve-module-search-path-lookup
[Serialization] Improve module loading performance
2021-12-20 18:09:17 +01:00
swift-ci
3321e4715d Merge remote-tracking branch 'origin/main' into rebranch 2021-12-17 16:15:07 -08:00
Rintaro Ishizaki
2c7cbe9748 [SourceKit] Initialize llvm in SourceKit
Preparation for code generation in SourceKit
2021-12-17 10:19:53 -08:00
swift-ci
09c4a37ac9 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-15 16:44:42 -08:00
Ben Barham
65ef8020de [CodeComplete] Add option to add calls with no defaults (or not)
Now that arguments are marked up with whether they have a default or
not, clients may not need the extra call (that has no default
arguments). Add an option to allow not adding this item.

Resolves rdar://85526214.
2021-12-15 13:30:57 +10:00
swift-ci
7ff906d730 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-14 04:53:37 -08:00
Alex Hoppen
4fc9d015de Merge pull request #40107 from ahoppen/pr/load-stdlib-in-setup
[Frontend] Load standard libarary in CompilerInstance::setup
2021-12-14 13:45:23 +01:00
Alex Hoppen
fe7878ecce [Serialization] Improve module loading performance
When looking for a Swift module on disk, we were scanning all module search paths if they contain the module we are searching for. In a setup where each module is contained in its own framework search path, this scaled quadratically with the number of modules being imported. E.g. a setup with 100 modules being imported form 100 module search paths could cause on the order of 10,000 checks of `FileSystem::exists`. While these checks are fairly fast (~10µs), they add up to ~100ms.

To improve this, perform a first scan of all module search paths and list the files they contain. From this, create a lookup map that maps filenames to the search paths they can be found in. E.g. for
```
searchPath1/
  Module1.framework

searchPath2/
  Module1.framework
  Module2.swiftmodule
```
we create the following lookup table
```
Module1.framework -> [searchPath1, searchPath2]
Module2.swiftmodule -> [searchPath2]
```
2021-12-14 12:44:13 +01:00
swift-ci
60fc05af03 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-13 10:54:40 -08:00
Alex Hoppen
f5b6103ef7 [SourceKit] Fix a crash that occurred when a document without an associated source file is reopened
When opening a file for the first time, we don’t store a snapshot for it. This could cause a crash when trying to consult its snapshot to see whether an AST can be reused for cursor info.
2021-12-13 16:43:32 +01:00
Alex Hoppen
22f67e89a6 [SourceKit] Explicitly specify frontend action type when creating compiler invocation
Explicitly specify the frontend action to make sure we aren’t loading thes stdlib if the performed action is syntactic only.
2021-12-13 15:32:08 +01:00
Alex Hoppen
63c31033fc [Frontend] Load standard libarary in CompilerInstance::setup
Instead of checking that the stdlib can be loaded in a variety of places, check it when setting up the compiler instance. This required a couple more checks to avoid loading the stdlib in cases where it’s not needed.

To be able to differentiate stdlib loading failures from other setup errors, make `CompilerInstance::setup` return an error message on failure via an inout parameter. Consume that error on the call side, replacing a previous, more generic error message, adding error handling where appropriate or ignoring the error message, depending on the context.
2021-12-13 15:32:08 +01:00
swift-ci
6aa71465d0 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-10 05:33:50 -08:00
Alex Hoppen
5a6341bd65 Merge pull request #40493 from ahoppen/pr/enqueue-consumer-on-background-queue
[SourceKit] Enqueue `SwiftASTConsumer`s async on a queue
2021-12-10 14:23:47 +01:00
Alex Hoppen
c90c7a2975 [SourceKit] Enqueue SwiftASTConsumers async on a queue
Enqueuing `SwiftASTConsumer`s might be expensive because `getBuildOperationForConsumer` consults the file system. Since all results from the AST build are processed asynchronously anyway, there’s no need to perform the enqueuing  synchronously.

rdar://86289703
2021-12-10 09:11:02 +01:00
swift-ci
1c8c75ac62 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-09 17:08:58 -08:00
Ben Barham
9dabad41b6 Merge pull request #40491 from apple/revert-40353-pr/no-semantic-info-if-not-requested
Revert "[SourceKit] Don't build an AST if no semantic info is requested"
2021-12-10 10:39:40 +10:00
Alex Hoppen
4aa911023a Merge pull request #40339 from ahoppen/pr/improve-sourcekit-stamp-handling
[SourceKit] Improvements to stamp handling in SwiftASTManager
2021-12-09 23:53:59 +01:00
Alex Hoppen
a5b3f83223 Revert "[SourceKit] Don't build an AST if no semantic info is requested" 2021-12-09 21:20:43 +01:00
Alex Hoppen
e17faa5bcf [SourceKit] Improve memory cost function of ASTBuildOperation 2021-12-08 15:17:13 +01:00
Alex Hoppen
3adb9c2823 [SourceKit] Make FileContent non ref-counted
We never need to have two copies of the same `FileContent` object, so we don’t need a copy constructor and can thus pass it on the stack again, instead of storing it on the heap.
2021-12-08 15:17:13 +01:00
Alex Hoppen
dcbedc65fd [SourceKit] Remove some dupliate computation of realpaths 2021-12-08 15:17:13 +01:00
Alex Hoppen
5f4b1a0b27 [SourceKit] Don't store Stamps in ASTBuildOperation
FileContents already contains the stamps.
2021-12-08 15:17:13 +01:00
Alex Hoppen
a8bfd4fe44 [SourceKit] Store FileContents in ASTBuildOperation instead of snapshots 2021-12-08 15:17:13 +01:00
Alex Hoppen
de25265de0 [SourceKit] Remove ability to specify fixed snapshots to use when building an AST
The feature was never used and just complicated the implementation.
2021-12-08 15:17:13 +01:00
swift-ci
8abc3941d1 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-07 08:14:19 -08:00
Alex Hoppen
1739c23a9b Merge pull request #40158 from ahoppen/pr/cancel-code-completion
[SourceKit] Support cancellation of code completion like requests
2021-12-07 17:10:05 +01:00
swift-ci
fcc173765f Merge remote-tracking branch 'origin/main' into rebranch 2021-12-04 09:33:47 -08:00
Rintaro Ishizaki
f17671c4a6 Guard a static assert for MSVC
MSVC doens't pack diffrent underlying int types into a bitfield. e.g.

  struct S {
    int a: 1;
    char b: 1;
    int c: 1;
  };

These fields are considered three sparate bitfields.
2021-12-04 00:19:25 -08:00
Saleem Abdulrasool
1e5df70d89 build: add a workaround for CMake[>=3.22] and SourceKit
The switch between compilers causes problems due to new flags being used
for building.  This adds a workaround to avoid the search path
re-ordering which breaks the build with a newer CMake.
2021-12-03 16:26:38 -08:00
Rintaro Ishizaki
94a372e8ca [CodeCompletion] Use enums in bit fields as-is
We don't need to convert them from/to integer
2021-12-03 15:33:28 -08:00
swift-ci
ee8f9ee1f3 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-03 15:14:24 -08:00
Connor Wakamo
b553a92718 Merge pull request #40235 from cwakamo/eng/PR-85511244-fix-some-SourceKit-CMake-issues
[CMake] Fix a couple SourceKit CMake issues.

This addresses <rdar://problem/85511244>.
2021-12-03 15:09:00 -08:00
Alex Hoppen
177ab6e8e7 [SourceKit] Support cancellation of code completion like requests
Essentially, just wire up cancellation tokens and cancellation flags for `CompletionInstance` and make sure to return `CancellableResult::cancelled()` when cancellation is detected.

rdar://83391488
2021-12-02 13:05:03 +01:00
Alex Hoppen
d482ee392e [SourceKit] Make sourcektid_request_handle_t const void* 2021-12-02 13:03:17 +01:00
Alex Hoppen
9042536323 [SourceKit] Move the cancellation flag from TypeCheckerOptions to ASTContext
We need to modify the pointer pointing to the cancellation flag when reusing an ASTContext for code completion. This is not possible by the previous design because `TypeCheckerOptions` was `const`. Moving the cancellation flag to `ASTContext` will also allow other stages of the compiler to honor a cancellation request.
2021-12-02 12:57:34 +01:00
swift-ci
8de2ddb02e Merge remote-tracking branch 'origin/main' into rebranch 2021-12-01 13:54:08 -08:00
Alex Hoppen
9cd109cd16 Merge pull request #40353 from ahoppen/pr/no-semantic-info-if-not-requested
[SourceKit] Don't build an AST if no semantic info is requested
2021-12-01 22:42:11 +01:00
Alex Hoppen
558c3b240c Merge pull request #40169 from ahoppen/pr/add-disposecancellationtoken-to-exports
[SourceKit] Add `sourcekitd::disposeCancellationToken` to Darwin exports
2021-12-01 22:41:52 +01:00
Alex Hoppen
debeebb443 [SourceKit] Don't build an AST if no semantic info is requested
Currently, we were building an AST on document open or edit even if
- `key_enablesyntaxmap` = 0
- `key_enablesubstructure` = 0
- `key_enablediagnostics` = 0 and
- syntax tree transfer mode is off

In those cases we were just ignoring the result.

If all of the options are 0, don’t build an AST.

rdar://85847659
2021-12-01 16:47:50 +01:00
swift-ci
bc71cf7c54 Merge remote-tracking branch 'origin/main' into rebranch 2021-11-30 15:21:46 -08:00
Ben Barham
9180e010c1 Merge pull request #40323 from bnbarham/lint-crash
[SourceKit] Add structure node for SubscriptExpr
2021-12-01 08:57:16 +10:00
swift-ci
ee96d2798c Merge remote-tracking branch 'origin/main' into rebranch 2021-11-30 08:33:02 -08:00