Sha256: 8a3769b86fba5ad2d32b6df85233f1690ac7f09dc2f8e2953dde7bf3b87c517e
Contents?: true
Size: 1.04 KB
Versions: 25
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true module PlatformosCheck module LanguageServer class CodeActionEngine include PositionHelper def initialize(storage, diagnostics_manager) @storage = storage @providers = CodeActionProvider.all.map { |c| c.new(storage, diagnostics_manager) } end def code_actions(absolute_path, start_position, end_position, only_kinds = []) relative_path = @storage.relative_path(absolute_path) buffer = @storage.read(relative_path) start_index = from_row_column_to_index(buffer, start_position[0], start_position[1]) end_index = from_row_column_to_index(buffer, end_position[0], end_position[1]) range = (start_index...end_index) @providers .filter do |provider| only_kinds.empty? || only_kinds.include?(provider.kind) || only_kinds.include?(provider.base_kind) end .flat_map do |provider| provider.code_actions(relative_path, range) end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems