class Solargraph::LanguageServer::Host::Sources
A Host class for managing sources.
Public Instance Methods
Source
# File lib/solargraph/language_server/host/sources.rb, line 16 def add_uri(uri) queue.push(uri) end
@param uri [String] @return [void]
Source
# File lib/solargraph/language_server/host/sources.rb, line 79 def clear open_source_hash.clear end
@return [void]
Source
# File lib/solargraph/language_server/host/sources.rb, line 67 def close uri open_source_hash.delete uri end
Close the source with the given URI.
@param uri [String] @return [void]
Source
# 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
Find the source with the given URI.
@raise [FileNotFoundError] if the URI does not match an open source.
@param uri [String] @return [Solargraph::Source]
Source
# File lib/solargraph/language_server/host/sources.rb, line 74 def include? uri open_source_hash.key? uri end
True if a source with given URI is currently open. @param uri [String] @return [Boolean]
Source
# 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 a source.
@param uri [String] @param text [String] @param version [Integer] @return [Source]
Source
# 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
@param uri [String] @return [void]
Source
# 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
Update an existing source.
@raise [FileNotFoundError] if the URI does not match an open source.
@param uri [String] @param updater [Source::Updater] @return [void]
Private Instance Methods
Source
# File lib/solargraph/language_server/host/sources.rb, line 86 def open_source_hash @open_source_hash ||= {} end
@return [Hash{String => Solargraph::Source}]
Source
# File lib/solargraph/language_server/host/sources.rb, line 93 def queue @queue ||= [] end
An array of source URIs that are waiting to finish synchronizing.
@return [::Array<String>]