|
LLDB mainline
|
#include <TreeSitterHighlighter.h>
Classes | |
| struct | HLRange |
| struct | TSState |
Public Member Functions | |
| TreeSitterHighlighter ()=default | |
| ~TreeSitterHighlighter () override=default | |
| 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. | |
| Public Member Functions inherited from lldb_private::Highlighter | |
| Highlighter ()=default | |
| virtual | ~Highlighter ()=default |
| Highlighter (const Highlighter &)=delete | |
| const Highlighter & | operator= (const Highlighter &)=delete |
| virtual llvm::StringRef | GetName () const =0 |
| Returns a human readable name for the selected highlighter. | |
| std::string | Highlight (const HighlightStyle &options, llvm::StringRef line, std::optional< size_t > cursor_pos, llvm::StringRef previous_lines="") const |
| Utility method for calling Highlight without a stream. | |
| Public Member Functions inherited from lldb_private::PluginInterface | |
| PluginInterface ()=default | |
| virtual | ~PluginInterface ()=default |
| virtual llvm::StringRef | GetPluginName ()=0 |
| PluginInterface (const PluginInterface &)=delete | |
| PluginInterface & | operator= (const PluginInterface &)=delete |
Protected Member Functions | |
| virtual const TSLanguage * | GetLanguage () const =0 |
| Returns the tree-sitter language for this highlighter. | |
| virtual llvm::StringRef | GetHighlightQuery () const =0 |
| Returns the tree-sitter highlight query for this language. | |
Private Member Functions | |
| HighlightStyle::ColorStyle | GetStyleForCapture (llvm::StringRef capture_name, const HighlightStyle &options) const |
| Maps a tree-sitter capture name to a HighlightStyle color. | |
| 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. | |
| TSState & | GetTSState () const |
| Lazily creates a tree-sitter state (TSState). | |
Private Attributes | |
| std::optional< TSState > | m_ts_state |
Definition at line 23 of file TreeSitterHighlighter.h.
|
default |
|
overridedefault |
|
protectedpure virtual |
Returns the tree-sitter highlight query for this language.
Implemented in lldb_private::RustTreeSitterHighlighter, and lldb_private::SwiftTreeSitterHighlighter.
Referenced by GetTSState().
|
protectedpure virtual |
Returns the tree-sitter language for this highlighter.
Implemented in lldb_private::RustTreeSitterHighlighter, and lldb_private::SwiftTreeSitterHighlighter.
Referenced by GetTSState().
|
private |
Maps a tree-sitter capture name to a HighlightStyle color.
Definition at line 67 of file TreeSitterHighlighter.cpp.
References lldb_private::HighlightStyle::braces, lldb_private::HighlightStyle::colon, lldb_private::HighlightStyle::comma, lldb_private::HighlightStyle::comment, lldb_private::HighlightStyle::identifier, lldb_private::HighlightStyle::keyword, lldb_private::HighlightStyle::operators, lldb_private::HighlightStyle::parentheses, lldb_private::HighlightStyle::pp_directive, lldb_private::HighlightStyle::scalar_literal, lldb_private::HighlightStyle::semicolons, lldb_private::HighlightStyle::square_brackets, and lldb_private::HighlightStyle::string_literal.
Referenced by Highlight().
|
private |
Lazily creates a tree-sitter state (TSState).
Definition at line 29 of file TreeSitterHighlighter.cpp.
References GetHighlightQuery(), GetLanguage(), lldb_private::GetLog(), lldb_private::Highlighter::GetName(), LLDB_LOG, m_ts_state, and lldb_private::Source.
Referenced by Highlight().
|
overridevirtual |
Highlights a single line of code using tree-sitter parsing.
Implements lldb_private::Highlighter.
Definition at line 146 of file TreeSitterHighlighter.cpp.
References GetStyleForCapture(), GetTSState(), HighlightRange(), lldb_private::TreeSitterHighlighter::TSState::parser, and lldb_private::TreeSitterHighlighter::TSState::query.
|
private |
Applies syntax highlighting to a range of text.
Definition at line 90 of file TreeSitterHighlighter.cpp.
References lldb_private::HighlightStyle::ColorStyle::Apply(), lldb_private::StreamString::GetString(), and lldb_private::HighlightStyle::selected.
Referenced by Highlight().
|
mutableprivate |
Definition at line 72 of file TreeSitterHighlighter.h.
Referenced by GetTSState().