Commit Graph

2161 Commits

Author SHA1 Message Date
Alex Hoppen
3a96cc7c51 [SourceKit] Use a deep stack to perform syntactic parsing
Othwerise we were performing the syntactic parsing on a background queue that had a reduced stack size which could result in stack overflows.

rdar://84474387
2021-11-09 18:36:09 +01:00
Alex Hoppen
86a1bfd340 Merge pull request #39631 from ahoppen/pr/cancel-completion-infrastructure
[CodeCompletion] Refactor how code completion results are returned to support cancellation
2021-11-09 13:35:18 +01:00
Ben Barham
fd7d59daa6 [CursorInfo] Add a synthesized field
Mark implicit declarations with a `synthesized` field, since while we
still want them to have a cursor info result (eg. for their USR to find
possible overrides), it's likely that clients will want to treat them
differently to results that have a real location in source.

An alternative could be to remove the location entirely, but:
  - the module name would also have to be removed to prevent wasted
    lookups in the generated interface
  - having the location could still be useful as the location that
    caused the synthesized declaration (though at the moment only
    synthesized initializers have a location)

Resolves rdar://84990655
2021-11-05 15:52:10 +10:00
Karoy Lorentey
e2cfab4f28 [stdlib][test] Adopt availability macros in tests 2021-10-31 15:00:58 -07:00
Alex Hoppen
b6e03e3d98 [CodeCompletion] Make sure callback is always called from performOperation
We had some situations left that neither returned an error, nor called the callback with results in `performOperation`. Return an error in these and adjust the tests to correctly match the error.
2021-10-28 11:10:30 +02:00
Ben Barham
8128450690 [CursorInfo] Always add module name to response
To simplify clients, have the cursorinfo result be consistent whether
requesting a symbol within the current module or not, ie. do not skip
adding the module name.

Resolves rdar://77003299
2021-10-22 12:35:53 +10:00
Alex Hoppen
64bbb12671 Merge pull request #39585 from ahoppen/pr/explicit-diags-request
[SourceKit] Add a dedicated request to retrieve the diagnostics of a file
2021-10-14 13:55:25 +02:00
Alex Hoppen
e2ebd2bf72 [SourceKit] Flush llvm::outs() before printing to STDOUT_FILENO in soucekitd-test
Otherwise, we get non-deterministic ordering of results printed through `llvm::outs()` and `STDOUT_FILENO`.
2021-10-13 21:29:18 +02:00
Alex Hoppen
2f19d1847f [SourceKit] Add a dedicated request to retrieve the diagnostics of a file
Currently, SourceKit always implicitly sends diagnostics to the client after every edit. This doesn’t match our new cancellation story because diagnostics retrieval is no request and thus can’t be cancelled.

Instead, diagnostics retrieval should be a standalone request, which returns a cancellation token like every other request and which can thus also be cancelled as such.

The indented transition path here is to change all open and edit requests to be syntactic only. When diagnostics are needed, the new diagnostics request should be used.

rdar://83391522
2021-10-13 21:28:18 +02:00
zoecarver
eeeb27d66e [cxx-interop] Add members to the LookupTable where possible.
If possible, add imported members to the StructDecl's LookupTable rather than adding them directly as members. This will fix the issues with ordering that #39436 poorly attempted to solve during IRGen.

This also allows us to break out most of the test changes from #39436.
2021-10-13 11:53:58 -07:00
Alex Hoppen
fa0ead5dc1 [SourceKit] Add option to simulate a long-running request
This allows us to remove the dependency on a slow-to-typecheck example for a `sourcekitd-test`.
2021-10-04 21:43:53 +02:00
Alex Hoppen
fb2644742b [SourceKit] Add an option to cancel async requests 2021-09-30 11:45:24 +02:00
Alex Hoppen
7a80034e35 [SourceKit] Support cancellation of requests while an AST is being built
This commit refactors the way ASTs are being built in SourceKit and how `SwiftASTConsumer`s are served by the built ASTs. `SwiftASTManager.h` should give an overview of the new design.

This commit does not change the cancellation paradigm in SourceKit (yet). That is, subsequent requests with the same `OncePerASTToken` still cancel previous requests with the same token. But while previously, we were only able to cancel requests that haven’t started an AST build yet, we can now also cancel the AST build of the to-be-cancelled requests.

With this change in place, we can start looking into explicit cancellation of requests or other cancellation paradigms.
2021-09-23 11:53:45 +02:00
Hamish Knight
dc60996f89 Merge pull request #38836 from hamishknight/toil-and-tuple 2021-09-04 19:30:04 +01:00
Rintaro Ishizaki
7e7b2c3557 [CodeCompletion] Annotate override completions
* "description" for override completion is now annotatable
* "description" doesn't include attributes and decl introducer, but it
  includes generic paramters, effects specifiers, result type clause,
  and generic where clauses
