clang  14.0.0git
CodeCompletionHandler.h
Go to the documentation of this file.
1 //===--- CodeCompletionHandler.h - Preprocessor code completion -*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the CodeCompletionHandler interface, which provides
10 // code-completion callbacks for the preprocessor.
11 //
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_LEX_CODECOMPLETIONHANDLER_H
14 #define LLVM_CLANG_LEX_CODECOMPLETIONHANDLER_H
15 
16 #include "llvm/ADT/StringRef.h"
17 
18 namespace clang {
19 
20 class IdentifierInfo;
21 class MacroInfo;
22 
23 /// Callback handler that receives notifications when performing code
24 /// completion within the preprocessor.
26 public:
27  virtual ~CodeCompletionHandler();
28 
29  /// Callback invoked when performing code completion for a preprocessor
30  /// directive.
31  ///
32  /// This callback will be invoked when the preprocessor processes a '#' at the
33  /// start of a line, followed by the code-completion token.
34  ///
35  /// \param InConditional Whether we're inside a preprocessor conditional
36  /// already.
37  virtual void CodeCompleteDirective(bool InConditional) { }
38 
39  /// Callback invoked when performing code completion within a block of
40  /// code that was excluded due to preprocessor conditionals.
42 
43  /// Callback invoked when performing code completion in a context
44  /// where the name of a macro is expected.
45  ///
46  /// \param IsDefinition Whether this is the definition of a macro, e.g.,
47  /// in a \#define.
48  virtual void CodeCompleteMacroName(bool IsDefinition) { }
49 
50  /// Callback invoked when performing code completion in a preprocessor
51  /// expression, such as the condition of an \#if or \#elif directive.
53 
54  /// Callback invoked when performing code completion inside a
55  /// function-like macro argument.
56  ///
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.
62  unsigned ArgumentIndex) { }
63 
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) {}
68 
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() { }
73 };
74 
75 }
76 
77 #endif // LLVM_CLANG_LEX_CODECOMPLETIONHANDLER_H
clang::CodeCompletionHandler::CodeCompleteMacroName
virtual void CodeCompleteMacroName(bool IsDefinition)
Callback invoked when performing code completion in a context where the name of a macro is expected.
Definition: CodeCompletionHandler.h:48
clang::MacroInfo
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:39
clang::CodeCompletionHandler
Callback handler that receives notifications when performing code completion within the preprocessor.
Definition: CodeCompletionHandler.h:25
clang::CodeCompletionHandler::CodeCompleteIncludedFile
virtual void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled)
Callback invoked when performing code completion inside the filename part of an include directive.
Definition: CodeCompletionHandler.h:67
clang::CodeCompletionHandler::CodeCompletePreprocessorExpression
virtual void CodeCompletePreprocessorExpression()
Callback invoked when performing code completion in a preprocessor expression, such as the condition ...
Definition: CodeCompletionHandler.h:52
clang::CodeCompletionHandler::CodeCompleteDirective
virtual void CodeCompleteDirective(bool InConditional)
Callback invoked when performing code completion for a preprocessor directive.
Definition: CodeCompletionHandler.h:37
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:84
clang
Definition: CalledOnceCheck.h:17
clang::CodeCompletionHandler::CodeCompleteNaturalLanguage
virtual void CodeCompleteNaturalLanguage()
Callback invoked when performing code completion in a part of the file where we expect natural langua...
Definition: CodeCompletionHandler.h:72
clang::CodeCompletionHandler::CodeCompleteInConditionalExclusion
virtual void CodeCompleteInConditionalExclusion()
Callback invoked when performing code completion within a block of code that was excluded due to prep...
Definition: CodeCompletionHandler.h:41
clang::CodeCompletionHandler::~CodeCompletionHandler
virtual ~CodeCompletionHandler()
clang::CodeCompletionHandler::CodeCompleteMacroArgument
virtual void CodeCompleteMacroArgument(IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned ArgumentIndex)
Callback invoked when performing code completion inside a function-like macro argument.
Definition: CodeCompletionHandler.h:60