Commit Graph

34 Commits

Author SHA1 Message Date
Rintaro Ishizaki
2bf9dde17b [CodeCompletion][NFC] Fix typo 2020-04-13 11:55:34 -07:00
Rintaro Ishizaki
de6a402116 [CodeCompletion] Add pretty stacktrace for completion operation 2020-04-10 09:28:40 -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
Hamish Knight
d2434e1bf7 NFC: Rename NameBinding to ImportResolution 2020-03-29 18:43:58 -07:00
Hamish Knight
011f4f1584 Requestify SourceFile parsing
Add ParseSourceFileRequest that parses a SourceFile
for its top-level decls.
2020-03-03 15:53:18 -08:00
Hamish Knight
d77cae6720 Move PersistentParserState onto SourceFile
Move the global PersistentParserState from
the CompilerInstance to the source file that code
completion is operating on, only hooking up the
state when it's needed. This will help make it
easier to requestify source file parsing.
2020-03-02 11:22:44 -08:00
Rintaro Ishizaki
0a0cde92a4 [CodeCompletion] Fast completion for top-level code in single file script
e.g. Playground.
A single file script is like a single function body; the interface of
the file does not affect any other files.
So when a completion happens in a single file script, re-parse the whole
file. But we are still be able to reuse imported modules.

rdar://problem/58378157
2020-02-25 15:56:28 -08:00
Hamish Knight
312f7ddc50 Parse Swift decls in one shot
Instead of interleaving typechecking and parsing
for SIL files, first parse the file for Swift
decls by skipping over any intermixed SIL decls.
Then we can perform type checking, and finally SIL
parsing where we now skip over Swift decls.

This is an intermediate step to requestifying the
parsing of a source file for its Swift decls.
2020-02-04 13:04:50 -08:00
David Ungar
a2df6b98f5 Merge pull request #29463 from davidungar/PBP-2-21-ICNR-on
[DNM, Incremental: Type-body-fingerprints on-by-default]
2020-01-27 18:03:38 -08:00
David Ungar
d61f6f2f66 Changes to support per-type-body fingerprints. 2020-01-27 15:14:46 -08:00
Robert Widmann
6ec3ab94d2 [NFC] Define SILGen Request Zone and GenerateSIL Request
Define a high-level request for SILGen and switch the high-level
entrypoint to vector through it.
2020-01-26 13:43:52 -08:00
Rintaro Ishizaki
7b4466f400 [CodeCompletion] Ignore implicit decl when finding equivalent decl
TypeChecker sometimes (e.g. property wrappers) inserts implicit decls
(e.g. 'PatternBindingDecl's and 'VarDecl's) between decls in the AST.
This used to confuse 'getEquivalentDeclContextFromSourceFile()'. It
canceled fast-completion, caused crashes, or completed in a wrong
context.

Ignore implicit decls in the AST so that we can find the correct decl
context.

rdar://problem/58665268
2020-01-22 22:28:33 -08:00
Rintaro Ishizaki
9eeb96c5ba [CodeCompletion] Handle cases where PersistentParserState is not created
For example, if stdlib is not found, CompilerInstance simply returns
before creating PersistentParserState. In such cases, completion should
just return empty result.

Previously, it caused SourceKit crash.

rdar://problem/58663066
2020-01-17 00:10:50 -08:00
Rintaro Ishizaki
13e865c11c Merge pull request #29245 from rintaro/ide-completion-fastaccessor-rdar58632889
[CodeCompletion] Enable fast completion within accessors
2020-01-16 09:08:12 -08:00
Rintaro Ishizaki
9b1212b4fb [CodeCompletion] Make getEquivalentDeclContextFromSourceFile() safe
Gracefully give up finding equivalent decl contxt if something goes wrong.
2020-01-15 21:38:36 -08:00
Rintaro Ishizaki
3018b55914 [CodeCompletion] Enable fast completion within accessors
'getEquivalentDeclContextFromSourceFile()' didn't work for accessors
because DeclContext hierarchy and AST hierarhy are not the same.

AST hierarchy:
    (TypeDecl or SourceFile) > AbstractStorageDecl > AccessorDecl
DeclContext hierarchy:
    (TypeDecl or SourceFile) > AccessorDecl

Handle them specially.

rdar://problem/58632889
2020-01-15 21:33:49 -08:00
Rintaro Ishizaki
951b85359a [SourceKit] Disable module system headers validation
in all SourceKit requests.
This validation may call many stat(2). Since we don't expect system files
are edited. Disable it for SourceKit requests. Even if they are edited,
manual builds can validates and updates them.