* "name" now only include the name and the parameter names
* "sourcetext" should be the same

rdar://63835352
2021-09-02 12:12:26 -07:00
Hamish Knight
01a082a058 [AST] Adopt ArgumentList
Switch out the representation of argument lists
in various AST nodes with ArgumentList.
2021-09-01 18:40:23 +01:00
Kavon Farvardin
eecaa44cdd disable SourceKit/Sema/sema_build_session.swift to unblock CI 2021-08-25 17:04:28 -07:00
Ben Barham
3b99e9079b Merge pull request #38920 from apple/show-cursor-refactorings
[Refactorings] Add cursor refactorings for the start of the range
2021-08-21 07:35:51 +10:00
Egor Zhdan
3464cb189d Merge pull request #38882 from egorzhdan/astprinter-protocols
ASTPrinter: print public inherited protocols of the skipped private protocols
2021-08-20 23:44:15 +03:00
Ben Barham
c7620fa979 [Refactorings] Add cursor refactorings for the start of the range
When a range is a single expression/statement/decl or part of
expression, also return cursor based refactorings for the start of the
range.

This is a stop gap until the available refactorings are properly fixed
to be more lenient in general - the current fix is a little odd as eg.
if all of `foo.bar()` is selected, rename will be returned as an
available refactoring for `foo`. Still an improvement over completely
missing cursor based refactorings, however.

Resolves rdar://82060063
2021-08-18 14:04:10 +10:00
Egor Zhdan
b2198e2c99 ASTPrinter: print public inherited protocols of the skipped private protocols
When printing the list of inherited protocols in the module interface, if private stdlib protocols are requested to be hidden, make sure to print public inherited protocols of the hidden protocols.
2021-08-14 14:10:25 +03:00
Ben Barham
f6899eda96 [SourceKit] Suppress oslog_invalid_log_message diagnostic in live issues
The index build skips *all* function bodies, including inlinable. The
`OSLogOptimization` pass expects SIL for inlinable bodies and thus
outputs a spurious diagnostic for live issues when the
`OSLogInterpolation` extension is in a separate module to the log
statement.

Ignore this for now, but we may need to re-evaluate if this becomes a
more widespread problem.

Resolves rdar://79100763
2021-08-06 16:49:43 +10:00
Doug Gregor
f9c34756ef Parameterize conformance lookup on whether "missing" conformances are allowed.
Many clients of the conformance lookup operations would prefer to get
an invalid conformance (== there is no conformance) rather than a
missing conformance. Parameterize the conformance lookup operations so
that most callers won't see missing conformances, by filtering them
out at the end. Opt-in those callers that do want to see missing
conformances so they can be diagnosed.
2021-08-03 00:10:45 -07:00
Rintaro Ishizaki
d747ee97c1 Merge pull request #38521 from rintaro/astprinter-introducerkeyword
[ASTPrinter] Intorduce 'IntroducerKeyword' name kind
2021-07-30 14:57:41 -07:00
Rintaro Ishizaki
6e69a44c3d [ASTPrinter] Intorduce 'IntroducerKeyword' name kind
For more fine grained annoations. For now, it's handled as the same as
'Keyword' name kind.

Fix an issue where 'extension' wasn't marked as "keyword".

Also, move 'static' priting out of 'SkipIntroducerKeywords' guard
because 'static' is not an declaration introducer.
2021-07-29 12:50:24 -07:00
Ben Barham
e7e9b57051 Replace @completionHandlerAsync with @available(*, renamed:)
Instead of a new attribute `@completionHandlerAsync`, allow the use of
the existing `renamed` parameter of `@available` to specify the
asynchronous alternative of a synchronous function.

No errors will be output from invalid names as `@completionHandlerAsync`
had, but if a function is correctly matched then it will be used to
output warnings when using the synchronous function in an asynchronous
context (as before).

Resolves rdar://80612731
2021-07-29 09:14:44 +10:00
Hamish Knight
470cb261ef [SyntaxModel] Correctly annotate unlabelled unary args
Previously we would only handle TupleExpr argument
list exprs. Update the logic to handle ParenExpr
argument lists too.

rdar://81154978
2021-07-27 11:38:07 +01:00
Doug Gregor
eeeea49764 Remove -enable-experimental-concurrency almost everywhere. 2021-07-26 21:24:43 -07:00
Doug Gregor
b2dee32b00 Enable async let without the experimental flag 2021-07-26 16:14:34 -07:00
Ben Barham
fabb02100f [Test] Add @escaping to async refactoring tests
The async refactorings ignore whether a completion handler had
`@escaping` or not. In preparation of fixing this, fix up all functions
to have `@escaping` for their completion handler parameter.

