Class: LanguageServer::Protocol::Interface::WorkspaceEdit

Inherits:
Object
  • Object
show all
Defined in:
lib/language_server/protocol/interface/workspace_edit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(changes: nil, document_changes: nil, change_annotations: nil) ⇒ WorkspaceEdit

Returns a new instance of WorkspaceEdit.



5
6
7
8
9
10
11
12
13
# File 'lib/language_server/protocol/interface/workspace_edit.rb', line 5

def initialize(changes: nil, document_changes: nil, change_annotations: nil)
  @attributes = {}

  @attributes[:changes] = changes if changes
  @attributes[:documentChanges] = document_changes if document_changes
  @attributes[:changeAnnotations] = change_annotations if change_annotations

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



56
57
58
# File 'lib/language_server/protocol/interface/workspace_edit.rb', line 56

def attributes
  @attributes
end

Instance Method Details

#change_annotations{ [id: string]: ChangeAnnotation; }

A map of change annotations that can be referenced in ‘AnnotatedTextEdit`s or create, rename and delete file / folder operations.

Whether clients honor this property depends on the client capability ‘workspace.changeAnnotationSupport`.

Returns:



52
53
54
# File 'lib/language_server/protocol/interface/workspace_edit.rb', line 52

def change_annotations
  attributes.fetch(:changeAnnotations)
end

#changes{}

Holds changes to existing resources.

Returns:

  • ({})


19
20
21
# File 'lib/language_server/protocol/interface/workspace_edit.rb', line 19

def changes
  attributes.fetch(:changes)
end

#document_changesTextDocumentEdit[] | (TextDocumentEdit | CreateFile | RenameFile | DeleteFile)[]

Depending on the client capability ‘workspace.workspaceEdit.resourceOperations` document changes are either an array of `TextDocumentEdit`s to express changes to n different text documents where each text document edit addresses a specific version of a text document. Or it can contain above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations.

Whether a client supports versioned document edits is expressed via ‘workspace.workspaceEdit.documentChanges` client capability.

If a client neither supports ‘documentChanges` nor `workspace.workspaceEdit.resourceOperations` then only plain `TextEdit`s using the `changes` property are supported.



39
40
41
# File 'lib/language_server/protocol/interface/workspace_edit.rb', line 39

def document_changes
  attributes.fetch(:documentChanges)
end

#to_hashObject



58
59
60
# File 'lib/language_server/protocol/interface/workspace_edit.rb', line 58

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



62
63
64
# File 'lib/language_server/protocol/interface/workspace_edit.rb', line 62

def to_json(*args)
  to_hash.to_json(*args)
end