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

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

Overview

A document filter describes a top level text document or a notebook cell document.

Since:

  • 3.17.0 - proposed support for NotebookCellTextDocumentFilter.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of DocumentFilter.

Since:

  • 3.17.0 - proposed support for NotebookCellTextDocumentFilter.



11
12
13
14
15
16
17
18
19
20
# File 'lib/language_server/protocol/interface/document_filter.rb', line 11

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

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

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Since:

  • 3.17.0 - proposed support for NotebookCellTextDocumentFilter.



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

def attributes
  @attributes
end

Instance Method Details

#languagestring

A language id, like typescript. */

Returns:

  • (string)

Since:

  • 3.17.0 - proposed support for NotebookCellTextDocumentFilter.



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

def language
  attributes.fetch(:language)
end

#notebookstring | NotebookDocumentFilter

A filter that matches against the notebook containing the notebook cell. If a string value is provided it matches against the notebook type. ‘*’ matches every notebook.

Returns:

Since:

  • 3.17.0 - proposed support for NotebookCellTextDocumentFilter.



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

def notebook
  attributes.fetch(:notebook)
end

#patternstring | nil

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

Returns:

  • (string | nil)

Since:

  • 3.17.0 - proposed support for NotebookCellTextDocumentFilter.



42
43
44
# File 'lib/language_server/protocol/interface/document_filter.rb', line 42

def pattern
  attributes.fetch(:pattern)
end

#schemestring | nil

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

Returns:

  • (string | nil)

Since:

  • 3.17.0 - proposed support for NotebookCellTextDocumentFilter.



34
35
36
# File 'lib/language_server/protocol/interface/document_filter.rb', line 34

def scheme
  attributes.fetch(:scheme)
end

#to_hashObject

Since:

  • 3.17.0 - proposed support for NotebookCellTextDocumentFilter.



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

def to_hash
  attributes
end

#to_json(*args) ⇒ Object

Since:

  • 3.17.0 - proposed support for NotebookCellTextDocumentFilter.



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

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