rdar://problem/58550697
2020-01-14 13:06:57 -08:00
Rintaro Ishizaki
ec70a40205 [CodeCompletion] Disable module system headers validation
This validation may call many `stat(2)`. Since we don't expect system
files are edited. Disable it for code completion, even if they are
edited, they are validated when the user manually build the project.

rdar://problem/58550697
2020-01-13 17:47:47 -08:00
Rintaro Ishizaki
70ad17a932 Merge pull request #28904 from rintaro/ide-completion-rdar58119719
[CodeCompletion] Reduce accumulating memory per fast completion
2020-01-13 16:49:51 -08:00
Robert Widmann
96b3b9f0f4 [NFC] Hide SourceFile::Decls
In preparation for installing some stable paths infrastructure here,
hide access to the array of top-level decls.
2020-01-03 14:14:00 -08:00
Rintaro Ishizaki
108b9c3a25 [CodeCompletion] Open virtual file for fast completion buffers
This improves diangostics message for completion traces
2020-01-02 14:13:16 -08:00
Rintaro Ishizaki
8f38105bc3 [CodeCompletion] Reduce leaking memory per fast completion
For each fast completion, the memory grows for the source buffer and the
AST of the function body in memory. They are kept until the next slow
completion.

To mitigate the memory consumption per completion, use sliced source
text which is actually required for the second pass.

rdar://problem/58119719
2020-01-02 14:04:11 -08:00
Rintaro Ishizaki
eebcbf6564 [SourceKit] Pass 'EnableASTCaching' flag as an argument
so that it is associated with a specific completion.
2019-12-19 12:20:20 -08:00
Rintaro Ishizaki
2aec5d4d28 [CodeCompletionn] Block completions in other threads
if fast-completion is enabled. So they have higher chance to use the cached
completion instance.
If it's disabled, don't block, use an ephemeral instance so we can peform
multiple completions simultaneously.
2019-12-18 21:52:20 -08:00
Rintaro Ishizaki
fe07d4491b [CodeCompletion] Pack cached instance information into single struct
To prevent them from out-of-sync.
2019-12-18 21:52:20 -08:00
Rintaro Ishizaki
044477e7a3 [SourceKit/CodeCompletion] Use callback function to run the second pass
To controls the lifetime of CompilerInstance within CompletionIntance.

- Prevent from using the same CompilerInstance from multiple completion
  requests
- Separate the stacktrace between "fast" and "normal" completions
- Further code consolidation between various completion-like requests
2019-12-18 21:52:20 -08:00
Rintaro Ishizaki
0f45267927 [CodeCompletion] Use the arguments to check the equality of the invocation
Checking "selected" properties of CompilerInvocation is hard to keep it
up to date. If the arguments are the same, the invocations are the same.
2019-12-18 21:52:20 -08:00
Rintaro Ishizaki
f2466deed8 [CodeCompletion] Rename getReusingCompilerInstance()
to getCachedCompilerInstance()
2019-12-18 21:52:20 -08:00
Rintaro Ishizaki
204ae49b38 [CodeCompletion] Add doc-comment for CompletionInstance 2019-12-18 21:52:20 -08:00
Rintaro Ishizaki
c3d582841d [SourceKit] Limit compiler instance reuse count for completions 2019-12-18 21:52:20 -08:00
Rintaro Ishizaki
fcc7e411f8 [SourceKit] Add a test case for fast code completion 2019-12-18 21:52:20 -08:00
Rintaro Ishizaki
a83c7e86b7 [SourceKit] Calculate CompilerInvocation hash 2019-12-18 21:52:20 -08:00
Rintaro Ishizaki
c1530eedca [SourceKit] Add option to enable ASTContext reusing for code completion 2019-12-18 21:52:20 -08:00
Rintaro Ishizaki
62c44126b6 [SourceKit] Reuse compiler instance between multiple completion
- Introduce ide::CompletionInstance to manage CompilerInstance
- `CompletionInstance` vends the cached CompilerInstance when:
-- The compiler arguments (i.e. CompilerInvocation) has has not changed
-- The primary file is the same
-- The completion happens inside function bodies in both previous and
   current completion
-- The interface hash of the primary file has not changed
- Otherwise, it vends a fresh CompilerInstance and cache it for the next
  completion

rdar://problem/20787086
2019-12-18 21:52:20 -08:00