clang  14.0.0git
CodeCompleteConsumer.h
Go to the documentation of this file.
1 //===- CodeCompleteConsumer.h - Code Completion Interface -------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the CodeCompleteConsumer class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H
14 #define LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H
15 
16 #include "clang-c/Index.h"
17 #include "clang/AST/Type.h"
18 #include "clang/Basic/LLVM.h"
19 #include "clang/Lex/MacroInfo.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.
166 QualType getDeclUsageType(ASTContext &C, const NamedDecl *ND);
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.
183 CXCursorKind getCursorKindForDecl(const Decl *D);
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 both a new name and an existing symbol is
277  /// permissible.
279 
280  /// Code completion occurred where an existing name(such as type, function
281  /// or variable) is expected.
283 
284  /// Code completion occurred where an macro is being defined.
286 
287  /// Code completion occurred where a macro name is expected
288  /// (without any arguments, in the case of a function-like macro).
290 
291  /// Code completion occurred within a preprocessor expression.
293 
294  /// Code completion occurred where a preprocessor directive is
295  /// expected.
297 
298  /// Code completion occurred in a context where natural language is
299  /// expected, e.g., a comment or string literal.
300  ///
301  /// This context usually implies that no completions should be added,
302  /// unless they come from an appropriate natural-language dictionary.
304 
305  /// Code completion for a selector, as in an \@selector expression.
307 
308  /// Code completion within a type-qualifier list.
310 
311  /// Code completion in a parenthesized expression, which means that
312  /// we may also have types here in C and Objective-C (as well as in C++).
314 
315  /// Code completion where an Objective-C instance message is
316  /// expected.
318 
319  /// Code completion where an Objective-C class message is expected.
321 
322  /// Code completion where the name of an Objective-C class is
323  /// expected.
325 
326  /// Code completion where an Objective-C category name is expected.
328 
329  /// Code completion inside the filename part of a #include directive.
331 
332  /// Code completion of an attribute name.
334 
335  /// An unknown context, in which we are recovering from a parsing
336  /// error and don't know which completions we should give.
338  };
339 
341 
342 private:
343  Kind CCKind;
344 
345  /// Indicates whether we are completing a name of a using declaration, e.g.
346  /// using ^;
347  /// using a::^;
348  bool IsUsingDeclaration;
349 
350  /// The type that would prefer to see at this point (e.g., the type
351  /// of an initializer or function parameter).
352  QualType PreferredType;
353 
354  /// The type of the base object in a member access expression.
355  QualType BaseType;
356 
357  /// The identifiers for Objective-C selector parts.
358  ArrayRef<IdentifierInfo *> SelIdents;
359 
360  /// The scope specifier that comes before the completion token e.g.
361  /// "a::b::"
362  llvm::Optional<CXXScopeSpec> ScopeSpecifier;
363 
364  /// A set of declaration contexts visited by Sema when doing lookup for
365  /// code completion.
366  VisitedContextSet VisitedContexts;
367 
368 public:
369  /// Construct a new code-completion context of the given kind.
371  : CCKind(CCKind), IsUsingDeclaration(false), SelIdents(None) {}
372 
373  /// Construct a new code-completion context of the given kind.
375  ArrayRef<IdentifierInfo *> SelIdents = None)
376  : CCKind(CCKind), IsUsingDeclaration(false), SelIdents(SelIdents) {
377  if (CCKind == CCC_DotMemberAccess || CCKind == CCC_ArrowMemberAccess ||
378  CCKind == CCC_ObjCPropertyAccess || CCKind == CCC_ObjCClassMessage ||
379  CCKind == CCC_ObjCInstanceMessage)
380  BaseType = T;
381  else
382  PreferredType = T;
383  }
384 
385  bool isUsingDeclaration() const { return IsUsingDeclaration; }
386  void setIsUsingDeclaration(bool V) { IsUsingDeclaration = V; }
387 
388  /// Retrieve the kind of code-completion context.
389  Kind getKind() const { return CCKind; }
390 
391  /// Retrieve the type that this expression would prefer to have, e.g.,
392  /// if the expression is a variable initializer or a function argument, the
393  /// type of the corresponding variable or function parameter.
394  QualType getPreferredType() const { return PreferredType; }
395  void setPreferredType(QualType T) { PreferredType = T; }
396 
397  /// Retrieve the type of the base object in a member-access
398  /// expression.
399  QualType getBaseType() const { return BaseType; }
400 
401  /// Retrieve the Objective-C selector identifiers.
402  ArrayRef<IdentifierInfo *> getSelIdents() const { return SelIdents; }
403 
404  /// Determines whether we want C++ constructors as results within this
405  /// context.
406  bool wantConstructorResults() const;
407 
408  /// Sets the scope specifier that comes before the completion token.
409  /// This is expected to be set in code completions on qualfied specifiers
410  /// (e.g. "a::b::").
412  this->ScopeSpecifier = std::move(SS);
413  }
414 
415  /// Adds a visited context.
417  VisitedContexts.insert(Ctx);
418  }
419 
420  /// Retrieves all visited contexts.
422  return VisitedContexts;
423  }
424 
426  if (ScopeSpecifier)
427  return ScopeSpecifier.getPointer();
428  return llvm::None;
429  }
430 };
431 
432 /// Get string representation of \p Kind, useful for for debugging.
434 
435 /// A "string" used to describe how code completion can
436 /// be performed for an entity.
437 ///
438 /// A code completion string typically shows how a particular entity can be
439 /// used. For example, the code completion string for a function would show
440 /// the syntax to call it, including the parentheses, placeholders for the
441 /// arguments, etc.
443 public:
444  /// The different kinds of "chunks" that can occur within a code
445  /// completion string.
446  enum ChunkKind {
447  /// The piece of text that the user is expected to type to
448  /// match the code-completion string, typically a keyword or the name of a
449  /// declarator or macro.
451 
452  /// A piece of text that should be placed in the buffer, e.g.,
453  /// parentheses or a comma in a function call.
455 
456  /// A code completion string that is entirely optional. For example,
457  /// an optional code completion string that describes the default arguments
458  /// in a function call.
460 
461  /// A string that acts as a placeholder for, e.g., a function
462  /// call argument.
464 
465  /// A piece of text that describes something about the result but
466  /// should not be inserted into the buffer.
468  /// A piece of text that describes the type of an entity or, for
469  /// functions and methods, the return type.
471 
472  /// A piece of text that describes the parameter that corresponds
473  /// to the code-completion location within a function call, message send,
474  /// macro invocation, etc.
476 
477  /// A left parenthesis ('(').
479 
480  /// A right parenthesis (')').
482 
483  /// A left bracket ('[').
485 
486  /// A right bracket (']').
488 
489  /// A left brace ('{').
491 
492  /// A right brace ('}').
494 
495  /// A left angle bracket ('<').
497 
498  /// A right angle bracket ('>').
500 
501  /// A comma separator (',').
503 
504  /// A colon (':').
506 
507  /// A semicolon (';').
509 
510  /// An '=' sign.
512 
513  /// Horizontal whitespace (' ').
515 
516  /// Vertical whitespace ('\\n' or '\\r\\n', depending on the
517  /// platform).
519  };
520 
521  /// One piece of the code completion string.
522  struct Chunk {
523  /// The kind of data stored in this piece of the code completion
524  /// string.
526 
527  union {
528  /// The text string associated with a CK_Text, CK_Placeholder,
529  /// CK_Informative, or CK_Comma chunk.
530  /// The string is owned by the chunk and will be deallocated
531  /// (with delete[]) when the chunk is destroyed.
532  const char *Text;
533 
534  /// The code completion string associated with a CK_Optional chunk.
535  /// The optional code completion string is owned by the chunk, and will
536  /// be deallocated (with delete) when the chunk is destroyed.
538  };
539 
540  Chunk() : Text(nullptr) {}
541 
542  explicit Chunk(ChunkKind Kind, const char *Text = "");
543 
544  /// Create a new text chunk.
545  static Chunk CreateText(const char *Text);
546 
547  /// Create a new optional chunk.
549 
550  /// Create a new placeholder chunk.
551  static Chunk CreatePlaceholder(const char *Placeholder);
552 
553  /// Create a new informative chunk.
554  static Chunk CreateInformative(const char *Informative);
555 
556  /// Create a new result type chunk.
557  static Chunk CreateResultType(const char *ResultType);
558 
559  /// Create a new current-parameter chunk.
560  static Chunk CreateCurrentParameter(const char *CurrentParameter);
561  };
562 
563 private:
564  friend class CodeCompletionBuilder;
565  friend class CodeCompletionResult;
566 
567  /// The number of chunks stored in this string.
568  unsigned NumChunks : 16;
569 
570  /// The number of annotations for this code-completion result.
571  unsigned NumAnnotations : 16;
572 
573  /// The priority of this code-completion string.
574  unsigned Priority : 16;
575 
576  /// The availability of this code-completion result.
577  unsigned Availability : 2;
578 
579  /// The name of the parent context.
580  StringRef ParentName;
581 
582  /// A brief documentation comment attached to the declaration of
583  /// entity being completed by this result.
584  const char *BriefComment;
585 
586  CodeCompletionString(const Chunk *Chunks, unsigned NumChunks,
587  unsigned Priority, CXAvailabilityKind Availability,
588  const char **Annotations, unsigned NumAnnotations,
589  StringRef ParentName,
590  const char *BriefComment);
591  ~CodeCompletionString() = default;
592 
593 public:
594  CodeCompletionString(const CodeCompletionString &) = delete;
596 
597  using iterator = const Chunk *;
598 
599  iterator begin() const { return reinterpret_cast<const Chunk *>(this + 1); }
600  iterator end() const { return begin() + NumChunks; }
601  bool empty() const { return NumChunks == 0; }
602  unsigned size() const { return NumChunks; }
603 
604  const Chunk &operator[](unsigned I) const {
605  assert(I < size() && "Chunk index out-of-range");
606  return begin()[I];
607  }
608 
609  /// Returns the text in the TypedText chunk.
610  const char *getTypedText() const;
611 
612  /// Retrieve the priority of this code completion result.
613  unsigned getPriority() const { return Priority; }
614 
615  /// Retrieve the availability of this code completion result.
616  unsigned getAvailability() const { return Availability; }
617 
618  /// Retrieve the number of annotations for this code completion result.
619  unsigned getAnnotationCount() const;
620 
621  /// Retrieve the annotation string specified by \c AnnotationNr.
622  const char *getAnnotation(unsigned AnnotationNr) const;
623 
624  /// Retrieve the name of the parent context.
625  StringRef getParentContextName() const {
626  return ParentName;
627  }
628 
629  const char *getBriefComment() const {
630  return BriefComment;
631  }
632 
633  /// Retrieve a string representation of the code completion string,
634  /// which is mainly useful for debugging.
635  std::string getAsString() const;
636 };
637 
638 /// An allocator used specifically for the purpose of code completion.
639 class CodeCompletionAllocator : public llvm::BumpPtrAllocator {
640 public:
641  /// Copy the given string into this allocator.
642  const char *CopyString(const Twine &String);
643 };
644 
645 /// Allocator for a cached set of global code completions.
647 
649  llvm::DenseMap<const DeclContext *, StringRef> ParentNames;
650  std::shared_ptr<GlobalCodeCompletionAllocator> AllocatorRef;
651 
652 public:
654  std::shared_ptr<GlobalCodeCompletionAllocator> Allocator)
655  : AllocatorRef(std::move(Allocator)) {}
656 
657  std::shared_ptr<GlobalCodeCompletionAllocator> getAllocatorRef() const {
658  return AllocatorRef;
659  }
660 
662  assert(AllocatorRef);
663  return *AllocatorRef;
664  }
665 
666  StringRef getParentName(const DeclContext *DC);
667 };
668 
669 } // namespace clang
670 
671 namespace clang {
672 
673 /// A builder class used to construct new code-completion strings.
675 public:
677 
678 private:
679  CodeCompletionAllocator &Allocator;
680  CodeCompletionTUInfo &CCTUInfo;
681  unsigned Priority = 0;
683  StringRef ParentName;
684  const char *BriefComment = nullptr;
685 
686  /// The chunks stored in this string.
687  SmallVector<Chunk, 4> Chunks;
688 
689  SmallVector<const char *, 2> Annotations;
690 
691 public:
693  CodeCompletionTUInfo &CCTUInfo)
694  : Allocator(Allocator), CCTUInfo(CCTUInfo) {}
695 
697  CodeCompletionTUInfo &CCTUInfo,
698  unsigned Priority, CXAvailabilityKind Availability)
699  : Allocator(Allocator), CCTUInfo(CCTUInfo), Priority(Priority),
700  Availability(Availability) {}
701 
702  /// Retrieve the allocator into which the code completion
703  /// strings should be allocated.
704  CodeCompletionAllocator &getAllocator() const { return Allocator; }
705 
706  CodeCompletionTUInfo &getCodeCompletionTUInfo() const { return CCTUInfo; }
707 
708  /// Take the resulting completion string.
709  ///
710  /// This operation can only be performed once.
712 
713  /// Add a new typed-text chunk.
714  void AddTypedTextChunk(const char *Text);
715 
716  /// Add a new text chunk.
717  void AddTextChunk(const char *Text);
718 
719  /// Add a new optional chunk.
721 
722  /// Add a new placeholder chunk.
723  void AddPlaceholderChunk(const char *Placeholder);
724 
725  /// Add a new informative chunk.
726  void AddInformativeChunk(const char *Text);
727 
728  /// Add a new result-type chunk.
729  void AddResultTypeChunk(const char *ResultType);
730 
731  /// Add a new current-parameter chunk.
732  void AddCurrentParameterChunk(const char *CurrentParameter);
733 
734  /// Add a new chunk.
735  void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text = "");
736 
737  void AddAnnotation(const char *A) { Annotations.push_back(A); }
738 
739  /// Add the parent context information to this code completion.
740  void addParentContext(const DeclContext *DC);
741 
742  const char *getBriefComment() const { return BriefComment; }
743  void addBriefComment(StringRef Comment);
744 
745  StringRef getParentName() const { return ParentName; }
746 };
747 
748 /// Captures a result of code completion.
750 public:
751  /// Describes the kind of result generated.
752  enum ResultKind {
753  /// Refers to a declaration.
755 
756  /// Refers to a keyword or symbol.
758 
759  /// Refers to a macro.
761 
762  /// Refers to a precomputed pattern.
764  };
765 
766  /// When Kind == RK_Declaration or RK_Pattern, the declaration we are
767  /// referring to. In the latter case, the declaration might be NULL.
768  const NamedDecl *Declaration = nullptr;
769 
770  union {
771  /// When Kind == RK_Keyword, the string representing the keyword
772  /// or symbol's spelling.
773  const char *Keyword;
774 
775  /// When Kind == RK_Pattern, the code-completion string that
776  /// describes the completion text to insert.
778 
779  /// When Kind == RK_Macro, the identifier that refers to a macro.
781  };
782 
783  /// The priority of this particular code-completion result.
784  unsigned Priority;
785 
786  /// Specifies which parameter (of a function, Objective-C method,
787  /// macro, etc.) we should start with when formatting the result.
788  unsigned StartParameter = 0;
789 
790  /// The kind of result stored here.
792 
793  /// The cursor kind that describes this result.
795 
796  /// The availability of this result.
798 
799  /// Fix-its that *must* be applied before inserting the text for the
800  /// corresponding completion.
801  ///
802  /// By default, CodeCompletionBuilder only returns completions with empty
803  /// fix-its. Extra completions with non-empty fix-its should be explicitly
804  /// requested by setting CompletionOptions::IncludeFixIts.
805  ///
806  /// For the clients to be able to compute position of the cursor after
807  /// applying fix-its, the following conditions are guaranteed to hold for
808  /// RemoveRange of the stored fix-its:
809  /// - Ranges in the fix-its are guaranteed to never contain the completion
810  /// point (or identifier under completion point, if any) inside them, except
811  /// at the start or at the end of the range.
812  /// - If a fix-it range starts or ends with completion point (or starts or
813  /// ends after the identifier under completion point), it will contain at
814  /// least one character. It allows to unambiguously recompute completion
815  /// point after applying the fix-it.
816  ///
817  /// The intuition is that provided fix-its change code around the identifier
818  /// we complete, but are not allowed to touch the identifier itself or the
819  /// completion point. One example of completions with corrections are the ones
820  /// replacing '.' with '->' and vice versa:
821  ///
822  /// std::unique_ptr<std::vector<int>> vec_ptr;
823  /// In 'vec_ptr.^', one of the completions is 'push_back', it requires
824  /// replacing '.' with '->'.
825  /// In 'vec_ptr->^', one of the completions is 'release', it requires
826  /// replacing '->' with '.'.
827  std::vector<FixItHint> FixIts;
828 
829  /// Whether this result is hidden by another name.
830  bool Hidden : 1;
831 
832  /// Whether this is a class member from base class.
833  bool InBaseClass : 1;
834 
835  /// Whether this result was found via lookup into a base class.
837 
838  /// Whether this declaration is the beginning of a
839  /// nested-name-specifier and, therefore, should be followed by '::'.
841 
842  /// Whether all parameters (of a function, Objective-C
843  /// method, etc.) should be considered "informative".
845 
846  /// Whether we're completing a declaration of the given entity,
847  /// rather than a use of that entity.
848  bool DeclaringEntity : 1;
849 
850  /// If the result should have a nested-name-specifier, this is it.
851  /// When \c QualifierIsInformative, the nested-name-specifier is
852  /// informative rather than required.
854 
855  /// If this Decl was unshadowed by using declaration, this can store a
856  /// pointer to the UsingShadowDecl which was used in the unshadowing process.
857  /// This information can be used to uprank CodeCompletionResults / which have
858  /// corresponding `using decl::qualified::name;` nearby.
859  const UsingShadowDecl *ShadowDecl = nullptr;
860 
861  /// If the result is RK_Macro, this can store the information about the macro
862  /// definition. This should be set in most cases but can be missing when
863  /// the macro has been undefined.
864  const MacroInfo *MacroDefInfo = nullptr;
865 
866  /// Build a result that refers to a declaration.
868  NestedNameSpecifier *Qualifier = nullptr,
869  bool QualifierIsInformative = false,
870  bool Accessible = true,
871  std::vector<FixItHint> FixIts = std::vector<FixItHint>())
877  // FIXME: Add assert to check FixIts range requirements.
878  computeCursorKindAndAvailability(Accessible);
879  }
880 
881  /// Build a result that refers to a keyword or symbol.
887 
888  /// Build a result that refers to a macro.
890  const MacroInfo *MI = nullptr,
891  unsigned Priority = CCP_Macro)
896  MacroDefInfo(MI) {}
897 
898  /// Build a result that refers to a pattern.
903  const NamedDecl *D = nullptr)
909 
910  /// Build a result that refers to a pattern with an associated
911  /// declaration.
913  unsigned Priority)
918  computeCursorKindAndAvailability();
919  }
920 
921  /// Retrieve the declaration stored in this result. This might be nullptr if
922  /// Kind is RK_Pattern.
923  const NamedDecl *getDeclaration() const {
924  assert(((Kind == RK_Declaration) || (Kind == RK_Pattern)) &&
925  "Not a declaration or pattern result");
926  return Declaration;
927  }
928 
929  /// Retrieve the keyword stored in this result.
930  const char *getKeyword() const {
931  assert(Kind == RK_Keyword && "Not a keyword result");
932  return Keyword;
933  }
934 
935  /// Create a new code-completion string that describes how to insert
936  /// this result into a program.
937  ///
938  /// \param S The semantic analysis that created the result.
939  ///
940  /// \param Allocator The allocator that will be used to allocate the
941  /// string itself.
943  const CodeCompletionContext &CCContext,
944  CodeCompletionAllocator &Allocator,
945  CodeCompletionTUInfo &CCTUInfo,
946  bool IncludeBriefComments);
948  Preprocessor &PP,
949  const CodeCompletionContext &CCContext,
950  CodeCompletionAllocator &Allocator,
951  CodeCompletionTUInfo &CCTUInfo,
952  bool IncludeBriefComments);
953  /// Creates a new code-completion string for the macro result. Similar to the
954  /// above overloads, except this only requires preprocessor information.
955  /// The result kind must be `RK_Macro`.
958  CodeCompletionAllocator &Allocator,
959  CodeCompletionTUInfo &CCTUInfo);
960 
962  Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result,
963  bool IncludeBriefComments, const CodeCompletionContext &CCContext,
964  PrintingPolicy &Policy);
965 
967  Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result,
968  bool IncludeBriefComments, const CodeCompletionContext &CCContext,
969  PrintingPolicy &Policy);
970 
971  /// Retrieve the name that should be used to order a result.
972  ///
973  /// If the name needs to be constructed as a string, that string will be
974  /// saved into Saved and the returned StringRef will refer to it.
975  StringRef getOrderedName(std::string &Saved) const;
976 
977 private:
978  void computeCursorKindAndAvailability(bool Accessible = true);
979 };
980 
981 bool operator<(const CodeCompletionResult &X, const CodeCompletionResult &Y);
982 
983 inline bool operator>(const CodeCompletionResult &X,
984  const CodeCompletionResult &Y) {
985  return Y < X;
986 }
987 
988 inline bool operator<=(const CodeCompletionResult &X,
989  const CodeCompletionResult &Y) {
990  return !(Y < X);
991 }
992 
993 inline bool operator>=(const CodeCompletionResult &X,
994  const CodeCompletionResult &Y) {
995  return !(X < Y);
996 }
997 
998 /// Abstract interface for a consumer of code-completion
999 /// information.
1001 protected:
1003 
1004 public:
1006  public:
1007  /// Describes the type of overload candidate.
1009  /// The candidate is a function declaration.
1011 
1012  /// The candidate is a function template.
1014 
1015  /// The "candidate" is actually a variable, expression, or block
1016  /// for which we only have a function prototype.
1018  };
1019 
1020  private:
1021  /// The kind of overload candidate.
1022  CandidateKind Kind;
1023 
1024  union {
1025  /// The function overload candidate, available when
1026  /// Kind == CK_Function.
1028 
1029  /// The function template overload candidate, available when
1030  /// Kind == CK_FunctionTemplate.
1032 
1033  /// The function type that describes the entity being called,
1034  /// when Kind == CK_FunctionType.
1036  };
1037 
1038  public:
1040  : Kind(CK_Function), Function(Function) {}
1041 
1044 
1046  : Kind(CK_FunctionType), Type(Type) {}
1047 
1048  /// Determine the kind of overload candidate.
1049  CandidateKind getKind() const { return Kind; }
1050 
1051  /// Retrieve the function overload candidate or the templated
1052  /// function declaration for a function template.
1053  FunctionDecl *getFunction() const;
1054 
1055  /// Retrieve the function template overload candidate.
1057  assert(getKind() == CK_FunctionTemplate && "Not a function template");
1058  return FunctionTemplate;
1059  }
1060 
1061  /// Retrieve the function type of the entity, regardless of how the
1062  /// function is stored.
1063  const FunctionType *getFunctionType() const;
1064 
1065  /// Create a new code-completion string that describes the function
1066  /// signature of this overload candidate.
1067  CodeCompletionString *CreateSignatureString(unsigned CurrentArg,
1068  Sema &S,
1069  CodeCompletionAllocator &Allocator,
1070  CodeCompletionTUInfo &CCTUInfo,
1071  bool IncludeBriefComments) const;
1072  };
1073 
1076 
1077  /// Whether the code-completion consumer wants to see macros.
1078  bool includeMacros() const {
1080  }
1081 
1082  /// Whether the code-completion consumer wants to see code patterns.
1083  bool includeCodePatterns() const {
1085  }
1086 
1087  /// Whether to include global (top-level) declaration results.
1089 
1090  /// Whether to include declarations in namespace contexts (including
1091  /// the global namespace). If this is false, `includeGlobals()` will be
1092  /// ignored.
1095  }
1096 
1097  /// Whether to include brief documentation comments within the set of
1098  /// code completions returned.
1099  bool includeBriefComments() const {
1101  }
1102 
1103  /// Whether to include completion items with small fix-its, e.g. change
1104  /// '.' to '->' on member access, etc.
1106 
1107  /// Hint whether to load data from the external AST in order to provide
1108  /// full results. If false, declarations from the preamble may be omitted.
1109  bool loadExternal() const {
1111  }
1112 
1113  /// Deregisters and destroys this code-completion consumer.
1114  virtual ~CodeCompleteConsumer();
1115 
1116  /// \name Code-completion filtering
1117  /// Check if the result should be filtered out.
1118  virtual bool isResultFilteredOut(StringRef Filter,
1119  CodeCompletionResult Results) {
1120  return false;
1121  }
1122 
1123  /// \name Code-completion callbacks
1124  //@{
1125  /// Process the finalized code-completion results.
1127  CodeCompletionContext Context,
1128  CodeCompletionResult *Results,
1129  unsigned NumResults) {}
1130 
1131  /// \param S the semantic-analyzer object for which code-completion is being
1132  /// done.
1133  ///
1134  /// \param CurrentArg the index of the current argument.
1135  ///
1136  /// \param Candidates an array of overload candidates.
1137  ///
1138  /// \param NumCandidates the number of overload candidates
1139  ///
1140  /// \param OpenParLoc location of the opening parenthesis of the argument
1141  /// list.
1142  virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
1143  OverloadCandidate *Candidates,
1144  unsigned NumCandidates,
1145  SourceLocation OpenParLoc) {}
1146  //@}
1147 
1148  /// Retrieve the allocator that will be used to allocate
1149  /// code completion strings.
1150  virtual CodeCompletionAllocator &getAllocator() = 0;
1151 
1153 };
1154 
1155 /// Get the documentation comment used to produce
1156 /// CodeCompletionString::BriefComment for RK_Declaration.
1157 const RawComment *getCompletionComment(const ASTContext &Ctx,
1158  const NamedDecl *Decl);
1159 
1160 /// Get the documentation comment used to produce
1161 /// CodeCompletionString::BriefComment for RK_Pattern.
1162 const RawComment *getPatternCompletionComment(const ASTContext &Ctx,
1163  const NamedDecl *Decl);
1164 
1165 /// Get the documentation comment used to produce
1166 /// CodeCompletionString::BriefComment for OverloadCandidate.
1167 const RawComment *
1168 getParameterComment(const ASTContext &Ctx,
1169  const CodeCompleteConsumer::OverloadCandidate &Result,
1170  unsigned ArgIndex);
1171 
1172 /// A simple code-completion consumer that prints the results it
1173 /// receives in a simple format.
1175  /// The raw output stream.
1176  raw_ostream &OS;
1177 
1178  CodeCompletionTUInfo CCTUInfo;
1179 
1180 public:
1181  /// Create a new printing code-completion consumer that prints its
1182  /// results to the given raw output stream.
1184  raw_ostream &OS)
1186  CCTUInfo(std::make_shared<GlobalCodeCompletionAllocator>()) {}
1187 
1188  /// Prints the finalized code-completion results.
1190  CodeCompletionResult *Results,
1191  unsigned NumResults) override;
1192 
1193  void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
1194  OverloadCandidate *Candidates,
1195  unsigned NumCandidates,
1196  SourceLocation OpenParLoc) override;
1197 
1198  bool isResultFilteredOut(StringRef Filter, CodeCompletionResult Results) override;
1199 
1201  return CCTUInfo.getAllocator();
1202  }
1203 
1204  CodeCompletionTUInfo &getCodeCompletionTUInfo() override { return CCTUInfo; }
1205 };
1206 
1207 } // namespace clang
1208 
1209 #endif // LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H
clang::CodeCompleteConsumer::OverloadCandidate::OverloadCandidate
OverloadCandidate(FunctionDecl *Function)
Definition: CodeCompleteConsumer.h:1039
clang::CodeCompletionContext::CCC_SymbolOrNewName
@ CCC_SymbolOrNewName
Code completion occurred where both a new name and an existing symbol is permissible.
Definition: CodeCompleteConsumer.h:278
clang::CodeCompleteConsumer::OverloadCandidate::CK_FunctionTemplate
@ CK_FunctionTemplate
The candidate is a function template.
Definition: CodeCompleteConsumer.h:1013
clang::CodeCompleteOptions::IncludeMacros
unsigned IncludeMacros
Show macros in code completion results.
Definition: CodeCompleteOptions.h:18
clang::CodeCompletionContext::CCC_Other
@ CCC_Other
An unspecified code-completion context.
Definition: CodeCompleteConsumer.h:191
clang::CodeCompleteConsumer::OverloadCandidate::CK_Function
@ CK_Function
The candidate is a function declaration.
Definition: CodeCompleteConsumer.h:1010
clang::CodeCompleteConsumer::includeCodePatterns
bool includeCodePatterns() const
Whether the code-completion consumer wants to see code patterns.
Definition: CodeCompleteConsumer.h:1083
clang::CodeCompletionBuilder::addParentContext
void addParentContext(const DeclContext *DC)
Add the parent context information to this code completion.
Definition: CodeCompleteConsumer.cpp:468
clang::CodeCompletionResult::Keyword
const char * Keyword
When Kind == RK_Keyword, the string representing the keyword or symbol's spelling.
Definition: CodeCompleteConsumer.h:773
clang::CCP_ObjC_cmd
@ CCP_ObjC_cmd
Priority for the Objective-C "_cmd" implicit parameter.
Definition: CodeCompleteConsumer.h:100
clang::CCP_SuperCompletion
@ CCP_SuperCompletion
Priority for a send-to-super completion.
Definition: CodeCompleteConsumer.h:64
clang::CodeCompletionString::getAnnotationCount
unsigned getAnnotationCount() const
Retrieve the number of annotations for this code completion result.
Definition: CodeCompleteConsumer.cpp:303
clang::CodeCompletionString::getPriority
unsigned getPriority() const
Retrieve the priority of this code completion result.
Definition: CodeCompleteConsumer.h:613
clang::CodeCompletionContext::Kind
Kind
Definition: CodeCompleteConsumer.h:189
clang::CodeCompleteConsumer::loadExternal
bool loadExternal() const
Hint whether to load data from the external AST in order to provide full results.
Definition: CodeCompleteConsumer.h:1109
clang::CodeCompletionContext::CodeCompletionContext
CodeCompletionContext(Kind CCKind)
Construct a new code-completion context of the given kind.
Definition: CodeCompleteConsumer.h:370
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1347
clang::CodeCompleteConsumer::includeNamespaceLevelDecls
bool includeNamespaceLevelDecls() const
Whether to include declarations in namespace contexts (including the global namespace).
Definition: CodeCompleteConsumer.h:1093
clang::CodeCompletionBuilder::TakeString
CodeCompletionString * TakeString()
Take the resulting completion string.
Definition: CodeCompleteConsumer.cpp:422
clang::CodeCompletionContext::CCC_ObjCInstanceMessage
@ CCC_ObjCInstanceMessage
Code completion where an Objective-C instance message is expected.
Definition: CodeCompleteConsumer.h:317
clang::CodeCompletionContext::CCC_Expression
@ CCC_Expression
Code completion occurred where an expression is expected.
Definition: CodeCompleteConsumer.h:221
clang::CodeCompletionResult::CodeCompletionResult
CodeCompletionResult(const IdentifierInfo *Macro, const MacroInfo *MI=nullptr, unsigned Priority=CCP_Macro)
Build a result that refers to a macro.
Definition: CodeCompleteConsumer.h:889
clang::CodeCompletionBuilder::AddOptionalChunk
void AddOptionalChunk(CodeCompletionString *Optional)
Add a new optional chunk.
Definition: CodeCompleteConsumer.cpp:442
clang::CodeCompletionAllocator::CopyString
const char * CopyString(const Twine &String)
Copy the given string into this allocator.
Definition: CodeCompleteConsumer.cpp:349
clang::PrintingCodeCompleteConsumer::isResultFilteredOut
bool isResultFilteredOut(StringRef Filter, CodeCompletionResult Results) override
Definition: CodeCompleteConsumer.cpp:521
clang::PrintingCodeCompleteConsumer
A simple code-completion consumer that prints the results it receives in a simple format.
Definition: CodeCompleteConsumer.h:1174
llvm::SmallVector
Definition: LLVM.h:38
clang::STC_Pointer
@ STC_Pointer
Definition: CodeCompleteConsumer.h:156
clang::CodeCompleteConsumer::OverloadCandidate::OverloadCandidate
OverloadCandidate(FunctionTemplateDecl *FunctionTemplateDecl)
Definition: CodeCompleteConsumer.h:1042
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
clang::CodeCompleteConsumer::includeGlobals
bool includeGlobals() const
Whether to include global (top-level) declaration results.
Definition: CodeCompleteConsumer.h:1088
clang::CodeCompleteOptions::IncludeBriefComments
unsigned IncludeBriefComments
Show brief documentation comments in code completion results.
Definition: CodeCompleteOptions.h:35
clang::CodeCompletionContext::CCC_Type
@ CCC_Type
Code completion occurred where a type name is expected.
Definition: CodeCompleteConsumer.h:271
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:249
clang::CodeCompleteOptions::IncludeFixIts
unsigned IncludeFixIts
Include results after corrections (small fix-its), e.g.
Definition: CodeCompleteOptions.h:44
clang::CodeCompletionContext::CCC_ObjCImplementation
@ CCC_ObjCImplementation
Code completion occurred within an Objective-C implementation or category implementation.
Definition: CodeCompleteConsumer.h:207
clang::CodeCompletionResult::CreateCodeCompletionString
CodeCompletionString * CreateCodeCompletionString(Sema &S, const CodeCompletionContext &CCContext, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments)
Create a new code-completion string that describes how to insert this result into a program.
Definition: SemaCodeComplete.cpp:3279
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:673
clang::CodeCompletionBuilder::AddChunk
void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text="")
Add a new chunk.
Definition: CodeCompleteConsumer.cpp:463
clang::CodeCompletionString::CK_Text
@ CK_Text
A piece of text that should be placed in the buffer, e.g., parentheses or a comma in a function call.
Definition: CodeCompleteConsumer.h:454
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:54
clang::NestedNameSpecifier
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Definition: NestedNameSpecifier.h:50
clang::tooling::Filter
llvm::cl::opt< std::string > Filter
clang::CodeCompletionResult::CreateCodeCompletionStringForMacro
CodeCompletionString * CreateCodeCompletionStringForMacro(Preprocessor &PP, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo)
Creates a new code-completion string for the macro result.
Definition: SemaCodeComplete.cpp:3287
clang::CodeCompleteConsumer::OverloadCandidate::getFunctionType
const FunctionType * getFunctionType() const
Retrieve the function type of the entity, regardless of how the function is stored.
Definition: CodeCompleteConsumer.cpp:498
clang::CodeCompletionBuilder::getCodeCompletionTUInfo
CodeCompletionTUInfo & getCodeCompletionTUInfo() const
Definition: CodeCompleteConsumer.h:706
clang::CodeCompleteConsumer::OverloadCandidate::getKind
CandidateKind getKind() const
Determine the kind of overload candidate.
Definition: CodeCompleteConsumer.h:1049
Index.h
clang::CodeCompletionString::empty
bool empty() const
Definition: CodeCompleteConsumer.h:601
clang::CodeCompletionString::CK_RightParen
@ CK_RightParen
A right parenthesis (')').
Definition: CodeCompleteConsumer.h:481
clang::UsingShadowDecl
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3187
clang::CCP_LocalDeclaration
@ CCP_LocalDeclaration
Priority for a declaration that is in the local scope.
Definition: CodeCompleteConsumer.h:67
clang::CodeCompleteConsumer::getCodeCompletionTUInfo
virtual CodeCompletionTUInfo & getCodeCompletionTUInfo()=0
clang::CodeCompletionBuilder::getBriefComment
const char * getBriefComment() const
Definition: CodeCompleteConsumer.h:742
clang::CodeCompletionString::CK_TypedText
@ CK_TypedText
The piece of text that the user is expected to type to match the code-completion string,...
Definition: CodeCompleteConsumer.h:450
llvm::Optional
Definition: LLVM.h:40
clang::CodeCompletionContext::CCC_IncludedFile
@ CCC_IncludedFile
Code completion inside the filename part of a include directive.
Definition: CodeCompleteConsumer.h:330
clang::CodeCompletionResult::Pattern
CodeCompletionString * Pattern
When Kind == RK_Pattern, the code-completion string that describes the completion text to insert.
Definition: CodeCompleteConsumer.h:777
llvm::SmallPtrSet< DeclContext *, 8 >
clang::MacroInfo
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:39
clang::CodeCompletionResult::RK_Keyword
@ RK_Keyword
Refers to a keyword or symbol.
Definition: CodeCompleteConsumer.h:757
clang::CodeCompletionString::Chunk::Chunk
Chunk()
Definition: CodeCompleteConsumer.h:540
clang::CCF_SimilarTypeMatch
@ CCF_SimilarTypeMatch
Divide by this factor when a code-completion result's type is similar to the type we expect (e....
Definition: CodeCompleteConsumer.h:144
DeclSpec.h
clang::CodeCompletionResult::Priority
unsigned Priority
The priority of this particular code-completion result.
Definition: CodeCompleteConsumer.h:784
clang::CodeCompletionString::CK_VerticalSpace
@ CK_VerticalSpace
Vertical whitespace ('\n' or '\r\n', depending on the platform).
Definition: CodeCompleteConsumer.h:518
clang::tooling::X
static ToolExecutorPluginRegistry::Add< AllTUsToolExecutorPlugin > X("all-TUs", "Runs FrontendActions on all TUs in the compilation database. " "Tool results are stored in memory.")
clang::CXXScopeSpec
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:64
clang::CodeCompleteConsumer::OverloadCandidate::CandidateKind
CandidateKind
Describes the type of overload candidate.
Definition: CodeCompleteConsumer.h:1008
clang::STC_Void
@ STC_Void
Definition: CodeCompleteConsumer.h:158
clang::PrintingPolicy
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:59
clang::CodeCompletionResult::StartsNestedNameSpecifier
bool StartsNestedNameSpecifier
Whether this declaration is the beginning of a nested-name-specifier and, therefore,...
Definition: CodeCompleteConsumer.h:840
clang::CCP_Constant
@ CCP_Constant
Priority for a constant value (e.g., enumerator).
Definition: CodeCompleteConsumer.h:87
clang::CodeCompletionBuilder::AddTypedTextChunk
void AddTypedTextChunk(const char *Text)
Add a new typed-text chunk.
Definition: CodeCompleteConsumer.cpp:434
clang::FunctionType
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3546
clang::getMacroUsagePriority
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.
Definition: SemaCodeComplete.cpp:3813
clang::CodeCompletionString::CK_HorizontalSpace
@ CK_HorizontalSpace
Horizontal whitespace (' ').
Definition: CodeCompleteConsumer.h:514
clang::CodeCompletionContext::getBaseType
QualType getBaseType() const
Retrieve the type of the base object in a member-access expression.
Definition: CodeCompleteConsumer.h:399
clang::CodeCompleteConsumer::OverloadCandidate::FunctionTemplate
FunctionTemplateDecl * FunctionTemplate
The function template overload candidate, available when Kind == CK_FunctionTemplate.
Definition: CodeCompleteConsumer.h:1031
clang::getPatternCompletionComment
const RawComment * getPatternCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Pattern.
Definition: SemaCodeComplete.cpp:3658
clang::CodeCompletionString::end
iterator end() const
Definition: CodeCompleteConsumer.h:600
clang::CodeCompletionString::CK_ResultType
@ CK_ResultType
A piece of text that describes the type of an entity or, for functions and methods,...
Definition: CodeCompleteConsumer.h:470
clang::STC_Block
@ STC_Block
Definition: CodeCompleteConsumer.h:152
clang::CodeCompletionResult
Captures a result of code completion.
Definition: CodeCompleteConsumer.h:749
clang::CCD_MethodAsProperty
@ CCD_MethodAsProperty
An Objective-C method being used as a property.
Definition: CodeCompleteConsumer.h:127
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1490
clang::CodeCompletionString::ChunkKind
ChunkKind
The different kinds of "chunks" that can occur within a code completion string.
Definition: CodeCompleteConsumer.h:446
clang::CodeCompleteConsumer::OverloadCandidate::getFunctionTemplate
FunctionTemplateDecl * getFunctionTemplate() const
Retrieve the function template overload candidate.
Definition: CodeCompleteConsumer.h:1056
clang::CodeGen::AlignmentSource::Decl
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
clang::CodeCompletionContext::CCC_ObjCCategoryName
@ CCC_ObjCCategoryName
Code completion where an Objective-C category name is expected.
Definition: CodeCompleteConsumer.h:327
clang::STC_Array
@ STC_Array
Definition: CodeCompleteConsumer.h:151
clang::CodeCompletionBuilder::CodeCompletionBuilder
CodeCompletionBuilder(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo)
Definition: CodeCompleteConsumer.h:692
clang::CodeCompletionContext::CCC_TopLevel
@ CCC_TopLevel
Code completion occurred within a "top-level" completion context, e.g., at namespace or global scope.
Definition: CodeCompleteConsumer.h:199
clang::CCP_EnumInCase
@ CCP_EnumInCase
Priority for an enumeration constant inside a switch whose condition is of the enumeration type.
Definition: CodeCompleteConsumer.h:61
clang::FunctionTemplateDecl
Declaration of a template function.
Definition: DeclTemplate.h:978
clang::CCD_bool_in_ObjC
@ CCD_bool_in_ObjC
Adjustment to the "bool" type in Objective-C, where the typedef "BOOL" is preferred.
Definition: CodeCompleteConsumer.h:120
clang::CodeCompletionString::CK_LeftAngle
@ CK_LeftAngle
A left angle bracket ('<').
Definition: CodeCompleteConsumer.h:496
V
#define V(N, I)
Definition: ASTContext.h:3121
clang::CodeCompletionResult::ShadowDecl
const UsingShadowDecl * ShadowDecl
If this Decl was unshadowed by using declaration, this can store a pointer to the UsingShadowDecl whi...
Definition: CodeCompleteConsumer.h:859
clang::CodeCompleteConsumer::ProcessOverloadCandidates
virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates, SourceLocation OpenParLoc)
Definition: CodeCompleteConsumer.h:1142
clang::operator>
bool operator>(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
Definition: DeclarationName.h:546
clang::CodeCompletionBuilder::AddCurrentParameterChunk
void AddCurrentParameterChunk(const char *CurrentParameter)
Add a new current-parameter chunk.
Definition: CodeCompleteConsumer.cpp:458
clang::CodeCompletionResult::Availability
CXAvailabilityKind Availability
The availability of this result.
Definition: CodeCompleteConsumer.h:797
clang::CodeCompleteOptions::IncludeGlobals
unsigned IncludeGlobals
Show top-level decls in code completion results.
Definition: CodeCompleteOptions.h:24
clang::CodeCompletionContext::CCC_Recovery
@ CCC_Recovery
An unknown context, in which we are recovering from a parsing error and don't know which completions ...
Definition: CodeCompleteConsumer.h:337
clang::CodeCompletionString::CK_RightBracket
@ CK_RightBracket
A right bracket (']').
Definition: CodeCompleteConsumer.h:487
clang::CodeCompletionContext::CCC_ObjCProtocolName
@ CCC_ObjCProtocolName
Code completion occurred where a protocol name is expected.
Definition: CodeCompleteConsumer.h:264
clang::CodeCompletionContext::CCC_EnumTag
@ CCC_EnumTag
Code completion occurred after the "enum" keyword, to indicate an enumeration name.
Definition: CodeCompleteConsumer.h:253
CodeCompleteOptions.h
clang::CodeCompletionString::Chunk::CreateOptional
static Chunk CreateOptional(CodeCompletionString *Optional)
Create a new optional chunk.
Definition: CodeCompleteConsumer.cpp:256
clang::CodeCompleteOptions::IncludeCodePatterns
unsigned IncludeCodePatterns
Show code patterns in code completion results.
Definition: CodeCompleteOptions.h:21
clang::CodeCompletionBuilder
A builder class used to construct new code-completion strings.
Definition: CodeCompleteConsumer.h:674
clang::CCP_Macro
@ CCP_Macro
Priority for a preprocessor macro.
Definition: CodeCompleteConsumer.h:90
CXCursor_NotImplemented
@ CXCursor_NotImplemented
Definition: Index.h:1904
clang::CodeCompletionResult::CodeCompletionResult
CodeCompletionResult(CodeCompletionString *Pattern, const NamedDecl *D, unsigned Priority)
Build a result that refers to a pattern with an associated declaration.
Definition: CodeCompleteConsumer.h:912
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:212
clang::CodeCompletionContext::CCC_ArrowMemberAccess
@ CCC_ArrowMemberAccess
Code completion occurred on the right-hand side of a member access expression using the arrow operato...
Definition: CodeCompleteConsumer.h:241
clang::CodeCompletionContext::CCC_Symbol
@ CCC_Symbol
Code completion occurred where an existing name(such as type, function or variable) is expected.
Definition: CodeCompleteConsumer.h:282
clang::CodeCompletionBuilder::AddTextChunk
void AddTextChunk(const char *Text)
Add a new text chunk.
Definition: CodeCompleteConsumer.cpp:438
clang::CodeCompletionString::Chunk::CreateResultType
static Chunk CreateResultType(const char *ResultType)
Create a new result type chunk.
Definition: CodeCompleteConsumer.cpp:274
clang::CodeCompletionString::getParentContextName
StringRef getParentContextName() const
Retrieve the name of the parent context.
Definition: CodeCompleteConsumer.h:625
clang::PrintingCodeCompleteConsumer::getCodeCompletionTUInfo
CodeCompletionTUInfo & getCodeCompletionTUInfo() override
Definition: CodeCompleteConsumer.h:1204
clang::CCD_ProbablyNotObjCCollection
@ CCD_ProbablyNotObjCCollection
Adjustment for KVC code pattern priorities when it doesn't look like the.
Definition: CodeCompleteConsumer.h:124
clang::CodeCompleteConsumer::isResultFilteredOut
virtual bool isResultFilteredOut(StringRef Filter, CodeCompletionResult Results)
Definition: CodeCompleteConsumer.h:1118
clang::CodeCompleteConsumer::OverloadCandidate::Function
FunctionDecl * Function
The function overload candidate, available when Kind == CK_Function.
Definition: CodeCompleteConsumer.h:1027
clang::CanQualType
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
Definition: CanonicalType.h:212
clang::CodeCompletionContext::CCC_ObjCInterfaceName
@ CCC_ObjCInterfaceName
Code completion where the name of an Objective-C class is expected.
Definition: CodeCompleteConsumer.h:324
clang::CodeCompletionString::CK_Informative
@ CK_Informative
A piece of text that describes something about the result but should not be inserted into the buffer.
Definition: CodeCompleteConsumer.h:467
Type.h
clang::CCP_Unlikely
@ CCP_Unlikely
Priority for a result that isn't likely to be what the user wants, but is included for completeness.
Definition: CodeCompleteConsumer.h:97
clang::CodeCompletionContext::CCC_Attribute
@ CCC_Attribute
Code completion of an attribute name.
Definition: CodeCompleteConsumer.h:333
clang::CodeCompletionContext::setCXXScopeSpecifier
void setCXXScopeSpecifier(CXXScopeSpec SS)
Sets the scope specifier that comes before the completion token.
Definition: CodeCompleteConsumer.h:411
clang::CodeCompletionString::CK_LeftParen
@ CK_LeftParen
A left parenthesis ('(').
Definition: CodeCompleteConsumer.h:478
clang::CodeCompleteConsumer::OverloadCandidate::CK_FunctionType
@ CK_FunctionType
The "candidate" is actually a variable, expression, or block for which we only have a function protot...
Definition: CodeCompleteConsumer.h:1017
clang::CodeCompletionString::Chunk::Optional
CodeCompletionString * Optional
The code completion string associated with a CK_Optional chunk.
Definition: CodeCompleteConsumer.h:537
clang::CodeCompletionContext::CCC_ObjCMessageReceiver
@ CCC_ObjCMessageReceiver
Code completion occurred where an Objective-C message receiver is expected.
Definition: CodeCompleteConsumer.h:225
clang::CodeCompletionResult::MacroDefInfo
const MacroInfo * MacroDefInfo
If the result is RK_Macro, this can store the information about the macro definition.
Definition: CodeCompleteConsumer.h:864
clang::CodeCompletionResult::QualifierIsInformative
bool QualifierIsInformative
Whether this result was found via lookup into a base class.
Definition: CodeCompleteConsumer.h:836
clang::CodeCompletionContext::setPreferredType
void setPreferredType(QualType T)
Definition: CodeCompleteConsumer.h:395
clang::CodeCompletionBuilder::getAllocator
CodeCompletionAllocator & getAllocator() const
Retrieve the allocator into which the code completion strings should be allocated.
Definition: CodeCompleteConsumer.h:704
clang::CodeCompletionString::operator=
CodeCompletionString & operator=(const CodeCompletionString &)=delete
clang::getParameterComment
const RawComment * getParameterComment(const ASTContext &Ctx, const CodeCompleteConsumer::OverloadCandidate &Result, unsigned ArgIndex)
Get the documentation comment used to produce CodeCompletionString::BriefComment for OverloadCandidat...
Definition: SemaCodeComplete.cpp:3681
clang::CodeCompletionResult::StartParameter
unsigned StartParameter
Specifies which parameter (of a function, Objective-C method, macro, etc.) we should start with when ...
Definition: CodeCompleteConsumer.h:788
clang::CodeCompletionString::getAsString
std::string getAsString() const
Retrieve a string representation of the code completion string, which is mainly useful for debugging.
Definition: CodeCompleteConsumer.cpp:314
clang::CCP_Declaration
@ CCP_Declaration
Priority for a non-type declaration.
Definition: CodeCompleteConsumer.h:81
clang::CodeCompleteConsumer::OverloadCandidate::CreateSignatureString
CodeCompletionString * CreateSignatureString(unsigned CurrentArg, Sema &S, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments) const
Create a new code-completion string that describes the function signature of this overload candidate.
Definition: SemaCodeComplete.cpp:3762
clang::CodeCompletionString
A "string" used to describe how code completion can be performed for an entity.
Definition: CodeCompleteConsumer.h:442
clang::CodeCompletionString::Chunk::CreateCurrentParameter
static Chunk CreateCurrentParameter(const char *CurrentParameter)
Create a new current-parameter chunk.
Definition: CodeCompleteConsumer.cpp:278
clang::CodeCompleteConsumer::includeMacros
bool includeMacros() const
Whether the code-completion consumer wants to see macros.
Definition: CodeCompleteConsumer.h:1078
clang::CodeCompleteConsumer::ProcessCodeCompleteResults
virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Process the finalized code-completion results.
Definition: CodeCompleteConsumer.h:1126
clang::CodeCompletionContext::CCC_OtherWithMacros
@ CCC_OtherWithMacros
An unspecified code-completion context where we should also add macro completions.
Definition: CodeCompleteConsumer.h:195
clang::CodeCompletionResult::createCodeCompletionStringForOverride
CodeCompletionString * createCodeCompletionStringForOverride(Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, bool IncludeBriefComments, const CodeCompletionContext &CCContext, PrintingPolicy &Policy)
Definition: SemaCodeComplete.cpp:3395
clang::CodeCompletionBuilder::AddResultTypeChunk
void AddResultTypeChunk(const char *ResultType)
Add a new result-type chunk.
Definition: CodeCompleteConsumer.cpp:454
clang::CodeCompletionContext::CCC_Namespace
@ CCC_Namespace
Code completion occurred where a namespace or namespace alias is expected.
Definition: CodeCompleteConsumer.h:268
clang::CodeCompletionResult::RK_Macro
@ RK_Macro
Refers to a macro.
Definition: CodeCompleteConsumer.h:760
clang::CodeCompletionString::begin
iterator begin() const
Definition: CodeCompleteConsumer.h:599
clang::CodeCompleteOptions::IncludeNamespaceLevelDecls
unsigned IncludeNamespaceLevelDecls
Show decls in namespace (including the global namespace) in code completion results.
Definition: CodeCompleteOptions.h:32
clang::CodeCompletionString::operator[]
const Chunk & operator[](unsigned I) const
Definition: CodeCompleteConsumer.h:604
clang::CodeCompleteConsumer::OverloadCandidate
Definition: CodeCompleteConsumer.h:1005
clang::getSimplifiedTypeClass
SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T)
Determine the simplified type class of the given canonical type.
Definition: SemaCodeComplete.cpp:841
clang::CodeCompletionResult::Declaration
const NamedDecl * Declaration
When Kind == RK_Declaration or RK_Pattern, the declaration we are referring to.
Definition: CodeCompleteConsumer.h:768
clang::PrintingCodeCompleteConsumer::PrintingCodeCompleteConsumer
PrintingCodeCompleteConsumer(const CodeCompleteOptions &CodeCompleteOpts, raw_ostream &OS)
Create a new printing code-completion consumer that prints its results to the given raw output stream...
Definition: CodeCompleteConsumer.h:1183
clang::CodeCompletionString::CK_RightBrace
@ CK_RightBrace
A right brace ('}').
Definition: CodeCompleteConsumer.h:493
clang::CodeCompletionTUInfo::getAllocatorRef
std::shared_ptr< GlobalCodeCompletionAllocator > getAllocatorRef() const
Definition: CodeCompleteConsumer.h:657
clang::CodeCompletionContext::CCC_ObjCPropertyAccess
@ CCC_ObjCPropertyAccess
Code completion occurred on the right-hand side of an Objective-C property access expression.
Definition: CodeCompleteConsumer.h:249
clang::CodeCompletionString::Chunk::Kind
ChunkKind Kind
The kind of data stored in this piece of the code completion string.
Definition: CodeCompleteConsumer.h:525
clang::CCD_ObjectQualifierMatch
@ CCD_ObjectQualifierMatch
The result is a C++ non-static member function whose qualifiers exactly match the object type on whic...
Definition: CodeCompleteConsumer.h:111
clang::CodeCompletionString::CK_SemiColon
@ CK_SemiColon
A semicolon (';').
Definition: CodeCompleteConsumer.h:508
clang::operator<=
bool operator<=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
Definition: DeclarationName.h:552
clang::CodeCompletionContext::getCXXScopeSpecifier
llvm::Optional< const CXXScopeSpec * > getCXXScopeSpecifier()
Definition: CodeCompleteConsumer.h:425
false
#define false
Definition: stdbool.h:17
clang::CodeCompletionContext::CCC_PreprocessorExpression
@ CCC_PreprocessorExpression
Code completion occurred within a preprocessor expression.
Definition: CodeCompleteConsumer.h:292
clang::CCP_Type
@ CCP_Type
Priority for a type.
Definition: CodeCompleteConsumer.h:84
clang::CodeCompletionBuilder::AddAnnotation
void AddAnnotation(const char *A)
Definition: CodeCompleteConsumer.h:737
clang::CodeCompletionContext::getKind
Kind getKind() const
Retrieve the kind of code-completion context.
Definition: CodeCompleteConsumer.h:389
CXCursor_MacroDefinition
@ CXCursor_MacroDefinition
Definition: Index.h:2662
CXAvailability_Available
@ CXAvailability_Available
The entity is available.
Definition: Index.h:129
clang::PrintingCodeCompleteConsumer::ProcessOverloadCandidates
void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates, SourceLocation OpenParLoc) override
Definition: CodeCompleteConsumer.cpp:647
CXAvailabilityKind
CXAvailabilityKind
Describes the availability of a particular entity, which indicates whether the use of this entity wil...
Definition: Index.h:125
clang::CodeCompletionResult::Qualifier
NestedNameSpecifier * Qualifier
If the result should have a nested-name-specifier, this is it.
Definition: CodeCompleteConsumer.h:853
clang::CodeCompletionString::getTypedText
const char * getTypedText() const
Returns the text in the TypedText chunk.
Definition: CodeCompleteConsumer.cpp:341
llvm::ArrayRef
Definition: LLVM.h:34
clang::CodeCompletionContext::CCC_PreprocessorDirective
@ CCC_PreprocessorDirective
Code completion occurred where a preprocessor directive is expected.
Definition: CodeCompleteConsumer.h:296
clang::CodeCompleteConsumer::includeFixIts
bool includeFixIts() const
Whether to include completion items with small fix-its, e.g.
Definition: CodeCompleteConsumer.h:1105
clang::CodeCompletionContext::isUsingDeclaration
bool isUsingDeclaration() const
Definition: CodeCompleteConsumer.h:385
clang::CCP_NextInitializer
@ CCP_NextInitializer
Priority for the next initialization in a constructor initializer list.
Definition: CodeCompleteConsumer.h:57
CXCursorKind
CXCursorKind
Describes the kind of entity that a cursor refers to.
Definition: Index.h:1706
clang::OverloadCandidate
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
Definition: Overload.h:807
clang::PrintingCodeCompleteConsumer::ProcessCodeCompleteResults
void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults) override
Prints the finalized code-completion results.
Definition: CodeCompleteConsumer.cpp:538
clang::CodeCompletionString::CK_Equal
@ CK_Equal
An '=' sign.
Definition: CodeCompleteConsumer.h:511
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:355
LLVM.h
clang::CodeCompletionResult::getKeyword
const char * getKeyword() const
Retrieve the keyword stored in this result.
Definition: CodeCompleteConsumer.h:930
clang::CodeCompletionContext::CCC_ClassStructUnion
@ CCC_ClassStructUnion
Code completion occurred within a class, struct, or union.
Definition: CodeCompleteConsumer.h:214
clang::CCP_MemberDeclaration
@ CCP_MemberDeclaration
Priority for a member declaration found from the current method or member function.
Definition: CodeCompleteConsumer.h:71
clang::CodeCompletionContext::CCC_Statement
@ CCC_Statement
Code completion occurred where a statement (or declaration) is expected in a function,...
Definition: CodeCompleteConsumer.h:218
clang::CodeCompleteConsumer
Abstract interface for a consumer of code-completion information.
Definition: CodeCompleteConsumer.h:1000
clang::CodeCompletionContext::CCC_DotMemberAccess
@ CCC_DotMemberAccess
Code completion occurred on the right-hand side of a member access expression using the dot operator.
Definition: CodeCompleteConsumer.h:233
clang::CodeCompletionResult::Hidden
bool Hidden
Whether this result is hidden by another name.
Definition: CodeCompleteConsumer.h:830
clang::CodeCompletionString::getAvailability
unsigned getAvailability() const
Retrieve the availability of this code completion result.
Definition: CodeCompleteConsumer.h:616
clang::CodeCompletionResult::CodeCompletionResult
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.
Definition: CodeCompleteConsumer.h:899
clang::CodeCompletionResult::createCodeCompletionStringForDecl
CodeCompletionString * createCodeCompletionStringForDecl(Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, bool IncludeBriefComments, const CodeCompletionContext &CCContext, PrintingPolicy &Policy)
Definition: SemaCodeComplete.cpp:3426
clang::CodeCompletionResult::Macro
const IdentifierInfo * Macro
When Kind == RK_Macro, the identifier that refers to a macro.
Definition: CodeCompleteConsumer.h:780
clang::CodeCompletionString::CK_CurrentParameter
@ CK_CurrentParameter
A piece of text that describes the parameter that corresponds to the code-completion location within ...
Definition: CodeCompleteConsumer.h:475
clang::CodeCompletionResult::getDeclaration
const NamedDecl * getDeclaration() const
Retrieve the declaration stored in this result.
Definition: CodeCompleteConsumer.h:923
clang::CodeCompletionString::getAnnotation
const char * getAnnotation(unsigned AnnotationNr) const
Retrieve the annotation string specified by AnnotationNr.
Definition: CodeCompleteConsumer.cpp:307
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:84
clang::CCP_Keyword
@ CCP_Keyword
Priority for a language keyword (that isn't any of the other categories).
Definition: CodeCompleteConsumer.h:75
clang::SimplifiedTypeClass
SimplifiedTypeClass
A simplified classification of types used when determining "similar" types for code completion.
Definition: CodeCompleteConsumer.h:149
clang::STC_Function
@ STC_Function
Definition: CodeCompleteConsumer.h:153
Priority
int Priority
Definition: Format.cpp:2337
clang::CodeCompleteConsumer::CodeCompleteOpts
const CodeCompleteOptions CodeCompleteOpts
Definition: CodeCompleteConsumer.h:1002
clang::STC_Other
@ STC_Other
Definition: CodeCompleteConsumer.h:155
clang::CodeCompletionString::CK_LeftBracket
@ CK_LeftBracket
A left bracket ('[').
Definition: CodeCompleteConsumer.h:484
clang::CodeCompletionContext::CodeCompletionContext
CodeCompletionContext(Kind CCKind, QualType T, ArrayRef< IdentifierInfo * > SelIdents=None)
Construct a new code-completion context of the given kind.
Definition: CodeCompleteConsumer.h:374
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::CodeCompleteConsumer::includeBriefComments
bool includeBriefComments() const
Whether to include brief documentation comments within the set of code completions returned.
Definition: CodeCompleteConsumer.h:1099
clang::CodeCompletionString::getBriefComment
const char * getBriefComment() const
Definition: CodeCompleteConsumer.h:629
clang::CodeCompletionResult::RK_Pattern
@ RK_Pattern
Refers to a precomputed pattern.
Definition: CodeCompleteConsumer.h:763
clang::CodeCompletionResult::ResultKind
ResultKind
Describes the kind of result generated.
Definition: CodeCompleteConsumer.h:752
clang::CodeCompletionBuilder::CodeCompletionBuilder
CodeCompletionBuilder(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, unsigned Priority, CXAvailabilityKind Availability)
Definition: CodeCompleteConsumer.h:696
std
Definition: Format.h:4034
clang::CodeCompletionResult::AllParametersAreInformative
bool AllParametersAreInformative
Whether all parameters (of a function, Objective-C method, etc.) should be considered "informative".
Definition: CodeCompleteConsumer.h:844
clang::CodeCompletionString::Chunk::CreatePlaceholder
static Chunk CreatePlaceholder(const char *Placeholder)
Create a new placeholder chunk.
Definition: CodeCompleteConsumer.cpp:264
clang::CodeCompletionContext::CCC_NaturalLanguage
@ CCC_NaturalLanguage
Code completion occurred in a context where natural language is expected, e.g., a comment or string l...
Definition: CodeCompleteConsumer.h:303
clang::CodeCompletionString::CK_Placeholder
@ CK_Placeholder
A string that acts as a placeholder for, e.g., a function call argument.
Definition: CodeCompleteConsumer.h:463
clang::STC_Record
@ STC_Record
Definition: CodeCompleteConsumer.h:157
clang
Definition: CalledOnceCheck.h:17
Text
StringRef Text
Definition: Format.cpp:2334
clang::getCompletionComment
const RawComment * getCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Declaration.
Definition: SemaCodeComplete.cpp:3640
clang::CodeCompleteConsumer::getAllocator
virtual CodeCompletionAllocator & getAllocator()=0
Retrieve the allocator that will be used to allocate code completion strings.
clang::CodeCompleteConsumer::OverloadCandidate::OverloadCandidate
OverloadCandidate(const FunctionType *Type)
Definition: CodeCompleteConsumer.h:1045
clang::CodeCompletionResult::InBaseClass
bool InBaseClass
Whether this is a class member from base class.
Definition: CodeCompleteConsumer.h:833
MacroInfo.h
clang::CodeCompletionContext::CCC_NewName
@ CCC_NewName
Code completion occurred where a new name is expected.
Definition: CodeCompleteConsumer.h:274
clang::CodeCompletionString::Chunk::CreateInformative
static Chunk CreateInformative(const char *Informative)
Create a new informative chunk.
Definition: CodeCompleteConsumer.cpp:269
clang::CCF_ExactTypeMatch
@ CCF_ExactTypeMatch
Divide by this factor when a code-completion result's type exactly matches the type we expect.
Definition: CodeCompleteConsumer.h:139
clang::getDeclUsageType
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.
Definition: SemaCodeComplete.cpp:910
clang::CodeCompletionResult::getOrderedName
StringRef getOrderedName(std::string &Saved) const
Retrieve the name that should be used to order a result.
Definition: CodeCompleteConsumer.cpp:729
clang::operator<
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
Definition: DeclarationName.h:540
clang::CCP_CodePattern
@ CCP_CodePattern
Priority for a code pattern.
Definition: CodeCompleteConsumer.h:78
clang::CodeCompletionContext::setIsUsingDeclaration
void setIsUsingDeclaration(bool V)
Definition: CodeCompleteConsumer.h:386
clang::CCP_NestedNameSpecifier
@ CCP_NestedNameSpecifier
Priority for a nested-name-specifier.
Definition: CodeCompleteConsumer.h:93
clang::CodeCompletionBuilder::AddPlaceholderChunk
void AddPlaceholderChunk(const char *Placeholder)
Add a new placeholder chunk.
Definition: CodeCompleteConsumer.cpp:446
clang::CodeCompletionBuilder::addBriefComment
void addBriefComment(StringRef Comment)
Definition: CodeCompleteConsumer.cpp:481
clang::CodeCompletionTUInfo::CodeCompletionTUInfo
CodeCompletionTUInfo(std::shared_ptr< GlobalCodeCompletionAllocator > Allocator)
Definition: CodeCompleteConsumer.h:653
clang::CCD_BlockPropertySetter
@ CCD_BlockPropertySetter
An Objective-C block property completed as a setter with a block placeholder.
Definition: CodeCompleteConsumer.h:131
clang::CodeCompletionContext::CCC_ObjCIvarList
@ CCC_ObjCIvarList
Code completion occurred within the instance variable list of an Objective-C interface,...
Definition: CodeCompleteConsumer.h:211
clang::CodeCompletionString::CK_RightAngle
@ CK_RightAngle
A right angle bracket ('>').
Definition: CodeCompleteConsumer.h:499
clang::CodeCompletionResult::RK_Declaration
@ RK_Declaration
Refers to a declaration.
Definition: CodeCompleteConsumer.h:754
clang::CCD_InBaseClass
@ CCD_InBaseClass
The result is in a base class.
Definition: CodeCompleteConsumer.h:107
clang::CodeCompleteOptions
Options controlling the behavior of code completion.
Definition: CodeCompleteOptions.h:15
clang::CodeCompletionAllocator
An allocator used specifically for the purpose of code completion.
Definition: CodeCompleteConsumer.h:639
clang::CodeCompletionContext::CCC_ParenthesizedExpression
@ CCC_ParenthesizedExpression
Code completion in a parenthesized expression, which means that we may also have types here in C and ...
Definition: CodeCompleteConsumer.h:313
clang::CodeCompleteConsumer::OverloadCandidate::Type
const FunctionType * Type
The function type that describes the entity being called, when Kind == CK_FunctionType.
Definition: CodeCompleteConsumer.h:1035
clang::CodeCompletionResult::DeclaringEntity
bool DeclaringEntity
Whether we're completing a declaration of the given entity, rather than a use of that entity.
Definition: CodeCompleteConsumer.h:848
clang::CodeCompletionString::Chunk::CreateText
static Chunk CreateText(const char *Text)
Create a new text chunk.
Definition: CodeCompleteConsumer.cpp:251
clang::CodeCompletionContext::wantConstructorResults
bool wantConstructorResults() const
Determines whether we want C++ constructors as results within this context.
Definition: CodeCompleteConsumer.cpp:45
clang::CodeCompletionString::Chunk
One piece of the code completion string.
Definition: CodeCompleteConsumer.h:522
clang::CodeCompletionContext::CCC_SelectorName
@ CCC_SelectorName
Code completion for a selector, as in an @selector expression.
Definition: CodeCompleteConsumer.h:306
clang::CodeCompleteConsumer::~CodeCompleteConsumer
virtual ~CodeCompleteConsumer()
Deregisters and destroys this code-completion consumer.
clang::CodeCompletionResult::Kind
ResultKind Kind
The kind of result stored here.
Definition: CodeCompleteConsumer.h:791
clang::CodeCompletionString::CK_Optional
@ CK_Optional
A code completion string that is entirely optional.
Definition: CodeCompleteConsumer.h:459
clang::GlobalCodeCompletionAllocator
Allocator for a cached set of global code completions.
Definition: CodeCompleteConsumer.h:646
clang::getCursorKindForDecl
CXCursorKind getCursorKindForDecl(const Decl *D)
Determine the libclang cursor kind associated with the given declaration.
Definition: SemaCodeComplete.cpp:3836
clang::CodeCompletionContext
The context in which code completion occurred, so that the code-completion consumer can process the r...
Definition: CodeCompleteConsumer.h:187
clang::CodeCompleteOptions::LoadExternal
unsigned LoadExternal
Hint whether to load data from the external AST to provide full results.
Definition: CodeCompleteOptions.h:40
clang::getCompletionKindString
llvm::StringRef getCompletionKindString(CodeCompletionContext::Kind Kind)
Get string representation of Kind, useful for for debugging.
Definition: CodeCompleteConsumer.cpp:92
clang::CodeCompletionBuilder::AddInformativeChunk
void AddInformativeChunk(const char *Text)
Add a new informative chunk.
Definition: CodeCompleteConsumer.cpp:450
clang::operator>=
bool operator>=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
Definition: DeclarationName.h:558
clang::CodeCompletionString::CK_LeftBrace
@ CK_LeftBrace
A left brace ('{').
Definition: CodeCompleteConsumer.h:490
clang::CodeCompletionResult::FixIts
std::vector< FixItHint > FixIts
Fix-its that must be applied before inserting the text for the corresponding completion.
Definition: CodeCompleteConsumer.h:827
clang::CodeCompletionTUInfo::getParentName
StringRef getParentName(const DeclContext *DC)
Definition: CodeCompleteConsumer.cpp:361
clang::Preprocessor
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:130
clang::STC_ObjectiveC
@ STC_ObjectiveC
Definition: CodeCompleteConsumer.h:154
clang::CodeCompletionTUInfo::getAllocator
CodeCompletionAllocator & getAllocator() const
Definition: CodeCompleteConsumer.h:661
clang::CodeCompletionResult::CodeCompletionResult
CodeCompletionResult(const char *Keyword, unsigned Priority=CCP_Keyword)
Build a result that refers to a keyword or symbol.
Definition: CodeCompleteConsumer.h:882
clang::CodeCompleteConsumer::CodeCompleteConsumer
CodeCompleteConsumer(const CodeCompleteOptions &CodeCompleteOpts)
Definition: CodeCompleteConsumer.h:1074
clang::CodeCompletionString::CK_Colon
@ CK_Colon
A colon (':').
Definition: CodeCompleteConsumer.h:505
clang::CodeCompletionBuilder::getParentName
StringRef getParentName() const
Definition: CodeCompleteConsumer.h:745
clang::CodeCompletionResult::CursorKind
CXCursorKind CursorKind
The cursor kind that describes this result.
Definition: CodeCompleteConsumer.h:794
clang::CodeCompletionContext::getPreferredType
QualType getPreferredType() const
Retrieve the type that this expression would prefer to have, e.g., if the expression is a variable in...
Definition: CodeCompleteConsumer.h:394
clang::CodeCompletionResult::CodeCompletionResult
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.
Definition: CodeCompleteConsumer.h:867
clang::CodeCompletionString::CK_Comma
@ CK_Comma
A comma separator (',').
Definition: CodeCompleteConsumer.h:502
clang::CodeCompletionString::Chunk::Text
const char * Text
The text string associated with a CK_Text, CK_Placeholder, CK_Informative, or CK_Comma chunk.
Definition: CodeCompleteConsumer.h:532
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1856
clang::CCD_SelectorMatch
@ CCD_SelectorMatch
The selector of the given message exactly matches the selector of the current method,...
Definition: CodeCompleteConsumer.h:116
clang::CodeCompletionContext::CCC_UnionTag
@ CCC_UnionTag
Code completion occurred after the "union" keyword, to indicate a union name.
Definition: CodeCompleteConsumer.h:257
clang::CodeCompletionString::size
unsigned size() const
Definition: CodeCompleteConsumer.h:602
clang::CodeCompleteConsumer::OverloadCandidate::getFunction
FunctionDecl * getFunction() const
Retrieve the function overload candidate or the templated function declaration for a function templat...
Definition: CodeCompleteConsumer.cpp:488
clang::PrintingCodeCompleteConsumer::getAllocator
CodeCompletionAllocator & getAllocator() override
Retrieve the allocator that will be used to allocate code completion strings.
Definition: CodeCompleteConsumer.h:1200
clang::CodeCompletionContext::CCC_MacroName
@ CCC_MacroName
Code completion occurred where an macro is being defined.
Definition: CodeCompleteConsumer.h:285
clang::CodeCompletionContext::addVisitedContext
void addVisitedContext(DeclContext *Ctx)
Adds a visited context.
Definition: CodeCompleteConsumer.h:416
clang::CodeCompletionContext::getVisitedContexts
const VisitedContextSet & getVisitedContexts() const
Retrieves all visited contexts.
Definition: CodeCompleteConsumer.h:421
clang::CodeCompletionContext::CCC_ObjCClassMessage
@ CCC_ObjCClassMessage
Code completion where an Objective-C class message is expected.
Definition: CodeCompleteConsumer.h:320
clang::CodeCompletionTUInfo
Definition: CodeCompleteConsumer.h:648
clang::CodeCompletionContext::CCC_ObjCInterface
@ CCC_ObjCInterface
Code completion occurred within an Objective-C interface, protocol, or category interface.
Definition: CodeCompleteConsumer.h:203
clang::CodeCompletionContext::CCC_ClassOrStructTag
@ CCC_ClassOrStructTag
Code completion occurred after the "struct" or "class" keyword, to indicate a struct or class name.
Definition: CodeCompleteConsumer.h:261
clang::CodeCompletionContext::CCC_TypeQualifiers
@ CCC_TypeQualifiers
Code completion within a type-qualifier list.
Definition: CodeCompleteConsumer.h:309
clang::CodeCompletionContext::CCC_MacroNameUse
@ CCC_MacroNameUse
Code completion occurred where a macro name is expected (without any arguments, in the case of a func...
Definition: CodeCompleteConsumer.h:289
clang::STC_Arithmetic
@ STC_Arithmetic
Definition: CodeCompleteConsumer.h:150
clang::CodeCompletionContext::getSelIdents
ArrayRef< IdentifierInfo * > getSelIdents() const
Retrieve the Objective-C selector identifiers.
Definition: CodeCompleteConsumer.h:402