1 //===--- CodeCompletionHandler.h - Preprocessor code completion -*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines the CodeCompletionHandler interface, which provides
10 // code-completion callbacks for the preprocessor.
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_LEX_CODECOMPLETIONHANDLER_H
14 #define LLVM_CLANG_LEX_CODECOMPLETIONHANDLER_H
16 #include "llvm/ADT/StringRef.h"
23 /// Callback handler that receives notifications when performing code
24 /// completion within the preprocessor.
25 class CodeCompletionHandler {
27 virtual ~CodeCompletionHandler();
29 /// Callback invoked when performing code completion for a preprocessor
32 /// This callback will be invoked when the preprocessor processes a '#' at the
33 /// start of a line, followed by the code-completion token.
35 /// \param InConditional Whether we're inside a preprocessor conditional
37 virtual void CodeCompleteDirective(bool InConditional) { }
39 /// Callback invoked when performing code completion within a block of
40 /// code that was excluded due to preprocessor conditionals.
41 virtual void CodeCompleteInConditionalExclusion() { }
43 /// Callback invoked when performing code completion in a context
44 /// where the name of a macro is expected.
46 /// \param IsDefinition Whether this is the definition of a macro, e.g.,
48 virtual void CodeCompleteMacroName(bool IsDefinition) { }
50 /// Callback invoked when performing code completion in a preprocessor
51 /// expression, such as the condition of an \#if or \#elif directive.
52 virtual void CodeCompletePreprocessorExpression() { }
54 /// Callback invoked when performing code completion inside a
55 /// function-like macro argument.
57 /// There will be another callback invocation after the macro arguments are
58 /// parsed, so this callback should generally be used to note that the next
59 /// callback is invoked inside a macro argument.
60 virtual void CodeCompleteMacroArgument(IdentifierInfo *Macro,
62 unsigned ArgumentIndex) { }
64 /// Callback invoked when performing code completion inside the filename
65 /// part of an #include directive. (Also #import, #include_next, etc).
66 /// \p Dir is the directory relative to the include path.
67 virtual void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled) {}
69 /// Callback invoked when performing code completion in a part of the
70 /// file where we expect natural language, e.g., a comment, string, or
71 /// \#error directive.
72 virtual void CodeCompleteNaturalLanguage() { }
77 #endif // LLVM_CLANG_LEX_CODECOMPLETIONHANDLER_H