ink_lsp_server/translator.rs
1//! Translates between ink! analyzer and LSP types.
2
3pub mod from_lsp;
4pub mod to_lsp;
5
6use line_index::LineIndex;
7use lsp_types::PositionEncodingKind;
8
9/// Represents context information necessary to translate between an LSP position/range and ink! analyzer offset/text range.
10pub struct PositionTranslationContext {
11 pub encoding: PositionEncodingKind,
12 pub line_index: LineIndex,
13}
14
15impl PositionTranslationContext {
16 pub(crate) fn new(content: &str, encoding: PositionEncodingKind) -> Self {
17 Self {
18 encoding,
19 line_index: LineIndex::new(content),
20 }
21 }
22}