aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Sema/CodeCompleteConsumer.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-08-15 06:18:01 +0000
committerDouglas Gregor <dgregor@apple.com>2010-08-15 06:18:01 +0000
commit8071e4212ae08f8014e0c3ae6d18b7388003a5cc (patch)
treeea359a2c105912267f6e067eef19639c5fc48cdc /include/clang/Sema/CodeCompleteConsumer.h
parentde7a0fcdf9f30cb5a97aab614f3975d93cd9926f (diff)
Extend the code-completion caching infrastructure to include global
declarations (in addition to macros). Each kind of declaration maps to a certain set of completion contexts, and the ASTUnit completion logic introduces the completion strings for those declarations if the actual code-completion occurs in one of the contexts where it matters. There are a few new code-completion-context kinds. Without these, certain completions (e.g., after "using namespace") would need to suppress all global completions, which would be unfortunate. Note that we don't get the priorities right for global completions, because we don't have enough type information. We'll need a way to compare types in an ASTContext-agnostic way before this can be implemented. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111093 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Sema/CodeCompleteConsumer.h')
-rw-r--r--include/clang/Sema/CodeCompleteConsumer.h29
1 files changed, 22 insertions, 7 deletions
diff --git a/include/clang/Sema/CodeCompleteConsumer.h b/include/clang/Sema/CodeCompleteConsumer.h
index 48e422383f..16dd69d401 100644
--- a/include/clang/Sema/CodeCompleteConsumer.h
+++ b/include/clang/Sema/CodeCompleteConsumer.h
@@ -127,7 +127,12 @@ public:
/// to indicate a struct or class name.
CCC_ClassOrStructTag,
/// \brief Code completion occurred where a protocol name is expected.
- CCC_ObjCProtocolName
+ CCC_ObjCProtocolName,
+ /// \brief Code completion occurred where a namespace or namespace alias
+ /// is expected.
+ CCC_Namespace,
+ /// \brief Code completion occurred where a type name is expected.
+ CCC_Type
};
private:
@@ -382,6 +387,10 @@ protected:
/// 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;
@@ -588,12 +597,12 @@ public:
};
CodeCompleteConsumer() : IncludeMacros(false), IncludeCodePatterns(false),
- OutputIsBinary(false) { }
+ IncludeGlobals(true), OutputIsBinary(false) { }
CodeCompleteConsumer(bool IncludeMacros, bool IncludeCodePatterns,
- bool OutputIsBinary)
+ bool IncludeGlobals, bool OutputIsBinary)
: IncludeMacros(IncludeMacros), IncludeCodePatterns(IncludeCodePatterns),
- OutputIsBinary(OutputIsBinary) { }
+ IncludeGlobals(IncludeGlobals), OutputIsBinary(OutputIsBinary) { }
/// \brief Whether the code-completion consumer wants to see macros.
bool includeMacros() const { return IncludeMacros; }
@@ -601,6 +610,9 @@ public:
/// \brief Whether the code-completion consumer wants to see code patterns.
bool includeCodePatterns() const { return IncludeCodePatterns; }
+ /// \brief Whether to include global (top-level) declaration results.
+ bool includeGlobals() const { return IncludeGlobals; }
+
/// \brief Determine whether the output of this consumer is binary.
bool isOutputBinary() const { return OutputIsBinary; }
@@ -639,8 +651,10 @@ public:
/// \brief Create a new printing code-completion consumer that prints its
/// results to the given raw output stream.
PrintingCodeCompleteConsumer(bool IncludeMacros, bool IncludeCodePatterns,
+ bool IncludeGlobals,
llvm::raw_ostream &OS)
- : CodeCompleteConsumer(IncludeMacros, IncludeCodePatterns, false), OS(OS) {}
+ : CodeCompleteConsumer(IncludeMacros, IncludeCodePatterns, IncludeGlobals,
+ false), OS(OS) {}
/// \brief Prints the finalized code-completion results.
virtual void ProcessCodeCompleteResults(Sema &S,
@@ -664,8 +678,9 @@ public:
/// results to the given raw output stream in a format readable to the CIndex
/// library.
CIndexCodeCompleteConsumer(bool IncludeMacros, bool IncludeCodePatterns,
- llvm::raw_ostream &OS)
- : CodeCompleteConsumer(IncludeMacros, IncludeCodePatterns, true), OS(OS) {}
+ bool IncludeGlobals, llvm::raw_ostream &OS)
+ : CodeCompleteConsumer(IncludeMacros, IncludeCodePatterns, IncludeGlobals,
+ true), OS(OS) {}
/// \brief Prints the finalized code-completion results.
virtual void ProcessCodeCompleteResults(Sema &S,