CodeCompletionHandler.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--- CodeCompletionHandler.h - Preprocessor code completion -*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file defines the CodeCompletionHandler interface, which provides
  15. // code-completion callbacks for the preprocessor.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CLANG_LEX_CODECOMPLETIONHANDLER_H
  19. #define LLVM_CLANG_LEX_CODECOMPLETIONHANDLER_H
  20. #include "llvm/ADT/StringRef.h"
  21. namespace clang {
  22. class IdentifierInfo;
  23. class MacroInfo;
  24. /// Callback handler that receives notifications when performing code
  25. /// completion within the preprocessor.
  26. class CodeCompletionHandler {
  27. public:
  28. virtual ~CodeCompletionHandler();
  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. /// Callback invoked when performing code completion within a block of
  39. /// code that was excluded due to preprocessor conditionals.
  40. virtual void CodeCompleteInConditionalExclusion() { }
  41. /// Callback invoked when performing code completion in a context
  42. /// where the name of a macro is expected.
  43. ///
  44. /// \param IsDefinition Whether this is the definition of a macro, e.g.,
  45. /// in a \#define.
  46. virtual void CodeCompleteMacroName(bool IsDefinition) { }
  47. /// Callback invoked when performing code completion in a preprocessor
  48. /// expression, such as the condition of an \#if or \#elif directive.
  49. virtual void CodeCompletePreprocessorExpression() { }
  50. /// Callback invoked when performing code completion inside a
  51. /// function-like macro argument.
  52. ///
  53. /// There will be another callback invocation after the macro arguments are
  54. /// parsed, so this callback should generally be used to note that the next
  55. /// callback is invoked inside a macro argument.
  56. virtual void CodeCompleteMacroArgument(IdentifierInfo *Macro,
  57. MacroInfo *MacroInfo,
  58. unsigned ArgumentIndex) { }
  59. /// Callback invoked when performing code completion inside the filename
  60. /// part of an #include directive. (Also #import, #include_next, etc).
  61. /// \p Dir is the directory relative to the include path.
  62. virtual void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled) {}
  63. /// Callback invoked when performing code completion in a part of the
  64. /// file where we expect natural language, e.g., a comment, string, or
  65. /// \#error directive.
  66. virtual void CodeCompleteNaturalLanguage() { }
  67. };
  68. }
  69. #endif // LLVM_CLANG_LEX_CODECOMPLETIONHANDLER_H
  70. #ifdef __GNUC__
  71. #pragma GCC diagnostic pop
  72. #endif