Class: SorbetView::Lsp::DocumentStore
- Inherits:
-
Object
- Object
- SorbetView::Lsp::DocumentStore
- Extended by:
- T::Sig
- Defined in:
- lib/sorbet_view/lsp/document_store.rb
Overview
In-memory store of open template documents
Instance Method Summary collapse
- #all ⇒ Object
- #change(uri, content, version) ⇒ Object
- #close(uri) ⇒ Object
- #get(uri) ⇒ Object
-
#initialize ⇒ DocumentStore
constructor
A new instance of DocumentStore.
- #open(uri, content, version) ⇒ Object
Constructor Details
#initialize ⇒ DocumentStore
Returns a new instance of DocumentStore.
18 19 20 |
# File 'lib/sorbet_view/lsp/document_store.rb', line 18 def initialize @documents = T.let({}, T::Hash[String, Document]) end |
Instance Method Details
#all ⇒ Object
51 52 53 |
# File 'lib/sorbet_view/lsp/document_store.rb', line 51 def all @documents.values end |
#change(uri, content, version) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/sorbet_view/lsp/document_store.rb', line 30 def change(uri, content, version) doc = @documents[uri] return nil unless doc doc.content = content doc.version = version doc.compile_result = nil # Invalidate doc end |
#close(uri) ⇒ Object
41 42 43 |
# File 'lib/sorbet_view/lsp/document_store.rb', line 41 def close(uri) @documents.delete(uri) end |
#get(uri) ⇒ Object
46 47 48 |
# File 'lib/sorbet_view/lsp/document_store.rb', line 46 def get(uri) @documents[uri] end |
#open(uri, content, version) ⇒ Object
23 24 25 26 27 |
# File 'lib/sorbet_view/lsp/document_store.rb', line 23 def open(uri, content, version) doc = Document.new(uri: uri, content: content, version: version, compile_result: nil) @documents[uri] = doc doc end |