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

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

Overview

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

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.[!0-9] 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: nil, scheme: nil, pattern: nil) ⇒ TextDocumentFilter

Returns a new instance of TextDocumentFilter.

Parameters:

  • language: (String) (defaults to: nil)
  • scheme: (String) (defaults to: nil)
  • pattern: (String) (defaults to: nil)

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: 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

#attributesHash[Symbol, untyped] (readonly)

Returns:

  • (Hash[Symbol, untyped])

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.

Returns:

  • (string)

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

A glob pattern, like *.{ts,js}.

Returns:

  • (string)

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

A Uri Uri.scheme scheme, like file or untitled.

Returns:

  • (string)

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_hashHash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])

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) ⇒ String

Parameters:

  • (Object)

Returns:

  • (String)

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