9#ifndef LLDB_SOURCE_PLUGINS_HIGHLIGHTER_TREESITTER_TREESITTERHIGHLIGHTER_H
10#define LLDB_SOURCE_PLUGINS_HIGHLIGHTER_TREESITTER_TREESITTERHIGHLIGHTER_H
14#include "llvm/ADT/StringRef.h"
17#include <tree_sitter/api.h>
30 std::optional<size_t> cursor_pos,
31 llvm::StringRef previous_lines,
Stream &s)
const override;
48 uint32_t start_byte, uint32_t end_byte,
50 std::optional<size_t> cursor_pos,
51 bool &highlighted_cursor,
Stream &s)
const;
65 explicit operator bool()
const;
A pair of strings that should be placed around a certain token.
A stream class that can stream formatted output to a file.
TreeSitterHighlighter()=default
virtual llvm::StringRef GetHighlightQuery() const =0
Returns the tree-sitter highlight query for this language.
virtual const TSLanguage * GetLanguage() const =0
Returns the tree-sitter language for this highlighter.
void Highlight(const HighlightStyle &options, llvm::StringRef line, std::optional< size_t > cursor_pos, llvm::StringRef previous_lines, Stream &s) const override
Highlights a single line of code using tree-sitter parsing.
void HighlightRange(const HighlightStyle &options, llvm::StringRef text, uint32_t start_byte, uint32_t end_byte, const HighlightStyle::ColorStyle &style, std::optional< size_t > cursor_pos, bool &highlighted_cursor, Stream &s) const
Applies syntax highlighting to a range of text.
~TreeSitterHighlighter() override=default
TSState & GetTSState() const
Lazily creates a tree-sitter state (TSState).
HighlightStyle::ColorStyle GetStyleForCapture(llvm::StringRef capture_name, const HighlightStyle &options) const
Maps a tree-sitter capture name to a HighlightStyle color.
std::optional< TSState > m_ts_state
A class that represents a running process on the host machine.
Represents style that the highlighter should apply to the given source code.
HighlightStyle::ColorStyle style
TSState(const TSState &)=delete
TSState & operator=(const TSState &)=delete