Class: LanguageServer::Protocol::Interface::DocumentFilter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(language: nil, scheme: nil, pattern: nil) ⇒ DocumentFilter

Returns a new instance of DocumentFilter.



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

def initialize(language: nil, scheme: nil, pattern: nil)
  @attributes = {}

  @attributes[:language] = language if language
  @attributes[:scheme] = scheme if scheme
  @attributes[:pattern] = pattern if pattern

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

Instance Method Details

#languagestring

A language id, like ‘typescript`.

Returns:

  • (string)


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

def language
  attributes.fetch(:language)
end

#patternstring

A glob pattern, like ‘*.ts,js`.

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)


47
48
49
# File 'lib/language_server/protocol/interface/document_filter.rb', line 47

def pattern
  attributes.fetch(:pattern)
end

#schemestring

A Uri [scheme](#Uri.scheme), like ‘file` or `untitled`.

Returns:

  • (string)


27
28
29
# File 'lib/language_server/protocol/interface/document_filter.rb', line 27

def scheme
  attributes.fetch(:scheme)
end

#to_hashObject



53
54
55
# File 'lib/language_server/protocol/interface/document_filter.rb', line 53

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



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

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