Class: LanguageServer::Protocol::Interface::FileSystemWatcher

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(glob_pattern:, kind: nil) ⇒ FileSystemWatcher

Returns a new instance of FileSystemWatcher.



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

def initialize(glob_pattern:, kind: nil)
  @attributes = {}

  @attributes[:globPattern] = glob_pattern
  @attributes[:kind] = kind if kind

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



44
45
46
# File 'lib/language_server/protocol/interface/file_system_watcher.rb', line 44

def attributes
  @attributes
end

Instance Method Details

#glob_patternstring

The glob pattern to watch.

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)


30
31
32
# File 'lib/language_server/protocol/interface/file_system_watcher.rb', line 30

def glob_pattern
  attributes.fetch(:globPattern)
end

#kindnumber

The kind of events of interest. If omitted it defaults to WatchKind.Create | WatchKind.Change | WatchKind.Delete which is 7.

Returns:

  • (number)


40
41
42
# File 'lib/language_server/protocol/interface/file_system_watcher.rb', line 40

def kind
  attributes.fetch(:kind)
end

#to_hashObject



46
47
48
# File 'lib/language_server/protocol/interface/file_system_watcher.rb', line 46

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



50
51
52
# File 'lib/language_server/protocol/interface/file_system_watcher.rb', line 50

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