Commit Graph

98 Commits

Author SHA1 Message Date
Alex Hoppen
bfe0a00551 Merge pull request #35429 from ahoppen/remove-bytetree
Remove ByteTree serialization format
2021-01-15 09:28:19 +01:00
Alex Hoppen
8ec8516893 Remove ByteTree serialization format
It was originally designed for faster trasmission of syntax trees from
C++ to SwiftSyntax, but superceded by the CLibParseActions. There's no
deserializer for it anymore, so let's just remove it.
2021-01-14 20:37:49 +01:00
Rintaro Ishizaki
4286c44e72 [CodeCompletion/SourceKit] Consolidate some chunk kinds
Consolidate ThrowsKeyword, RethrowsKeyword, and AsyncKeyword to
EffectsSpecifierKeyword.
Abolish 'key.throwsoffset' and 'key.throwslength' as they aren't used.
2020-12-14 12:25:30 -08:00
Nathan Hawes
388052b6ab [SymbolGraph][CursorInfo] Add option to SourceKit's CursorInfo request to include the SymbolGraph JSON
Adds a new 'key.retrieve_symbol_graph' option to the request. When set to 1 it
includes the JSON for a SymbolGraph containing a single node for the symbol at
the requested position.

This also extends the SymbolGraph library with a new entry point to get a graph
for a single symbol, and to additionally support type substitution to match the
existing CursorInfo behavior (e.g. so that when invoked on `first` in
`Array<Int>().first`, the type is given as `Int?` rather than `Element?`).

Resolves rdar://problem/70551509
2020-12-12 14:38:41 +10:00
Rintaro Ishizaki
77b4f75608 [SourceKit] Reorgantize code completion options
* Abolish 'reuseastcontext' per-request option
* Add 'MaxASTContextReuseCount' global configuration
2020-09-03 19:30:05 -07:00
Rintaro Ishizaki
33336dfb45 [SouceKit] Make "ASTContext reusing" optional
for 'ConformingMethodList' and 'TypeContextInfo'
2020-06-29 15:09:42 -07:00
Bruno Rocha
f000639cce Improve tests and generate the rest of the output 2020-05-29 18:59:25 +02:00
Bruno Rocha
2a48e19ff0 [SourceKit] Add Effective Scope to Index 2020-05-29 18:59:25 +02:00
David Goldman
67a2fe494a Fix up compile operation kind
- `key.compile_operation` instead of `key.compileoperation`
- Make the operation kind optional (nothing emitted for perform sema)
2020-05-18 13:18:40 -04:00
David Goldman
40759df737 [SourceKit] Include operation kind in compile notifications
- Compile will start / did finish now includes the operation
  kind (perform sema or code complete).
- See also
  https://forums.swift.org/t/sourcekit-lsp-file-status-ux/35947
2020-05-15 17:16:30 -04:00
Rintaro Ishizaki
7086ffb79f [CodeCompletion] Annotated result type
Introduced 'TypeAnnotationBegin' chunk kind for grouping the result type
name chunks.

rdar://problem/62617558
2020-05-11 22:56:22 -07:00
Rintaro Ishizaki
05a87e86c4 [CodeCompletion] Give up fast-completion if dependent files are modified
Check if dependencies are modified since the last checking.
Dependencies:

 - Other source files in the current module
 - Dependent files collected by the dependency tracker

When:

 - If the last dependency check was over N (defaults to 5) seconds ago

Invalidate if:

 - The dependency file is missing
 - The modification time of the dependecy is greater than the last check
 - If the modification time is zero, compare the content using the file
   system from the previous completion and the current completion

rdar://problem/62336432
2020-05-04 13:02:09 -07:00
Rintaro Ishizaki
4870d1c017 [SourceKit] Don't use diagnostics to indicate fast-completion
Add 'key.reusingastcontext: 1' to the response instead.
Using diagnostics can be a noise to indexing log clients.

rdar://problem/61367416
2020-04-07 16:26:00 -07:00
Nathan Hawes
9aafadd090 [SourceKit/DocSupport] Report the required bystander modules on symbols from cross-import overlays.
Resolves rdar://problem/59446044
2020-03-24 10:31:08 -07:00
Owen Voorhees
f11df3ee22 [Diagnostics][SourceKit] Expose diagnostic educational notes through SourceKit requests 2020-02-26 14:30:28 -08:00
Rintaro Ishizaki
1e74c39956 [SourceKit] Expose ExpectedTypeRelation for the completion results
So that clients can sort the results using this.

rdar://problem/59066560
2020-02-03 15:57:43 -08:00
Nathan Hawes
b9d5672ca1 [SourceKit] Add a global-configuration request to control SourceKit's behavior around .swiftsourceinfo files
SwiftSourceInfo files provide source location information for decls coming from
loaded modules. For most IDE use cases it either has an undesirable impact on
performance with no benefit (code completion), results in stale locations being
used instead of more up-to-date indexer locations (cursor info), or has no
observable effect (live diagnostics, which are filtered to just those with a
location in the primary file).

