Skip to content

Commit 204ae49

Browse files
committed
[CodeCompletion] Add doc-comment for CompletionInstance
1 parent 2160134 commit 204ae49

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

include/swift/IDE/CompletionInstance.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,32 @@ class DiagnosticConsumer;
2828

2929
namespace ide {
3030

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.
3232
std::unique_ptr<llvm::MemoryBuffer>
3333
makeCodeCompletionMemoryBuffer(const llvm::MemoryBuffer *origBuf,
3434
unsigned &Offset,
3535
llvm::StringRef bufferIdentifier);
3636

37+
/// Manages \c CompilerInstance for completion like operations.
3738
class CompletionInstance {
3839
std::unique_ptr<CompilerInstance> CachedCI = nullptr;
3940
bool EnableASTCaching = false;
4041
unsigned MaxASTReuseCount = 100;
4142
unsigned CurrentASTReuseCount = 0;
4243

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.
4349
swift::CompilerInstance *
4450
getReusingCompilerInstance(const swift::CompilerInvocation &Invocation,
4551
llvm::MemoryBuffer *completionBuffer,
4652
unsigned int Offset, DiagnosticConsumer *DiagC);
4753

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.
4857
swift::CompilerInstance *renewCompilerInstance(
4958
swift::CompilerInvocation &Invocation,
5059
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
@@ -56,6 +65,8 @@ class CompletionInstance {
5665
EnableASTCaching = Flag;
5766
}
5867

68+
/// Returns \C CompilerInstance for the completion request. Users can check if
69+
/// it's cached or not by 'hasPersistentParserState()'.
5970
swift::CompilerInstance *getCompilerInstance(
6071
swift::CompilerInvocation &Invocation,
6172
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,

lib/IDE/CompletionInstance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ template <typename Range> Decl *getElementAt(const Range &Decls, unsigned N) {
7474
/// This assumes the AST which contains \p DC has exact the same structure with
7575
/// \p SF.
7676
/// FIXME: This doesn't support IfConfigDecl blocks. If \p DC is in an inactive
77-
/// config block, this function probably returns false.
77+
/// config block, this function returns \c false.
7878
static DeclContext *getEquivalentDeclContextFromSourceFile(DeclContext *DC,
7979
SourceFile *SF) {
8080
auto *newDC = DC;

0 commit comments

Comments
 (0)