Class: LanguageServer::Protocol::Interface::TextDocumentFilter

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

Overview

A document filter denotes a document by different properties like the [language](#TextDocument.languageId), the [scheme](#Uri.scheme) of its resource, or a glob-pattern that is applied to the [path](#TextDocument.fileName).

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.[0-9] 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)

Since:

  • 3.17.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of TextDocumentFilter.

Since:

  • 3.17.0



23
24
25
26
27
28
29
30
31
# File 'lib/language_server/protocol/interface/text_document_filter.rb', line 23

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

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

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Since:

  • 3.17.0



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

def attributes
  @attributes
end

Instance Method Details

#languagestring

A language id, like typescript. */

Since:

  • 3.17.0



37
38
39
# File 'lib/language_server/protocol/interface/text_document_filter.rb', line 37

def language
  attributes.fetch(:language)
end

#patternstring | nil

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

Since:

  • 3.17.0



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

def pattern
  attributes.fetch(:pattern)
end

#schemestring | nil

A Uri [scheme](#Uri.scheme), like file or untitled. */

Since:

  • 3.17.0



45
46
47
# File 'lib/language_server/protocol/interface/text_document_filter.rb', line 45

def scheme
  attributes.fetch(:scheme)
end

#to_hashObject

Since:

  • 3.17.0



59
60
61
# File 'lib/language_server/protocol/interface/text_document_filter.rb', line 59

def to_hash
  attributes
end

#to_json(*args) ⇒ Object

Since:

  • 3.17.0



63
64
65
# File 'lib/language_server/protocol/interface/text_document_filter.rb', line 63

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