//===-- ClangHighlighter.cpp ----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "ClangHighlighter.h" #include "lldb/Host/FileSystem.h" #include "lldb/Target/Language.h" #include "lldb/Utility/AnsiTerminal.h" #include "lldb/Utility/StreamString.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" #include "clang/Lex/Lexer.h" #include "llvm/ADT/StringSet.h" #include "llvm/Support/MemoryBuffer.h" #include <optional> usingnamespacelldb_private; bool ClangHighlighter::isKeyword(llvm::StringRef token) const { … } ClangHighlighter::ClangHighlighter() { … } /// Determines which style should be applied to the given token. /// \param highlighter /// The current highlighter that should use the style. /// \param token /// The current token. /// \param tok_str /// The string in the source code the token represents. /// \param options /// The style we use for coloring the source code. /// \param in_pp_directive /// If we are currently in a preprocessor directive. NOTE: This is /// passed by reference and will be updated if the current token starts /// or ends a preprocessor directive. /// \return /// The ColorStyle that should be applied to the token. static HighlightStyle::ColorStyle determineClangStyle(const ClangHighlighter &highlighter, const clang::Token &token, llvm::StringRef tok_str, const HighlightStyle &options, bool &in_pp_directive) { … } void ClangHighlighter::Highlight(const HighlightStyle &options, llvm::StringRef line, std::optional<size_t> cursor_pos, llvm::StringRef previous_lines, Stream &result) const { … }