#include "clang/Index/ASTLocation.h"
#include "clang/Serialization/ASTBitCodes.h"
#include "clang/Sema/Sema.h"
+#include "clang/Sema/CodeCompleteConsumer.h"
#include "clang/Lex/PreprocessingRecord.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/FileManager.h"
#include <string>
namespace llvm {
-class raw_ostream;
+ class raw_ostream;
}
namespace clang {
/// of this macro is a pointer type.
unsigned getMacroUsagePriority(llvm::StringRef MacroName,
bool PreferredTypeIsPointer = false);
-
+
class FunctionDecl;
class FunctionType;
class FunctionTemplateDecl;
/// \returns true if successful, false otherwise.
bool Deserialize(const char *&Str, const char *StrEnd);
};
-
-llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
- const CodeCompletionString &CCS);
-
-/// \brief Abstract interface for a consumer of code-completion
-/// information.
-class CodeCompleteConsumer {
-protected:
- /// \brief Whether to include macros in the code-completion results.
- bool IncludeMacros;
- /// \brief Whether to include code patterns (such as for loops) within
- /// the completion results.
- bool IncludeCodePatterns;
-
- /// \brief Whether to include global (top-level) declarations and names in
- /// the completion results.
- bool IncludeGlobals;
-
- /// \brief Whether the output format for the code-completion consumer is
- /// binary.
- bool OutputIsBinary;
-
+/// \brief Captures a result of code completion.
+class CodeCompletionResult {
public:
- /// \brief Captures a result of code completion.
- struct Result {
- /// \brief Describes the kind of result generated.
- enum ResultKind {
- RK_Declaration = 0, //< Refers to a declaration
- RK_Keyword, //< Refers to a keyword or symbol.
- RK_Macro, //< Refers to a macro
- RK_Pattern //< Refers to a precomputed pattern.
- };
+ /// \brief Describes the kind of result generated.
+ enum ResultKind {
+ RK_Declaration = 0, //< Refers to a declaration
+ RK_Keyword, //< Refers to a keyword or symbol.
+ RK_Macro, //< Refers to a macro
+ RK_Pattern //< Refers to a precomputed pattern.
+ };
- /// \brief The kind of result stored here.
- ResultKind Kind;
+ /// \brief The kind of result stored here.
+ ResultKind Kind;
- union {
- /// \brief When Kind == RK_Declaration, the declaration we are referring
- /// to.
- NamedDecl *Declaration;
+ union {
+ /// \brief When Kind == RK_Declaration, the declaration we are referring
+ /// to.
+ NamedDecl *Declaration;
- /// \brief When Kind == RK_Keyword, the string representing the keyword
- /// or symbol's spelling.
- const char *Keyword;
+ /// \brief When Kind == RK_Keyword, the string representing the keyword
+ /// or symbol's spelling.
+ const char *Keyword;
- /// \brief When Kind == RK_Pattern, the code-completion string that
- /// describes the completion text to insert.
- CodeCompletionString *Pattern;
+ /// \brief When Kind == RK_Pattern, the code-completion string that
+ /// describes the completion text to insert.
+ CodeCompletionString *Pattern;
- /// \brief When Kind == RK_Macro, the identifier that refers to a macro.
- IdentifierInfo *Macro;
- };
+ /// \brief When Kind == RK_Macro, the identifier that refers to a macro.
+ IdentifierInfo *Macro;
+ };
- /// \brief The priority of this particular code-completion result.
- unsigned Priority;
+ /// \brief The priority of this particular code-completion result.
+ unsigned Priority;
- /// \brief The cursor kind that describes this result.
- CXCursorKind CursorKind;
+ /// \brief The cursor kind that describes this result.
+ CXCursorKind CursorKind;
- /// \brief The availability of this result.
- CXAvailabilityKind Availability;
+ /// \brief The availability of this result.
+ CXAvailabilityKind Availability;
- /// \brief Specifies which parameter (of a function, Objective-C method,
- /// macro, etc.) we should start with when formatting the result.
- unsigned StartParameter;
+ /// \brief Specifies which parameter (of a function, Objective-C method,
+ /// macro, etc.) we should start with when formatting the result.
+ unsigned StartParameter;
- /// \brief Whether this result is hidden by another name.
- bool Hidden : 1;
+ /// \brief Whether this result is hidden by another name.
+ bool Hidden : 1;
- /// \brief Whether this result was found via lookup into a base class.
- bool QualifierIsInformative : 1;
+ /// \brief Whether this result was found via lookup into a base class.
+ bool QualifierIsInformative : 1;
- /// \brief Whether this declaration is the beginning of a
- /// nested-name-specifier and, therefore, should be followed by '::'.
- bool StartsNestedNameSpecifier : 1;
+ /// \brief Whether this declaration is the beginning of a
+ /// nested-name-specifier and, therefore, should be followed by '::'.
+ bool StartsNestedNameSpecifier : 1;
- /// \brief Whether all parameters (of a function, Objective-C
- /// method, etc.) should be considered "informative".
- bool AllParametersAreInformative : 1;
+ /// \brief Whether all parameters (of a function, Objective-C
+ /// method, etc.) should be considered "informative".
+ bool AllParametersAreInformative : 1;
- /// \brief Whether we're completing a declaration of the given entity,
- /// rather than a use of that entity.
- bool DeclaringEntity : 1;
+ /// \brief Whether we're completing a declaration of the given entity,
+ /// rather than a use of that entity.
+ bool DeclaringEntity : 1;
- /// \brief If the result should have a nested-name-specifier, this is it.
- /// When \c QualifierIsInformative, the nested-name-specifier is
- /// informative rather than required.
- NestedNameSpecifier *Qualifier;
+ /// \brief If the result should have a nested-name-specifier, this is it.
+ /// When \c QualifierIsInformative, the nested-name-specifier is
+ /// informative rather than required.
+ NestedNameSpecifier *Qualifier;
- /// \brief Build a result that refers to a declaration.
- Result(NamedDecl *Declaration,
- NestedNameSpecifier *Qualifier = 0,
- bool QualifierIsInformative = false)
- : Kind(RK_Declaration), Declaration(Declaration),
- Priority(getPriorityFromDecl(Declaration)),
- Availability(CXAvailability_Available), StartParameter(0),
- Hidden(false), QualifierIsInformative(QualifierIsInformative),
- StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
- DeclaringEntity(false), Qualifier(Qualifier) {
- computeCursorKindAndAvailability();
- }
+ /// \brief Build a result that refers to a declaration.
+ CodeCompletionResult(NamedDecl *Declaration,
+ NestedNameSpecifier *Qualifier = 0,
+ bool QualifierIsInformative = false)
+ : Kind(RK_Declaration), Declaration(Declaration),
+ Priority(getPriorityFromDecl(Declaration)),
+ Availability(CXAvailability_Available), StartParameter(0),
+ Hidden(false), QualifierIsInformative(QualifierIsInformative),
+ StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
+ DeclaringEntity(false), Qualifier(Qualifier) {
+ computeCursorKindAndAvailability();
+ }
- /// \brief Build a result that refers to a keyword or symbol.
- Result(const char *Keyword, unsigned Priority = CCP_Keyword)
- : Kind(RK_Keyword), Keyword(Keyword), Priority(Priority),
- Availability(CXAvailability_Available),
- StartParameter(0), Hidden(false), QualifierIsInformative(0),
- StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
- DeclaringEntity(false), Qualifier(0) {
- computeCursorKindAndAvailability();
- }
+ /// \brief Build a result that refers to a keyword or symbol.
+ CodeCompletionResult(const char *Keyword, unsigned Priority = CCP_Keyword)
+ : Kind(RK_Keyword), Keyword(Keyword), Priority(Priority),
+ Availability(CXAvailability_Available),
+ StartParameter(0), Hidden(false), QualifierIsInformative(0),
+ StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
+ DeclaringEntity(false), Qualifier(0) {
+ computeCursorKindAndAvailability();
+ }
- /// \brief Build a result that refers to a macro.
- Result(IdentifierInfo *Macro, unsigned Priority = CCP_Macro)
- : Kind(RK_Macro), Macro(Macro), Priority(Priority),
- Availability(CXAvailability_Available), StartParameter(0),
- Hidden(false), QualifierIsInformative(0),
- StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
- DeclaringEntity(false), Qualifier(0) {
- computeCursorKindAndAvailability();
- }
+ /// \brief Build a result that refers to a macro.
+ CodeCompletionResult(IdentifierInfo *Macro, unsigned Priority = CCP_Macro)
+ : Kind(RK_Macro), Macro(Macro), Priority(Priority),
+ Availability(CXAvailability_Available), StartParameter(0),
+ Hidden(false), QualifierIsInformative(0),
+ StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
+ DeclaringEntity(false), Qualifier(0) {
+ computeCursorKindAndAvailability();
+ }
- /// \brief Build a result that refers to a pattern.
- Result(CodeCompletionString *Pattern, unsigned Priority = CCP_CodePattern,
- CXCursorKind CursorKind = CXCursor_NotImplemented,
- CXAvailabilityKind Availability = CXAvailability_Available)
- : Kind(RK_Pattern), Pattern(Pattern), Priority(Priority),
- CursorKind(CursorKind), Availability(Availability), StartParameter(0),
- Hidden(false), QualifierIsInformative(0),
- StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
- DeclaringEntity(false), Qualifier(0)
- {
- }
-
- /// \brief Retrieve the declaration stored in this result.
- NamedDecl *getDeclaration() const {
- assert(Kind == RK_Declaration && "Not a declaration result");
- return Declaration;
- }
+ /// \brief Build a result that refers to a pattern.
+ CodeCompletionResult(CodeCompletionString *Pattern,
+ unsigned Priority = CCP_CodePattern,
+ CXCursorKind CursorKind = CXCursor_NotImplemented,
+ CXAvailabilityKind Availability = CXAvailability_Available)
+ : Kind(RK_Pattern), Pattern(Pattern), Priority(Priority),
+ CursorKind(CursorKind), Availability(Availability), StartParameter(0),
+ Hidden(false), QualifierIsInformative(0),
+ StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
+ DeclaringEntity(false), Qualifier(0)
+ {
+ }
- /// \brief Retrieve the keyword stored in this result.
- const char *getKeyword() const {
- assert(Kind == RK_Keyword && "Not a keyword result");
- return Keyword;
- }
+ /// \brief Retrieve the declaration stored in this result.
+ NamedDecl *getDeclaration() const {
+ assert(Kind == RK_Declaration && "Not a declaration result");
+ return Declaration;
+ }
- /// \brief Create a new code-completion string that describes how to insert
- /// this result into a program.
- ///
- /// \param S The semantic analysis that created the result.
- ///
- /// \param Result If non-NULL, the already-allocated, empty
- /// code-completion string that will be populated with the
- /// appropriate code completion string for this result.
- CodeCompletionString *CreateCodeCompletionString(Sema &S,
- CodeCompletionString *Result = 0);
+ /// \brief Retrieve the keyword stored in this result.
+ const char *getKeyword() const {
+ assert(Kind == RK_Keyword && "Not a keyword result");
+ return Keyword;
+ }
- void Destroy();
+ /// \brief Create a new code-completion string that describes how to insert
+ /// this result into a program.
+ ///
+ /// \param S The semantic analysis that created the result.
+ ///
+ /// \param Result If non-NULL, the already-allocated, empty
+ /// code-completion string that will be populated with the
+ /// appropriate code completion string for this result.
+ CodeCompletionString *CreateCodeCompletionString(Sema &S,
+ CodeCompletionString *Result = 0);
- /// brief Determine a base priority for the given declaration.
- static unsigned getPriorityFromDecl(NamedDecl *ND);
+ void Destroy();
- private:
- void computeCursorKindAndAvailability();
- };
+ /// brief Determine a base priority for the given declaration.
+ static unsigned getPriorityFromDecl(NamedDecl *ND);
+private:
+ void computeCursorKindAndAvailability();
+};
+
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
+ const CodeCompletionString &CCS);
+
+/// \brief Abstract interface for a consumer of code-completion
+/// information.
+class CodeCompleteConsumer {
+protected:
+ /// \brief Whether to include macros in the code-completion results.
+ bool IncludeMacros;
+
+ /// \brief Whether to include code patterns (such as for loops) within
+ /// the completion results.
+ bool IncludeCodePatterns;
+
+ /// \brief Whether to include global (top-level) declarations and names in
+ /// the completion results.
+ bool IncludeGlobals;
+
+ /// \brief Whether the output format for the code-completion consumer is
+ /// binary.
+ bool OutputIsBinary;
+
+public:
class OverloadCandidate {
public:
/// \brief Describes the type of overload candidate.
/// \brief Process the finalized code-completion results.
virtual void ProcessCodeCompleteResults(Sema &S,
CodeCompletionContext Context,
- Result *Results,
+ CodeCompletionResult *Results,
unsigned NumResults) { }
/// \param S the semantic-analyzer object for which code-completion is being
unsigned NumCandidates) { }
//@}
};
-
+
/// \brief A simple code-completion consumer that prints the results it
/// receives in a simple format.
class PrintingCodeCompleteConsumer : public CodeCompleteConsumer {
/// \brief Prints the finalized code-completion results.
virtual void ProcessCodeCompleteResults(Sema &S,
CodeCompletionContext Context,
- Result *Results,
+ CodeCompletionResult *Results,
unsigned NumResults);
virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
/// \brief Prints the finalized code-completion results.
virtual void ProcessCodeCompleteResults(Sema &S,
CodeCompletionContext Context,
- Result *Results,
+ CodeCompletionResult *Results,
unsigned NumResults);
virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
OverloadCandidate *Candidates,
unsigned NumCandidates);
};
-
+
} // end namespace clang
#endif // LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H
#include "clang/Sema/Action.h"
#include "clang/Sema/AnalysisBasedWarnings.h"
-#include "clang/Sema/CodeCompleteConsumer.h"
#include "clang/Sema/IdentifierResolver.h"
#include "clang/Sema/ObjCMethodList.h"
#include "clang/Sema/SemaDiagnostic.h"
class ClassTemplateDecl;
class ClassTemplatePartialSpecializationDecl;
class ClassTemplateSpecializationDecl;
+ class CodeCompleteConsumer;
+ class CodeCompletionResult;
class Decl;
class DeclAccessPair;
class DeclContext;
MacroInfo *MacroInfo,
unsigned Argument);
void GatherGlobalCodeCompletions(
- llvm::SmallVectorImpl<CodeCompleteConsumer::Result> &Results);
+ llvm::SmallVectorImpl<CodeCompletionResult> &Results);
//@}
//===--------------------------------------------------------------------===//
ClearCachedCompletionResults();
// Gather the set of global code completions.
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
llvm::SmallVector<Result, 8> Results;
TheSema->GatherGlobalCodeCompletions(Results);
virtual void ProcessCodeCompleteResults(Sema &S,
CodeCompletionContext Context,
- Result *Results,
+ CodeCompletionResult *Results,
unsigned NumResults);
virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
/// \brief Helper function that computes which global names are hidden by the
/// local code-completion results.
void CalculateHiddenNames(const CodeCompletionContext &Context,
- CodeCompleteConsumer::Result *Results,
+ CodeCompletionResult *Results,
unsigned NumResults,
ASTContext &Ctx,
llvm::StringSet<> &HiddenNames) {
return;
}
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
for (unsigned I = 0; I != NumResults; ++I) {
if (Results[I].Kind != Result::RK_Declaration)
continue;
void AugmentedCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &S,
CodeCompletionContext Context,
- Result *Results,
+ CodeCompletionResult *Results,
unsigned NumResults) {
// Merge the results we were given with the results we cached.
bool AddedResult = false;
// Contains the set of names that are hidden by "local" completion results.
llvm::StringSet<> HiddenNames;
llvm::SmallVector<CodeCompletionString *, 4> StringsToDestroy;
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
llvm::SmallVector<Result, 8> AllResults;
for (ASTUnit::cached_completion_iterator
C = AST.cached_completion_begin(),
return true;
}
-void CodeCompleteConsumer::Result::Destroy() {
+void CodeCompletionResult::Destroy() {
if (Kind == RK_Pattern) {
delete Pattern;
Pattern = 0;
}
}
-unsigned CodeCompleteConsumer::Result::getPriorityFromDecl(NamedDecl *ND) {
+unsigned CodeCompletionResult::getPriorityFromDecl(NamedDecl *ND) {
if (!ND)
return CCP_Unlikely;
void
PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef,
CodeCompletionContext Context,
- Result *Results,
+ CodeCompletionResult *Results,
unsigned NumResults) {
// Print the results.
for (unsigned I = 0; I != NumResults; ++I) {
OS << "COMPLETION: ";
switch (Results[I].Kind) {
- case Result::RK_Declaration:
+ case CodeCompletionResult::RK_Declaration:
OS << Results[I].Declaration;
if (Results[I].Hidden)
OS << " (Hidden)";
OS << '\n';
break;
- case Result::RK_Keyword:
+ case CodeCompletionResult::RK_Keyword:
OS << Results[I].Keyword << '\n';
break;
- case Result::RK_Macro: {
+ case CodeCompletionResult::RK_Macro: {
OS << Results[I].Macro->getName();
if (CodeCompletionString *CCS
= Results[I].CreateCodeCompletionString(SemaRef)) {
break;
}
- case Result::RK_Pattern: {
+ case CodeCompletionResult::RK_Pattern: {
OS << "Pattern : "
<< Results[I].Pattern->getAsString() << '\n';
break;
}
}
-void CodeCompleteConsumer::Result::computeCursorKindAndAvailability() {
+void CodeCompletionResult::computeCursorKindAndAvailability() {
switch (Kind) {
case RK_Declaration:
// Set the availability based on attributes.
}
break;
- case Result::RK_Macro:
+ case RK_Macro:
Availability = CXAvailability_Available;
CursorKind = CXCursor_MacroDefinition;
break;
- case Result::RK_Keyword:
+ case RK_Keyword:
Availability = CXAvailability_Available;
CursorKind = CXCursor_NotImplemented;
break;
- case Result::RK_Pattern:
+ case RK_Pattern:
// Do nothing: Patterns can come with cursor kinds!
break;
}
void
CIndexCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef,
CodeCompletionContext Context,
- Result *Results,
+ CodeCompletionResult *Results,
unsigned NumResults) {
// Print the results.
for (unsigned I = 0; I != NumResults; ++I) {
/// filtered out (returns false).
typedef bool (ResultBuilder::*LookupFilter)(NamedDecl *) const;
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
private:
/// \brief The actual results we have found.
/// \brief Add type specifiers for the current language as keyword results.
static void AddTypeSpecifierResults(const LangOptions &LangOpts,
ResultBuilder &Results) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
Results.AddResult(Result("short", CCP_Type));
Results.AddResult(Result("long", CCP_Type));
Results.AddResult(Result("signed", CCP_Type));
static void AddStorageSpecifiers(Action::ParserCompletionContext CCC,
const LangOptions &LangOpts,
ResultBuilder &Results) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
// Note: we don't suggest either "auto" or "register", because both
// are pointless as storage specifiers. Elsewhere, we suggest "auto"
// in C++0x as a type specifier.
static void AddFunctionSpecifiers(Action::ParserCompletionContext CCC,
const LangOptions &LangOpts,
ResultBuilder &Results) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
switch (CCC) {
case Action::PCC_Class:
case Action::PCC_MemberTemplate:
Pattern->AddPlaceholderChunk("type");
Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace);
Pattern->AddPlaceholderChunk("name");
- Results.AddResult(CodeCompleteConsumer::Result(Pattern));
+ Results.AddResult(CodeCompletionResult(Pattern));
}
static bool WantTypesInContext(Action::ParserCompletionContext CCC,
Scope *S,
Sema &SemaRef,
ResultBuilder &Results) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
switch (CCC) {
case Action::PCC_Namespace:
if (SemaRef.getLangOptions().CPlusPlus) {
/// how to use this result, or NULL to indicate that the string or name of the
/// result is all that is needed.
CodeCompletionString *
-CodeCompleteConsumer::Result::CreateCodeCompletionString(Sema &S,
+CodeCompletionResult::CreateCodeCompletionString(Sema &S,
CodeCompletionString *Result) {
typedef CodeCompletionString::Chunk Chunk;
namespace {
struct SortCodeCompleteResult {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
/// \brief Retrieve the name that should be used to order a result.
///
static void AddMacroResults(Preprocessor &PP, ResultBuilder &Results,
bool TargetTypeIsPointer = false) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
Results.EnterNewScope();
for (Preprocessor::macro_iterator M = PP.macro_begin(),
static void AddPrettyFunctionResults(const LangOptions &LangOpts,
ResultBuilder &Results) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
Results.EnterNewScope();
Results.AddResult(Result("__PRETTY_FUNCTION__", CCP_Constant));
static void HandleCodeCompleteResults(Sema *S,
CodeCompleteConsumer *CodeCompleter,
CodeCompletionContext Context,
- CodeCompleteConsumer::Result *Results,
+ CodeCompletionResult *Results,
unsigned NumResults) {
std::stable_sort(Results, Results + NumResults, SortCodeCompleteResult());
void Sema::CodeCompleteOrdinaryName(Scope *S,
ParserCompletionContext CompletionContext) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
ResultBuilder Results(*this);
// Determine how to filter results, e.g., so that the names of
void Sema::CodeCompleteDeclarator(Scope *S,
bool AllowNonIdentifiers,
bool AllowNestedNameSpecifiers) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
ResultBuilder Results(*this);
Results.EnterNewScope();
/// expressions.
void Sema::CodeCompleteExpression(Scope *S,
const CodeCompleteExpressionData &Data) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
ResultBuilder Results(*this);
if (Data.ObjCCollection)
bool AllowCategories,
DeclContext *CurContext,
ResultBuilder &Results) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
// Add properties in this container.
for (ObjCContainerDecl::prop_iterator P = Container->prop_begin(),
if (!BaseE || !CodeCompleter)
return;
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
Expr *Base = static_cast<Expr *>(BaseE);
QualType BaseType = Base->getType();
if (!CodeCompleter)
return;
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
ResultBuilder::LookupFilter Filter = 0;
enum CodeCompletionContext::Kind ContextKind
= CodeCompletionContext::CCC_Other;
if (EnumeratorsSeen.count(*E))
continue;
- Results.AddResult(CodeCompleteConsumer::Result(*E, Qualifier),
+ Results.AddResult(CodeCompletionResult(*E, Qualifier),
CurContext, 0, false);
}
Results.ExitScope();
// If we aren't in class scope, we could see the "namespace" keyword.
if (!S->isClassScope())
- Results.AddResult(CodeCompleteConsumer::Result("namespace"));
+ Results.AddResult(CodeCompletionResult("namespace"));
// After "using", we can see anything that would start a
// nested-name-specifier.
for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
NS = OrigToLatest.begin(), NSEnd = OrigToLatest.end();
NS != NSEnd; ++NS)
- Results.AddResult(CodeCompleteConsumer::Result(NS->second, 0),
+ Results.AddResult(CodeCompletionResult(NS->second, 0),
CurContext, 0, false);
Results.ExitScope();
}
if (!CodeCompleter)
return;
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
ResultBuilder Results(*this, &ResultBuilder::IsType);
Results.EnterNewScope();
static void AddObjCImplementationResults(const LangOptions &LangOpts,
ResultBuilder &Results,
bool NeedAt) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
// Since we have an implementation, we can end it.
Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,end)));
static void AddObjCInterfaceResults(const LangOptions &LangOpts,
ResultBuilder &Results,
bool NeedAt) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
// Since we have an interface or protocol, we can end it.
Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,end)));
}
static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
CodeCompletionString *Pattern = 0;
// @class name ;
void Sema::CodeCompleteObjCAtDirective(Scope *S, Decl *ObjCImpDecl,
bool InInterface) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
ResultBuilder Results(*this);
Results.EnterNewScope();
if (ObjCImpDecl)
}
static void AddObjCExpressionResults(ResultBuilder &Results, bool NeedAt) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
CodeCompletionString *Pattern = 0;
// @encode ( type-name )
}
static void AddObjCStatementResults(ResultBuilder &Results, bool NeedAt) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
CodeCompletionString *Pattern = 0;
if (Results.includeCodePatterns()) {
static void AddObjCVisibilityResults(const LangOptions &LangOpts,
ResultBuilder &Results,
bool NeedAt) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,private)));
Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,protected)));
Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,public)));
unsigned Attributes = ODS.getPropertyAttributes();
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
ResultBuilder Results(*this);
Results.EnterNewScope();
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_readonly))
- Results.AddResult(CodeCompleteConsumer::Result("readonly"));
+ Results.AddResult(CodeCompletionResult("readonly"));
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_assign))
- Results.AddResult(CodeCompleteConsumer::Result("assign"));
+ Results.AddResult(CodeCompletionResult("assign"));
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_readwrite))
- Results.AddResult(CodeCompleteConsumer::Result("readwrite"));
+ Results.AddResult(CodeCompletionResult("readwrite"));
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_retain))
- Results.AddResult(CodeCompleteConsumer::Result("retain"));
+ Results.AddResult(CodeCompletionResult("retain"));
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_copy))
- Results.AddResult(CodeCompleteConsumer::Result("copy"));
+ Results.AddResult(CodeCompletionResult("copy"));
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_nonatomic))
- Results.AddResult(CodeCompleteConsumer::Result("nonatomic"));
+ Results.AddResult(CodeCompletionResult("nonatomic"));
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_setter)) {
CodeCompletionString *Setter = new CodeCompletionString;
Setter->AddTypedTextChunk("setter");
Setter->AddTextChunk(" = ");
Setter->AddPlaceholderChunk("method");
- Results.AddResult(CodeCompleteConsumer::Result(Setter));
+ Results.AddResult(CodeCompletionResult(Setter));
}
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_getter)) {
CodeCompletionString *Getter = new CodeCompletionString;
Getter->AddTypedTextChunk("getter");
Getter->AddTextChunk(" = ");
Getter->AddPlaceholderChunk("method");
- Results.AddResult(CodeCompleteConsumer::Result(Getter));
+ Results.AddResult(CodeCompletionResult(Getter));
}
Results.ExitScope();
HandleCodeCompleteResults(this, CodeCompleter,
DeclContext *CurContext,
ResultBuilder &Results,
bool InOriginalClass = true) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
for (ObjCContainerDecl::method_iterator M = Container->meth_begin(),
MEnd = Container->meth_end();
M != MEnd; ++M) {
void Sema::CodeCompleteObjCPropertyGetter(Scope *S, Decl *ClassDecl,
Decl **Methods,
unsigned NumMethods) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
// Try to find the interface where getters might live.
ObjCInterfaceDecl *Class = dyn_cast_or_null<ObjCInterfaceDecl>(ClassDecl);
void Sema::CodeCompleteObjCPropertySetter(Scope *S, Decl *ObjCImplDecl,
Decl **Methods,
unsigned NumMethods) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
// Try to find the interface where setters might live.
ObjCInterfaceDecl *Class
}
void Sema::CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
ResultBuilder Results(*this);
Results.EnterNewScope();
}
void Sema::CodeCompleteObjCMessageReceiver(Scope *S) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
ResultBuilder Results(*this);
// Find anything that looks like it could be a message receiver.
void Sema::CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver,
IdentifierInfo **SelIdents,
unsigned NumSelIdents) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
ObjCInterfaceDecl *CDecl = 0;
// If the given name refers to an interface type, retrieve the
void Sema::CodeCompleteObjCInstanceMessage(Scope *S, ExprTy *Receiver,
IdentifierInfo **SelIdents,
unsigned NumSelIdents) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
Expr *RecExpr = static_cast<Expr *>(Receiver);
static void AddProtocolResults(DeclContext *Ctx, DeclContext *CurContext,
bool OnlyForwardDeclarations,
ResultBuilder &Results) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
for (DeclContext::decl_iterator D = Ctx->decls_begin(),
DEnd = Ctx->decls_end();
bool OnlyForwardDeclarations,
bool OnlyUnimplemented,
ResultBuilder &Results) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
for (DeclContext::decl_iterator D = Ctx->decls_begin(),
DEnd = Ctx->decls_end();
void Sema::CodeCompleteObjCInterfaceCategory(Scope *S,
IdentifierInfo *ClassName,
SourceLocation ClassNameLoc) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
ResultBuilder Results(*this);
void Sema::CodeCompleteObjCImplementationCategory(Scope *S,
IdentifierInfo *ClassName,
SourceLocation ClassNameLoc) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
// Find the corresponding interface. If we couldn't find the interface, the
// program itself is ill-formed. However, we'll try to be helpful still by
}
void Sema::CodeCompleteObjCPropertyDefinition(Scope *S, Decl *ObjCImpDecl) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
ResultBuilder Results(*this);
// Figure out where this @synthesize lives.
void Sema::CodeCompleteObjCPropertySynthesizeIvar(Scope *S,
IdentifierInfo *PropertyName,
Decl *ObjCImpDecl) {
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
ResultBuilder Results(*this);
// Figure out where this @synthesize lives.
}
// Add declarations or definitions for each of the known methods.
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
ResultBuilder Results(*this);
Results.EnterNewScope();
PrintingPolicy Policy(Context.PrintingPolicy);
}
// Build the set of methods we can see.
- typedef CodeCompleteConsumer::Result Result;
+ typedef CodeCompletionResult Result;
ResultBuilder Results(*this);
if (ReturnTy)
}
void Sema::GatherGlobalCodeCompletions(
- llvm::SmallVectorImpl<CodeCompleteConsumer::Result> &Results) {
+ llvm::SmallVectorImpl<CodeCompletionResult> &Results) {
ResultBuilder Builder(*this);
if (!CodeCompleter || CodeCompleter->includeGlobals()) {
virtual void ProcessCodeCompleteResults(Sema &S,
CodeCompletionContext Context,
- Result *Results,
+ CodeCompletionResult *Results,
unsigned NumResults) {
AllocatedResults.Results = new CXCompletionResult [NumResults];
AllocatedResults.NumResults = NumResults;