Also some small miscellaneous fixes in order to reduce the number of
warnings output on test failures and also the addition of `REQUIRES:
concurrency` on all tests.
2021-07-24 09:53:17 +10:00
Ted Kremenek
13f04295c9 Update Swift version to 5.6 (#38574)
* Update Swift version to 5.6

* Add Swift 5.6 to changelog
2021-07-22 19:35:58 -07:00
Doug Gregor
1e2012d816 Disable availability checking in tests that use concurrency 2021-07-20 12:46:26 -07:00
Rintaro Ishizaki
90b3f6ec57 [CodeCompletion] Fix a test case after CodeComletionString::getName() obsoletion
Since 7c24d19, sorted result from SourceKit for 'foo(a: Int)' and
'foo(a: String)' is non-deterministic. Update the test case.

rdar://80729544
2021-07-19 14:10:22 -07:00
David Ungar
9e7eb2fb7d Disable failing test. 2021-07-17 10:30:28 -07:00
Rintaro Ishizaki
7c24d19df2 Merge pull request #38446 from rintaro/ide-completion-getname-remove 2021-07-16 17:47:27 -07:00
Rintaro Ishizaki
18dc9c1c27 [CodeCompletion] Remove CodeComletionString::getName()
`CodeCompletioString::getName()` was used only as the sorting keys in
`CodeCompletionContext::sortCompletionResults()` which is effectively
deprecated. There's no reason to check them in `swift-ide-test`. Instead,
check `printCodeCompletionResultFilterName()` that is actually used for
filtering.
2021-07-16 13:24:19 -07:00
Ben Barham
f9b3e40595 [SourceKit/DocInfo] Add is_async for properties with async getters
Resolves rdar://80546521
2021-07-16 13:35:50 +10:00
Alex Hoppen
92b7e135b8 Merge pull request #38084 from fwcd/fix-sourcekit-var-types-if-let
[SourceKit] Determine correctly whether typed  variables in `if/guard/while-let`-statements have explicit type annotations
2021-07-02 12:02:32 +02:00
Alex Hoppen
3ea37693a5 Merge pull request #38085 from fwcd/fix-wildcard-name-range
[IDE] Fix name range of wildcard declarations
2021-06-29 15:03:27 +02:00
Fredrik Wieczerkowski
8a79268202 Add VariableType test for unnamed variables 2021-06-25 13:19:35 +02:00
Ben Barham
eaf604f4e8 Merge pull request #37946 from bnbarham/importer-use-working-dir
[ClangImporter] Respect -working-directory in the created VFS
2021-06-25 09:01:13 +10:00
Fredrik Wieczerkowski
88dd082260 Add VariableType test case for backticked names 2021-06-24 23:03:28 +02:00
Fredrik Wieczerkowski
748f60d0f4 Add wildcard parameter case to VariableType test 2021-06-24 21:59:37 +02:00
Fredrik Wieczerkowski
1b74379b1a Add VariableType test cases for if/guard/while-let
- Add VariableType test case for guarded variables
- Add if-let to VariableType test case
- Add while-let test case for VariableType
- Test pattern matching with VariableType
- Test guard/while-case-let with VariableType
2021-06-24 21:07:13 +02:00
Alex Hoppen
ba910cc786 Merge pull request #37867 from fwcd/sourcekit-var-types
[SourceKit] Add `CollectVariableType` request
2021-06-24 08:50:45 +02:00
Ben Barham
28bb2505b0 [ClangImporter] Respect -working-directory in the created VFS
Pass a wrapped VFS down into `clang::createInvocationFromCommandLine` so
that the working directory is set and then used in the underlying Clang
`CompilerInstance`.

Fixes the possibility of differing modules hashes when the same
arguments are used in Clang directly vs from the importer.

Resolves rdar://79376364
2021-06-24 11:07:40 +10:00
Fredrik Wieczerkowski
1a844efe5e Ignore error types in VariableTypeCollector
Also add a test to verify that error types get ignored (as intended).
2021-06-22 15:02:43 +02:00
Mishal Shah
10e93d62e4 Merge pull request #37979 from rintaro/disable-rdar79416986
[SourceKit][Tests] Disable a test case while investigating
2021-06-21 10:51:37 -07:00
Fredrik Wieczerkowski
ebe1b91663 Add tests for CollectVariableType request
- Add CollectVariableType test for function/closure parameters
- Test ranged CollectVariableType request
- Add separate test for ranged CollectVariableType
- Use line:col positions in sourcekitd-test for var types
- Add test case for CollectVariableType and inout params
- Update ranged CollectVariableType test
  ...as per the PR suggestions.
- Fix style issue
2021-06-21 19:33:43 +02:00
Rintaro Ishizaki
c48dc6d9c8 [SourceKit][Tests] Disable a test case while investigating
This test fails in Apple Silicon bot. Disable it while investigating.

rdar://79416986
2021-06-17 14:00:17 -07:00