Class: LSP::CodeAction

Inherits:
LSPBase show all
Defined in:
lib/lsp/lsp_types.rb

Overview

export interface CodeAction

/**
 * A short, human-readable, title for this code action.
 */
title: string;
/**
 * The kind of the code action.
 *
 * Used to filter code actions.
 */
kind?: CodeActionKind;
/**
 * The diagnostics that this code action resolves.
 */
diagnostics?: Diagnostic[];
/**
 * Marks this as a preferred action. Preferred actions are used by the `auto fix` command and can be targeted
 * by keybindings.
 *
 * A quick fix should be marked preferred if it properly addresses the underlying error.
 * A refactoring should be marked preferred if it is the most reasonable choice of actions to take.
 *
 * @since 3.15.0
 */
isPreferred?: boolean;
/**
 * The workspace edit this code action performs.
 */
edit?: WorkspaceEdit;
/**
 * A command this code action executes. If a code action
 * provides a edit and a command, first the edit is
 * executed and then the command.
 */
command?: Command;

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from LSPBase

#to_h, #to_json

Constructor Details

#initialize(initial_hash = nil) ⇒ CodeAction

Returns a new instance of CodeAction.



1250
1251
1252
1253
# File 'lib/lsp/lsp_types.rb', line 1250

def initialize(initial_hash = nil)
  super
  @optional_method_names = i[kind diagnostics isPreferred edit command]
end

Instance Attribute Details

#commandObject

type: string # type: CodeActionKind # type: Diagnostic[] # type: boolean # type: WorkspaceEdit # type: Command



1248
1249
1250
# File 'lib/lsp/lsp_types.rb', line 1248

def command
  @command
end

#diagnosticsObject

type: string # type: CodeActionKind # type: Diagnostic[] # type: boolean # type: WorkspaceEdit # type: Command



1248
1249
1250
# File 'lib/lsp/lsp_types.rb', line 1248

def diagnostics
  @diagnostics
end

#editObject

type: string # type: CodeActionKind # type: Diagnostic[] # type: boolean # type: WorkspaceEdit # type: Command



1248
1249
1250
# File 'lib/lsp/lsp_types.rb', line 1248

def edit
  @edit
end

#isPreferredObject

type: string # type: CodeActionKind # type: Diagnostic[] # type: boolean # type: WorkspaceEdit # type: Command



1248
1249
1250
# File 'lib/lsp/lsp_types.rb', line 1248

def isPreferred
  @isPreferred
end

#kindObject

type: string # type: CodeActionKind # type: Diagnostic[] # type: boolean # type: WorkspaceEdit # type: Command



1248
1249
1250
# File 'lib/lsp/lsp_types.rb', line 1248

def kind
  @kind
end

#titleObject

type: string # type: CodeActionKind # type: Diagnostic[] # type: boolean # type: WorkspaceEdit # type: Command



1248
1249
1250
# File 'lib/lsp/lsp_types.rb', line 1248

def title
  @title
end

Instance Method Details

#from_h!(value) ⇒ Object



1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
# File 'lib/lsp/lsp_types.rb', line 1255

def from_h!(value)
  value = {} if value.nil?
  self.title = value['title']
  self.kind = value['kind'] # Unknown type
  self.diagnostics = to_typed_aray(value['diagnostics'], Diagnostic)
  self.isPreferred = value['isPreferred'] # Unknown type
  self.edit = WorkspaceEdit.new(value['edit']) unless value['edit'].nil?
  self.command = Command.new(value['command']) unless value['command'].nil?
  self
end