Class: Yoda::Server::Workspace
- Inherits:
-
Object
- Object
- Yoda::Server::Workspace
- Extended by:
- Forwardable
- Defined in:
- lib/yoda/server/workspace.rb
Overview
Denotes workspace folder in LSP. @see: microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_workspaceFolders
Defined Under Namespace
Classes: UriEncoder
Instance Attribute Summary collapse
- #name ⇒ String readonly
- #root_uri ⇒ String readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, root_uri:) ⇒ Workspace
constructor
A new instance of Workspace.
- #project ⇒ Store::Project?
- #read_at(uri) ⇒ String?
- #read_source(uri) ⇒ Object
- #remove_source(uri:) ⇒ Object
- #root_path ⇒ String
-
#setup ⇒ Array<Exception>
Errors on setup.
- #store_source(uri:, source:) ⇒ Object
- #suburi?(uri) ⇒ Boolean
Constructor Details
#initialize(name:, root_uri:) ⇒ Workspace
Returns a new instance of Workspace.
29 30 31 32 |
# File 'lib/yoda/server/workspace.rb', line 29 def initialize(name:, root_uri:) @name = name @root_uri = root_uri end |
Instance Attribute Details
#name ⇒ String (readonly)
12 13 14 |
# File 'lib/yoda/server/workspace.rb', line 12 def name @name end |
#root_uri ⇒ String (readonly)
15 16 17 |
# File 'lib/yoda/server/workspace.rb', line 15 def root_uri @root_uri end |
Class Method Details
.from_workspace_folder(folder) ⇒ Workspace
23 24 25 |
# File 'lib/yoda/server/workspace.rb', line 23 def self.from_workspace_folder(folder) new(name: folder.name, root_uri: folder.uri) end |
Instance Method Details
#project ⇒ Store::Project?
40 41 42 |
# File 'lib/yoda/server/workspace.rb', line 40 def project @project ||= Store::Project.for_path(root_path) end |
#read_at(uri) ⇒ String?
51 52 53 54 |
# File 'lib/yoda/server/workspace.rb', line 51 def read_at(uri) path = UriDecoder.path_of_uri(uri) path && file_tree.read_at(path) end |
#read_source(uri) ⇒ Object
57 58 59 60 61 |
# File 'lib/yoda/server/workspace.rb', line 57 def read_source(uri) path = UriDecoder.path_of_uri(uri) return if !path || !program_file?(path) file_tree.clear_editing_at(path) end |
#remove_source(uri:) ⇒ Object
72 73 74 75 |
# File 'lib/yoda/server/workspace.rb', line 72 def remove_source(uri:) path = UriDecoder.path_of_uri(uri) file_tree.mark_deleted(path) end |
#root_path ⇒ String
45 46 47 |
# File 'lib/yoda/server/workspace.rb', line 45 def root_path UriDecoder.path_of_uri(root_uri) end |
#setup ⇒ Array<Exception>
Returns errors on setup.
35 36 37 |
# File 'lib/yoda/server/workspace.rb', line 35 def setup project.setup end |
#store_source(uri:, source:) ⇒ Object
65 66 67 68 69 |
# File 'lib/yoda/server/workspace.rb', line 65 def store_source(uri:, source:) path = UriDecoder.path_of_uri(uri) return if !path || !program_file?(path) file_tree.set_editing_at(path, source) end |
#suburi?(uri) ⇒ Boolean
77 78 79 80 |
# File 'lib/yoda/server/workspace.rb', line 77 def suburi?(uri) path = UriDecoder.path_of_uri(uri) path && subpath?(path) end |