clang  8.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 RawComment;
49 class Sema;
50 class UsingShadowDecl;
51 
52 /// Default priority values for code-completion results based
53 /// on their kind.
54 enum {
55  /// Priority for the next initialization in a constructor initializer
56  /// list.
58 
59  /// Priority for an enumeration constant inside a switch whose
60  /// condition is of the enumeration type.
62 
63  /// Priority for a send-to-super completion.
65 
66  /// Priority for a declaration that is in the local scope.
68 
69  /// Priority for a member declaration found from the current
70  /// method or member function.
72 
73  /// Priority for a language keyword (that isn't any of the other
74  /// categories).
76 
77  /// Priority for a code pattern.
79 
80  /// Priority for a non-type declaration.
82 
83  /// Priority for a type.
85 
86  /// Priority for a constant value (e.g., enumerator).
88 
89  /// Priority for a preprocessor macro.
90  CCP_Macro = 70,
91 
92  /// Priority for a nested-name-specifier.
94 
95  /// Priority for a result that isn't likely to be what the user wants,
96  /// but is included for completeness.
98 
99  /// Priority for the Objective-C "_cmd" implicit parameter.
101 };
102 
103 /// Priority value deltas that are added to code-completion results
104 /// based on the context of the result.
105 enum {
106  /// The result is in a base class.
108 
109  /// The result is a C++ non-static member function whose qualifiers
110  /// exactly match the object type on which the member function can be called.
112 
113  /// The selector of the given message exactly matches the selector
114  /// of the current method, which might imply that some kind of delegation
115  /// is occurring.
117 
118  /// Adjustment to the "bool" type in Objective-C, where the typedef
119  /// "BOOL" is preferred.
121 
122  /// Adjustment for KVC code pattern priorities when it doesn't look
123  /// like the
125 
126  /// An Objective-C method being used as a property.
128 
129  /// An Objective-C block property completed as a setter with a
130  /// block placeholder.
132 };
133 
134 /// Priority value factors by which we will divide or multiply the
135 /// priority of a code-completion result.
136 enum {
137  /// Divide by this factor when a code-completion result's type exactly
138  /// matches the type we expect.
140 
141  /// Divide by this factor when a code-completion result's type is
142  /// similar to the type we expect (e.g., both arithmetic types, both
143  /// Objective-C object pointer types).
145 };
146 
147 /// A simplified classification of types used when determining
148 /// "similar" types for code completion.
159 };
160 
161 /// Determine the simplified type class of the given canonical type.
163 
164 /// Determine the type that this declaration will have if it is used
165 /// as a type or in an expression.
167 
168 /// Determine the priority to be given to a macro code completion result
169 /// with the given name.
170 ///
171 /// \param MacroName The name of the macro.
172 ///
173 /// \param LangOpts Options describing the current language dialect.
174 ///
175 /// \param PreferredTypeIsPointer Whether the preferred type for the context
176 /// of this macro is a pointer type.
177 unsigned getMacroUsagePriority(StringRef MacroName,
178  const LangOptions &LangOpts,
179  bool PreferredTypeIsPointer = false);
180 
181 /// Determine the libclang cursor kind associated with the given
182 /// declaration.
184 
185 /// The context in which code completion occurred, so that the
186 /// code-completion consumer can process the results accordingly.
188 public:
189  enum Kind {
190  /// An unspecified code-completion context.
192 
193  /// An unspecified code-completion context where we should also add
194  /// macro completions.
196 
197  /// Code completion occurred within a "top-level" completion context,
198  /// e.g., at namespace or global scope.
200 
201  /// Code completion occurred within an Objective-C interface,
202  /// protocol, or category interface.
204 
205  /// Code completion occurred within an Objective-C implementation
206  /// or category implementation.
208 
209  /// Code completion occurred within the instance variable list of
210  /// an Objective-C interface, implementation, or category implementation.
212 
213  /// Code completion occurred within a class, struct, or union.
215 
216  /// Code completion occurred where a statement (or declaration) is
217  /// expected in a function, method, or block.
219 
220  /// Code completion occurred where an expression is expected.
222 
223  /// Code completion occurred where an Objective-C message receiver
224  /// is expected.
226 
227  /// Code completion occurred on the right-hand side of a member
228  /// access expression using the dot operator.
229  ///
230  /// The results of this completion are the members of the type being
231  /// accessed. The type itself is available via
232  /// \c CodeCompletionContext::getType().
234 
235  /// Code completion occurred on the right-hand side of a member
236  /// access expression using the arrow operator.
237  ///
238  /// The results of this completion are the members of the type being
239  /// accessed. The type itself is available via
240  /// \c CodeCompletionContext::getType().
242 
243  /// Code completion occurred on the right-hand side of an Objective-C
244  /// property access expression.
245  ///
246  /// The results of this completion are the members of the type being
247  /// accessed. The type itself is available via
248  /// \c CodeCompletionContext::getType().
250 
251  /// Code completion occurred after the "enum" keyword, to indicate
252  /// an enumeration name.
254 
255  /// Code completion occurred after the "union" keyword, to indicate
256  /// a union name.
258 
259  /// Code completion occurred after the "struct" or "class" keyword,
260  /// to indicate a struct or class name.
262 
263  /// Code completion occurred where a protocol name is expected.
265 
266  /// Code completion occurred where a namespace or namespace alias
267  /// is expected.
269 
270  /// Code completion occurred where a type name is expected.
272 
273  /// Code completion occurred where a new name is expected.
275 
276  /// Code completion occurred where a new name is expected and a
277  /// qualified name is permissible.
279 
280  /// Code completion occurred where an macro is being defined.
282 
283  /// Code completion occurred where a macro name is expected
284  /// (without any arguments, in the case of a function-like macro).
286 
287  /// Code completion occurred within a preprocessor expression.
289 
290  /// Code completion occurred where a preprocessor directive is
291  /// expected.
293 
294  /// Code completion occurred in a context where natural language is
295  /// expected, e.g., a comment or string literal.
296  ///
297  /// This context usually implies that no completions should be added,
298  /// unless they come from an appropriate natural-language dictionary.
300 
301  /// Code completion for a selector, as in an \@selector expression.
303 
304  /// Code completion within a type-qualifier list.
306 
307  /// Code completion in a parenthesized expression, which means that
308  /// we may also have types here in C and Objective-C (as well as in C++).
310 
311  /// Code completion where an Objective-C instance message is
312  /// expected.
314 
315  /// Code completion where an Objective-C class message is expected.
317 
318  /// Code completion where the name of an Objective-C class is
319  /// expected.
321 
322  /// Code completion where an Objective-C category name is expected.
324 
325  /// An unknown context, in which we are recovering from a parsing
326  /// error and don't know which completions we should give.
328  };
329 
330  using VisitedContextSet = llvm::SmallPtrSet<DeclContext *, 8>;
331 
332 private:
333  Kind CCKind;
334 
335  /// The type that would prefer to see at this point (e.g., the type
336  /// of an initializer or function parameter).
337  QualType PreferredType;
338 
339  /// The type of the base object in a member access expression.
340  QualType BaseType;
341 
342  /// The identifiers for Objective-C selector parts.
343  ArrayRef<IdentifierInfo *> SelIdents;
344 
345  /// The scope specifier that comes before the completion token e.g.
346  /// "a::b::"
347  llvm::Optional<CXXScopeSpec> ScopeSpecifier;
348 
349  /// A set of declaration contexts visited by Sema when doing lookup for
350  /// code completion.
351  VisitedContextSet VisitedContexts;
352 
353 public:
354  /// Construct a new code-completion context of the given kind.
355  CodeCompletionContext(Kind CCKind) : CCKind(CCKind), SelIdents(None) {}
356 
357  /// Construct a new code-completion context of the given kind.
359  ArrayRef<IdentifierInfo *> SelIdents = None)
360  : CCKind(CCKind), SelIdents(SelIdents) {
361  if (CCKind == CCC_DotMemberAccess || CCKind == CCC_ArrowMemberAccess ||
362  CCKind == CCC_ObjCPropertyAccess || CCKind == CCC_ObjCClassMessage ||
363  CCKind == CCC_ObjCInstanceMessage)
364  BaseType = T;
365  else
366  PreferredType = T;
367  }
368 
369  /// Retrieve the kind of code-completion context.
370  Kind getKind() const { return CCKind; }
371 
372  /// Retrieve the type that this expression would prefer to have, e.g.,
373  /// if the expression is a variable initializer or a function argument, the
374  /// type of the corresponding variable or function parameter.
375  QualType getPreferredType() const { return PreferredType; }
376 
377  /// Retrieve the type of the base object in a member-access
378  /// expression.
379  QualType getBaseType() const { return BaseType; }
380 
381  /// Retrieve the Objective-C selector identifiers.
382  ArrayRef<IdentifierInfo *> getSelIdents() const { return SelIdents; }
383 
384  /// Determines whether we want C++ constructors as results within this
385  /// context.
386  bool wantConstructorResults() const;
387 
388  /// Sets the scope specifier that comes before the completion token.
389  /// This is expected to be set in code completions on qualfied specifiers
390  /// (e.g. "a::b::").
392  this->ScopeSpecifier = std::move(SS);
393  }
394 
395  /// Adds a visited context.
397  VisitedContexts.insert(Ctx);
398  }
399 
400  /// Retrieves all visited contexts.
402  return VisitedContexts;
403  }
404 
406  if (ScopeSpecifier)
407  return ScopeSpecifier.getPointer();
408  return llvm::None;
409  }
410 };
411 
412 /// Get string representation of \p Kind, useful for for debugging.
414 
415 /// A "string" used to describe how code completion can
416 /// be performed for an entity.
417 ///
418 /// A code completion string typically shows how a particular entity can be
419 /// used. For example, the code completion string for a function would show
420 /// the syntax to call it, including the parentheses, placeholders for the
421 /// arguments, etc.
423 public:
424  /// The different kinds of "chunks" that can occur within a code
425  /// completion string.
426  enum ChunkKind {
427  /// The piece of text that the user is expected to type to
428  /// match the code-completion string, typically a keyword or the name of a
429  /// declarator or macro.
431 
432  /// A piece of text that should be placed in the buffer, e.g.,
433  /// parentheses or a comma in a function call.
435 
436  /// A code completion string that is entirely optional. For example,
437  /// an optional code completion string that describes the default arguments
438  /// in a function call.
440 
441  /// A string that acts as a placeholder for, e.g., a function
442  /// call argument.
444 
445  /// A piece of text that describes something about the result but
446  /// should not be inserted into the buffer.
448  /// A piece of text that describes the type of an entity or, for
449  /// functions and methods, the return type.
451 
452  /// A piece of text that describes the parameter that corresponds
453  /// to the code-completion location within a function call, message send,
454  /// macro invocation, etc.
456 
457  /// A left parenthesis ('(').
459 
460  /// A right parenthesis (')').
462 
463  /// A left bracket ('[').
465 
466  /// A right bracket (']').
468 
469  /// A left brace ('{').
471 
472  /// A right brace ('}').
474 
475  /// A left angle bracket ('<').
477 
478  /// A right angle bracket ('>').
480 
481  /// A comma separator (',').
483 
484  /// A colon (':').
486 
487  /// A semicolon (';').
489 
490  /// An '=' sign.
492 
493  /// Horizontal whitespace (' ').
495 
496  /// Vertical whitespace ('\\n' or '\\r\\n', depending on the
497  /// platform).
498  CK_VerticalSpace
499  };
500 
501  /// One piece of the code completion string.
502  struct Chunk {
503  /// The kind of data stored in this piece of the code completion
504  /// string.
505  ChunkKind Kind = CK_Text;
506 
507  union {
508  /// The text string associated with a CK_Text, CK_Placeholder,
509  /// CK_Informative, or CK_Comma chunk.
510  /// The string is owned by the chunk and will be deallocated
511  /// (with delete[]) when the chunk is destroyed.
512  const char *Text;
513 
514  /// The code completion string associated with a CK_Optional chunk.
515  /// The optional code completion string is owned by the chunk, and will
516  /// be deallocated (with delete) when the chunk is destroyed.
518  };
519 
520  Chunk() : Text(nullptr) {}
521 
522  explicit Chunk(ChunkKind Kind, const char *Text = "");
523 
524  /// Create a new text chunk.
525  static Chunk CreateText(const char *Text);
526 
527  /// Create a new optional chunk.
528  static Chunk CreateOptional(CodeCompletionString *Optional);
529 
530  /// Create a new placeholder chunk.
531  static Chunk CreatePlaceholder(const char *Placeholder);
532 
533  /// Create a new informative chunk.
534  static Chunk CreateInformative(const char *Informative);
535 
536  /// Create a new result type chunk.
537  static Chunk CreateResultType(const char *ResultType);
538 
539  /// Create a new current-parameter chunk.
540  static Chunk CreateCurrentParameter(const char *CurrentParameter);
541  };
542 
543 private:
544  friend class CodeCompletionBuilder;
545  friend class CodeCompletionResult;
546 
547  /// The number of chunks stored in this string.
548  unsigned NumChunks : 16;
549 
550  /// The number of annotations for this code-completion result.
551  unsigned NumAnnotations : 16;
552 
553  /// The priority of this code-completion string.
554  unsigned Priority : 16;
555 
556  /// The availability of this code-completion result.
557  unsigned Availability : 2;
558 
559  /// The name of the parent context.
560  StringRef ParentName;
561 
562  /// A brief documentation comment attached to the declaration of
563  /// entity being completed by this result.
564  const char *BriefComment;
565 
566  CodeCompletionString(const Chunk *Chunks, unsigned NumChunks,
567  unsigned Priority, CXAvailabilityKind Availability,
568  const char **Annotations, unsigned NumAnnotations,
569  StringRef ParentName,
570  const char *BriefComment);
571  ~CodeCompletionString() = default;
572 
573 public:
574  CodeCompletionString(const CodeCompletionString &) = delete;
575  CodeCompletionString &operator=(const CodeCompletionString &) = delete;
576 
577  using iterator = const Chunk *;
578 
579  iterator begin() const { return reinterpret_cast<const Chunk *>(this + 1); }
580  iterator end() const { return begin() + NumChunks; }
581  bool empty() const { return NumChunks == 0; }
582  unsigned size() const { return NumChunks; }
583 
584  const Chunk &operator[](unsigned I) const {
585  assert(I < size() && "Chunk index out-of-range");
586  return begin()[I];
587  }
588 
589  /// Returns the text in the TypedText chunk.
590  const char *getTypedText() const;
591 
592  /// Retrieve the priority of this code completion result.
593  unsigned getPriority() const { return Priority; }
594 
595  /// Retrieve the availability of this code completion result.
596  unsigned getAvailability() const { return Availability; }
597 
598  /// Retrieve the number of annotations for this code completion result.
599  unsigned getAnnotationCount() const;
600 
601  /// Retrieve the annotation string specified by \c AnnotationNr.
602  const char *getAnnotation(unsigned AnnotationNr) const;
603 
604  /// Retrieve the name of the parent context.
605  StringRef getParentContextName() const {
606  return ParentName;
607  }
608 
609  const char *getBriefComment() const {
610  return BriefComment;
611  }
612 
613  /// Retrieve a string representation of the code completion string,
614  /// which is mainly useful for debugging.
615  std::string getAsString() const;
616 };
617 
618 /// An allocator used specifically for the purpose of code completion.
619 class CodeCompletionAllocator : public llvm::BumpPtrAllocator {
620 public:
621  /// Copy the given string into this allocator.
622  const char *CopyString(const Twine &String);
623 };
624 
625 /// Allocator for a cached set of global code completions.
627 
629  llvm::DenseMap<const DeclContext *, StringRef> ParentNames;
630  std::shared_ptr<GlobalCodeCompletionAllocator> AllocatorRef;
631 
632 public:
634  std::shared_ptr<GlobalCodeCompletionAllocator> Allocator)
635  : AllocatorRef(std::move(Allocator)) {}
636 
637  std::shared_ptr<GlobalCodeCompletionAllocator> getAllocatorRef() const {
638  return AllocatorRef;
639  }
640 
642  assert(AllocatorRef);
643  return *AllocatorRef;
644  }
645 
646  StringRef getParentName(const DeclContext *DC);
647 };
648 
649 } // namespace clang
650 
651 namespace llvm {
652 
653 template <> struct isPodLike<clang::CodeCompletionString::Chunk> {
654  static const bool value = true;
655 };
656 
657 } // namespace llvm
658 
659 namespace clang {
660 
661 /// A builder class used to construct new code-completion strings.
663 public:
665 
666 private:
667  CodeCompletionAllocator &Allocator;
668  CodeCompletionTUInfo &CCTUInfo;
669  unsigned Priority = 0;
671  StringRef ParentName;
672  const char *BriefComment = nullptr;
673 
674  /// The chunks stored in this string.
675  SmallVector<Chunk, 4> Chunks;
676 
677  SmallVector<const char *, 2> Annotations;
678 
679 public:
681  CodeCompletionTUInfo &CCTUInfo)
682  : Allocator(Allocator), CCTUInfo(CCTUInfo) {}
683 
685  CodeCompletionTUInfo &CCTUInfo,
686  unsigned Priority, CXAvailabilityKind Availability)
687  : Allocator(Allocator), CCTUInfo(CCTUInfo), Priority(Priority),
688  Availability(Availability) {}
689 
690  /// Retrieve the allocator into which the code completion
691  /// strings should be allocated.
692  CodeCompletionAllocator &getAllocator() const { return Allocator; }
693 
694  CodeCompletionTUInfo &getCodeCompletionTUInfo() const { return CCTUInfo; }
695 
696  /// Take the resulting completion string.
697  ///
698  /// This operation can only be performed once.
699  CodeCompletionString *TakeString();
700 
701  /// Add a new typed-text chunk.
702  void AddTypedTextChunk(const char *Text);
703 
704  /// Add a new text chunk.
705  void AddTextChunk(const char *Text);
706 
707  /// Add a new optional chunk.
708  void AddOptionalChunk(CodeCompletionString *Optional);
709 
710  /// Add a new placeholder chunk.
711  void AddPlaceholderChunk(const char *Placeholder);
712 
713  /// Add a new informative chunk.
714  void AddInformativeChunk(const char *Text);
715 
716  /// Add a new result-type chunk.
717  void AddResultTypeChunk(const char *ResultType);
718 
719  /// Add a new current-parameter chunk.
720  void AddCurrentParameterChunk(const char *CurrentParameter);
721 
722  /// Add a new chunk.
723  void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text = "");
724 
725  void AddAnnotation(const char *A) { Annotations.push_back(A); }
726 
727  /// Add the parent context information to this code completion.
728  void addParentContext(const DeclContext *DC);
729 
730  const char *getBriefComment() const { return BriefComment; }
731  void addBriefComment(StringRef Comment);
732 
733  StringRef getParentName() const { return ParentName; }
734 };
735 
736 /// Captures a result of code completion.
738 public:
739  /// Describes the kind of result generated.
740  enum ResultKind {
741  /// Refers to a declaration.
742  RK_Declaration = 0,
743 
744  /// Refers to a keyword or symbol.
746 
747  /// Refers to a macro.
749 
750  /// Refers to a precomputed pattern.
751  RK_Pattern
752  };
753 
754  /// When Kind == RK_Declaration or RK_Pattern, the declaration we are
755  /// referring to. In the latter case, the declaration might be NULL.
756  const NamedDecl *Declaration = nullptr;
757 
758  union {
759  /// When Kind == RK_Keyword, the string representing the keyword
760  /// or symbol's spelling.
761  const char *Keyword;
762 
763  /// When Kind == RK_Pattern, the code-completion string that
764  /// describes the completion text to insert.
766 
767  /// When Kind == RK_Macro, the identifier that refers to a macro.
769  };
770 
771  /// The priority of this particular code-completion result.
772  unsigned Priority;
773 
774  /// Specifies which parameter (of a function, Objective-C method,
775  /// macro, etc.) we should start with when formatting the result.
776  unsigned StartParameter = 0;
777 
778  /// The kind of result stored here.
780 
781  /// The cursor kind that describes this result.
783 
784  /// The availability of this result.
786 
787  /// Fix-its that *must* be applied before inserting the text for the
788  /// corresponding completion.
789  ///
790  /// By default, CodeCompletionBuilder only returns completions with empty
791  /// fix-its. Extra completions with non-empty fix-its should be explicitly
792  /// requested by setting CompletionOptions::IncludeFixIts.
793  ///
794  /// For the clients to be able to compute position of the cursor after
795  /// applying fix-its, the following conditions are guaranteed to hold for
796  /// RemoveRange of the stored fix-its:
797  /// - Ranges in the fix-its are guaranteed to never contain the completion
798  /// point (or identifier under completion point, if any) inside them, except
799  /// at the start or at the end of the range.
800  /// - If a fix-it range starts or ends with completion point (or starts or
801  /// ends after the identifier under completion point), it will contain at
802  /// least one character. It allows to unambiguously recompute completion
803  /// point after applying the fix-it.
804  ///
805  /// The intuition is that provided fix-its change code around the identifier
806  /// we complete, but are not allowed to touch the identifier itself or the
807  /// completion point. One example of completions with corrections are the ones
808  /// replacing '.' with '->' and vice versa:
809  ///
810  /// std::unique_ptr<std::vector<int>> vec_ptr;
811  /// In 'vec_ptr.^', one of the completions is 'push_back', it requires
812  /// replacing '.' with '->'.
813  /// In 'vec_ptr->^', one of the completions is 'release', it requires
814  /// replacing '->' with '.'.
815  std::vector<FixItHint> FixIts;
816 
817  /// Whether this result is hidden by another name.
818  bool Hidden : 1;
819 
820  /// Whether this result was found via lookup into a base class.
822 
823  /// Whether this declaration is the beginning of a
824  /// nested-name-specifier and, therefore, should be followed by '::'.
826 
827  /// Whether all parameters (of a function, Objective-C
828  /// method, etc.) should be considered "informative".
830 
831  /// Whether we're completing a declaration of the given entity,
832  /// rather than a use of that entity.
833  bool DeclaringEntity : 1;
834 
835  /// If the result should have a nested-name-specifier, this is it.
836  /// When \c QualifierIsInformative, the nested-name-specifier is
837  /// informative rather than required.
838  NestedNameSpecifier *Qualifier = nullptr;
839 
840  /// If this Decl was unshadowed by using declaration, this can store a
841  /// pointer to the UsingShadowDecl which was used in the unshadowing process.
842  /// This information can be used to uprank CodeCompletionResults / which have
843  /// corresponding `using decl::qualified::name;` nearby.
844  const UsingShadowDecl *ShadowDecl = nullptr;
845 
846  /// Build a result that refers to a declaration.
847  CodeCompletionResult(const NamedDecl *Declaration, unsigned Priority,
848  NestedNameSpecifier *Qualifier = nullptr,
849  bool QualifierIsInformative = false,
850  bool Accessible = true,
851  std::vector<FixItHint> FixIts = std::vector<FixItHint>())
852  : Declaration(Declaration), Priority(Priority), Kind(RK_Declaration),
853  FixIts(std::move(FixIts)), Hidden(false),
854  QualifierIsInformative(QualifierIsInformative),
855  StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
856  DeclaringEntity(false), Qualifier(Qualifier) {
857  // FIXME: Add assert to check FixIts range requirements.
858  computeCursorKindAndAvailability(Accessible);
859  }
860 
861  /// Build a result that refers to a keyword or symbol.
862  CodeCompletionResult(const char *Keyword, unsigned Priority = CCP_Keyword)
863  : Keyword(Keyword), Priority(Priority), Kind(RK_Keyword),
864  CursorKind(CXCursor_NotImplemented), Hidden(false),
865  QualifierIsInformative(false), StartsNestedNameSpecifier(false),
866  AllParametersAreInformative(false), DeclaringEntity(false) {}
867 
868  /// Build a result that refers to a macro.
870  unsigned Priority = CCP_Macro)
871  : Macro(Macro), Priority(Priority), Kind(RK_Macro),
872  CursorKind(CXCursor_MacroDefinition), Hidden(false),
873  QualifierIsInformative(false), StartsNestedNameSpecifier(false),
874  AllParametersAreInformative(false), DeclaringEntity(false) {}
875 
876  /// Build a result that refers to a pattern.
878  unsigned Priority = CCP_CodePattern,
881  const NamedDecl *D = nullptr)
882  : Declaration(D), Pattern(Pattern), Priority(Priority), Kind(RK_Pattern),
883  CursorKind(CursorKind), Availability(Availability), Hidden(false),
884  QualifierIsInformative(false), StartsNestedNameSpecifier(false),
885  AllParametersAreInformative(false), DeclaringEntity(false) {}
886 
887  /// Build a result that refers to a pattern with an associated
888  /// declaration.
890  unsigned Priority)
891  : Declaration(D), Pattern(Pattern), Priority(Priority), Kind(RK_Pattern),
892  Hidden(false), QualifierIsInformative(false),
893  StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
894  DeclaringEntity(false) {
895  computeCursorKindAndAvailability();
896  }
897 
898  /// Retrieve the declaration stored in this result. This might be nullptr if
899  /// Kind is RK_Pattern.
900  const NamedDecl *getDeclaration() const {
901  assert(((Kind == RK_Declaration) || (Kind == RK_Pattern)) &&
902  "Not a declaration or pattern result");
903  return Declaration;
904  }
905 
906  /// Retrieve the keyword stored in this result.
907  const char *getKeyword() const {
908  assert(Kind == RK_Keyword && "Not a keyword result");
909  return Keyword;
910  }
911 
912  /// Create a new code-completion string that describes how to insert
913  /// this result into a program.
914  ///
915  /// \param S The semantic analysis that created the result.
916  ///
917  /// \param Allocator The allocator that will be used to allocate the
918  /// string itself.
919  CodeCompletionString *CreateCodeCompletionString(Sema &S,
920  const CodeCompletionContext &CCContext,
921  CodeCompletionAllocator &Allocator,
922  CodeCompletionTUInfo &CCTUInfo,
923  bool IncludeBriefComments);
924  CodeCompletionString *CreateCodeCompletionString(ASTContext &Ctx,
925  Preprocessor &PP,
926  const CodeCompletionContext &CCContext,
927  CodeCompletionAllocator &Allocator,
928  CodeCompletionTUInfo &CCTUInfo,
929  bool IncludeBriefComments);
930  /// Creates a new code-completion string for the macro result. Similar to the
931  /// above overloads, except this only requires preprocessor information.
932  /// The result kind must be `RK_Macro`.
934  CreateCodeCompletionStringForMacro(Preprocessor &PP,
935  CodeCompletionAllocator &Allocator,
936  CodeCompletionTUInfo &CCTUInfo);
937 
938  /// Retrieve the name that should be used to order a result.
939  ///
940  /// If the name needs to be constructed as a string, that string will be
941  /// saved into Saved and the returned StringRef will refer to it.
942  StringRef getOrderedName(std::string &Saved) const;
943 
944 private:
945  void computeCursorKindAndAvailability(bool Accessible = true);
946 };
947 
949 
950 inline bool operator>(const CodeCompletionResult &X,
951  const CodeCompletionResult &Y) {
952  return Y < X;
953 }
954 
955 inline bool operator<=(const CodeCompletionResult &X,
956  const CodeCompletionResult &Y) {
957  return !(Y < X);
958 }
959 
960 inline bool operator>=(const CodeCompletionResult &X,
961  const CodeCompletionResult &Y) {
962  return !(X < Y);
963 }
964 
965 raw_ostream &operator<<(raw_ostream &OS,
966  const CodeCompletionString &CCS);
967 
968 /// Abstract interface for a consumer of code-completion
969 /// information.
971 protected:
973 
974  /// Whether the output format for the code-completion consumer is
975  /// binary.
977 
978 public:
980  public:
981  /// Describes the type of overload candidate.
983  /// The candidate is a function declaration.
985 
986  /// The candidate is a function template.
988 
989  /// The "candidate" is actually a variable, expression, or block
990  /// for which we only have a function prototype.
991  CK_FunctionType
992  };
993 
994  private:
995  /// The kind of overload candidate.
997 
998  union {
999  /// The function overload candidate, available when
1000  /// Kind == CK_Function.
1002 
1003  /// The function template overload candidate, available when
1004  /// Kind == CK_FunctionTemplate.
1006 
1007  /// The function type that describes the entity being called,
1008  /// when Kind == CK_FunctionType.
1010  };
1011 
1012  public:
1014  : Kind(CK_Function), Function(Function) {}
1015 
1017  : Kind(CK_FunctionTemplate), FunctionTemplate(FunctionTemplateDecl) {}
1018 
1020  : Kind(CK_FunctionType), Type(Type) {}
1021 
1022  /// Determine the kind of overload candidate.
1023  CandidateKind getKind() const { return Kind; }
1024 
1025  /// Retrieve the function overload candidate or the templated
1026  /// function declaration for a function template.
1027  FunctionDecl *getFunction() const;
1028 
1029  /// Retrieve the function template overload candidate.
1031  assert(getKind() == CK_FunctionTemplate && "Not a function template");
1032  return FunctionTemplate;
1033  }
1034 
1035  /// Retrieve the function type of the entity, regardless of how the
1036  /// function is stored.
1037  const FunctionType *getFunctionType() const;
1038 
1039  /// Create a new code-completion string that describes the function
1040  /// signature of this overload candidate.
1041  CodeCompletionString *CreateSignatureString(unsigned CurrentArg,
1042  Sema &S,
1043  CodeCompletionAllocator &Allocator,
1044  CodeCompletionTUInfo &CCTUInfo,
1045  bool IncludeBriefComments) const;
1046  };
1047 
1049  bool OutputIsBinary)
1050  : CodeCompleteOpts(CodeCompleteOpts), OutputIsBinary(OutputIsBinary) {}
1051 
1052  /// Whether the code-completion consumer wants to see macros.
1053  bool includeMacros() const {
1054  return CodeCompleteOpts.IncludeMacros;
1055  }
1056 
1057  /// Whether the code-completion consumer wants to see code patterns.
1058  bool includeCodePatterns() const {
1059  return CodeCompleteOpts.IncludeCodePatterns;
1060  }
1061 
1062  /// Whether to include global (top-level) declaration results.
1063  bool includeGlobals() const { return CodeCompleteOpts.IncludeGlobals; }
1064 
1065  /// Whether to include declarations in namespace contexts (including
1066  /// the global namespace). If this is false, `includeGlobals()` will be
1067  /// ignored.
1069  return CodeCompleteOpts.IncludeNamespaceLevelDecls;
1070  }
1071 
1072  /// Whether to include brief documentation comments within the set of
1073  /// code completions returned.
1074  bool includeBriefComments() const {
1075  return CodeCompleteOpts.IncludeBriefComments;
1076  }
1077 
1078  /// Whether to include completion items with small fix-its, e.g. change
1079  /// '.' to '->' on member access, etc.
1080  bool includeFixIts() const { return CodeCompleteOpts.IncludeFixIts; }
1081 
1082  /// Hint whether to load data from the external AST in order to provide
1083  /// full results. If false, declarations from the preamble may be omitted.
1084  bool loadExternal() const {
1085  return CodeCompleteOpts.LoadExternal;
1086  }
1087 
1088  /// Determine whether the output of this consumer is binary.
1089  bool isOutputBinary() const { return OutputIsBinary; }
1090 
1091  /// Deregisters and destroys this code-completion consumer.
1092  virtual ~CodeCompleteConsumer();
1093 
1094  /// \name Code-completion filtering
1095  /// Check if the result should be filtered out.
1096  virtual bool isResultFilteredOut(StringRef Filter,
1097  CodeCompletionResult Results) {
1098  return false;
1099  }
1100 
1101  /// \name Code-completion callbacks
1102  //@{
1103  /// Process the finalized code-completion results.
1105  CodeCompletionContext Context,
1106  CodeCompletionResult *Results,
1107  unsigned NumResults) {}
1108 
1109  /// \param S the semantic-analyzer object for which code-completion is being
1110  /// done.
1111  ///
1112  /// \param CurrentArg the index of the current argument.
1113  ///
1114  /// \param Candidates an array of overload candidates.
1115  ///
1116  /// \param NumCandidates the number of overload candidates
1117  virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
1118  OverloadCandidate *Candidates,
1119  unsigned NumCandidates) {}
1120  //@}
1121 
1122  /// Retrieve the allocator that will be used to allocate
1123  /// code completion strings.
1124  virtual CodeCompletionAllocator &getAllocator() = 0;
1125 
1126  virtual CodeCompletionTUInfo &getCodeCompletionTUInfo() = 0;
1127 };
1128 
1129 /// Get the documentation comment used to produce
1130 /// CodeCompletionString::BriefComment for RK_Declaration.
1131 const RawComment *getCompletionComment(const ASTContext &Ctx,
1132  const NamedDecl *Decl);
1133 
1134 /// Get the documentation comment used to produce
1135 /// CodeCompletionString::BriefComment for RK_Pattern.
1137  const NamedDecl *Decl);
1138 
1139 /// Get the documentation comment used to produce
1140 /// CodeCompletionString::BriefComment for OverloadCandidate.
1141 const RawComment *
1142 getParameterComment(const ASTContext &Ctx,
1144  unsigned ArgIndex);
1145 
1146 /// A simple code-completion consumer that prints the results it
1147 /// receives in a simple format.
1149  /// The raw output stream.
1150  raw_ostream &OS;
1151 
1152  CodeCompletionTUInfo CCTUInfo;
1153 
1154 public:
1155  /// Create a new printing code-completion consumer that prints its
1156  /// results to the given raw output stream.
1158  raw_ostream &OS)
1159  : CodeCompleteConsumer(CodeCompleteOpts, false), OS(OS),
1160  CCTUInfo(std::make_shared<GlobalCodeCompletionAllocator>()) {}
1161 
1162  /// Prints the finalized code-completion results.
1163  void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context,
1164  CodeCompletionResult *Results,
1165  unsigned NumResults) override;
1166 
1167  void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
1168  OverloadCandidate *Candidates,
1169  unsigned NumCandidates) override;
1170 
1171  bool isResultFilteredOut(StringRef Filter, CodeCompletionResult Results) override;
1172 
1174  return CCTUInfo.getAllocator();
1175  }
1176 
1177  CodeCompletionTUInfo &getCodeCompletionTUInfo() override { return CCTUInfo; }
1178 };
1179 
1180 } // namespace clang
1181 
1182 #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
CodeCompletionAllocator & getAllocator() const
Represents a function declaration or definition.
Definition: Decl.h:1722
llvm::SmallPtrSet< DeclContext *, 8 > VisitedContextSet
ResultKind Kind
The kind of result stored here.
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.
Priority for an enumeration constant inside a switch whose condition is of the enumeration type...
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:640
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:3259
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.
Priority for a code pattern.
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.
Priority for the Objective-C "_cmd" implicit parameter.
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
CandidateKind
Describes the type of overload candidate.
The result is in a base class.
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
Definition: Attr.h:322
The base class of the type hierarchy.
Definition: Type.h:1413
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 ...
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.
An Objective-C block property completed as a setter with a block placeholder.
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 a member declaration found from the current method or member function.
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:153
A "string" used to describe how code completion can be performed for an entity.
Definition: Format.h:2031
Kind getKind() const
Retrieve the kind of code-completion context.
Priority for a preprocessor macro.
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.
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 language keyword (that isn&#39;t any of the other categories).
Adjustment for KVC code pattern priorities when it doesn&#39;t look like the.
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.
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:1714
FunctionTemplateDecl * getFunctionTemplate() const
Retrieve the function template overload candidate.
CodeCompletionAllocator & getAllocator() const
Retrieve the allocator into which the code completion strings should be allocated.
Priority for a constant value (e.g., enumerator).
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:277
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...
Priority for a non-type declaration.
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.
llvm::StringRef getAsString(SyncScope S)
Definition: SyncScope.h:51
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.
Priority for a nested-name-specifier.
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
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...
virtual bool isResultFilteredOut(StringRef Filter, CodeCompletionResult Results)
FunctionDecl * Function
The function overload candidate, available when Kind == CK_Function.
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.
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
Priority for a result that isn&#39;t likely to be what the user wants, but is included for completeness...
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>::".
Priority for the next initialization in a constructor initializer list.
Represents a canonical, potentially-qualified type.
Definition: CanonicalType.h:66
Divide by this factor when a code-completion result&#39;s type exactly matches the type we expect...
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
Divide by this factor when a code-completion result&#39;s type is similar to the type we expect (e...
Abstract interface for a consumer of code-completion information.
Options controlling the behavior of code completion.
Dataflow Directional Tag Classes.
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:1272
A piece of text that describes something about the result but should not be inserted into the buffer...
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.
The result is a C++ non-static member function whose qualifiers exactly match the object type on whic...
const RawComment * getPatternCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Pattern...
const char * getKeyword() const
Retrieve the keyword stored in this result.
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.
An Objective-C method being used as a property.
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 ...
Adjustment to the "bool" type in Objective-C, where the typedef "BOOL" is preferred.
The selector of the given message exactly matches the selector of the current method, which might imply that some kind of delegation is occurring.
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.
Priority for a type.
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:13790
Code completion occurred within a preprocessor expression.
Code completion occurred where an expression is expected.
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.
Priority for a send-to-super completion.
Priority for a declaration that is in the local scope.
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:1606
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
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:3142
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.