For non-IDE clients of SourceKit though, cursor info providing declaration
locations for symbols from other modules is useful, so add a global
configuration option (and a new request to set it) to control whether
.swiftsourceinfo files are loaded or not based on use case (they are loaded by
default).
2019-12-03 13:15:20 -08:00
Ben Langmuir
8784a7b96d Migrate to OptionsDictionary to pass arguments to FileSystemProvider 2019-07-16 10:19:24 -07:00
Marc Rasi
ed3a8ec6fc change it to use a FileSystemProvider selected by the request 2019-07-16 10:19:24 -07:00
Xi Ge
ff32d5899a SourceKit/ExpressionType: allow users to canonicalize collected expression types
The default response of the expression type request doesn't canonicalize expression
types. This patch adds a flag to allow users to canonicalize them.
2019-06-28 11:36:44 -07:00
David Goldman
1b1756cb55 Add InternalDiagnostic to CursorInfoData and NameTranslatingInfo 2019-05-28 04:24:25 -04:00
Joe Groff
7d54810b92 Revert "[SourceKit] Fail requests when an error occurs" 2019-05-22 15:18:28 -07:00
David Goldman
a3a4d2d22b Add InternalDiagnostic to CursorInfoData and NameTranslatingInfo 2019-05-03 11:01:22 -04:00
Rintaro Ishizaki
b5351a154c [CursorInfo] UID for opaque result type.
rdar://problem/49819227
2019-04-19 17:34:08 -07:00
Xi Ge
3fc52305a3 sourcekitd: define a new custom buffer for expression type response.
This custom buffer encapsulates the memory layout details of the response
for the expression type request. From the client side, each expression type
is represented as a tuple of {expr_offset, expr_length, printed_type}.

rdar://35199889
2019-02-22 16:58:10 -08:00
Nathan Hawes
4ced0afd9e Merge pull request #22764 from nathawes/add-implicit-to-index-request-output
[sourcekitd] Expose the 'implicit' symbol role in the 'index' request response
2019-02-21 15:17:43 -08:00
Nathan Hawes
e5e9dc6c05 [sourcekitd] Expose the 'implicit' symbol role in the 'index' request response
Resolves rdar://problem/48148270.
2019-02-20 17:12:23 -08:00
Xi Ge
74e86a8f35 SourceKit: Add a new request to collect expression types in a source file.
This request collects the types of all expressions in a source file after type checking.
To fulfill this task, the client must provide the path to the Swift source file under
type checking and the necessary compiler arguments to help resolve all dependencies.

Request:

{
    <key.request>:            (UID)     <source.request.expression.type>,
    <key.sourcefile>:         (string)  // Absolute path to the file.
    <key.compilerargs>:       [string*] // Array of zero or more strings for the compiler arguments,
                                        // e.g ["-sdk", "/path/to/sdk"]. If key.sourcefile is provided,
                                        // these must include the path to that file.
}

Response:

{
    <key.printedtypebuffer>:          (string)                    // A text buffer where all expression types are printed to.
    <key.expression_type_list>:       (array) [expr-type-info*]   // A list of expression and type
}

expr-type-info ::=
{
  <key.expression_offset>:    (int64)    // Offset of an expression in the source file
  <key.expression_length>:    (int64)    // Length of an expression in the source file
  <key.type_offset>:          (int64)    // Offset of the printed type of the expression in the printed type buffer
  <key.type_length>:          (int64)    // Length of the printed type of the expression in the printed type buffer
}

rdar:://35199889
2019-02-20 10:49:39 -08:00
Rintaro Ishizaki
552dcd81aa Merge pull request #22429 from rintaro/sourcekit-conformingmethods
[IDE/SourceKit] New SourceKit request for filtered method list
2019-02-11 18:13:15 -08:00
Rintaro Ishizaki
1d845d6e3f [IDE/SourceKit] New SourceKit request for filtered method list
`source.request.conformingmethods` is a new SourceKit request which
receives a source position and a list of protocol namses, returns a list
of methods whose return type conforms to the requested protocols.

rdar://problem/44699573
2019-02-08 12:56:58 -08:00
Marcelo Fabri
f61751bdcf [SR-9630][SourceKit] Add request to get compiler version 2019-01-20 10:39:25 -08:00
Rintaro Ishizaki
3797b7a334 [SourceKit] New request to retrieve context type information
This is a new SourceKit request which receives a position in the source
file, returns possible expected types and their members which can be
referenced by "implicit member expression" syntax.
2019-01-11 00:49:57 +09:00
Xi Ge
d620dfae5e Sourcekit/DocSupport: include fully annotated generic signatures for extension decls. rdar://40906297 2018-12-04 14:29:28 -08:00
Pavol Vaskovic
53cd115b0e [Gardening] Fix W291 trailing whitespace 2018-11-28 16:57:23 +01:00
Alex Hoppen
750e7e8f73 [SourceKit] Remove option to regions reused as part of incremental parsing 2018-08-20 11:15:50 -07:00
Alex Hoppen
4cda5cbeb0 [libSyntax] Support serializing the syntax tree as ByteTree 2018-08-13 20:03:47 -07:00
Alex Hoppen
749a13a6fe [libSyntax] Remove the C++ SyntaxClassifier
The recommended way forward is to use the SyntaxClassifier on the Swift
side.

