clang  3.9.0
CodeCompleteConsumer.cpp
Go to the documentation of this file.
1 //===--- CodeCompleteConsumer.cpp - 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 implements the CodeCompleteConsumer class.
11 //
12 //===----------------------------------------------------------------------===//
14 #include "clang-c/Index.h"
15 #include "clang/AST/DeclCXX.h"
16 #include "clang/AST/DeclObjC.h"
17 #include "clang/AST/DeclTemplate.h"
18 #include "clang/Sema/Scope.h"
19 #include "clang/Sema/Sema.h"
20 #include "llvm/ADT/STLExtras.h"
21 #include "llvm/ADT/SmallString.h"
22 #include "llvm/ADT/Twine.h"
23 #include "llvm/Support/raw_ostream.h"
24 #include <algorithm>
25 #include <cstring>
26 #include <functional>
27 
28 using namespace clang;
29 
30 //===----------------------------------------------------------------------===//
31 // Code completion context implementation
32 //===----------------------------------------------------------------------===//
33 
35  switch (Kind) {
36  case CCC_Recovery:
37  case CCC_Statement:
38  case CCC_Expression:
41  return true;
42 
43  case CCC_TopLevel:
44  case CCC_ObjCInterface:
46  case CCC_ObjCIvarList:
51  case CCC_EnumTag:
52  case CCC_UnionTag:
55  case CCC_Namespace:
56  case CCC_Type:
57  case CCC_Name:
59  case CCC_MacroName:
60  case CCC_MacroNameUse:
64  case CCC_SelectorName:
65  case CCC_TypeQualifiers:
66  case CCC_Other:
72  return false;
73  }
74 
75  llvm_unreachable("Invalid CodeCompletionContext::Kind!");
76 }
77 
78 //===----------------------------------------------------------------------===//
79 // Code completion string implementation
80 //===----------------------------------------------------------------------===//
82  : Kind(Kind), Text("")
83 {
84  switch (Kind) {
85  case CK_TypedText:
86  case CK_Text:
87  case CK_Placeholder:
88  case CK_Informative:
89  case CK_ResultType:
91  this->Text = Text;
92  break;
93 
94  case CK_Optional:
95  llvm_unreachable("Optional strings cannot be created from text");
96 
97  case CK_LeftParen:
98  this->Text = "(";
99  break;
100 
101  case CK_RightParen:
102  this->Text = ")";
103  break;
104 
105  case CK_LeftBracket:
106  this->Text = "[";
107  break;
108 
109  case CK_RightBracket:
110  this->Text = "]";
111  break;
112 
113  case CK_LeftBrace:
114  this->Text = "{";
115  break;
116 
117  case CK_RightBrace:
118  this->Text = "}";
119  break;
120 
121  case CK_LeftAngle:
122  this->Text = "<";
123  break;
124 
125  case CK_RightAngle:
126  this->Text = ">";
127  break;
128 
129  case CK_Comma:
130  this->Text = ", ";
131  break;
132 
133  case CK_Colon:
134  this->Text = ":";
135  break;
136 
137  case CK_SemiColon:
138  this->Text = ";";
139  break;
140 
141  case CK_Equal:
142  this->Text = " = ";
143  break;
144 
145  case CK_HorizontalSpace:
146  this->Text = " ";
147  break;
148 
149  case CK_VerticalSpace:
150  this->Text = "\n";
151  break;
152  }
153 }
154 
157  return Chunk(CK_Text, Text);
158 }
159 
162  Chunk Result;
163  Result.Kind = CK_Optional;
164  Result.Optional = Optional;
165  return Result;
166 }
167 
170  return Chunk(CK_Placeholder, Placeholder);
171 }
172 
175  return Chunk(CK_Informative, Informative);
176 }
177 
180  return Chunk(CK_ResultType, ResultType);
181 }
182 
185  const char *CurrentParameter) {
186  return Chunk(CK_CurrentParameter, CurrentParameter);
187 }
188 
189 CodeCompletionString::CodeCompletionString(const Chunk *Chunks,
190  unsigned NumChunks,
191  unsigned Priority,
192  CXAvailabilityKind Availability,
193  const char **Annotations,
194  unsigned NumAnnotations,
195  StringRef ParentName,
196  const char *BriefComment)
197  : NumChunks(NumChunks), NumAnnotations(NumAnnotations),
198  Priority(Priority), Availability(Availability),
199  ParentName(ParentName), BriefComment(BriefComment)
200 {
201  assert(NumChunks <= 0xffff);
202  assert(NumAnnotations <= 0xffff);
203 
204  Chunk *StoredChunks = reinterpret_cast<Chunk *>(this + 1);
205  for (unsigned I = 0; I != NumChunks; ++I)
206  StoredChunks[I] = Chunks[I];
207 
208  const char **StoredAnnotations = reinterpret_cast<const char **>(StoredChunks + NumChunks);
209  for (unsigned I = 0; I != NumAnnotations; ++I)
210  StoredAnnotations[I] = Annotations[I];
211 }
212 
214  return NumAnnotations;
215 }
216 
217 const char *CodeCompletionString::getAnnotation(unsigned AnnotationNr) const {
218  if (AnnotationNr < NumAnnotations)
219  return reinterpret_cast<const char * const*>(end())[AnnotationNr];
220  else
221  return nullptr;
222 }
223 
224 
226  std::string Result;
227  llvm::raw_string_ostream OS(Result);
228 
229  for (iterator C = begin(), CEnd = end(); C != CEnd; ++C) {
230  switch (C->Kind) {
231  case CK_Optional: OS << "{#" << C->Optional->getAsString() << "#}"; break;
232  case CK_Placeholder: OS << "<#" << C->Text << "#>"; break;
233 
234  case CK_Informative:
235  case CK_ResultType:
236  OS << "[#" << C->Text << "#]";
237  break;
238 
239  case CK_CurrentParameter: OS << "<#" << C->Text << "#>"; break;
240  default: OS << C->Text; break;
241  }
242  }
243  return OS.str();
244 }
245 
247  for (iterator C = begin(), CEnd = end(); C != CEnd; ++C)
248  if (C->Kind == CK_TypedText)
249  return C->Text;
250 
251  return nullptr;
252 }
253 
254 const char *CodeCompletionAllocator::CopyString(const Twine &String) {
255  SmallString<128> Data;
256  StringRef Ref = String.toStringRef(Data);
257  // FIXME: It would be more efficient to teach Twine to tell us its size and
258  // then add a routine there to fill in an allocated char* with the contents
259  // of the string.
260  char *Mem = (char *)Allocate(Ref.size() + 1, 1);
261  std::copy(Ref.begin(), Ref.end(), Mem);
262  Mem[Ref.size()] = 0;
263  return Mem;
264 }
265 
267  const NamedDecl *ND = dyn_cast<NamedDecl>(DC);
268  if (!ND)
269  return StringRef();
270 
271  // Check whether we've already cached the parent name.
272  StringRef &CachedParentName = ParentNames[DC];
273  if (!CachedParentName.empty())
274  return CachedParentName;
275 
276  // If we already processed this DeclContext and assigned empty to it, the
277  // data pointer will be non-null.
278  if (CachedParentName.data() != nullptr)
279  return StringRef();
280 
281  // Find the interesting names.
283  while (DC && !DC->isFunctionOrMethod()) {
284  if (const NamedDecl *ND = dyn_cast<NamedDecl>(DC)) {
285  if (ND->getIdentifier())
286  Contexts.push_back(DC);
287  }
288 
289  DC = DC->getParent();
290  }
291 
292  {
294  llvm::raw_svector_ostream OS(S);
295  bool First = true;
296  for (unsigned I = Contexts.size(); I != 0; --I) {
297  if (First)
298  First = false;
299  else {
300  OS << "::";
301  }
302 
303  const DeclContext *CurDC = Contexts[I-1];
304  if (const ObjCCategoryImplDecl *CatImpl = dyn_cast<ObjCCategoryImplDecl>(CurDC))
305  CurDC = CatImpl->getCategoryDecl();
306 
307  if (const ObjCCategoryDecl *Cat = dyn_cast<ObjCCategoryDecl>(CurDC)) {
308  const ObjCInterfaceDecl *Interface = Cat->getClassInterface();
309  if (!Interface) {
310  // Assign an empty StringRef but with non-null data to distinguish
311  // between empty because we didn't process the DeclContext yet.
312  CachedParentName = StringRef((const char *)(uintptr_t)~0U, 0);
313  return StringRef();
314  }
315 
316  OS << Interface->getName() << '(' << Cat->getName() << ')';
317  } else {
318  OS << cast<NamedDecl>(CurDC)->getName();
319  }
320  }
321 
322  CachedParentName = AllocatorRef->CopyString(OS.str());
323  }
324 
325  return CachedParentName;
326 }
327 
329  void *Mem = getAllocator().Allocate(
330  sizeof(CodeCompletionString) + sizeof(Chunk) * Chunks.size()
331  + sizeof(const char *) * Annotations.size(),
332  llvm::alignOf<CodeCompletionString>());
334  = new (Mem) CodeCompletionString(Chunks.data(), Chunks.size(),
335  Priority, Availability,
336  Annotations.data(), Annotations.size(),
337  ParentName, BriefComment);
338  Chunks.clear();
339  return Result;
340 }
341 
343  Chunks.push_back(Chunk(CodeCompletionString::CK_TypedText, Text));
344 }
345 
347  Chunks.push_back(Chunk::CreateText(Text));
348 }
349 
351  Chunks.push_back(Chunk::CreateOptional(Optional));
352 }
353 
354 void CodeCompletionBuilder::AddPlaceholderChunk(const char *Placeholder) {
355  Chunks.push_back(Chunk::CreatePlaceholder(Placeholder));
356 }
357 
359  Chunks.push_back(Chunk::CreateInformative(Text));
360 }
361 
362 void CodeCompletionBuilder::AddResultTypeChunk(const char *ResultType) {
363  Chunks.push_back(Chunk::CreateResultType(ResultType));
364 }
365 
366 void
367 CodeCompletionBuilder::AddCurrentParameterChunk(const char *CurrentParameter) {
368  Chunks.push_back(Chunk::CreateCurrentParameter(CurrentParameter));
369 }
370 
372  const char *Text) {
373  Chunks.push_back(Chunk(CK, Text));
374 }
375 
377  if (DC->isTranslationUnit()) {
378  return;
379  }
380 
381  if (DC->isFunctionOrMethod())
382  return;
383 
384  const NamedDecl *ND = dyn_cast<NamedDecl>(DC);
385  if (!ND)
386  return;
387 
388  ParentName = getCodeCompletionTUInfo().getParentName(DC);
389 }
390 
391 void CodeCompletionBuilder::addBriefComment(StringRef Comment) {
392  BriefComment = Allocator.CopyString(Comment);
393 }
394 
395 //===----------------------------------------------------------------------===//
396 // Code completion overload candidate implementation
397 //===----------------------------------------------------------------------===//
398 FunctionDecl *
400  if (getKind() == CK_Function)
401  return Function;
402  else if (getKind() == CK_FunctionTemplate)
403  return FunctionTemplate->getTemplatedDecl();
404  else
405  return nullptr;
406 }
407 
408 const FunctionType *
410  switch (Kind) {
411  case CK_Function:
412  return Function->getType()->getAs<FunctionType>();
413 
414  case CK_FunctionTemplate:
415  return FunctionTemplate->getTemplatedDecl()->getType()
416  ->getAs<FunctionType>();
417 
418  case CK_FunctionType:
419  return Type;
420  }
421 
422  llvm_unreachable("Invalid CandidateKind!");
423 }
424 
425 //===----------------------------------------------------------------------===//
426 // Code completion consumer implementation
427 //===----------------------------------------------------------------------===//
428 
430 
431 void
434  CodeCompletionResult *Results,
435  unsigned NumResults) {
436  std::stable_sort(Results, Results + NumResults);
437 
438  // Print the results.
439  for (unsigned I = 0; I != NumResults; ++I) {
440  OS << "COMPLETION: ";
441  switch (Results[I].Kind) {
443  OS << *Results[I].Declaration;
444  if (Results[I].Hidden)
445  OS << " (Hidden)";
446  if (CodeCompletionString *CCS
447  = Results[I].CreateCodeCompletionString(SemaRef, Context,
448  getAllocator(),
449  CCTUInfo,
450  includeBriefComments())) {
451  OS << " : " << CCS->getAsString();
452  if (const char *BriefComment = CCS->getBriefComment())
453  OS << " : " << BriefComment;
454  }
455 
456  OS << '\n';
457  break;
458 
460  OS << Results[I].Keyword << '\n';
461  break;
462 
464  OS << Results[I].Macro->getName();
465  if (CodeCompletionString *CCS
466  = Results[I].CreateCodeCompletionString(SemaRef, Context,
467  getAllocator(),
468  CCTUInfo,
469  includeBriefComments())) {
470  OS << " : " << CCS->getAsString();
471  }
472  OS << '\n';
473  break;
474  }
475 
477  OS << "Pattern : "
478  << Results[I].Pattern->getAsString() << '\n';
479  break;
480  }
481  }
482  }
483 }
484 
485 // This function is used solely to preserve the former presentation of overloads
486 // by "clang -cc1 -code-completion-at", since CodeCompletionString::getAsString
487 // needs to be improved for printing the newer and more detailed overload
488 // chunks.
489 static std::string getOverloadAsString(const CodeCompletionString &CCS) {
490  std::string Result;
491  llvm::raw_string_ostream OS(Result);
492 
493  for (auto &C : CCS) {
494  switch (C.Kind) {
497  OS << "[#" << C.Text << "#]";
498  break;
499 
501  OS << "<#" << C.Text << "#>";
502  break;
503 
504  default: OS << C.Text; break;
505  }
506  }
507  return OS.str();
508 }
509 
510 void
512  unsigned CurrentArg,
513  OverloadCandidate *Candidates,
514  unsigned NumCandidates) {
515  for (unsigned I = 0; I != NumCandidates; ++I) {
516  if (CodeCompletionString *CCS
517  = Candidates[I].CreateSignatureString(CurrentArg, SemaRef,
518  getAllocator(), CCTUInfo,
519  includeBriefComments())) {
520  OS << "OVERLOAD: " << getOverloadAsString(*CCS) << "\n";
521  }
522  }
523 }
524 
525 /// \brief Retrieve the effective availability of the given declaration.
527  AvailabilityResult AR = D->getAvailability();
528  if (isa<EnumConstantDecl>(D))
529  AR = std::max(AR, cast<Decl>(D->getDeclContext())->getAvailability());
530  return AR;
531 }
532 
533 void CodeCompletionResult::computeCursorKindAndAvailability(bool Accessible) {
534  switch (Kind) {
535  case RK_Pattern:
536  if (!Declaration) {
537  // Do nothing: Patterns can come with cursor kinds!
538  break;
539  }
540  // Fall through
541 
542  case RK_Declaration: {
543  // Set the availability based on attributes.
544  switch (getDeclAvailability(Declaration)) {
545  case AR_Available:
546  case AR_NotYetIntroduced:
547  Availability = CXAvailability_Available;
548  break;
549 
550  case AR_Deprecated:
551  Availability = CXAvailability_Deprecated;
552  break;
553 
554  case AR_Unavailable:
555  Availability = CXAvailability_NotAvailable;
556  break;
557  }
558 
559  if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(Declaration))
560  if (Function->isDeleted())
561  Availability = CXAvailability_NotAvailable;
562 
563  CursorKind = getCursorKindForDecl(Declaration);
564  if (CursorKind == CXCursor_UnexposedDecl) {
565  // FIXME: Forward declarations of Objective-C classes and protocols
566  // are not directly exposed, but we want code completion to treat them
567  // like a definition.
568  if (isa<ObjCInterfaceDecl>(Declaration))
569  CursorKind = CXCursor_ObjCInterfaceDecl;
570  else if (isa<ObjCProtocolDecl>(Declaration))
571  CursorKind = CXCursor_ObjCProtocolDecl;
572  else
573  CursorKind = CXCursor_NotImplemented;
574  }
575  break;
576  }
577 
578  case RK_Macro:
579  case RK_Keyword:
580  llvm_unreachable("Macro and keyword kinds are handled by the constructors");
581  }
582 
583  if (!Accessible)
584  Availability = CXAvailability_NotAccessible;
585 }
586 
587 /// \brief Retrieve the name that should be used to order a result.
588 ///
589 /// If the name needs to be constructed as a string, that string will be
590 /// saved into Saved and the returned StringRef will refer to it.
591 static StringRef getOrderedName(const CodeCompletionResult &R,
592  std::string &Saved) {
593  switch (R.Kind) {
595  return R.Keyword;
596 
598  return R.Pattern->getTypedText();
599 
601  return R.Macro->getName();
602 
604  // Handle declarations below.
605  break;
606  }
607 
609 
610  // If the name is a simple identifier (by far the common case), or a
611  // zero-argument selector, just return a reference to that identifier.
612  if (IdentifierInfo *Id = Name.getAsIdentifierInfo())
613  return Id->getName();
614  if (Name.isObjCZeroArgSelector())
615  if (IdentifierInfo *Id
617  return Id->getName();
618 
619  Saved = Name.getAsString();
620  return Saved;
621 }
622 
624  const CodeCompletionResult &Y) {
625  std::string XSaved, YSaved;
626  StringRef XStr = getOrderedName(X, XSaved);
627  StringRef YStr = getOrderedName(Y, YSaved);
628  int cmp = XStr.compare_lower(YStr);
629  if (cmp)
630  return cmp < 0;
631 
632  // If case-insensitive comparison fails, try case-sensitive comparison.
633  cmp = XStr.compare(YStr);
634  if (cmp)
635  return cmp < 0;
636 
637  return false;
638 }
One piece of the code completion string.
An unknown context, in which we are recovering from a parsing error and don'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:125
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1561
ResultKind Kind
The kind of result stored here.
FunctionDecl * getFunction() const
Retrieve the function overload candidate or the templated function declaration for a function templat...
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:237
StringRef getParentName(const DeclContext *DC)
Code completion for a selector, as in an @selector expression.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
Definition: Decl.h:232
void AddTextChunk(const char *Text)
Add a new text chunk.
Code completion where an Objective-C class message is expected.
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:2879
Code completion within a type-qualifier list.
void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text="")
Add a new chunk.
Defines the C++ template declaration subclasses.
static Chunk CreateText(const char *Text)
Create a new text chunk.
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
Definition: Type.h:1281
An unspecified code-completion context.
static Chunk CreateOptional(CodeCompletionString *Optional)
Create a new optional chunk.
Code completion occurred where an Objective-C message receiver is expected.
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.
unsigned getAvailability() const
Retrieve the availability of this code completion result.
A piece of text that describes the type of an entity or, for functions and methods, the return type.
const char * Keyword
When Kind == RK_Keyword, the string representing the keyword or symbol's spelling.
static Chunk CreateResultType(const char *ResultType)
Create a new result type chunk.
void AddOptionalChunk(CodeCompletionString *Optional)
Add a new optional chunk.
Code completion occurred within the instance variable list of an Objective-C interface, implementation, or category implementation.
void AddTypedTextChunk(const char *Text)
Add a new typed-text chunk.
The entity is not available; any use of it will be an error.
Definition: Index.h:138
const FunctionType * getFunctionType() const
Retrieve the function type of the entity, regardless of how the function is stored.
One of these records is kept for each identifier that is lexed.
CodeCompletionString * TakeString()
Take the resulting completion string.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:4549
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
static Chunk CreateInformative(const char *Informative)
Create a new informative chunk.
unsigned getAnnotationCount() const
Retrieve the number of annotations for this code completion result.
A "string" used to describe how code completion can be performed for an entity.
An Objective-C @protocol declaration.
Definition: Index.h:1591
bool isTranslationUnit() const
Definition: DeclBase.h:1283
void AddResultTypeChunk(const char *ResultType)
Add a new result-type chunk.
static Chunk CreatePlaceholder(const char *Placeholder)
Create a new placeholder chunk.
CodeCompletionString * Pattern
When Kind == RK_Pattern, the code-completion string that describes the completion text to insert...
Code completion occurred where a preprocessor directive is expected.
Code completion occurred within an Objective-C implementation or category implementation.
bool wantConstructorResults() const
Determines whether we want C++ constructors as results within this context.
Code completion occurred where a namespace or namespace alias is expected.
static Chunk CreateCurrentParameter(const char *CurrentParameter)
Create a new current-parameter chunk.
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
Represents an ObjC class declaration.
Definition: DeclObjC.h:1091
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.
detail::InMemoryDirectory::const_iterator I
AvailabilityResult
Captures the result of checking the availability of a declaration.
Definition: DeclBase.h:64
Code completion where an Objective-C category name is expected.
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:263
Code completion occurred within a "top-level" completion context, e.g., at namespace or global scope...
static std::string getOverloadAsString(const CodeCompletionString &CCS)
const char * getTypedText() const
Returns the text in the TypedText chunk.
ASTContext * Context
llvm::SpecificBumpPtrAllocator< StateNode > Allocator
Code completion occurred where a protocol name is expected.
CXCursorKind getCursorKindForDecl(const Decl *D)
Determine the libclang cursor kind associated with the given declaration.
StringRef getName() const
Return the actual identifier string.
Code completion occurred where a new name is expected.
const char * Text
The text string associated with a CK_Text, CK_Placeholder, CK_Informative, or CK_Comma chunk...
const NamedDecl * Declaration
When Kind == RK_Declaration or RK_Pattern, the declaration we are referring to.
Captures a result of code completion.
Code completion occurred where a new name is expected and a qualified name is permissible.
Code completion in a parenthesized expression, which means that we may also have types here in C and ...
bool isFunctionOrMethod() const
Definition: DeclBase.h:1263
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1214
Code completion occurred in a context where natural language is expected, e.g., a comment or string l...
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Definition: Decl.h:258
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.
const char * CopyString(const Twine &String)
Copy the given string into this allocator.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Definition: opencl-c.h:75
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.
Code completion occurred within a class, struct, or union.
static StringRef getOrderedName(const CodeCompletionResult &R, std::string &Saved)
Retrieve the name that should be used to order a result.
Kind
Code completion where the name of an Objective-C class is expected.
Code completion occurred within an Objective-C interface, protocol, or category interface.
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2171
The entity is available.
Definition: Index.h:129
void addParentContext(const DeclContext *DC)
Add the parent context information to this code completion.
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
The entity is available, but not accessible; any use of it will be an error.
Definition: Index.h:143
ChunkKind Kind
The kind of data stored in this piece of the code completion string.
void addBriefComment(StringRef Comment)
Selector getObjCSelector() const
getObjCSelector - Get the Objective-C selector stored in this declaration name.
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:1135
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...
static AvailabilityResult getDeclAvailability(const Decl *D)
Retrieve the effective availability of the given declaration.
void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults) override
Prints the finalized code-completion results.
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...
std::string getAsString() const
Retrieve a string representation of the code completion string, which is mainly useful for debugging...
Code completion where an Objective-C instance message is expected.
DeclarationName - The name of a declaration.
Refers to a precomputed pattern.
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...
SmallVector< Context, 8 > Contexts
void AddInformativeChunk(const char *Text)
Add a new informative chunk.
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:5818
void AddCurrentParameterChunk(const char *CurrentParameter)
Add a new current-parameter chunk.
A declaration whose specific kind is not exposed via this interface.
Definition: Index.h:1564
A piece of text that describes the parameter that corresponds to the code-completion location within ...
A string that acts as a placeholder for, e.g., a function call argument.
bool isObjCZeroArgSelector() const
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Definition: SemaDecl.cpp:12171
Code completion occurred within a preprocessor expression.
Code completion occurred where an expression is expected.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
An unspecified code-completion context where we should also add macro completions.
const char * getAnnotation(unsigned AnnotationNr) const
Retrieve the annotation string specified by AnnotationNr.
Vertical whitespace ('\n' or '\r\n', depending on the platform).
void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates) override
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:810
Code completion occurred on the right-hand side of a member access expression using the dot operator...
void AddPlaceholderChunk(const char *Placeholder)
Add a new placeholder chunk.
Code completion occurred where a type name is expected.
StringRef Text
Definition: Format.cpp:1195
The entity is available, but has been deprecated (and its use is not recommended).
Definition: Index.h:134
NamedDecl - This represents a decl with a name.
Definition: Decl.h:213
An Objective-C @interface.
Definition: Index.h:1587
virtual ~CodeCompleteConsumer()
Deregisters and destroys this code-completion consumer.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
Definition: DeclObjC.h:2380