clang  7.0.0svn
CodeCompleteConsumer.h
Go to the documentation of this file.
1 //===- CodeCompleteConsumer.h - Code Completion Interface -------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the CodeCompleteConsumer class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H
15 #define LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H
16 
17 #include "clang-c/Index.h"
18 #include "clang/AST/Type.h"
19 #include "clang/Basic/LLVM.h"
21 #include "clang/Sema/DeclSpec.h"
22 #include "llvm/ADT/ArrayRef.h"
23 #include "llvm/ADT/DenseMap.h"
24 #include "llvm/ADT/None.h"
25 #include "llvm/ADT/Optional.h"
26 #include "llvm/ADT/SmallPtrSet.h"
27 #include "llvm/ADT/SmallVector.h"
28 #include "llvm/ADT/StringRef.h"
29 #include "llvm/Support/Allocator.h"
30 #include "llvm/Support/type_traits.h"
31 #include <cassert>
32 #include <memory>
33 #include <string>
34 #include <utility>
35 
36 namespace clang {
37 
38 class ASTContext;
39 class Decl;
40 class DeclContext;
41 class FunctionDecl;
42 class FunctionTemplateDecl;
43 class IdentifierInfo;
44 class LangOptions;
45 class NamedDecl;
46 class NestedNameSpecifier;
47 class Preprocessor;
48 class Sema;
49 class RawComment;
50 
51 /// Default priority values for code-completion results based
52 /// on their kind.
53 enum {
54  /// Priority for the next initialization in a constructor initializer
55  /// list.
57 
58  /// Priority for an enumeration constant inside a switch whose
59  /// condition is of the enumeration type.
61 
62  /// Priority for a send-to-super completion.
64 
65  /// Priority for a declaration that is in the local scope.
67 
68  /// Priority for a member declaration found from the current
69  /// method or member function.
71 
72  /// Priority for a language keyword (that isn't any of the other
73  /// categories).
75 
76  /// Priority for a code pattern.
78 
79  /// Priority for a non-type declaration.
81 
82  /// Priority for a type.
84 
85  /// Priority for a constant value (e.g., enumerator).
87 
88  /// Priority for a preprocessor macro.
89  CCP_Macro = 70,
90 
91  /// Priority for a nested-name-specifier.
93 
94  /// Priority for a result that isn't likely to be what the user wants,
95  /// but is included for completeness.
97 
98  /// Priority for the Objective-C "_cmd" implicit parameter.
100 };
101 
102 /// Priority value deltas that are added to code-completion results
103 /// based on the context of the result.
104 enum {
105  /// The result is in a base class.
107 
108  /// The result is a C++ non-static member function whose qualifiers
109  /// exactly match the object type on which the member function can be called.
111 
112  /// The selector of the given message exactly matches the selector
113  /// of the current method, which might imply that some kind of delegation
114  /// is occurring.
116 
117  /// Adjustment to the "bool" type in Objective-C, where the typedef
118  /// "BOOL" is preferred.
120 
121  /// Adjustment for KVC code pattern priorities when it doesn't look
122  /// like the
124 
125  /// An Objective-C method being used as a property.
127 
128  /// An Objective-C block property completed as a setter with a
129  /// block placeholder.
131 };
132 
133 /// Priority value factors by which we will divide or multiply the
134 /// priority of a code-completion result.
135 enum {
136  /// Divide by this factor when a code-completion result's type exactly
137  /// matches the type we expect.
139 
140  /// Divide by this factor when a code-completion result's type is
141  /// similar to the type we expect (e.g., both arithmetic types, both
142  /// Objective-C object pointer types).
144 };
145 
146 /// A simplified classification of types used when determining
147 /// "similar" types for code completion.
158 };
159 
160 /// Determine the simplified type class of the given canonical type.
162 
163 /// Determine the type that this declaration will have if it is used
164 /// as a type or in an expression.
166 
167 /// Determine the priority to be given to a macro code completion result
168 /// with the given name.
169 ///
170 /// \param MacroName The name of the macro.
171 ///
172 /// \param LangOpts Options describing the current language dialect.
173 ///
174 /// \param PreferredTypeIsPointer Whether the preferred type for the context
175 /// of this macro is a pointer type.
176 unsigned getMacroUsagePriority(StringRef MacroName,
177  const LangOptions &LangOpts,
178  bool PreferredTypeIsPointer = false);
179 
180 /// Determine the libclang cursor kind associated with the given
181 /// declaration.
183 
184 /// The context in which code completion occurred, so that the
185 /// code-completion consumer can process the results accordingly.
187 public:
188  enum Kind {
189  /// An unspecified code-completion context.
191 
192  /// An unspecified code-completion context where we should also add
193  /// macro completions.
195 
196  /// Code completion occurred within a "top-level" completion context,
197  /// e.g., at namespace or global scope.
199 
200  /// Code completion occurred within an Objective-C interface,
201  /// protocol, or category interface.
203 
204  /// Code completion occurred within an Objective-C implementation
205  /// or category implementation.
207 
208  /// Code completion occurred within the instance variable list of
209  /// an Objective-C interface, implementation, or category implementation.
211 
212  /// Code completion occurred within a class, struct, or union.
214 
215  /// Code completion occurred where a statement (or declaration) is
216  /// expected in a function, method, or block.
218 
219  /// Code completion occurred where an expression is expected.
221 
222  /// Code completion occurred where an Objective-C message receiver
223  /// is expected.
225 
226  /// Code completion occurred on the right-hand side of a member
227  /// access expression using the dot operator.
228  ///
229  /// The results of this completion are the members of the type being
230  /// accessed. The type itself is available via
231  /// \c CodeCompletionContext::getType().
233 
234  /// Code completion occurred on the right-hand side of a member
235  /// access expression using the arrow operator.
236  ///
237  /// The results of this completion are the members of the type being
238  /// accessed. The type itself is available via
239  /// \c CodeCompletionContext::getType().
241 
242  /// Code completion occurred on the right-hand side of an Objective-C
243  /// property access expression.
244  ///
245  /// The results of this completion are the members of the type being
246  /// accessed. The type itself is available via
247  /// \c CodeCompletionContext::getType().
249 
250  /// Code completion occurred after the "enum" keyword, to indicate
251  /// an enumeration name.
253 
254  /// Code completion occurred after the "union" keyword, to indicate
255  /// a union name.
257 
258  /// Code completion occurred after the "struct" or "class" keyword,
259  /// to indicate a struct or class name.
261 
262  /// Code completion occurred where a protocol name is expected.
264 
265  /// Code completion occurred where a namespace or namespace alias
266  /// is expected.
268 
269  /// Code completion occurred where a type name is expected.
271 
272  /// Code completion occurred where a new name is expected.
274 
275  /// Code completion occurred where a new name is expected and a
276  /// qualified name is permissible.
278 
279  /// Code completion occurred where an macro is being defined.
281 
282  /// Code completion occurred where a macro name is expected
283  /// (without any arguments, in the case of a function-like macro).
285 
286  /// Code completion occurred within a preprocessor expression.
288 
289  /// Code completion occurred where a preprocessor directive is
290  /// expected.
292 
293  /// Code completion occurred in a context where natural language is
294  /// expected, e.g., a comment or string literal.
295  ///
296  /// This context usually implies that no completions should be added,
297  /// unless they come from an appropriate natural-language dictionary.
299 
300  /// Code completion for a selector, as in an \@selector expression.
302 
303  /// Code completion within a type-qualifier list.
305 
306  /// Code completion in a parenthesized expression, which means that
307  /// we may also have types here in C and Objective-C (as well as in C++).
309 
310  /// Code completion where an Objective-C instance message is
311  /// expected.
313 
314  /// Code completion where an Objective-C class message is expected.
316 
317  /// Code completion where the name of an Objective-C class is
318  /// expected.
320 
321  /// Code completion where an Objective-C category name is expected.
323 
324  /// An unknown context, in which we are recovering from a parsing
325  /// error and don't know which completions we should give.
327  };
328 
329  using VisitedContextSet = llvm::SmallPtrSet<DeclContext *, 8>;
330 
331 private:
332  Kind CCKind;
333 
334  /// The type that would prefer to see at this point (e.g., the type
335  /// of an initializer or function parameter).
336  QualType PreferredType;
337 
338  /// The type of the base object in a member access expression.
339  QualType BaseType;
340 
341  /// The identifiers for Objective-C selector parts.
342  ArrayRef<IdentifierInfo *> SelIdents;
343 
344  /// The scope specifier that comes before the completion token e.g.
345  /// "a::b::"
346  llvm::Optional<CXXScopeSpec> ScopeSpecifier;
347 
348  /// A set of declaration contexts visited by Sema when doing lookup for
349  /// code completion.
350  VisitedContextSet VisitedContexts;
351 
352 public:
353  /// Construct a new code-completion context of the given kind.
354  CodeCompletionContext(Kind CCKind) : CCKind(CCKind), SelIdents(None) {}
355 
356  /// Construct a new code-completion context of the given kind.
358  ArrayRef<IdentifierInfo *> SelIdents = None)
359  : CCKind(CCKind), SelIdents(SelIdents) {
360  if (CCKind == CCC_DotMemberAccess || CCKind == CCC_ArrowMemberAccess ||
361  CCKind == CCC_ObjCPropertyAccess || CCKind == CCC_ObjCClassMessage ||
362  CCKind == CCC_ObjCInstanceMessage)
363  BaseType = T;
364  else
365  PreferredType = T;
366  }
367 
368  /// Retrieve the kind of code-completion context.
369  Kind getKind() const { return CCKind; }
370 
371  /// Retrieve the type that this expression would prefer to have, e.g.,
372  /// if the expression is a variable initializer or a function argument, the
373  /// type of the corresponding variable or function parameter.
374  QualType getPreferredType() const { return PreferredType; }
375 
376  /// Retrieve the type of the base object in a member-access
377  /// expression.
378  QualType getBaseType() const { return BaseType; }
379 
380  /// Retrieve the Objective-C selector identifiers.
381  ArrayRef<IdentifierInfo *> getSelIdents() const { return SelIdents; }
382 
383  /// Determines whether we want C++ constructors as results within this
384  /// context.
385  bool wantConstructorResults() const;
386 
387  /// Sets the scope specifier that comes before the completion token.
388  /// This is expected to be set in code completions on qualfied specifiers
389  /// (e.g. "a::b::").
391  this->ScopeSpecifier = std::move(SS);
392  }
393 
394  /// Adds a visited context.
396  VisitedContexts.insert(Ctx);
397  }
398 
399  /// Retrieves all visited contexts.
401  return VisitedContexts;
402  }
403 
405  if (ScopeSpecifier)
406  return ScopeSpecifier.getPointer();
407  return llvm::None;
408  }
409 };
410 
411 /// Get string representation of \p Kind, useful for for debugging.
413 
414 /// A "string" used to describe how code completion can
415 /// be performed for an entity.
416 ///
417 /// A code completion string typically shows how a particular entity can be
418 /// used. For example, the code completion string for a function would show
419 /// the syntax to call it, including the parentheses, placeholders for the
420 /// arguments, etc.
422 public:
423  /// The different kinds of "chunks" that can occur within a code
424  /// completion string.
425  enum ChunkKind {
426  /// The piece of text that the user is expected to type to
427  /// match the code-completion string, typically a keyword or the name of a
428  /// declarator or macro.
430 
431  /// A piece of text that should be placed in the buffer, e.g.,
432  /// parentheses or a comma in a function call.
434 
435  /// A code completion string that is entirely optional. For example,
436  /// an optional code completion string that describes the default arguments
437  /// in a function call.
439 
440  /// A string that acts as a placeholder for, e.g., a function
441  /// call argument.
443 
444  /// A piece of text that describes something about the result but
445  /// should not be inserted into the buffer.
447  /// A piece of text that describes the type of an entity or, for
448  /// functions and methods, the return type.
450 
451  /// A piece of text that describes the parameter that corresponds
452  /// to the code-completion location within a function call, message send,
453  /// macro invocation, etc.
455 
456  /// A left parenthesis ('(').
458 
459  /// A right parenthesis (')').
461 
462  /// A left bracket ('[').
464 
465  /// A right bracket (']').
467 
468  /// A left brace ('{').
470 
471  /// A right brace ('}').
473 
474  /// A left angle bracket ('<').
476 
477  /// A right angle bracket ('>').
479 
480  /// A comma separator (',').
482 
483  /// A colon (':').
485 
486  /// A semicolon (';').
488 
489  /// An '=' sign.
491 
492  /// Horizontal whitespace (' ').
494 
495  /// Vertical whitespace ('\\n' or '\\r\\n', depending on the
496  /// platform).
497  CK_VerticalSpace
498  };
499 
500  /// One piece of the code completion string.
501  struct Chunk {
502  /// The kind of data stored in this piece of the code completion
503  /// string.
504  ChunkKind Kind = CK_Text;
505 
506  union {
507  /// The text string associated with a CK_Text, CK_Placeholder,
508  /// CK_Informative, or CK_Comma chunk.
509  /// The string is owned by the chunk and will be deallocated
510  /// (with delete[]) when the chunk is destroyed.
511  const char *Text;
512 
513  /// The code completion string associated with a CK_Optional chunk.
514  /// The optional code completion string is owned by the chunk, and will
515  /// be deallocated (with delete) when the chunk is destroyed.
517  };
518 
519  Chunk() : Text(nullptr) {}
520 
521  explicit Chunk(ChunkKind Kind, const char *Text = "");
522 
523  /// Create a new text chunk.
524  static Chunk CreateText(const char *Text);
525 
526  /// Create a new optional chunk.
527  static Chunk CreateOptional(CodeCompletionString *Optional);
528 
529  /// Create a new placeholder chunk.
530  static Chunk CreatePlaceholder(const char *Placeholder);
531 
532  /// Create a new informative chunk.
533  static Chunk CreateInformative(const char *Informative);
534 
535  /// Create a new result type chunk.
536  static Chunk CreateResultType(const char *ResultType);
537 
538  /// Create a new current-parameter chunk.
539  static Chunk CreateCurrentParameter(const char *CurrentParameter);
540  };
541 
542 private:
543  friend class CodeCompletionBuilder;
544  friend class CodeCompletionResult;
545 
546  /// The number of chunks stored in this string.
547  unsigned NumChunks : 16;
548 
549  /// The number of annotations for this code-completion result.
550  unsigned NumAnnotations : 16;
551 
552  /// The priority of this code-completion string.
553  unsigned Priority : 16;
554 
555  /// The availability of this code-completion result.
556  unsigned Availability : 2;
557 
558  /// The name of the parent context.
559  StringRef ParentName;
560 
561  /// A brief documentation comment attached to the declaration of
562  /// entity being completed by this result.
563  const char *BriefComment;
564 
565  CodeCompletionString(const Chunk *Chunks, unsigned NumChunks,
566  unsigned Priority, CXAvailabilityKind Availability,
567  const char **Annotations, unsigned NumAnnotations,
568  StringRef ParentName,
569  const char *BriefComment);
570  ~CodeCompletionString() = default;
571 
572 public:
573  CodeCompletionString(const CodeCompletionString &) = delete;
574  CodeCompletionString &operator=(const CodeCompletionString &) = delete;
575 
576  using iterator = const Chunk *;
577 
578  iterator begin() const { return reinterpret_cast<const Chunk *>(this + 1); }
579  iterator end() const { return begin() + NumChunks; }
580  bool empty() const { return NumChunks == 0; }
581  unsigned size() const { return NumChunks; }
582 
583  const Chunk &operator[](unsigned I) const {
584  assert(I < size() && "Chunk index out-of-range");
585  return begin()[I];
586  }
587 
588  /// Returns the text in the TypedText chunk.
589  const char *getTypedText() const;
590 
591  /// Retrieve the priority of this code completion result.
592  unsigned getPriority() const { return Priority; }
593 
594  /// Retrieve the availability of this code completion result.
595  unsigned getAvailability() const { return Availability; }
596 
597  /// Retrieve the number of annotations for this code completion result.
598  unsigned getAnnotationCount() const;
599 
600  /// Retrieve the annotation string specified by \c AnnotationNr.
601  const char *getAnnotation(unsigned AnnotationNr) const;
602 
603  /// Retrieve the name of the parent context.
604  StringRef getParentContextName() const {
605  return ParentName;
606  }
607 
608  const char *getBriefComment() const {
609  return BriefComment;
610  }
611 
612  /// Retrieve a string representation of the code completion string,
613  /// which is mainly useful for debugging.
614  std::string getAsString() const;
615 };
616 
617 /// An allocator used specifically for the purpose of code completion.
618 class CodeCompletionAllocator : public llvm::BumpPtrAllocator {
619 public:
620  /// Copy the given string into this allocator.
621  const char *CopyString(const Twine &String);
622 };
623 
624 /// Allocator for a cached set of global code completions.
626 
628  llvm::DenseMap<const DeclContext *, StringRef> ParentNames;
629  std::shared_ptr<GlobalCodeCompletionAllocator> AllocatorRef;
630 
631 public:
633  std::shared_ptr<GlobalCodeCompletionAllocator> Allocator)
634  : AllocatorRef(std::move(Allocator)) {}
635 
636  std::shared_ptr<GlobalCodeCompletionAllocator> getAllocatorRef() const {
637  return AllocatorRef;
638  }
639 
641  assert(AllocatorRef);
642  return *AllocatorRef;
643  }
644 
645  StringRef getParentName(const DeclContext *DC);
646 };
647 
648 } // namespace clang
649 
650 namespace llvm {
651 
652 template <> struct isPodLike<clang::CodeCompletionString::Chunk> {
653  static const bool value = true;
654 };
655 
656 } // namespace llvm
657 
658 namespace clang {
659 
660 /// A builder class used to construct new code-completion strings.
662 public:
664 
665 private:
666  CodeCompletionAllocator &Allocator;
667  CodeCompletionTUInfo &CCTUInfo;
668  unsigned Priority = 0;
670  StringRef ParentName;
671  const char *BriefComment = nullptr;
672 
673  /// The chunks stored in this string.
674  SmallVector<Chunk, 4> Chunks;
675 
676  SmallVector<const char *, 2> Annotations;
677 
678 public:
680  CodeCompletionTUInfo &CCTUInfo)
681  : Allocator(Allocator), CCTUInfo(CCTUInfo) {}
682 
684  CodeCompletionTUInfo &CCTUInfo,
685  unsigned Priority, CXAvailabilityKind Availability)
686  : Allocator(Allocator), CCTUInfo(CCTUInfo), Priority(Priority),
687  Availability(Availability) {}
688 
689  /// Retrieve the allocator into which the code completion
690  /// strings should be allocated.
691  CodeCompletionAllocator &getAllocator() const { return Allocator; }
692 
693  CodeCompletionTUInfo &getCodeCompletionTUInfo() const { return CCTUInfo; }
694 
695  /// Take the resulting completion string.
696  ///
697  /// This operation can only be performed once.
698  CodeCompletionString *TakeString();
699 
700  /// Add a new typed-text chunk.
701  void AddTypedTextChunk(const char *Text);
702 
703  /// Add a new text chunk.
704  void AddTextChunk(const char *Text);
705 
706  /// Add a new optional chunk.
707  void AddOptionalChunk(CodeCompletionString *Optional);
708 
709  /// Add a new placeholder chunk.
710  void AddPlaceholderChunk(const char *Placeholder);
711 
712  /// Add a new informative chunk.
713  void AddInformativeChunk(const char *Text);
714 
715  /// Add a new result-type chunk.
716  void AddResultTypeChunk(const char *ResultType);
717 
718  /// Add a new current-parameter chunk.
719  void AddCurrentParameterChunk(const char *CurrentParameter);
720 
721  /// Add a new chunk.
722  void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text = "");
723 
724  void AddAnnotation(const char *A) { Annotations.push_back(A); }
725 
726  /// Add the parent context information to this code completion.
727  void addParentContext(const DeclContext *DC);
728 
729  const char *getBriefComment() const { return BriefComment; }
730  void addBriefComment(StringRef Comment);
731 
732  StringRef getParentName() const { return ParentName; }
733 };
734 
735 /// Captures a result of code completion.
737 public:
738  /// Describes the kind of result generated.
739  enum ResultKind {
740  /// Refers to a declaration.
741  RK_Declaration = 0,
742 
743  /// Refers to a keyword or symbol.
745 
746  /// Refers to a macro.
748 
749  /// Refers to a precomputed pattern.
750  RK_Pattern
751  };
752 
753  /// When Kind == RK_Declaration or RK_Pattern, the declaration we are
754  /// referring to. In the latter case, the declaration might be NULL.
755  const NamedDecl *Declaration = nullptr;
756 
757  union {
758  /// When Kind == RK_Keyword, the string representing the keyword
759  /// or symbol's spelling.
760  const char *Keyword;
761 
762  /// When Kind == RK_Pattern, the code-completion string that
763  /// describes the completion text to insert.
765 
766  /// When Kind == RK_Macro, the identifier that refers to a macro.
768  };
769 
770  /// The priority of this particular code-completion result.
771  unsigned Priority;
772 
773  /// Specifies which parameter (of a function, Objective-C method,
774  /// macro, etc.) we should start with when formatting the result.
775  unsigned StartParameter = 0;
776 
777  /// The kind of result stored here.
779 
780  /// The cursor kind that describes this result.
782 
783  /// The availability of this result.
785 
786  /// Fix-its that *must* be applied before inserting the text for the
787  /// corresponding completion.
788  ///
789  /// By default, CodeCompletionBuilder only returns completions with empty
790  /// fix-its. Extra completions with non-empty fix-its should be explicitly
791  /// requested by setting CompletionOptions::IncludeFixIts.
792  ///
793  /// For the clients to be able to compute position of the cursor after
794  /// applying fix-its, the following conditions are guaranteed to hold for
795  /// RemoveRange of the stored fix-its:
796  /// - Ranges in the fix-its are guaranteed to never contain the completion
797  /// point (or identifier under completion point, if any) inside them, except
798  /// at the start or at the end of the range.
799  /// - If a fix-it range starts or ends with completion point (or starts or
800  /// ends after the identifier under completion point), it will contain at
801  /// least one character. It allows to unambiguously recompute completion
802  /// point after applying the fix-it.
803  ///
804  /// The intuition is that provided fix-its change code around the identifier
805  /// we complete, but are not allowed to touch the identifier itself or the
806  /// completion point. One example of completions with corrections are the ones
807  /// replacing '.' with '->' and vice versa:
808  ///
809  /// std::unique_ptr<std::vector<int>> vec_ptr;
810  /// In 'vec_ptr.^', one of the completions is 'push_back', it requires
811  /// replacing '.' with '->'.
812  /// In 'vec_ptr->^', one of the completions is 'release', it requires
813  /// replacing '->' with '.'.
814  std::vector<FixItHint> FixIts;
815 
816  /// Whether this result is hidden by another name.
817  bool Hidden : 1;
818 
819  /// Whether this result was found via lookup into a base class.
821 
822  /// Whether this declaration is the beginning of a
823  /// nested-name-specifier and, therefore, should be followed by '::'.
825 
826  /// Whether all parameters (of a function, Objective-C
827  /// method, etc.) should be considered "informative".
829 
830  /// Whether we're completing a declaration of the given entity,
831  /// rather than a use of that entity.
832  bool DeclaringEntity : 1;
833 
834  /// If the result should have a nested-name-specifier, this is it.
835  /// When \c QualifierIsInformative, the nested-name-specifier is
836  /// informative rather than required.
837  NestedNameSpecifier *Qualifier = nullptr;
838 
839  /// Build a result that refers to a declaration.
840  CodeCompletionResult(const NamedDecl *Declaration, unsigned Priority,
841  NestedNameSpecifier *Qualifier = nullptr,
842  bool QualifierIsInformative = false,
843  bool Accessible = true,
844  std::vector<FixItHint> FixIts = std::vector<FixItHint>())
845  : Declaration(Declaration), Priority(Priority), Kind(RK_Declaration),
846  FixIts(std::move(FixIts)), Hidden(false),
847  QualifierIsInformative(QualifierIsInformative),
848  StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
849  DeclaringEntity(false), Qualifier(Qualifier) {
850  //FIXME: Add assert to check FixIts range requirements.
851  computeCursorKindAndAvailability(Accessible);
852  }
853 
854  /// Build a result that refers to a keyword or symbol.
855  CodeCompletionResult(const char *Keyword, unsigned Priority = CCP_Keyword)
856  : Keyword(Keyword), Priority(Priority), Kind(RK_Keyword),
857  CursorKind(CXCursor_NotImplemented), Hidden(false),
858  QualifierIsInformative(false), StartsNestedNameSpecifier(false),
859  AllParametersAreInformative(false), DeclaringEntity(false) {}
860 
861  /// Build a result that refers to a macro.
863  unsigned Priority = CCP_Macro)
864  : Macro(Macro), Priority(Priority), Kind(RK_Macro),
865  CursorKind(CXCursor_MacroDefinition), Hidden(false),
866  QualifierIsInformative(false), StartsNestedNameSpecifier(false),
867  AllParametersAreInformative(false), DeclaringEntity(false) {}
868 
869  /// Build a result that refers to a pattern.
871  unsigned Priority = CCP_CodePattern,
874  const NamedDecl *D = nullptr)
875  : Declaration(D), Pattern(Pattern), Priority(Priority), Kind(RK_Pattern),
876  CursorKind(CursorKind), Availability(Availability), Hidden(false),
877  QualifierIsInformative(false), StartsNestedNameSpecifier(false),
878  AllParametersAreInformative(false), DeclaringEntity(false) {}
879 
880  /// Build a result that refers to a pattern with an associated
881  /// declaration.
883  unsigned Priority)
884  : Declaration(D), Pattern(Pattern), Priority(Priority), Kind(RK_Pattern),
885  Hidden(false), QualifierIsInformative(false),
886  StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
887  DeclaringEntity(false) {
888  computeCursorKindAndAvailability();
889  }
890 
891  /// Retrieve the declaration stored in this result.
892  const NamedDecl *getDeclaration() const {
893  assert(Kind == RK_Declaration && "Not a declaration result");
894  return Declaration;
895  }
896 
897  /// Retrieve the keyword stored in this result.
898  const char *getKeyword() const {
899  assert(Kind == RK_Keyword && "Not a keyword result");
900  return Keyword;
901  }
902 
903  /// Create a new code-completion string that describes how to insert
904  /// this result into a program.
905  ///
906  /// \param S The semantic analysis that created the result.
907  ///
908  /// \param Allocator The allocator that will be used to allocate the
909  /// string itself.
910  CodeCompletionString *CreateCodeCompletionString(Sema &S,
911  const CodeCompletionContext &CCContext,
912  CodeCompletionAllocator &Allocator,
913  CodeCompletionTUInfo &CCTUInfo,
914  bool IncludeBriefComments);
915  CodeCompletionString *CreateCodeCompletionString(ASTContext &Ctx,
916  Preprocessor &PP,
917  const CodeCompletionContext &CCContext,
918  CodeCompletionAllocator &Allocator,
919  CodeCompletionTUInfo &CCTUInfo,
920  bool IncludeBriefComments);
921 
922  /// Retrieve the name that should be used to order a result.
923  ///
924  /// If the name needs to be constructed as a string, that string will be
925  /// saved into Saved and the returned StringRef will refer to it.
926  StringRef getOrderedName(std::string &Saved) const;
927 
928 private:
929  void computeCursorKindAndAvailability(bool Accessible = true);
930 };
931 
933 
934 inline bool operator>(const CodeCompletionResult &X,
935  const CodeCompletionResult &Y) {
936  return Y < X;
937 }
938 
939 inline bool operator<=(const CodeCompletionResult &X,
940  const CodeCompletionResult &Y) {
941  return !(Y < X);
942 }
943 
944 inline bool operator>=(const CodeCompletionResult &X,
945  const CodeCompletionResult &Y) {
946  return !(X < Y);
947 }
948 
949 raw_ostream &operator<<(raw_ostream &OS,
950  const CodeCompletionString &CCS);
951 
952 /// Abstract interface for a consumer of code-completion
953 /// information.
955 protected:
957 
958  /// Whether the output format for the code-completion consumer is
959  /// binary.
961 
962 public:
964  public:
965  /// Describes the type of overload candidate.
967  /// The candidate is a function declaration.
969 
970  /// The candidate is a function template.
972 
973  /// The "candidate" is actually a variable, expression, or block
974  /// for which we only have a function prototype.
975  CK_FunctionType
976  };
977 
978  private:
979  /// The kind of overload candidate.
981 
982  union {
983  /// The function overload candidate, available when
984  /// Kind == CK_Function.
986 
987  /// The function template overload candidate, available when
988  /// Kind == CK_FunctionTemplate.
990 
991  /// The function type that describes the entity being called,
992  /// when Kind == CK_FunctionType.
994  };
995 
996  public:
998  : Kind(CK_Function), Function(Function) {}
999 
1001  : Kind(CK_FunctionTemplate), FunctionTemplate(FunctionTemplateDecl) {}
1002 
1004  : Kind(CK_FunctionType), Type(Type) {}
1005 
1006  /// Determine the kind of overload candidate.
1007  CandidateKind getKind() const { return Kind; }
1008 
1009  /// Retrieve the function overload candidate or the templated
1010  /// function declaration for a function template.
1011  FunctionDecl *getFunction() const;
1012 
1013  /// Retrieve the function template overload candidate.
1015  assert(getKind() == CK_FunctionTemplate && "Not a function template");
1016  return FunctionTemplate;
1017  }
1018 
1019  /// Retrieve the function type of the entity, regardless of how the
1020  /// function is stored.
1021  const FunctionType *getFunctionType() const;
1022 
1023  /// Create a new code-completion string that describes the function
1024  /// signature of this overload candidate.
1025  CodeCompletionString *CreateSignatureString(unsigned CurrentArg,
1026  Sema &S,
1027  CodeCompletionAllocator &Allocator,
1028  CodeCompletionTUInfo &CCTUInfo,
1029  bool IncludeBriefComments) const;
1030  };
1031 
1033  bool OutputIsBinary)
1034  : CodeCompleteOpts(CodeCompleteOpts), OutputIsBinary(OutputIsBinary) {}
1035 
1036  /// Whether the code-completion consumer wants to see macros.
1037  bool includeMacros() const {
1038  return CodeCompleteOpts.IncludeMacros;
1039  }
1040 
1041  /// Whether the code-completion consumer wants to see code patterns.
1042  bool includeCodePatterns() const {
1043  return CodeCompleteOpts.IncludeCodePatterns;
1044  }
1045 
1046  /// Whether to include global (top-level) declaration results.
1047  bool includeGlobals() const { return CodeCompleteOpts.IncludeGlobals; }
1048 
1049  /// Whether to include declarations in namespace contexts (including
1050  /// the global namespace). If this is false, `includeGlobals()` will be
1051  /// ignored.
1053  return CodeCompleteOpts.IncludeNamespaceLevelDecls;
1054  }
1055 
1056  /// Whether to include brief documentation comments within the set of
1057  /// code completions returned.
1058  bool includeBriefComments() const {
1059  return CodeCompleteOpts.IncludeBriefComments;
1060  }
1061 
1062  /// Whether to include completion items with small fix-its, e.g. change
1063  /// '.' to '->' on member access, etc.
1064  bool includeFixIts() const { return CodeCompleteOpts.IncludeFixIts; }
1065 
1066  /// Hint whether to load data from the external AST in order to provide
1067  /// full results. If false, declarations from the preamble may be omitted.
1068  bool loadExternal() const {
1069  return CodeCompleteOpts.LoadExternal;
1070  }
1071 
1072  /// Determine whether the output of this consumer is binary.
1073  bool isOutputBinary() const { return OutputIsBinary; }
1074 
1075  /// Deregisters and destroys this code-completion consumer.
1076  virtual ~CodeCompleteConsumer();
1077 
1078  /// \name Code-completion filtering
1079  /// Check if the result should be filtered out.
1080  virtual bool isResultFilteredOut(StringRef Filter,
1081  CodeCompletionResult Results) {
1082  return false;
1083  }
1084 
1085  /// \name Code-completion callbacks
1086  //@{
1087  /// Process the finalized code-completion results.
1089  CodeCompletionContext Context,
1090  CodeCompletionResult *Results,
1091  unsigned NumResults) {}
1092 
1093  /// \param S the semantic-analyzer object for which code-completion is being
1094  /// done.
1095  ///
1096  /// \param CurrentArg the index of the current argument.
1097  ///
1098  /// \param Candidates an array of overload candidates.
1099  ///
1100  /// \param NumCandidates the number of overload candidates
1101  virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
1102  OverloadCandidate *Candidates,
1103  unsigned NumCandidates) {}
1104  //@}
1105 
1106  /// Retrieve the allocator that will be used to allocate
1107  /// code completion strings.
1108  virtual CodeCompletionAllocator &getAllocator() = 0;
1109 
1110  virtual CodeCompletionTUInfo &getCodeCompletionTUInfo() = 0;
1111 };
1112 
1113 /// Get the documentation comment used to produce
1114 /// CodeCompletionString::BriefComment for RK_Declaration.
1115 const RawComment *getCompletionComment(const ASTContext &Ctx,
1116  const NamedDecl *Decl);
1117 
1118 /// Get the documentation comment used to produce
1119 /// CodeCompletionString::BriefComment for RK_Pattern.
1121  const NamedDecl *Decl);
1122 
1123 /// Get the documentation comment used to produce
1124 /// CodeCompletionString::BriefComment for OverloadCandidate.
1125 const RawComment *
1126 getParameterComment(const ASTContext &Ctx,
1128  unsigned ArgIndex);
1129 
1130 /// A simple code-completion consumer that prints the results it
1131 /// receives in a simple format.
1133  /// The raw output stream.
1134  raw_ostream &OS;
1135 
1136  CodeCompletionTUInfo CCTUInfo;
1137 
1138 public:
1139  /// Create a new printing code-completion consumer that prints its
1140  /// results to the given raw output stream.
1142  raw_ostream &OS)
1143  : CodeCompleteConsumer(CodeCompleteOpts, false), OS(OS),
1144  CCTUInfo(std::make_shared<GlobalCodeCompletionAllocator>()) {}
1145 
1146  /// Prints the finalized code-completion results.
1147  void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context,
1148  CodeCompletionResult *Results,
1149  unsigned NumResults) override;
1150 
1151  void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
1152  OverloadCandidate *Candidates,
1153  unsigned NumCandidates) override;
1154 
1155  bool isResultFilteredOut(StringRef Filter, CodeCompletionResult Results) override;
1156 
1158  return CCTUInfo.getAllocator();
1159  }
1160 
1161  CodeCompletionTUInfo &getCodeCompletionTUInfo() override { return CCTUInfo; }
1162 };
1163 
1164 } // namespace clang
1165 
1166 #endif // LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H
One piece of the code completion string.
An unknown context, in which we are recovering from a parsing error and don&#39;t know which completions ...
A code completion string that is entirely optional.
CXAvailabilityKind
Describes the availability of a particular entity, which indicates whether the use of this entity wil...
Definition: Index.h:131
Priority for a declaration that is in the local scope.
CodeCompletionAllocator & getAllocator() const
Represents a function declaration or definition.
Definition: Decl.h:1714
llvm::SmallPtrSet< DeclContext *, 8 > VisitedContextSet
ResultKind Kind
The kind of result stored here.
An Objective-C method being used as a property.
CodeCompletionResult(const IdentifierInfo *Macro, unsigned Priority=CCP_Macro)
Build a result that refers to a macro.
std::vector< FixItHint > FixIts
Fix-its that must be applied before inserting the text for the corresponding completion.
const FunctionType * Type
The function type that describes the entity being called, when Kind == CK_FunctionType.
CXCursorKind CursorKind
The cursor kind that describes this result.
A (possibly-)qualified type.
Definition: Type.h:654
unsigned IncludeBriefComments
Show brief documentation comments in code completion results.
llvm::Optional< const CXXScopeSpec * > getCXXScopeSpecifier()
Code completion for a selector, as in an @selector expression.
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:30
unsigned IncludeGlobals
Show top-level decls in code completion results.
unsigned getMacroUsagePriority(StringRef MacroName, const LangOptions &LangOpts, bool PreferredTypeIsPointer=false)
Determine the priority to be given to a macro code completion result with the given name...
Code completion where an Objective-C class message is expected.
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3147
CodeCompletionResult(const NamedDecl *Declaration, unsigned Priority, NestedNameSpecifier *Qualifier=nullptr, bool QualifierIsInformative=false, bool Accessible=true, std::vector< FixItHint > FixIts=std::vector< FixItHint >())
Build a result that refers to a declaration.
C Language Family Type Representation.
Code completion within a type-qualifier list.
static void AddResultTypeChunk(ASTContext &Context, const PrintingPolicy &Policy, const NamedDecl *ND, QualType BaseType, CodeCompletionBuilder &Result)
If the given declaration has an associated type, add it as a result type chunk.
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
CandidateKind
Describes the type of overload candidate.
Adjustment for KVC code pattern priorities when it doesn&#39;t look like the.
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
Definition: Attr.h:322
The base class of the type hierarchy.
Definition: Type.h:1420
An unspecified code-completion context.
Allocator for a cached set of global code completions.
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
An Objective-C block property completed as a setter with a block placeholder.
bool loadExternal() const
Hint whether to load data from the external AST in order to provide full results. ...
Code completion occurred where an Objective-C message receiver is expected.
unsigned Priority
The priority of this particular code-completion result.
Code completion occurred on the right-hand side of a member access expression using the arrow operato...
ChunkKind
The different kinds of "chunks" that can occur within a code completion string.
Code completion occurred after the "enum" keyword, to indicate an enumeration name.
bool isOutputBinary() const
Determine whether the output of this consumer is binary.
A piece of text that describes the type of an entity or, for functions and methods, the return type.
bool StartsNestedNameSpecifier
Whether this declaration is the beginning of a nested-name-specifier and, therefore, should be followed by &#39;::&#39;.
const char * Keyword
When Kind == RK_Keyword, the string representing the keyword or symbol&#39;s spelling.
Priority for an enumeration constant inside a switch whose condition is of the enumeration type...
Code completion occurred within the instance variable list of an Objective-C interface, implementation, or category implementation.
bool operator<=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
CodeCompletionBuilder(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, unsigned Priority, CXAvailabilityKind Availability)
One of these records is kept for each identifier that is lexed.
OverloadCandidate(FunctionTemplateDecl *FunctionTemplateDecl)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:150
A "string" used to describe how code completion can be performed for an entity.
Adjustment to the "bool" type in Objective-C, where the typedef "BOOL" is preferred.
Definition: Format.h:2022
Kind getKind() const
Retrieve the kind of code-completion context.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:50
bool operator>(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
Priority for a language keyword (that isn&#39;t any of the other categories).
unsigned IncludeCodePatterns
Show code patterns in code completion results.
An allocator used specifically for the purpose of code completion.
CodeCompletionString * Pattern
When Kind == RK_Pattern, the code-completion string that describes the completion text to insert...
Priority for a nested-name-specifier.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
Code completion occurred where a preprocessor directive is expected.
Code completion occurred within an Objective-C implementation or category implementation.
bool QualifierIsInformative
Whether this result was found via lookup into a base class.
Priority for the Objective-C "_cmd" implicit parameter.
FunctionTemplateDecl * FunctionTemplate
The function template overload candidate, available when Kind == CK_FunctionTemplate.
QualType getDeclUsageType(ASTContext &C, const NamedDecl *ND)
Determine the type that this declaration will have if it is used as a type or in an expression...
Code completion occurred where a namespace or namespace alias is expected.
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:63
The piece of text that the user is expected to type to match the code-completion string, typically a keyword or the name of a declarator or macro.
A comma separator (&#39;,&#39;).
bool wantConstructorResults() const
Determines whether we want C++ constructors as results within this context.
CXCursorKind
Describes the kind of entity that a cursor refers to.
Definition: Index.h:1705
FunctionTemplateDecl * getFunctionTemplate() const
Retrieve the function template overload candidate.
CodeCompletionAllocator & getAllocator() const
Retrieve the allocator into which the code completion strings should be allocated.
A right parenthesis (&#39;)&#39;).
Code completion where an Objective-C category name is expected.
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:276
Code completion occurred within a "top-level" completion context, e.g., at namespace or global scope...
CodeCompletionTUInfo & getCodeCompletionTUInfo() override
Code completion occurred where a protocol name is expected.
CXCursorKind getCursorKindForDecl(const Decl *D)
Determine the libclang cursor kind associated with the given declaration.
const RawComment * getCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Declaration...
A simple code-completion consumer that prints the results it receives in a simple format...
QualType getPreferredType() const
Retrieve the type that this expression would prefer to have, e.g., if the expression is a variable in...
llvm::StringRef getCompletionKindString(CodeCompletionContext::Kind Kind)
Get string representation of Kind, useful for for debugging.
Code completion occurred where a new name is expected.
Divide by this factor when a code-completion result&#39;s type is similar to the type we expect (e...
llvm::StringRef getAsString(SyncScope S)
Definition: SyncScope.h:51
const FunctionProtoType * T
CodeCompletionResult(CodeCompletionString *Pattern, const NamedDecl *D, unsigned Priority)
Build a result that refers to a pattern with an associated declaration.
const char * Text
The text string associated with a CK_Text, CK_Placeholder, CK_Informative, or CK_Comma chunk...
This file defines the classes used to store parsed information about declaration-specifiers and decla...
virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Process the finalized code-completion results.
void addVisitedContext(DeclContext *Ctx)
Adds a visited context.
unsigned IncludeNamespaceLevelDecls
Show decls in namespace (including the global namespace) in code completion results.
Captures a result of code completion.
ArrayRef< IdentifierInfo * > getSelIdents() const
Retrieve the Objective-C selector identifiers.
Code completion occurred where a new name is expected and a qualified name is permissible.
CodeCompletionContext(Kind CCKind)
Construct a new code-completion context of the given kind.
std::shared_ptr< GlobalCodeCompletionAllocator > getAllocatorRef() const
Priority for a member declaration found from the current method or member function.
Code completion in a parenthesized expression, which means that we may also have types here in C and ...
Code completion occurred in a context where natural language is expected, e.g., a comment or string l...
Divide by this factor when a code-completion result&#39;s type exactly matches the type we expect...
virtual bool isResultFilteredOut(StringRef Filter, CodeCompletionResult Results)
FunctionDecl * Function
The function overload candidate, available when Kind == CK_Function.
Priority for a result that isn&#39;t likely to be what the user wants, but is included for completeness...
A piece of text that should be placed in the buffer, e.g., parentheses or a comma in a function call...
The result type of a method or function.
StringRef getParentContextName() const
Retrieve the name of the parent context.
CandidateKind getKind() const
Determine the kind of overload candidate.
CodeCompletionString * Optional
The code completion string associated with a CK_Optional chunk.
The context in which code completion occurred, so that the code-completion consumer can process the r...
const IdentifierInfo * Macro
When Kind == RK_Macro, the identifier that refers to a macro.
The result is in a base class.
PrintingCodeCompleteConsumer(const CodeCompleteOptions &CodeCompleteOpts, raw_ostream &OS)
Create a new printing code-completion consumer that prints its results to the given raw output stream...
Code completion occurred within a class, struct, or union.
const VisitedContextSet & getVisitedContexts() const
Retrieves all visited contexts.
#define false
Definition: stdbool.h:33
const char * getBriefComment() const
Code completion where the name of an Objective-C class is expected.
const Chunk & operator[](unsigned I) const
Code completion occurred within an Objective-C interface, protocol, or category interface.
CodeCompleteConsumer(const CodeCompleteOptions &CodeCompleteOpts, bool OutputIsBinary)
virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
The entity is available.
Definition: Index.h:135
SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T)
Determine the simplified type class of the given canonical type.
const RawComment * getParameterComment(const ASTContext &Ctx, const CodeCompleteConsumer::OverloadCandidate &Result, unsigned ArgIndex)
Get the documentation comment used to produce CodeCompletionString::BriefComment for OverloadCandidat...
bool operator>=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
const char * getBriefComment() const
bool includeMacros() const
Whether the code-completion consumer wants to see macros.
CodeCompletionTUInfo & getCodeCompletionTUInfo() const
Abstract interface for a consumer of code-completion information.
Options controlling the behavior of code completion.
Dataflow Directional Tag Classes.
Priority for a type.
Code completion occurred where an macro is being defined.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1262
A piece of text that describes something about the result but should not be inserted into the buffer...
Priority for a send-to-super completion.
Code completion occurred after the "struct" or "class" keyword, to indicate a struct or class name...
CodeCompletionResult(CodeCompletionString *Pattern, unsigned Priority=CCP_CodePattern, CXCursorKind CursorKind=CXCursor_NotImplemented, CXAvailabilityKind Availability=CXAvailability_Available, const NamedDecl *D=nullptr)
Build a result that refers to a pattern.
Code completion occurred after the "union" keyword, to indicate a union name.
Code completion occurred where a macro name is expected (without any arguments, in the case of a func...
bool includeFixIts() const
Whether to include completion items with small fix-its, e.g.
A builder class used to construct new code-completion strings.
Code completion where an Objective-C instance message is expected.
const RawComment * getPatternCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Pattern...
The result is a C++ non-static member function whose qualifiers exactly match the object type on whic...
const char * getKeyword() const
Retrieve the keyword stored in this result.
Priority for a constant value (e.g., enumerator).
Code completion occurred where a statement (or declaration) is expected in a function, method, or block.
Code completion occurred on the right-hand side of an Objective-C property access expression...
const CodeCompleteOptions CodeCompleteOpts
CodeCompletionResult(const char *Keyword, unsigned Priority=CCP_Keyword)
Build a result that refers to a keyword or symbol.
const NamedDecl * getDeclaration() const
Retrieve the declaration stored in this result.
Priority for a preprocessor macro.
QualType getBaseType() const
Retrieve the type of the base object in a member-access expression.
bool includeBriefComments() const
Whether to include brief documentation comments within the set of code completions returned...
A piece of text that describes the parameter that corresponds to the code-completion location within ...
A string that acts as a placeholder for, e.g., a function call argument.
CodeCompletionContext(Kind CCKind, QualType T, ArrayRef< IdentifierInfo *> SelIdents=None)
Construct a new code-completion context of the given kind.
bool Hidden
Whether this result is hidden by another name.
unsigned getAvailability() const
Retrieve the availability of this code completion result.
A left parenthesis (&#39;(&#39;).
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Definition: SemaDecl.cpp:13462
Code completion occurred within a preprocessor expression.
Code completion occurred where an expression is expected.
Priority for a code pattern.
bool AllParametersAreInformative
Whether all parameters (of a function, Objective-C method, etc.) should be considered "informative"...
An unspecified code-completion context where we should also add macro completions.
CodeCompletionAllocator & getAllocator() override
Retrieve the allocator that will be used to allocate code completion strings.
unsigned IncludeFixIts
Include results after corrections (small fix-its), e.g.
A left angle bracket (&#39;<&#39;).
void setCXXScopeSpecifier(CXXScopeSpec SS)
Sets the scope specifier that comes before the completion token.
A right angle bracket (&#39;>&#39;).
bool OutputIsBinary
Whether the output format for the code-completion consumer is binary.
ResultKind
Describes the kind of result generated.
The selector of the given message exactly matches the selector of the current method, which might imply that some kind of delegation is occurring.
CodeCompletionTUInfo(std::shared_ptr< GlobalCodeCompletionAllocator > Allocator)
unsigned LoadExternal
Hint whether to load data from the external AST to provide full results.
Code completion occurred on the right-hand side of a member access expression using the dot operator...
SimplifiedTypeClass
A simplified classification of types used when determining "similar" types for code completion...
Code completion occurred where a type name is expected.
Horizontal whitespace (&#39; &#39;).
bool includeCodePatterns() const
Whether the code-completion consumer wants to see code patterns.
StringRef Text
Definition: Format.cpp:1599
bool DeclaringEntity
Whether we&#39;re completing a declaration of the given entity, rather than a use of that entity...
unsigned getPriority() const
Retrieve the priority of this code completion result.
unsigned IncludeMacros
Show macros in code completion results.
CodeCompletionBuilder(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo)
This represents a decl that may have a name.
Definition: Decl.h:248
bool includeNamespaceLevelDecls() const
Whether to include declarations in namespace contexts (including the global namespace).
Declaration of a template function.
Definition: DeclTemplate.h:968
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:127
bool includeGlobals() const
Whether to include global (top-level) declaration results.
Priority for a non-type declaration.
Priority for the next initialization in a constructor initializer list.