@@ -63,16 +63,10 @@ defmodule Expert.State do
63
63
response = initialize_result ( )
64
64
65
65
projects =
66
- case event . workspace_folders do
67
- nil ->
68
- find_projects ( event . root_uri )
69
-
70
- _ ->
71
- for % { uri: uri } <- event . workspace_folders ,
72
- project = Project . new ( uri ) ,
73
- project . mix_project? do
74
- project
75
- end
66
+ for % { uri: uri } <- event . workspace_folders || [ ] ,
67
+ project = Project . new ( uri ) ,
68
+ project . mix_project? do
69
+ project
76
70
end
77
71
78
72
ActiveProjects . set_projects ( projects )
@@ -96,34 +90,6 @@ defmodule Expert.State do
96
90
Configuration . default ( config )
97
91
end
98
92
99
- defp find_projects ( root_uri ) do
100
- root_path = Forge.Document.Path . from_uri ( root_uri )
101
- root_mix_exs = Path . join ( root_path , "mix.exs" )
102
-
103
- projects =
104
- if File . exists? ( root_mix_exs ) do
105
- [ Project . new ( root_uri ) ]
106
- else
107
- find_multiroot_projects ( root_path )
108
- end
109
-
110
- if projects == [ ] , do: [ Project . new ( root_uri ) ] , else: projects
111
- end
112
-
113
- defp find_multiroot_projects ( root_path ) do
114
- mix_exs_blob = Path . join ( [ root_path , "**" , "mix.exs" ] )
115
-
116
- for mix_exs_path <- Path . wildcard ( mix_exs_blob ) ,
117
- "deps" not in Path . split ( mix_exs_path ) do
118
- project_uri =
119
- mix_exs_path
120
- |> Path . dirname ( )
121
- |> Forge.Document.Path . to_uri ( )
122
-
123
- Project . new ( project_uri )
124
- end
125
- end
126
-
127
93
def apply ( % __MODULE__ { initialized?: false } , request ) do
128
94
Logger . error ( "Received #{ request . method } before server was initialized" )
129
95
{ :error , :not_initialized }
@@ -257,7 +223,7 @@ defmodule Expert.State do
257
223
258
224
def apply ( % __MODULE__ { } = state , % GenLSP.Notifications.TextDocumentDidSave { params: params } ) do
259
225
uri = params . text_document . uri
260
- project = Forge.Project . project_for_uri ( state . configuration . projects , uri )
226
+ project = Forge.Project . project_for_uri ( ActiveProjects . projects ( ) , uri )
261
227
262
228
case Document.Store . save ( uri ) do
263
229
:ok ->
@@ -282,7 +248,7 @@ defmodule Expert.State do
282
248
end
283
249
284
250
def apply ( % __MODULE__ { } = state , % Notifications.WorkspaceDidChangeWatchedFiles { params: params } ) do
285
- for project <- state . configuration . projects ,
251
+ for project <- ActiveProjects . projects ( ) ,
286
252
change <- params . changes do
287
253
params = filesystem_event ( project: Project , uri: change . uri , event_type: change . type )
288
254
EngineApi . broadcast ( project , params )
0 commit comments