From 86925ea87f6452c22c114a9b094300f1bd9c9b6d Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Thu, 10 Oct 2024 11:31:41 -0400 Subject: [PATCH] Add code_units_cache helper --- lib/ruby_lsp/erb_document.rb | 10 ++++++++++ lib/ruby_lsp/ruby_document.rb | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/ruby_lsp/erb_document.rb b/lib/ruby_lsp/erb_document.rb index 9730fb4a0..310040ed0 100644 --- a/lib/ruby_lsp/erb_document.rb +++ b/lib/ruby_lsp/erb_document.rb @@ -64,6 +64,16 @@ def inside_host_language?(char_position) char && char != " " end + sig do + returns(T.any( + T.proc.params(arg0: Integer).returns(Integer), + Prism::CodeUnitsCache, + )) + end + def code_units_cache + @parse_result.code_units_cache(@encoding) + end + class ERBScanner extend T::Sig diff --git a/lib/ruby_lsp/ruby_document.rb b/lib/ruby_lsp/ruby_document.rb index 5bddb1ae8..03476e234 100644 --- a/lib/ruby_lsp/ruby_document.rb +++ b/lib/ruby_lsp/ruby_document.rb @@ -218,5 +218,15 @@ def locate_node(position, node_types: []) encoding: @encoding, ) end + + sig do + returns(T.any( + T.proc.params(arg0: Integer).returns(Integer), + Prism::CodeUnitsCache, + )) + end + def code_units_cache + @parse_result.code_units_cache(@encoding) + end end end