diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-24 19:08:16 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-24 19:08:16 +0000 |
commit | f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9 (patch) | |
tree | b3fd57ca42856df16b30ce95b7030b5a4e10123c /include/clang/Lex | |
parent | cdaa6a8fed16d8bd3987fb4f3304dfb4e52876c3 (diff) |
Introduce basic code-completion support for preprocessor directives,
e.g., after a "#" we'll suggest #if, #ifdef, etc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111943 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Lex')
-rw-r--r-- | include/clang/Lex/CodeCompletionHandler.h | 42 | ||||
-rw-r--r-- | include/clang/Lex/Preprocessor.h | 14 |
2 files changed, 56 insertions, 0 deletions
diff --git a/include/clang/Lex/CodeCompletionHandler.h b/include/clang/Lex/CodeCompletionHandler.h new file mode 100644 index 0000000000..4cc3b12d47 --- /dev/null +++ b/include/clang/Lex/CodeCompletionHandler.h @@ -0,0 +1,42 @@ +//===--- CodeCompletionHandler.h - Preprocessor code completion -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the CodeCompletionHandler interface, which provides +// code-completion callbacks for the preprocessor. +// +//===----------------------------------------------------------------------===// +#ifndef LLVM_CLANG_LEX_CODECOMPLETIONHANDLER_H +#define LLVM_CLANG_LEX_CODECOMPLETIONHANDLER_H + +namespace clang { + +/// \brief Callback handler that receives notifications when performing code +/// completion within the preprocessor. +class CodeCompletionHandler { +public: + virtual ~CodeCompletionHandler(); + + /// \brief Callback invoked when performing code completion for a preprocessor + /// directive. + /// + /// This callback will be invoked when the preprocessor processes a '#' at the + /// start of a line, followed by the code-completion token. + /// + /// \param InConditional Whether we're inside a preprocessor conditional + /// already. + virtual void CodeCompleteDirective(bool InConditional) { } + + /// \brief Callback invoked when performing code completion within a block of + /// code that was excluded due to preprocessor conditionals. + virtual void CodeCompleteInConditionalExclusion() { } +}; + +} + +#endif // LLVM_CLANG_LEX_CODECOMPLETIONHANDLER_H diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 8bf0df3d02..712feaa425 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -42,6 +42,7 @@ class CommentHandler; class ScratchBuffer; class TargetInfo; class PPCallbacks; +class CodeCompletionHandler; class DirectoryLookup; class PreprocessingRecord; @@ -131,6 +132,9 @@ class Preprocessor { /// with this preprocessor. std::vector<CommentHandler *> CommentHandlers; + /// \brief The code-completion handler. + CodeCompletionHandler *CodeComplete; + /// \brief The file that we're performing code-completion for, if any. const FileEntry *CodeCompletionFile; @@ -373,6 +377,16 @@ public: /// It is an error to remove a handler that has not been registered. void RemoveCommentHandler(CommentHandler *Handler); + /// \brief Set the code completion handler to the given object. + void setCodeCompletionHandler(CodeCompletionHandler &Handler) { + CodeComplete = &Handler; + } + + /// \brief Clear out the code completion handler. + void clearCodeCompletionHandler() { + CodeComplete = 0; + } + /// \brief Retrieve the preprocessing record, or NULL if there is no /// preprocessing record. PreprocessingRecord *getPreprocessingRecord() const { return Record; } |