In Files

  • typeprof-0.21.2/lib/typeprof/lsp.rb

Class/Module Index [+]

Quicksearch

TypeProf::LSP::Text

Attributes

caller_table[R]
definition_table[RW]
sigs[R]
text[R]
version[R]

Public Class Methods

new(server, uri, text, version) click to toggle source
 
               # File typeprof-0.21.2/lib/typeprof/lsp.rb, line 64
def initialize(server, uri, text, version)
  @server = server
  @uri = uri
  @text = text
  @version = version
  @sigs = nil

  @last_analysis_cancel_token = nil
  @analysis_queue = Queue.new
  @analysis_thread = Thread.new do
    loop do
      work = @analysis_queue.pop
      begin
        work.call
      rescue Exception
        puts "Rescued exception:"
        puts $!.full_message
        puts
      end
    end
  end

  # analyze synchronously to respond the first codeLens request
  res, def_table, caller_table = self.analyze(uri, text)
  on_text_changed_analysis(res, def_table, caller_table)
end
            

Public Instance Methods

apply_changes(changes, version) click to toggle source
 
               # File typeprof-0.21.2/lib/typeprof/lsp.rb, line 98
def apply_changes(changes, version)
  @definition_table = nil
  text = @text.empty? ? [] : @text.lines
  changes.each do |change|
    case change
    in {
      range: {
          start: { line: start_row, character: start_col },
          end:   { line: end_row  , character: end_col   }
      },
      text: change_text,
    }
    else
      raise
    end
    text << "" if start_row == text.size
    text << "" if end_row == text.size
    if start_row == end_row
      text[start_row][start_col...end_col] = change_text
    else
      text[start_row][start_col..] = ""
      text[end_row][...end_col] = ""
      change_text = change_text.lines
      case change_text.size
      when 0
        text[start_row] += text[end_row]
        text[start_row + 1 .. end_row] = []
      when 1
        text[start_row] += change_text.first + text[end_row]
        text[start_row + 1 .. end_row] = []
      else
        text[start_row] += change_text.shift
        text[end_row].prepend(change_text.pop)
        text[start_row + 1 ... end_row - 1] = change_text
      end
    end
  end
            
lines() click to toggle source
 
               # File typeprof-0.21.2/lib/typeprof/lsp.rb, line 94
def lines
  @text.lines
end
            
There is an updated format of the API docs for this version here.