1 //===---- CodeCompleteConsumer.h - Code Completion Interface ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the CodeCompleteConsumer class.
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H
14 #define LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H
16 #include "clang/AST/Type.h"
17 #include "clang/AST/CanonicalType.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "clang-c/Index.h"
32 /// \brief Default priority values for code-completion results based
35 /// \brief Priority for the next initialization in a constructor initializer
37 CCP_NextInitializer = 7,
38 /// \brief Priority for a send-to-super completion.
39 CCP_SuperCompletion = 8,
40 /// \brief Priority for a declaration that is in the local scope.
41 CCP_LocalDeclaration = 8,
42 /// \brief Priority for a member declaration found from the current
43 /// method or member function.
44 CCP_MemberDeclaration = 20,
45 /// \brief Priority for a language keyword (that isn't any of the other
48 /// \brief Priority for a code pattern.
50 /// \brief Priority for a non-type declaration.
52 /// \brief Priority for a constant value (e.g., enumerator).
54 /// \brief Priority for a type.
56 /// \brief Priority for a preprocessor macro.
58 /// \brief Priority for a nested-name-specifier.
59 CCP_NestedNameSpecifier = 75,
60 /// \brief Priority for a result that isn't likely to be what the user wants,
61 /// but is included for completeness.
65 /// \brief Priority value deltas that are added to code-completion results
66 /// based on the context of the result.
68 /// \brief The result is in a base class.
70 /// \brief The result is a type match against void.
72 /// Since everything converts to "void", we don't give as drastic an
73 /// adjustment for matching void.
75 /// \brief The result is a C++ non-static member function whose qualifiers
76 /// exactly match the object type on which the member function can be called.
77 CCD_ObjectQualifierMatch = -1,
78 /// \brief The selector of the given message exactly matches the selector
79 /// of the current method, which might imply that some kind of delegation
81 CCD_SelectorMatch = -3
84 /// \brief Priority value factors by which we will divide or multiply the
85 /// priority of a code-completion result.
87 /// \brief Divide by this factor when a code-completion result's type exactly
88 /// matches the type we expect.
89 CCF_ExactTypeMatch = 4,
90 /// \brief Divide by this factor when a code-completion result's type is
91 /// similar to the type we expect (e.g., both arithmetic types, both
92 /// Objective-C object pointer types).
93 CCF_SimilarTypeMatch = 2
96 /// \brief A simplified classification of types used when determining
97 /// "similar" types for code completion.
98 enum SimplifiedTypeClass {
110 /// \brief Determine the simplified type class of the given canonical type.
111 SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T);
113 /// \brief Determine the type that this declaration will have if it is used
114 /// as a type or in an expression.
115 QualType getDeclUsageType(ASTContext &C, NamedDecl *ND);
117 /// \brief Determine the priority to be given to a macro code completion result
118 /// with the given name.
120 /// \param MacroName The name of the macro.
122 /// \param PreferredTypeIsPointer Whether the preferred type for the context
123 /// of this macro is a pointer type.
124 unsigned getMacroUsagePriority(llvm::StringRef MacroName,
125 bool PreferredTypeIsPointer = false);
127 /// \brief Determine the libclang cursor kind associated with the given
129 CXCursorKind getCursorKindForDecl(Decl *D);
133 class FunctionTemplateDecl;
134 class IdentifierInfo;
136 class NestedNameSpecifier;
139 /// \brief The context in which code completion occurred, so that the
140 /// code-completion consumer can process the results accordingly.
141 class CodeCompletionContext {
144 /// \brief An unspecified code-completion context.
146 /// \brief Code completion occurred within a "top-level" completion context,
147 /// e.g., at namespace or global scope.
149 /// \brief Code completion occurred within an Objective-C interface,
150 /// protocol, or category interface.
152 /// \brief Code completion occurred within an Objective-C implementation
153 /// or category implementation.
154 CCC_ObjCImplementation,
155 /// \brief Code completion occurred within the instance variable list of
156 /// an Objective-C interface, implementation, or category implementation.
158 /// \brief Code completion occurred within a class, struct, or union.
159 CCC_ClassStructUnion,
160 /// \brief Code completion occurred where a statement (or declaration) is
161 /// expected in a function, method, or block.
163 /// \brief Code completion occurred where an expression is expected.
165 /// \brief Code completion occurred where an Objective-C message receiver
167 CCC_ObjCMessageReceiver,
168 /// \brief Code completion occurred on the right-hand side of a member
169 /// access expression.
171 /// The results of this completion are the members of the type being
172 /// accessed. The type itself is available via
173 /// \c CodeCompletionContext::getType().
175 /// \brief Code completion occurred after the "enum" keyword, to indicate
176 /// an enumeration name.
178 /// \brief Code completion occurred after the "union" keyword, to indicate
181 /// \brief Code completion occurred after the "struct" or "class" keyword,
182 /// to indicate a struct or class name.
183 CCC_ClassOrStructTag,
184 /// \brief Code completion occurred where a protocol name is expected.
185 CCC_ObjCProtocolName,
186 /// \brief Code completion occurred where a namespace or namespace alias
189 /// \brief Code completion occurred where a type name is expected.
191 /// \brief Code completion occurred where a new name is expected.
193 /// \brief Code completion occurred where a new name is expected and a
194 /// qualified name is permissible.
195 CCC_PotentiallyQualifiedName,
196 /// \brief Code completion occurred where an macro is being defined.
198 /// \brief Code completion occurred where a macro name is expected
199 /// (without any arguments, in the case of a function-like macro).
201 /// \brief Code completion occurred within a preprocessor expression.
202 CCC_PreprocessorExpression,
203 /// \brief Code completion occurred where a preprocessor directive is
205 CCC_PreprocessorDirective,
206 /// \brief Code completion occurred in a context where natural language is
207 /// expected, e.g., a comment or string literal.
209 /// This context usually implies that no completions should be added,
210 /// unless they come from an appropriate natural-language dictionary.
212 /// \brief Code completion for a selector, as in an @selector expression.
214 /// \brief Code completion within a type-qualifier list.
221 /// \brief The type that would prefer to see at this point (e.g., the type
222 /// of an initializer or function parameter).
223 QualType PreferredType;
225 /// \brief The type of the base object in a member access expression.
229 /// \brief Construct a new code-completion context of the given kind.
230 CodeCompletionContext(enum Kind Kind) : Kind(Kind) { }
232 /// \brief Construct a new code-completion context of the given kind.
233 CodeCompletionContext(enum Kind Kind, QualType T) : Kind(Kind) {
234 if (Kind == CCC_MemberAccess)
240 /// \brief Retrieve the kind of code-completion context.
241 enum Kind getKind() const { return Kind; }
243 /// \brief Retrieve the type that this expression would prefer to have, e.g.,
244 /// if the expression is a variable initializer or a function argument, the
245 /// type of the corresponding variable or function parameter.
246 QualType getPreferredType() const { return PreferredType; }
248 /// \brief Retrieve the type of the base object in a member-access
250 QualType getBaseType() const { return BaseType; }
254 /// \brief A "string" used to describe how code completion can
255 /// be performed for an entity.
257 /// A code completion string typically shows how a particular entity can be
258 /// used. For example, the code completion string for a function would show
259 /// the syntax to call it, including the parentheses, placeholders for the
261 class CodeCompletionString {
263 /// \brief The different kinds of "chunks" that can occur within a code
264 /// completion string.
266 /// \brief The piece of text that the user is expected to type to
267 /// match the code-completion string, typically a keyword or the name of a
268 /// declarator or macro.
270 /// \brief A piece of text that should be placed in the buffer, e.g.,
271 /// parentheses or a comma in a function call.
273 /// \brief A code completion string that is entirely optional. For example,
274 /// an optional code completion string that describes the default arguments
275 /// in a function call.
277 /// \brief A string that acts as a placeholder for, e.g., a function
280 /// \brief A piece of text that describes something about the result but
281 /// should not be inserted into the buffer.
283 /// \brief A piece of text that describes the type of an entity or, for
284 /// functions and methods, the return type.
286 /// \brief A piece of text that describes the parameter that corresponds
287 /// to the code-completion location within a function call, message send,
288 /// macro invocation, etc.
290 /// \brief A left parenthesis ('(').
292 /// \brief A right parenthesis (')').
294 /// \brief A left bracket ('[').
296 /// \brief A right bracket (']').
298 /// \brief A left brace ('{').
300 /// \brief A right brace ('}').
302 /// \brief A left angle bracket ('<').
304 /// \brief A right angle bracket ('>').
306 /// \brief A comma separator (',').
308 /// \brief A colon (':').
310 /// \brief A semicolon (';').
312 /// \brief An '=' sign.
314 /// \brief Horizontal whitespace (' ').
316 /// \brief Verticle whitespace ('\n' or '\r\n', depending on the
321 /// \brief One piece of the code completion string.
323 /// \brief The kind of data stored in this piece of the code completion
328 /// \brief The text string associated with a CK_Text, CK_Placeholder,
329 /// CK_Informative, or CK_Comma chunk.
330 /// The string is owned by the chunk and will be deallocated
331 /// (with delete[]) when the chunk is destroyed.
334 /// \brief The code completion string associated with a CK_Optional chunk.
335 /// The optional code completion string is owned by the chunk, and will
336 /// be deallocated (with delete) when the chunk is destroyed.
337 CodeCompletionString *Optional;
340 Chunk() : Kind(CK_Text), Text(0) { }
342 Chunk(ChunkKind Kind, llvm::StringRef Text = "");
344 /// \brief Create a new text chunk.
345 static Chunk CreateText(llvm::StringRef Text);
347 /// \brief Create a new optional chunk.
348 static Chunk CreateOptional(std::auto_ptr<CodeCompletionString> Optional);
350 /// \brief Create a new placeholder chunk.
351 static Chunk CreatePlaceholder(llvm::StringRef Placeholder);
353 /// \brief Create a new informative chunk.
354 static Chunk CreateInformative(llvm::StringRef Informative);
356 /// \brief Create a new result type chunk.
357 static Chunk CreateResultType(llvm::StringRef ResultType);
359 /// \brief Create a new current-parameter chunk.
360 static Chunk CreateCurrentParameter(llvm::StringRef CurrentParameter);
362 /// \brief Clone the given chunk.
365 /// \brief Destroy this chunk, deallocating any memory it owns.
370 /// \brief The chunks stored in this string.
371 llvm::SmallVector<Chunk, 4> Chunks;
373 CodeCompletionString(const CodeCompletionString &); // DO NOT IMPLEMENT
374 CodeCompletionString &operator=(const CodeCompletionString &); // DITTO
377 CodeCompletionString() { }
378 ~CodeCompletionString() { clear(); }
380 typedef llvm::SmallVector<Chunk, 4>::const_iterator iterator;
381 iterator begin() const { return Chunks.begin(); }
382 iterator end() const { return Chunks.end(); }
383 bool empty() const { return Chunks.empty(); }
384 unsigned size() const { return Chunks.size(); }
387 Chunk &operator[](unsigned I) {
388 assert(I < size() && "Chunk index out-of-range");
392 const Chunk &operator[](unsigned I) const {
393 assert(I < size() && "Chunk index out-of-range");
397 /// \brief Add a new typed-text chunk.
398 /// The text string will be copied.
399 void AddTypedTextChunk(llvm::StringRef Text) {
400 Chunks.push_back(Chunk(CK_TypedText, Text));
403 /// \brief Add a new text chunk.
404 /// The text string will be copied.
405 void AddTextChunk(llvm::StringRef Text) {
406 Chunks.push_back(Chunk::CreateText(Text));
409 /// \brief Add a new optional chunk.
410 void AddOptionalChunk(std::auto_ptr<CodeCompletionString> Optional) {
411 Chunks.push_back(Chunk::CreateOptional(Optional));
414 /// \brief Add a new placeholder chunk.
415 /// The placeholder text will be copied.
416 void AddPlaceholderChunk(llvm::StringRef Placeholder) {
417 Chunks.push_back(Chunk::CreatePlaceholder(Placeholder));
420 /// \brief Add a new informative chunk.
421 /// The text will be copied.
422 void AddInformativeChunk(llvm::StringRef Text) {
423 Chunks.push_back(Chunk::CreateInformative(Text));
426 /// \brief Add a new result-type chunk.
427 /// The text will be copied.
428 void AddResultTypeChunk(llvm::StringRef ResultType) {
429 Chunks.push_back(Chunk::CreateResultType(ResultType));
432 /// \brief Add a new current-parameter chunk.
433 /// The text will be copied.
434 void AddCurrentParameterChunk(llvm::StringRef CurrentParameter) {
435 Chunks.push_back(Chunk::CreateCurrentParameter(CurrentParameter));
438 /// \brief Add a new chunk.
439 void AddChunk(Chunk C) { Chunks.push_back(C); }
441 /// \brief Returns the text in the TypedText chunk.
442 const char *getTypedText() const;
444 /// \brief Retrieve a string representation of the code completion string,
445 /// which is mainly useful for debugging.
446 std::string getAsString() const;
448 /// \brief Clone this code-completion string.
450 /// \param Result If non-NULL, points to an empty code-completion
451 /// result that will be given a cloned copy of
452 CodeCompletionString *Clone(CodeCompletionString *Result = 0) const;
454 /// \brief Serialize this code-completion string to the given stream.
455 void Serialize(llvm::raw_ostream &OS) const;
457 /// \brief Deserialize a code-completion string from the given string.
459 /// \returns true if successful, false otherwise.
460 bool Deserialize(const char *&Str, const char *StrEnd);
463 /// \brief Captures a result of code completion.
464 class CodeCompletionResult {
466 /// \brief Describes the kind of result generated.
468 RK_Declaration = 0, //< Refers to a declaration
469 RK_Keyword, //< Refers to a keyword or symbol.
470 RK_Macro, //< Refers to a macro
471 RK_Pattern //< Refers to a precomputed pattern.
474 /// \brief The kind of result stored here.
478 /// \brief When Kind == RK_Declaration, the declaration we are referring
480 NamedDecl *Declaration;
482 /// \brief When Kind == RK_Keyword, the string representing the keyword
483 /// or symbol's spelling.
486 /// \brief When Kind == RK_Pattern, the code-completion string that
487 /// describes the completion text to insert.
488 CodeCompletionString *Pattern;
490 /// \brief When Kind == RK_Macro, the identifier that refers to a macro.
491 IdentifierInfo *Macro;
494 /// \brief The priority of this particular code-completion result.
497 /// \brief The cursor kind that describes this result.
498 CXCursorKind CursorKind;
500 /// \brief The availability of this result.
501 CXAvailabilityKind Availability;
503 /// \brief Specifies which parameter (of a function, Objective-C method,
504 /// macro, etc.) we should start with when formatting the result.
505 unsigned StartParameter;
507 /// \brief Whether this result is hidden by another name.
510 /// \brief Whether this result was found via lookup into a base class.
511 bool QualifierIsInformative : 1;
513 /// \brief Whether this declaration is the beginning of a
514 /// nested-name-specifier and, therefore, should be followed by '::'.
515 bool StartsNestedNameSpecifier : 1;
517 /// \brief Whether all parameters (of a function, Objective-C
518 /// method, etc.) should be considered "informative".
519 bool AllParametersAreInformative : 1;
521 /// \brief Whether we're completing a declaration of the given entity,
522 /// rather than a use of that entity.
523 bool DeclaringEntity : 1;
525 /// \brief If the result should have a nested-name-specifier, this is it.
526 /// When \c QualifierIsInformative, the nested-name-specifier is
527 /// informative rather than required.
528 NestedNameSpecifier *Qualifier;
530 /// \brief Build a result that refers to a declaration.
531 CodeCompletionResult(NamedDecl *Declaration,
532 NestedNameSpecifier *Qualifier = 0,
533 bool QualifierIsInformative = false)
534 : Kind(RK_Declaration), Declaration(Declaration),
535 Priority(getPriorityFromDecl(Declaration)),
536 Availability(CXAvailability_Available), StartParameter(0),
537 Hidden(false), QualifierIsInformative(QualifierIsInformative),
538 StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
539 DeclaringEntity(false), Qualifier(Qualifier) {
540 computeCursorKindAndAvailability();
543 /// \brief Build a result that refers to a keyword or symbol.
544 CodeCompletionResult(const char *Keyword, unsigned Priority = CCP_Keyword)
545 : Kind(RK_Keyword), Keyword(Keyword), Priority(Priority),
546 Availability(CXAvailability_Available),
547 StartParameter(0), Hidden(false), QualifierIsInformative(0),
548 StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
549 DeclaringEntity(false), Qualifier(0) {
550 computeCursorKindAndAvailability();
553 /// \brief Build a result that refers to a macro.
554 CodeCompletionResult(IdentifierInfo *Macro, unsigned Priority = CCP_Macro)
555 : Kind(RK_Macro), Macro(Macro), Priority(Priority),
556 Availability(CXAvailability_Available), StartParameter(0),
557 Hidden(false), QualifierIsInformative(0),
558 StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
559 DeclaringEntity(false), Qualifier(0) {
560 computeCursorKindAndAvailability();
563 /// \brief Build a result that refers to a pattern.
564 CodeCompletionResult(CodeCompletionString *Pattern,
565 unsigned Priority = CCP_CodePattern,
566 CXCursorKind CursorKind = CXCursor_NotImplemented,
567 CXAvailabilityKind Availability = CXAvailability_Available)
568 : Kind(RK_Pattern), Pattern(Pattern), Priority(Priority),
569 CursorKind(CursorKind), Availability(Availability), StartParameter(0),
570 Hidden(false), QualifierIsInformative(0),
571 StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
572 DeclaringEntity(false), Qualifier(0)
576 /// \brief Retrieve the declaration stored in this result.
577 NamedDecl *getDeclaration() const {
578 assert(Kind == RK_Declaration && "Not a declaration result");
582 /// \brief Retrieve the keyword stored in this result.
583 const char *getKeyword() const {
584 assert(Kind == RK_Keyword && "Not a keyword result");
588 /// \brief Create a new code-completion string that describes how to insert
589 /// this result into a program.
591 /// \param S The semantic analysis that created the result.
593 /// \param Result If non-NULL, the already-allocated, empty
594 /// code-completion string that will be populated with the
595 /// appropriate code completion string for this result.
596 CodeCompletionString *CreateCodeCompletionString(Sema &S,
597 CodeCompletionString *Result = 0);
601 /// brief Determine a base priority for the given declaration.
602 static unsigned getPriorityFromDecl(NamedDecl *ND);
605 void computeCursorKindAndAvailability();
608 bool operator<(const CodeCompletionResult &X, const CodeCompletionResult &Y);
610 inline bool operator>(const CodeCompletionResult &X,
611 const CodeCompletionResult &Y) {
615 inline bool operator<=(const CodeCompletionResult &X,
616 const CodeCompletionResult &Y) {
620 inline bool operator>=(const CodeCompletionResult &X,
621 const CodeCompletionResult &Y) {
626 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
627 const CodeCompletionString &CCS);
629 /// \brief Abstract interface for a consumer of code-completion
631 class CodeCompleteConsumer {
633 /// \brief Whether to include macros in the code-completion results.
636 /// \brief Whether to include code patterns (such as for loops) within
637 /// the completion results.
638 bool IncludeCodePatterns;
640 /// \brief Whether to include global (top-level) declarations and names in
641 /// the completion results.
644 /// \brief Whether the output format for the code-completion consumer is
649 class OverloadCandidate {
651 /// \brief Describes the type of overload candidate.
653 /// \brief The candidate is a function declaration.
655 /// \brief The candidate is a function template.
657 /// \brief The "candidate" is actually a variable, expression, or block
658 /// for which we only have a function prototype.
663 /// \brief The kind of overload candidate.
667 /// \brief The function overload candidate, available when
668 /// Kind == CK_Function.
669 FunctionDecl *Function;
671 /// \brief The function template overload candidate, available when
672 /// Kind == CK_FunctionTemplate.
673 FunctionTemplateDecl *FunctionTemplate;
675 /// \brief The function type that describes the entity being called,
676 /// when Kind == CK_FunctionType.
677 const FunctionType *Type;
681 OverloadCandidate(FunctionDecl *Function)
682 : Kind(CK_Function), Function(Function) { }
684 OverloadCandidate(FunctionTemplateDecl *FunctionTemplateDecl)
685 : Kind(CK_FunctionTemplate), FunctionTemplate(FunctionTemplate) { }
687 OverloadCandidate(const FunctionType *Type)
688 : Kind(CK_FunctionType), Type(Type) { }
690 /// \brief Determine the kind of overload candidate.
691 CandidateKind getKind() const { return Kind; }
693 /// \brief Retrieve the function overload candidate or the templated
694 /// function declaration for a function template.
695 FunctionDecl *getFunction() const;
697 /// \brief Retrieve the function template overload candidate.
698 FunctionTemplateDecl *getFunctionTemplate() const {
699 assert(getKind() == CK_FunctionTemplate && "Not a function template");
700 return FunctionTemplate;
703 /// \brief Retrieve the function type of the entity, regardless of how the
704 /// function is stored.
705 const FunctionType *getFunctionType() const;
707 /// \brief Create a new code-completion string that describes the function
708 /// signature of this overload candidate.
709 CodeCompletionString *CreateSignatureString(unsigned CurrentArg,
713 CodeCompleteConsumer() : IncludeMacros(false), IncludeCodePatterns(false),
714 IncludeGlobals(true), OutputIsBinary(false) { }
716 CodeCompleteConsumer(bool IncludeMacros, bool IncludeCodePatterns,
717 bool IncludeGlobals, bool OutputIsBinary)
718 : IncludeMacros(IncludeMacros), IncludeCodePatterns(IncludeCodePatterns),
719 IncludeGlobals(IncludeGlobals), OutputIsBinary(OutputIsBinary) { }
721 /// \brief Whether the code-completion consumer wants to see macros.
722 bool includeMacros() const { return IncludeMacros; }
724 /// \brief Whether the code-completion consumer wants to see code patterns.
725 bool includeCodePatterns() const { return IncludeCodePatterns; }
727 /// \brief Whether to include global (top-level) declaration results.
728 bool includeGlobals() const { return IncludeGlobals; }
730 /// \brief Determine whether the output of this consumer is binary.
731 bool isOutputBinary() const { return OutputIsBinary; }
733 /// \brief Deregisters and destroys this code-completion consumer.
734 virtual ~CodeCompleteConsumer();
736 /// \name Code-completion callbacks
738 /// \brief Process the finalized code-completion results.
739 virtual void ProcessCodeCompleteResults(Sema &S,
740 CodeCompletionContext Context,
741 CodeCompletionResult *Results,
742 unsigned NumResults) { }
744 /// \param S the semantic-analyzer object for which code-completion is being
747 /// \param CurrentArg the index of the current argument.
749 /// \param Candidates an array of overload candidates.
751 /// \param NumCandidates the number of overload candidates
752 virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
753 OverloadCandidate *Candidates,
754 unsigned NumCandidates) { }
758 /// \brief A simple code-completion consumer that prints the results it
759 /// receives in a simple format.
760 class PrintingCodeCompleteConsumer : public CodeCompleteConsumer {
761 /// \brief The raw output stream.
762 llvm::raw_ostream &OS;
765 /// \brief Create a new printing code-completion consumer that prints its
766 /// results to the given raw output stream.
767 PrintingCodeCompleteConsumer(bool IncludeMacros, bool IncludeCodePatterns,
769 llvm::raw_ostream &OS)
770 : CodeCompleteConsumer(IncludeMacros, IncludeCodePatterns, IncludeGlobals,
773 /// \brief Prints the finalized code-completion results.
774 virtual void ProcessCodeCompleteResults(Sema &S,
775 CodeCompletionContext Context,
776 CodeCompletionResult *Results,
777 unsigned NumResults);
779 virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
780 OverloadCandidate *Candidates,
781 unsigned NumCandidates);
784 /// \brief A code-completion consumer that prints the results it receives
785 /// in a format that is parsable by the CIndex library.
786 class CIndexCodeCompleteConsumer : public CodeCompleteConsumer {
787 /// \brief The raw output stream.
788 llvm::raw_ostream &OS;
791 /// \brief Create a new CIndex code-completion consumer that prints its
792 /// results to the given raw output stream in a format readable to the CIndex
794 CIndexCodeCompleteConsumer(bool IncludeMacros, bool IncludeCodePatterns,
795 bool IncludeGlobals, llvm::raw_ostream &OS)
796 : CodeCompleteConsumer(IncludeMacros, IncludeCodePatterns, IncludeGlobals,
799 /// \brief Prints the finalized code-completion results.
800 virtual void ProcessCodeCompleteResults(Sema &S,
801 CodeCompletionContext Context,
802 CodeCompletionResult *Results,
803 unsigned NumResults);
805 virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
806 OverloadCandidate *Candidates,
807 unsigned NumCandidates);
810 } // end namespace clang
812 #endif // LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H