Class: Solargraph::LanguageServer::Host::Sources
- Inherits:
-
Object
- Object
- Solargraph::LanguageServer::Host::Sources
- Includes:
- Observable, UriHelpers
- Defined in:
- lib/solargraph/language_server/host/sources.rb
Overview
A Host class for managing sources.
Instance Method Summary collapse
- #add_uri(uri) ⇒ void
- #clear ⇒ void
-
#close(uri) ⇒ void
Close the source with the given URI.
-
#find(uri) ⇒ Solargraph::Source
Find the source with the given URI.
-
#include?(uri) ⇒ Boolean
True if a source with given URI is currently open.
-
#open(uri, text, version) ⇒ Source
Open a source.
- #open_from_disk(uri) ⇒ void
-
#update(uri, updater) ⇒ void
Update an existing source.
Methods included from UriHelpers
decode, encode, file_to_uri, uri_to_file
Instance Method Details
#add_uri(uri) ⇒ void
This method returns an undefined value.
16 17 18 |
# File 'lib/solargraph/language_server/host/sources.rb', line 16 def add_uri(uri) queue.push(uri) end |
#clear ⇒ void
This method returns an undefined value.
79 80 81 |
# File 'lib/solargraph/language_server/host/sources.rb', line 79 def clear open_source_hash.clear end |
#close(uri) ⇒ void
This method returns an undefined value.
Close the source with the given URI.
67 68 69 |
# File 'lib/solargraph/language_server/host/sources.rb', line 67 def close uri open_source_hash.delete uri end |
#find(uri) ⇒ Solargraph::Source
Find the source with the given URI.
59 60 61 |
# File 'lib/solargraph/language_server/host/sources.rb', line 59 def find uri open_source_hash[uri] || raise(Solargraph::FileNotFoundError, "Host could not find #{uri}") end |
#include?(uri) ⇒ Boolean
True if a source with given URI is currently open.
74 75 76 |
# File 'lib/solargraph/language_server/host/sources.rb', line 74 def include? uri open_source_hash.key? uri end |
#open(uri, text, version) ⇒ Source
Open a source.
26 27 28 29 30 |
# File 'lib/solargraph/language_server/host/sources.rb', line 26 def open uri, text, version filename = uri_to_file(uri) source = Solargraph::Source.new(text, filename, version) open_source_hash[uri] = source end |
#open_from_disk(uri) ⇒ void
This method returns an undefined value.
34 35 36 37 |
# File 'lib/solargraph/language_server/host/sources.rb', line 34 def open_from_disk uri source = Solargraph::Source.load(UriHelpers.uri_to_file(uri)) open_source_hash[uri] = source end |
#update(uri, updater) ⇒ void
This method returns an undefined value.
Update an existing source.
46 47 48 49 50 51 |
# File 'lib/solargraph/language_server/host/sources.rb', line 46 def update uri, updater src = find(uri) open_source_hash[uri] = src.synchronize(updater) changed notify_observers uri end |