By removing the C++ SyntaxClassifier, we can also eliminate the
-force-libsyntax-based-processing option that was used to bootstrap
incremental parsing and would generate the syntax map from a syntax
tree.
2018-07-30 09:26:18 -07:00
Alex Hoppen
c8fc286428 Merge pull request #18152 from ahoppen/01-incr-tree-transfer
[libSyntax] Incremental syntax tree transfer
2018-07-25 15:26:57 -07:00
John McCall
7a4aeed570 Implement generalized accessors using yield-once coroutines.
For now, the accessors have been underscored as `_read` and `_modify`.
I'll prepare an evolution proposal for this feature which should allow
us to remove the underscores or, y'know, rename them to `purple` and
`lettuce`.

`_read` accessors do not make any effort yet to avoid copying the
value being yielded.  I'll work on it in follow-up patches.

Opaque accesses to properties and subscripts defined with `_modify`
accessors will use an inefficient `materializeForSet` pattern that
materializes the value to a temporary instead of accessing it in-place.
That will be fixed by migrating to `modify` over `materializeForSet`,
which is next up after the `read` optimizations.

SIL ownership verification doesn't pass yet for the test cases here
because of a general fault in SILGen where borrows can outlive their
borrowed value due to being cleaned up on the general cleanup stack
when the borrowed value is cleaned up on the formal-access stack.
Michael, Andy, and I discussed various ways to fix this, but it seems
clear to me that it's not in any way specific to coroutine accesses.

rdar://35399664
2018-07-23 18:59:58 -04:00
Alex Hoppen
57196f8902 [libSyntax] Enable serialization of syntax trees for incremental transfer 2018-07-23 12:32:49 -07:00
Alex Hoppen
7a750bf024 [libSyntax] Allow syntax cache reuse info to be passed back via SourceKit 2018-07-18 13:35:10 -07:00
Alex Hoppen
c8a3957ba2 [SourceKit] Add option to force the SyntaxMap to be generated via the syntax tree 2018-07-13 17:57:00 -07:00
Ben Langmuir
a88c73fe60 [sourcekit] Fix non-deterministic failure in CompileNotifications tests
This is a test-only change except for the introduction of a new request
that is only used by tests.

Our notifications are dispatched in the XPC event handler, which is not
synchronized with replies to explicit XPC send_message_with_reply calls.
This is fine for most users of sourcekitd, since the notifications are
already enqueued on the client side, but for testing we need a way to
guarantee that all notifications are passed to the client-side handler
before we exit. This commit introduces a new request for testing that
triggers a notification, allowing the client to wait on that
notification to ensure all previously posted notifications have been
handled.

Note: the non-deterministic test failures can be triggered by adding a
sleep of ~100 ms in the event handler before the notification is
dispatched to the main queue.

rdar://40311995
2018-06-13 11:32:18 -07:00
Ben Langmuir
23ab43c941 [sourcekitd] Change compile notifications to pass a single args string
... instead of an array of compiler arguments. This is good enough
for seeing what's going on, and it saves significant time for long
argument strings, because it doesn't create and destroy so many
xpc strings, and more of the string copying that happens is on a large
contiguous string instead of many small strings.

rdar://39538847
2018-04-19 13:59:27 -07:00
Ben Langmuir
e08c31759e [sourcekit] Remove dead UID value
This was renamed at some point and the usage in complete-test has become
dead anyway, so clean it up.
2018-04-13 13:49:57 -07:00
Ben Langmuir
79d641d89b [sourcekit] Add optional compile notifications
When enabled, send a notification before/after every "compilation",
which for now means `performSema`. This piggy-backs and modifies some
existing code that we had for "tracing" operations in sourcekitd that
unfortunately was untested.  At least now some of the basic parts are
tested via the new notifications.

Part of rdar://38438512
2018-03-29 14:59:30 -07:00
John Fairhurst
677491fc9b [SourceKit] Add syntaxtype for #error/#warning (#14742) 2018-02-21 14:48:18 -08:00
Xi Ge
69bbf2ba71 sourcekitd: using gyb to generate UIDs instead of a def file. NFC (#14549)
Inspired by the infrastructure of SwiftSyntax, a gyb file can facilitate
cross-language sharing.
2018-02-12 22:48:54 -08:00