@@ -28,23 +28,32 @@ class DiagnosticConsumer;
28
28
29
29
namespace ide {
30
30
31
- // / Copy a memory buffer inserting '0' at the position of \c origBuf.
31
+ // / Copy a memory buffer inserting '\ 0' at the position of \c origBuf.
32
32
std::unique_ptr<llvm::MemoryBuffer>
33
33
makeCodeCompletionMemoryBuffer (const llvm::MemoryBuffer *origBuf,
34
34
unsigned &Offset,
35
35
llvm::StringRef bufferIdentifier);
36
36
37
+ // / Manages \c CompilerInstance for completion like operations.
37
38
class CompletionInstance {
38
39
std::unique_ptr<CompilerInstance> CachedCI = nullptr ;
39
40
bool EnableASTCaching = false ;
40
41
unsigned MaxASTReuseCount = 100 ;
41
42
unsigned CurrentASTReuseCount = 0 ;
42
43
44
+ // / Returns cached \c CompilerInstance if it's usable for the specified
45
+ // / completion request.
46
+ // / Returns \c nullptr if the functionality is disabled, compiler argument has
47
+ // / changed, primary file is not the same, the \c Offset is not in function
48
+ // / bodies, or the interface hash of the file has changed.
43
49
swift::CompilerInstance *
44
50
getReusingCompilerInstance (const swift::CompilerInvocation &Invocation,
45
51
llvm::MemoryBuffer *completionBuffer,
46
52
unsigned int Offset, DiagnosticConsumer *DiagC);
47
53
54
+ // / Returns new \c CompilerInstance for the completion request. Users still
55
+ // / have to call \c performParseAndResolveImportsOnly() , and perform the
56
+ // / second pass on it.
48
57
swift::CompilerInstance *renewCompilerInstance (
49
58
swift::CompilerInvocation &Invocation,
50
59
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
@@ -56,6 +65,8 @@ class CompletionInstance {
56
65
EnableASTCaching = Flag;
57
66
}
58
67
68
+ // / Returns \C CompilerInstance for the completion request. Users can check if
69
+ // / it's cached or not by 'hasPersistentParserState()'.
59
70
swift::CompilerInstance *getCompilerInstance (
60
71
swift::CompilerInvocation &Invocation,
61
72
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
0 commit comments