clang: lib/Sema/CodeCompleteConsumer.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
24#include "llvm/ADT/StringExtras.h"
25#include "llvm/ADT/StringRef.h"
26#include "llvm/ADT/Twine.h"
27#include "llvm/Support/Compiler.h"
28#include "llvm/Support/ErrorHandling.h"
29#include "llvm/Support/raw_ostream.h"
30#include
31#include
32#include
33#include
34
35using namespace clang;
36
37
38
39
40
42 switch (CCKind) {
51 return true;
52
84 return false;
85 }
86
87 llvm_unreachable("Invalid CodeCompletionContext::Kind!");
88}
89
92 switch (Kind) {
93 case CCKind::CCC_Other:
94 return "Other";
95 case CCKind::CCC_OtherWithMacros:
96 return "OtherWithMacros";
97 case CCKind::CCC_TopLevel:
98 return "TopLevel";
99 case CCKind::CCC_ObjCInterface:
100 return "ObjCInterface";
101 case CCKind::CCC_ObjCImplementation:
102 return "ObjCImplementation";
103 case CCKind::CCC_ObjCIvarList:
104 return "ObjCIvarList";
105 case CCKind::CCC_ClassStructUnion:
106 return "ClassStructUnion";
107 case CCKind::CCC_Statement:
108 return "Statement";
109 case CCKind::CCC_Expression:
110 return "Expression";
111 case CCKind::CCC_ObjCMessageReceiver:
112 return "ObjCMessageReceiver";
113 case CCKind::CCC_DotMemberAccess:
114 return "DotMemberAccess";
115 case CCKind::CCC_ArrowMemberAccess:
116 return "ArrowMemberAccess";
117 case CCKind::CCC_ObjCPropertyAccess:
118 return "ObjCPropertyAccess";
119 case CCKind::CCC_EnumTag:
120 return "EnumTag";
121 case CCKind::CCC_UnionTag:
122 return "UnionTag";
123 case CCKind::CCC_ClassOrStructTag:
124 return "ClassOrStructTag";
125 case CCKind::CCC_ObjCProtocolName:
126 return "ObjCProtocolName";
127 case CCKind::CCC_Namespace:
128 return "Namespace";
129 case CCKind::CCC_Type:
130 return "Type";
131 case CCKind::CCC_NewName:
132 return "NewName";
133 case CCKind::CCC_Symbol:
134 return "Symbol";
135 case CCKind::CCC_SymbolOrNewName:
136 return "SymbolOrNewName";
137 case CCKind::CCC_MacroName:
138 return "MacroName";
139 case CCKind::CCC_MacroNameUse:
140 return "MacroNameUse";
141 case CCKind::CCC_PreprocessorExpression:
142 return "PreprocessorExpression";
143 case CCKind::CCC_PreprocessorDirective:
144 return "PreprocessorDirective";
145 case CCKind::CCC_NaturalLanguage:
146 return "NaturalLanguage";
147 case CCKind::CCC_SelectorName:
148 return "SelectorName";
149 case CCKind::CCC_TypeQualifiers:
150 return "TypeQualifiers";
151 case CCKind::CCC_ParenthesizedExpression:
152 return "ParenthesizedExpression";
153 case CCKind::CCC_ObjCInstanceMessage:
154 return "ObjCInstanceMessage";
155 case CCKind::CCC_ObjCClassMessage:
156 return "ObjCClassMessage";
157 case CCKind::CCC_ObjCInterfaceName:
158 return "ObjCInterfaceName";
159 case CCKind::CCC_ObjCCategoryName:
160 return "ObjCCategoryName";
161 case CCKind::CCC_IncludedFile:
162 return "IncludedFile";
163 case CCKind::CCC_Attribute:
164 return "Attribute";
165 case CCKind::CCC_Recovery:
166 return "Recovery";
167 case CCKind::CCC_ObjCClassForwardDecl:
168 return "ObjCClassForwardDecl";
169 case CCKind::CCC_TopLevelOrExpression:
170 return "ReplTopLevel";
171 }
172 llvm_unreachable("Invalid CodeCompletionContext::Kind!");
173}
174
175
176
177
178
181 switch (Kind) {
188 this->Text = Text;
189 break;
190
192 llvm_unreachable("Optional strings cannot be created from text");
193
195 this->Text = "(";
196 break;
197
199 this->Text = ")";
200 break;
201
203 this->Text = "[";
204 break;
205
207 this->Text = "]";
208 break;
209
211 this->Text = "{";
212 break;
213
215 this->Text = "}";
216 break;
217
219 this->Text = "<";
220 break;
221
223 this->Text = ">";
224 break;
225
227 this->Text = ", ";
228 break;
229
231 this->Text = ":";
232 break;
233
235 this->Text = ";";
236 break;
237
239 this->Text = " = ";
240 break;
241
243 this->Text = " ";
244 break;
245
247 this->Text = "\n";
248 break;
249 }
250}
251
256
264
269
274
279
281 const char *CurrentParameter) {
283}
284
285CodeCompletionString::CodeCompletionString(
286 const Chunk *Chunks, unsigned NumChunks, unsigned Priority,
287 CXAvailabilityKind Availability, const char **Annotations,
288 unsigned NumAnnotations, StringRef ParentName, const char *BriefComment)
289 : NumChunks(NumChunks), NumAnnotations(NumAnnotations), Priority(Priority),
290 Availability(Availability), ParentName(ParentName),
291 BriefComment(BriefComment) {
292 assert(NumChunks <= 0xffff);
293 assert(NumAnnotations <= 0xffff);
294
295 Chunk *StoredChunks = reinterpret_cast<Chunk *>(this + 1);
296 for (unsigned I = 0; I != NumChunks; ++I)
297 StoredChunks[I] = Chunks[I];
298
299 const char **StoredAnnotations =
300 reinterpret_cast<const char **>(StoredChunks + NumChunks);
301 for (unsigned I = 0; I != NumAnnotations; ++I)
302 StoredAnnotations[I] = Annotations[I];
303}
304
306 return NumAnnotations;
307}
308
310 if (AnnotationNr < NumAnnotations)
311 return reinterpret_cast<const char *const *>(end())[AnnotationNr];
312 else
313 return nullptr;
314}
315
318 llvm::raw_string_ostream OS(Result);
319
320 for (const Chunk &C : *this) {
321 switch (C.Kind) {
323 OS << "{#" << C.Optional->getAsString() << "#}";
324 break;
326 OS << "<#" << C.Text << "#>";
327 break;
330 OS << "[#" << C.Text << "#]";
331 break;
333 OS << "<#" << C.Text << "#>";
334 break;
335 default:
336 OS << C.Text;
337 break;
338 }
339 }
341}
342
344 for (const Chunk &C : *this)
346 return C.Text;
347
348 return nullptr;
349}
350
352 std::string Res;
353 for (const Chunk &C : *this)
355 Res += C.Text;
356
357 return Res;
358}
359
362 StringRef Ref = String.toStringRef(Data);
363
364
365
366 char *Mem = (char *)Allocate(Ref.size() + 1, 1);
367 std::copy(Ref.begin(), Ref.end(), Mem);
368 Mem[Ref.size()] = 0;
369 return Mem;
370}
371
374 return {};
375
376
377 StringRef &CachedParentName = ParentNames[DC];
378 if (!CachedParentName.empty())
379 return CachedParentName;
380
381
382
383 if (CachedParentName.data() != nullptr)
384 return {};
385
386
389 if (const auto *ND = dyn_cast(DC)) {
390 if (ND->getIdentifier())
391 Contexts.push_back(DC);
392 }
393
395 }
396
397 {
399 llvm::raw_svector_ostream OS(S);
400 bool First = true;
401 for (const DeclContext *CurDC : llvm::reverse(Contexts)) {
404 else {
405 OS << "::";
406 }
407
408 if (const auto *CatImpl = dyn_cast(CurDC))
409 CurDC = CatImpl->getCategoryDecl();
410
411 if (const auto *Cat = dyn_cast(CurDC)) {
414
415
416 CachedParentName = StringRef((const char *)(uintptr_t)~0U, 0);
417 return {};
418 }
419
420 OS << Interface->getName() << '(' << Cat->getName() << ')';
421 } else {
422 OS << cast(CurDC)->getName();
423 }
424 }
425
426 CachedParentName = AllocatorRef->CopyString(OS.str());
427 }
428
429 return CachedParentName;
430}
431
435 sizeof(const char *) * Annotations.size(),
438 Chunks.data(), Chunks.size(), Priority, Availability, Annotations.data(),
439 Annotations.size(), ParentName, BriefComment);
440 Chunks.clear();
442}
443
447
451
455
459
463
467
469 const char *CurrentParameter) {
471}
472
474 const char *Text) {
475 Chunks.push_back(Chunk(CK, Text));
476}
477
480 return;
481
483 return;
484
486 return;
487
489}
490
492 BriefComment = Allocator.CopyString(Comment);
493}
494
495
496
497
503 else
504 return nullptr;
505}
506
509 switch (Kind) {
512
515 ->getType()
517
524 return nullptr;
525 }
526
527 llvm_unreachable("Invalid CandidateKind!");
528}
529
536
539 return Template->getTemplateParameters()->size();
540
543 if (const auto *CRD = dyn_cast(AggregateType))
544 Count += CRD->getNumBases();
545 return Count;
546 }
547
549 if (const auto *FPT = dyn_cast(FT))
550 return FPT->getNumParams();
551
552 return 0;
553}
554
558 if (const auto *CRD = dyn_cast(AggregateType)) {
559 if (N < CRD->getNumBases())
560 return std::next(CRD->bases_begin(), N)->getType();
561 N -= CRD->getNumBases();
562 }
563 for (const auto *Field : AggregateType->fields())
564 if (N-- == 0)
565 return Field->getType();
567 }
568
571 if (N < TPL->size())
572 if (const auto *D = dyn_cast(TPL->getParam(N)))
573 return D->getType();
575 }
576
578 if (const auto *FPT = dyn_cast(FT))
580 return FPT->getParamType(N);
582}
583
587 if (const auto *CRD = dyn_cast(AggregateType)) {
588 if (N < CRD->getNumBases())
589 return std::next(CRD->bases_begin(), N)->getType()->getAsTagDecl();
590 N -= CRD->getNumBases();
591 }
592 for (const auto *Field : AggregateType->fields())
593 if (N-- == 0)
594 return Field;
595 return nullptr;
596 }
597
600 if (N < TPL->size())
602 return nullptr;
603 }
604
605
607 if (N < FD->param_size())
608 return FD->getParamDecl(N);
612 }
613 }
614
615 return nullptr;
616}
617
618
619
620
621
623
626 switch (Result.Kind) {
628 return !(
629 Result.Declaration->getIdentifier() &&
630 Result.Declaration->getIdentifier()->getName().starts_with(Filter));
632 return !StringRef(Result.Keyword).starts_with(Filter);
634 return .Macro->getName().starts_with(Filter);
636 return !(Result.Pattern->getTypedText() &&
637 StringRef(Result.Pattern->getTypedText()).starts_with(Filter));
638 }
639 llvm_unreachable("Unknown code completion result Kind.");
640}
641
644 unsigned NumResults) {
645 std::stable_sort(Results, Results + NumResults);
646
647 if (!Context.getPreferredType().isNull())
648 OS << "PREFERRED-TYPE: " << Context.getPreferredType() << '\n';
649
651
652 for (unsigned I = 0; I != NumResults; ++I) {
654 continue;
655 OS << "COMPLETION: ";
656 switch (Results[I].Kind) {
659 {
660 std::vectorstd::string Tags;
661 if (Results[I].Hidden)
662 Tags.push_back("Hidden");
663 if (Results[I].InBaseClass)
664 Tags.push_back("InBase");
665 if (Results[I].Availability ==
667 Tags.push_back("Inaccessible");
668 if (!Tags.empty())
669 OS << " (" << llvm::join(Tags, ",") << ")";
670 }
674 OS << " : " << CCS->getAsString();
675 if (const char *BriefComment = CCS->getBriefComment())
676 OS << " : " << BriefComment;
677 }
678 break;
679
681 OS << Results[I].Keyword;
682 break;
683
689 OS << " : " << CCS->getAsString();
690 }
691 break;
692
695 break;
696 }
697 for (const FixItHint &FixIt : Results[I].FixIts) {
698 const SourceLocation BLoc = FixIt.RemoveRange.getBegin();
699 const SourceLocation ELoc = FixIt.RemoveRange.getEnd();
700
704
705 if (FixIt.RemoveRange.isTokenRange())
707
708 OS << " (requires fix-it:"
709 << " {" << SM.getLineNumber(BInfo.first, BInfo.second) << ':'
710 << SM.getColumnNumber(BInfo.first, BInfo.second) << '-'
711 << SM.getLineNumber(EInfo.first, EInfo.second) << ':'
712 << SM.getColumnNumber(EInfo.first, EInfo.second) << "}"
713 << " to \"" << FixIt.CodeToInsert << "\")";
714 }
715 OS << '\n';
716 }
717}
718
719
720
721
722
724 std::string Result;
725 llvm::raw_string_ostream OS(Result);
726
727 for (auto &C : CCS) {
728 switch (C.Kind) {
731 OS << "[#" << C.Text << "#]";
732 break;
733
735 OS << "<#" << C.Text << "#>";
736 break;
737
738
740 break;
741
742 default:
743 OS << C.Text;
744 break;
745 }
746 }
747 return Result;
748}
749
752 unsigned NumCandidates, SourceLocation OpenParLoc, bool Braced) {
753 OS << "OPENING_PAREN_LOC: ";
755 OS << "\n";
756
757 for (unsigned I = 0; I != NumCandidates; ++I) {
759 CurrentArg, SemaRef, getAllocator(), CCTUInfo,
762 }
763 }
764}
765
766
773
774void CodeCompletionResult::computeCursorKindAndAvailability(bool Accessible) {
775 switch (Kind) {
776 case RK_Pattern:
778
779 break;
780 }
781 [[fallthrough]];
782
783 case RK_Declaration: {
784
789 break;
790
793 break;
794
797 break;
798 }
799
803
806
807
808
813 else
815 }
816 break;
817 }
818
819 case RK_Macro:
820 case RK_Keyword:
821 llvm_unreachable("Macro and keyword kinds are handled by the constructors");
822 }
823
824 if (!Accessible)
826}
827
828
829
830
831
833 switch (Kind) {
837 return Pattern->getTypedText();
839 return Macro->getName();
841
842 break;
843 }
844
846
847
848
850 return Id->getName();
854 return Id->getName();
855
857 return Saved;
858}
859
862 std::string XSaved, YSaved;
863 StringRef XStr = X.getOrderedName(XSaved);
865 int cmp = XStr.compare_insensitive(YStr);
866 if (cmp)
867 return cmp < 0;
868
869
870 return XStr.compare(YStr) < 0;
871}
static AvailabilityResult getDeclAvailability(const Decl *D)
Retrieve the effective availability of the given declaration.
Definition CodeCompleteConsumer.cpp:767
static std::string getOverloadAsString(const CodeCompletionString &CCS)
Definition CodeCompleteConsumer.cpp:723
static Decl::Kind getKind(const Decl *D)
Defines the C++ template declaration subclasses.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Defines the clang::Preprocessor interface.
C Language Family Type Representation.
const FunctionType * Type
The function type that describes the entity being called, when Kind == CK_FunctionType.
const RecordDecl * AggregateType
The class being aggregate-initialized, when Kind == CK_Aggregate.
FunctionProtoTypeLoc ProtoTypeLoc
The location of the function prototype that describes the entity being called, when Kind == CK_Functi...
QualType getParamType(unsigned N) const
Get the type of the Nth parameter.
Definition CodeCompleteConsumer.cpp:556
const FunctionType * getFunctionType() const
Retrieve the function type of the entity, regardless of how the function is stored.
Definition CodeCompleteConsumer.cpp:508
const TemplateDecl * getTemplate() const
FunctionDecl * getFunction() const
Retrieve the function overload candidate or the templated function declaration for a function templat...
Definition CodeCompleteConsumer.cpp:498
FunctionDecl * Function
The function overload candidate, available when Kind == CK_Function.
const FunctionProtoTypeLoc getFunctionProtoTypeLoc() const
Retrieve the function ProtoTypeLoc candidate.
Definition CodeCompleteConsumer.cpp:531
@ CK_Aggregate
The candidate is aggregate initialization of a record type.
@ CK_FunctionType
The "candidate" is actually a variable, expression, or block for which we only have a function protot...
@ CK_Function
The candidate is a function declaration.
@ CK_FunctionProtoTypeLoc
The candidate is a variable or expression of function type for which we have the location of the prot...
@ CK_Template
The candidate is a template, template arguments are being completed.
@ CK_FunctionTemplate
The candidate is a function template, arguments are being completed.
FunctionTemplateDecl * FunctionTemplate
The function template overload candidate, available when Kind == CK_FunctionTemplate.
const NamedDecl * getParamDecl(unsigned N) const
Get the declaration of the Nth parameter.
Definition CodeCompleteConsumer.cpp:585
unsigned getNumParams() const
Get the number of parameters in this signature.
Definition CodeCompleteConsumer.cpp:537
const TemplateDecl * Template
The template overload candidate, available when Kind == CK_Template.
virtual ~CodeCompleteConsumer()
Deregisters and destroys this code-completion consumer.
bool includeBriefComments() const
Whether to include brief documentation comments within the set of code completions returned.
const char * CopyString(const Twine &String)
Copy the given string into this allocator.
Definition CodeCompleteConsumer.cpp:360
CodeCompletionString * TakeString()
Take the resulting completion string.
Definition CodeCompleteConsumer.cpp:432
void AddPlaceholderChunk(const char *Placeholder)
Add a new placeholder chunk.
Definition CodeCompleteConsumer.cpp:456
void AddTextChunk(const char *Text)
Add a new text chunk.
Definition CodeCompleteConsumer.cpp:448
void addParentContext(const DeclContext *DC)
Add the parent context information to this code completion.
Definition CodeCompleteConsumer.cpp:478
void addBriefComment(StringRef Comment)
Definition CodeCompleteConsumer.cpp:491
void AddCurrentParameterChunk(const char *CurrentParameter)
Add a new current-parameter chunk.
Definition CodeCompleteConsumer.cpp:468
CodeCompletionTUInfo & getCodeCompletionTUInfo() const
void AddResultTypeChunk(const char *ResultType)
Add a new result-type chunk.
Definition CodeCompleteConsumer.cpp:464
void AddInformativeChunk(const char *Text)
Add a new informative chunk.
Definition CodeCompleteConsumer.cpp:460
void AddOptionalChunk(CodeCompletionString *Optional)
Add a new optional chunk.
Definition CodeCompleteConsumer.cpp:452
void AddTypedTextChunk(const char *Text)
Add a new typed-text chunk.
Definition CodeCompleteConsumer.cpp:444
void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text="")
Add a new chunk.
Definition CodeCompleteConsumer.cpp:473
CodeCompletionString::Chunk Chunk
CodeCompletionAllocator & getAllocator() const
Retrieve the allocator into which the code completion strings should be allocated.
The context in which code completion occurred, so that the code-completion consumer can process the r...
@ CCC_TypeQualifiers
Code completion within a type-qualifier list.
@ CCC_ObjCMessageReceiver
Code completion occurred where an Objective-C message receiver is expected.
@ CCC_PreprocessorExpression
Code completion occurred within a preprocessor expression.
@ CCC_ObjCCategoryName
Code completion where an Objective-C category name is expected.
@ CCC_ObjCIvarList
Code completion occurred within the instance variable list of an Objective-C interface,...
@ CCC_Statement
Code completion occurred where a statement (or declaration) is expected in a function,...
@ CCC_Type
Code completion occurred where a type name is expected.
@ CCC_ArrowMemberAccess
Code completion occurred on the right-hand side of a member access expression using the arrow operato...
@ CCC_ClassStructUnion
Code completion occurred within a class, struct, or union.
@ CCC_ObjCInterface
Code completion occurred within an Objective-C interface, protocol, or category interface.
@ CCC_ObjCPropertyAccess
Code completion occurred on the right-hand side of an Objective-C property access expression.
@ CCC_Expression
Code completion occurred where an expression is expected.
@ CCC_SelectorName
Code completion for a selector, as in an @selector expression.
@ CCC_TopLevelOrExpression
Code completion at a top level, i.e.
@ CCC_EnumTag
Code completion occurred after the "enum" keyword, to indicate an enumeration name.
@ CCC_UnionTag
Code completion occurred after the "union" keyword, to indicate a union name.
@ CCC_ParenthesizedExpression
Code completion in a parenthesized expression, which means that we may also have types here in C and ...
@ CCC_TopLevel
Code completion occurred within a "top-level" completion context, e.g., at namespace or global scope.
@ CCC_ClassOrStructTag
Code completion occurred after the "struct" or "class" keyword, to indicate a struct or class name.
@ CCC_ObjCClassMessage
Code completion where an Objective-C class message is expected.
@ CCC_ObjCImplementation
Code completion occurred within an Objective-C implementation or category implementation.
@ CCC_IncludedFile
Code completion inside the filename part of a include directive.
@ CCC_ObjCInstanceMessage
Code completion where an Objective-C instance message is expected.
@ CCC_SymbolOrNewName
Code completion occurred where both a new name and an existing symbol is permissible.
@ CCC_Recovery
An unknown context, in which we are recovering from a parsing error and don't know which completions ...
@ CCC_ObjCProtocolName
Code completion occurred where a protocol name is expected.
@ CCC_OtherWithMacros
An unspecified code-completion context where we should also add macro completions.
@ CCC_NewName
Code completion occurred where a new name is expected.
@ CCC_MacroNameUse
Code completion occurred where a macro name is expected (without any arguments, in the case of a func...
@ CCC_Symbol
Code completion occurred where an existing name(such as type, functionor variable) is expected.
@ CCC_Attribute
Code completion of an attribute name.
@ CCC_Other
An unspecified code-completion context.
@ CCC_DotMemberAccess
Code completion occurred on the right-hand side of a member access expression using the dot operator.
@ CCC_MacroName
Code completion occurred where an macro is being defined.
@ CCC_Namespace
Code completion occurred where a namespace or namespace alias is expected.
@ CCC_PreprocessorDirective
Code completion occurred where a preprocessor directive is expected.
@ CCC_NaturalLanguage
Code completion occurred in a context where natural language is expected, e.g., a comment or string l...
@ CCC_ObjCInterfaceName
Code completion where the name of an Objective-C class is expected.
@ CCC_ObjCClassForwardDecl
bool wantConstructorResults() const
Determines whether we want C++ constructors as results within this context.
Definition CodeCompleteConsumer.cpp:41
Captures a result of code completion.
ResultKind Kind
The kind of result stored here.
const char * Keyword
When Kind == RK_Keyword, the string representing the keyword or symbol's spelling.
const NamedDecl * Declaration
When Kind == RK_Declaration or RK_Pattern, the declaration we are referring to.
StringRef getOrderedName(std::string &Saved) const
Retrieve the name that should be used to order a result.
Definition CodeCompleteConsumer.cpp:832
CodeCompletionString * Pattern
When Kind == RK_Pattern, the code-completion string that describes the completion text to insert.
const IdentifierInfo * Macro
When Kind == RK_Macro, the identifier that refers to a macro.
@ RK_Pattern
Refers to a precomputed pattern.
@ RK_Declaration
Refers to a declaration.
@ RK_Macro
Refers to a macro.
@ RK_Keyword
Refers to a keyword or symbol.
A "string" used to describe how code completion can be performed for an entity.
ChunkKind
The different kinds of "chunks" that can occur within a code completion string.
@ CK_Optional
A code completion string that is entirely optional.
@ CK_CurrentParameter
A piece of text that describes the parameter that corresponds to the code-completion location within ...
@ CK_Comma
A comma separator (',').
@ CK_Text
A piece of text that should be placed in the buffer, e.g., parentheses or a comma in a function call.
@ CK_Placeholder
A string that acts as a placeholder for, e.g., a function call argument.
@ CK_LeftParen
A left parenthesis ('(').
@ CK_HorizontalSpace
Horizontal whitespace (' ').
@ CK_RightAngle
A right angle bracket ('>').
@ CK_Informative
A piece of text that describes something about the result but should not be inserted into the buffer.
@ CK_LeftBracket
A left bracket ('[').
@ CK_RightParen
A right parenthesis (')').
@ CK_RightBrace
A right brace ('}').
@ CK_VerticalSpace
Vertical whitespace ('\n' or '\r\n', depending on the platform).
@ CK_SemiColon
A semicolon (';').
@ CK_TypedText
The piece of text that the user is expected to type to match the code-completion string,...
@ CK_ResultType
A piece of text that describes the type of an entity or, for functions and methods,...
@ CK_RightBracket
A right bracket (']').
@ CK_LeftBrace
A left brace ('{').
@ CK_LeftAngle
A left angle bracket ('<').
std::string getAsString() const
Retrieve a string representation of the code completion string, which is mainly useful for debugging.
Definition CodeCompleteConsumer.cpp:316
std::string getAllTypedText() const
Returns the combined text from all TypedText chunks.
Definition CodeCompleteConsumer.cpp:351
const char * getTypedText() const
Returns the text in the first TypedText chunk.
Definition CodeCompleteConsumer.cpp:343
unsigned getAnnotationCount() const
Retrieve the number of annotations for this code completion result.
Definition CodeCompleteConsumer.cpp:305
const char * getAnnotation(unsigned AnnotationNr) const
Retrieve the annotation string specified by AnnotationNr.
Definition CodeCompleteConsumer.cpp:309
StringRef getParentName(const DeclContext *DC)
Definition CodeCompleteConsumer.cpp:372
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isTranslationUnit() const
bool isFunctionOrMethod() const
Decl - This represents one declaration (or definition), e.g.
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
DeclContext * getDeclContext()
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
std::string getAsString() const
Retrieve the human-readable string for this name.
bool isObjCZeroArgSelector() const
Selector getObjCSelector() const
Get the Objective-C selector stored in this declaration name.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
Represents a function declaration or definition.
FunctionType - C99 6.7.5.3 - Function Declarators.
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
static unsigned MeasureTokenLength(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
MeasureTokenLength - Relex the token at the specified location and return its length in bytes in the ...
This represents a decl that may have a name.
Represents an ObjC class declaration.
StringRef getCodeCompletionFilter()
Get the code completion token for filtering purposes.
void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults) override
Prints the finalized code-completion results.
Definition CodeCompleteConsumer.cpp:642
void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates, SourceLocation OpenParLoc, bool Braced) override
Definition CodeCompleteConsumer.cpp:750
CodeCompletionAllocator & getAllocator() override
Retrieve the allocator that will be used to allocate code completion strings.
bool isResultFilteredOut(StringRef Filter, CodeCompletionResult Results) override
Definition CodeCompleteConsumer.cpp:624
A (possibly-)qualified type.
const IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
Sema - This implements semantic analysis and AST building for C.
Preprocessor & getPreprocessor() const
const LangOptions & LangOpts
SourceManager & getSourceManager() const
SourceManager & SourceMgr
Encodes a location in the source.
void print(raw_ostream &OS, const SourceManager &SM) const
This class handles loading and caching of source files into memory.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
@ CXCursor_ObjCInterfaceDecl
An Objective-C @interface.
@ CXCursor_ObjCProtocolDecl
An Objective-C @protocol declaration.
@ CXCursor_UnexposedDecl
A declaration whose specific kind is not exposed via this interface.
@ CXCursor_NotImplemented
@ CXAvailability_Available
The entity is available.
@ CXAvailability_Deprecated
The entity is available, but has been deprecated (and its use is not recommended).
@ CXAvailability_NotAccessible
The entity is available, but not accessible; any use of it will be an error.
@ CXAvailability_NotAvailable
The entity is not available; any use of it will be an error.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
CXCursorKind getCursorKindForDecl(const Decl *D)
Determine the libclang cursor kind associated with the given declaration.
std::pair< FileID, unsigned > FileIDAndOffset
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
@ Result
The result type of a method or function.
AvailabilityResult
Captures the result of checking the availability of a declaration.
llvm::StringRef getCompletionKindString(CodeCompletionContext::Kind Kind)
Get string representation of Kind, useful for debugging.
Definition CodeCompleteConsumer.cpp:90
U cast(CodeGen::Address addr)
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
One piece of the code completion string.
static Chunk CreateOptional(CodeCompletionString *Optional)
Create a new optional chunk.
Definition CodeCompleteConsumer.cpp:258
ChunkKind Kind
The kind of data stored in this piece of the code completion string.
static Chunk CreatePlaceholder(const char *Placeholder)
Create a new placeholder chunk.
Definition CodeCompleteConsumer.cpp:266
static Chunk CreateCurrentParameter(const char *CurrentParameter)
Create a new current-parameter chunk.
Definition CodeCompleteConsumer.cpp:280
static Chunk CreateInformative(const char *Informative)
Create a new informative chunk.
Definition CodeCompleteConsumer.cpp:271
CodeCompletionString * Optional
The code completion string associated with a CK_Optional chunk.
static Chunk CreateResultType(const char *ResultType)
Create a new result type chunk.
Definition CodeCompleteConsumer.cpp:276
const char * Text
The text string associated with a CK_Text, CK_Placeholder, CK_Informative, or CK_Comma chunk.
static Chunk CreateText(const char *Text)
Create a new text chunk.
Definition CodeCompleteConsumer.cpp:253