Class: PuppetLanguageServer::SessionState::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet-languageserver/session_state/document_store.rb

Overview

Represents a Document in the Document Store. Can be subclassed to add additional methods and helpers

Direct Known Subclasses

EppDocument, ManifestDocument, PuppetfileDocument

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, content, version) ⇒ Document

Returns a new instance of Document.

Parameters:

  • uri

    String The content of the document

  • content

    String The content of the document

  • version

    Integer The version the document



13
14
15
16
17
18
# File 'lib/puppet-languageserver/session_state/document_store.rb', line 13

def initialize(uri, content, version)
  @uri = uri
  @content = content
  @version = version
  @tokens = nil
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



8
9
10
# File 'lib/puppet-languageserver/session_state/document_store.rb', line 8

def content
  @content
end

#tokensObject (readonly)

Returns the value of attribute tokens.



8
9
10
# File 'lib/puppet-languageserver/session_state/document_store.rb', line 8

def tokens
  @tokens
end

#uriObject (readonly)

Returns the value of attribute uri.



8
9
10
# File 'lib/puppet-languageserver/session_state/document_store.rb', line 8

def uri
  @uri
end

#versionObject (readonly)

Returns the value of attribute version.



8
9
10
# File 'lib/puppet-languageserver/session_state/document_store.rb', line 8

def version
  @version
end

Instance Method Details

#calculate_tokens!Object

Subclass this!



30
31
32
# File 'lib/puppet-languageserver/session_state/document_store.rb', line 30

def calculate_tokens!
  []
end

#update(content, version) ⇒ Object

Update a document with new content and version

Parameters:

  • content

    String The new content for the document

  • version

    Integer The version of the new document



23
24
25
26
27
# File 'lib/puppet-languageserver/session_state/document_store.rb', line 23

def update(content, version)
  @content = content
  @version = version
  @tokens = nil
end