@@ -63,16 +63,10 @@ defmodule Expert.State do
6363 response = initialize_result ( )
6464
6565 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
7670 end
7771
7872 ActiveProjects . set_projects ( projects )
@@ -96,34 +90,6 @@ defmodule Expert.State do
9690 Configuration . default ( config )
9791 end
9892
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-
12793 def apply ( % __MODULE__ { initialized?: false } , request ) do
12894 Logger . error ( "Received #{ request . method } before server was initialized" )
12995 { :error , :not_initialized }
@@ -257,7 +223,7 @@ defmodule Expert.State do
257223
258224 def apply ( % __MODULE__ { } = state , % GenLSP.Notifications.TextDocumentDidSave { params: params } ) do
259225 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 )
261227
262228 case Document.Store . save ( uri ) do
263229 :ok ->
@@ -282,7 +248,7 @@ defmodule Expert.State do
282248 end
283249
284250 def apply ( % __MODULE__ { } = state , % Notifications.WorkspaceDidChangeWatchedFiles { params: params } ) do
285- for project <- state . configuration . projects ,
251+ for project <- ActiveProjects . projects ( ) ,
286252 change <- params . changes do
287253 params = filesystem_event ( project: Project , uri: change . uri , event_type: change . type )
288254 EngineApi . broadcast ( project , params )
0 commit comments