1
0
Fork 0
mirror of https://github.com/laravel-ls/protocol.git synced 2026-06-16 03:54:56 +02:00
protocol/document_change_operation.go
2025-11-01 10:20:54 +01:00

76 lines
2.6 KiB
Go

package protocol
// DocumentChangeOperation - represents any valid document change operation.
type DocumentChangeOperation interface {
isDocumentChangeOperation()
}
// ResourceOperation - A generic resource operation.
type ResourceOperation struct {
// resource operation kind
Kind string `json:"kind"`
// An optional annotation identifier describing the operation.
AnnotationID string `json:"annotationId,omitempty"`
}
// CreateFile operation.
// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#createFile
type CreateFile struct {
ResourceOperation
URI DocumentURI `json:"uri"`
Options *CreateFileOptions `json:"options,omitempty"`
}
func (CreateFile) isDocumentChangeOperation() {}
// CreateFileOptions - Options to create a file.
// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#createFileOptions
type CreateFileOptions struct {
// Overwrite existing file. Overwrite wins over ignoreIfExists.
Overwrite bool `json:"overwrite,omitempty"`
// Ignore if exists.
IgnoreIfExists bool `json:"ignoreIfExists,omitempty"`
}
// RenameFile operation.
// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#renameFile
type RenameFile struct {
ResourceOperation
OldURI DocumentURI `json:"oldUri"`
NewURI DocumentURI `json:"newUri"`
Options *RenameFileOptions `json:"options,omitempty"`
}
// RenameFileOptions - Options to rename a file.
// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#renameFileOptions
type RenameFileOptions struct {
// Overwrite target if existing.
Overwrite bool `json:"overwrite,omitempty"`
// Ignores if target exists.
IgnoreIfExists bool `json:"ignoreIfExists,omitempty"`
}
func (RenameFile) isDocumentChangeOperation() {}
// DeleteFile operation.
// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#deleteFile
type DeleteFile struct {
ResourceOperation
URI DocumentURI `json:"uri"`
Options *DeleteFileOptions `json:"options,omitempty"`
}
func (DeleteFile) isDocumentChangeOperation() {}
// DeleteFileOptions - Options to delete a file.
// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#deleteFileOptions
type DeleteFileOptions struct {
// Delete content recursively if a folder is denoted.
Recursive bool `json:"recursive,omitempty"`
// Ignore the operation if the file doesn't exist.
IgnoreIfNotExists bool `json:"ignoreIfNotExists,omitempty"`
}