Class: LanguageServer::Protocol::Interface::FileOperationPattern

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

Overview

A pattern to describe in which file operation requests or notifications the server is interested in.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(glob:, matches: nil, options: nil) ⇒ FileOperationPattern

Returns a new instance of FileOperationPattern.



9
10
11
12
13
14
15
16
17
# File 'lib/language_server/protocol/interface/file_operation_pattern.rb', line 9

def initialize(glob:, matches: nil, options: nil)
  @attributes = {}

  @attributes[:glob] = glob
  @attributes[:matches] = matches if matches
  @attributes[:options] = options if options

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



55
56
57
# File 'lib/language_server/protocol/interface/file_operation_pattern.rb', line 55

def attributes
  @attributes
end

Instance Method Details

#globstring

The glob pattern to match. Glob patterns can have the following syntax:

  • ‘*` to match one or more characters in a path segment

  • ‘?` to match on one character in a path segment

  • ‘**` to match any number of path segments, including none

  • ‘{}` to group sub patterns into an OR expression. (e.g. `**​/*.ts,js`

matches all TypeScript and JavaScript files)

  • ‘[]` to declare a range of characters to match in a path segment

(e.g., ‘example.` to match on `example.0`, `example.1`, …)

  • ‘[!…]` to negate a range of characters to match in a path segment

(e.g., ‘example.` to match on `example.a`, `example.b`, but not `example.0`)

Returns:

  • (string)


33
34
35
# File 'lib/language_server/protocol/interface/file_operation_pattern.rb', line 33

def glob
  attributes.fetch(:glob)
end

#matchesFileOperationPatternKind

Whether to match files or folders with this pattern.

Matches both if undefined.

Returns:

  • (FileOperationPatternKind)


43
44
45
# File 'lib/language_server/protocol/interface/file_operation_pattern.rb', line 43

def matches
  attributes.fetch(:matches)
end

#optionsFileOperationPatternOptions

Additional options used during matching.



51
52
53
# File 'lib/language_server/protocol/interface/file_operation_pattern.rb', line 51

def options
  attributes.fetch(:options)
end

#to_hashObject



57
58
59
# File 'lib/language_server/protocol/interface/file_operation_pattern.rb', line 57

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



61
62
63
# File 'lib/language_server/protocol/interface/file_operation_pattern.rb', line 61

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