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

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

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: nil, scheme: nil, pattern: nil, notebook: nil) ⇒ DocumentFilter

Returns a new instance of DocumentFilter.

Parameters:

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

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: nil, scheme: nil, pattern: nil, notebook: nil)
  @attributes = {}

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

  @attributes.freeze
end

Instance Attribute Details

#attributesHash[Symbol, untyped] (readonly)

Returns:

  • (Hash[Symbol, untyped])

Since:

  • 3.17.0 - proposed support for NotebookCellTextDocumentFilter.



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

def attributes
  @attributes
end

Instance Method Details

#languagestring

A language id, like typescript.

--- OR ---

A language id like python.

Will be matched against the language id of the notebook cell document. '*' matches every language.

Returns:

  • (string)

Since:

  • 3.17.0 - proposed support for NotebookCellTextDocumentFilter.



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

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.



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

def notebook
  attributes.fetch(:notebook)
end

#patternstring

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

Returns:

  • (string)

Since:

  • 3.17.0 - proposed support for NotebookCellTextDocumentFilter.



49
50
51
# File 'lib/language_server/protocol/interface/document_filter.rb', line 49

def pattern
  attributes.fetch(:pattern)
end

#schemestring

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

Returns:

  • (string)

Since:

  • 3.17.0 - proposed support for NotebookCellTextDocumentFilter.



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

def scheme
  attributes.fetch(:scheme)
end

#to_hashHash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])

Since:

  • 3.17.0 - proposed support for NotebookCellTextDocumentFilter.



66
67
68
# File 'lib/language_server/protocol/interface/document_filter.rb', line 66

def to_hash
  attributes
end

#to_json(*args) ⇒ String

Parameters:

  • (Object)

Returns:

  • (String)

Since:

  • 3.17.0 - proposed support for NotebookCellTextDocumentFilter.



70
71
72
# File 'lib/language_server/protocol/interface/document_filter.rb', line 70

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