Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
purkhusid committed Nov 3, 2023
1 parent 3298702 commit 0f51003
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Components/SolutionExplorer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ module SolutionExplorer =
setParentRef s result
result
| WorkspacePeekFound.Directory dir ->
let items = dir.Fsprojs |> Array.map getProjItem |> List.ofArray
let items = dir.Fsprojs |> Array.map (fun f -> getProjItem f.Path) |> List.ofArray

let result = Workspace items
setParentRefs items result
Expand Down
6 changes: 5 additions & 1 deletion src/Core/DTO.fs
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,16 @@ module DTO =

type WorkspacePeek = { Found: WorkspacePeekFound[] }

and WorkspacePeekFsproj =
{ Path: string; CompileItems: string[] }

and WorkspacePeekFound =
| Directory of WorkspacePeekFoundDirectory
| Solution of WorkspacePeekFoundSolution

and WorkspacePeekFoundDirectory =
{ Directory: string; Fsprojs: string[] }
{ Directory: string
Fsprojs: WorkspacePeekFsproj[] }

and WorkspacePeekFoundSolution =
{ Path: string
Expand Down
29 changes: 18 additions & 11 deletions src/Core/Project.fs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ module Project =
| Folder folder -> folder.Items |> Array.collect getProjs

sln.Items |> Array.collect getProjs |> Array.toList
| Some(WorkspacePeekFound.Directory dir) -> dir.Fsprojs |> Array.toList

| Some(WorkspacePeekFound.Directory dir) -> dir.Fsprojs |> Array.map (fun f -> f.Path) |> Array.toList

let getNotLoaded () =
let lst =
Expand Down Expand Up @@ -252,7 +251,7 @@ module Project =
let projs =
match loadedWorkspace with
| None -> Array.empty
| Some(WorkspacePeekFound.Directory dir) -> dir.Fsprojs
| Some(WorkspacePeekFound.Directory dir) -> dir.Fsprojs |> Array.map (fun f -> f.Path)
| Some(WorkspacePeekFound.Solution sln) -> sln.Items |> Array.collect foldFsproj |> Array.map fst

let loadingInProgress p =
Expand Down Expand Up @@ -547,7 +546,7 @@ module Project =

let wdir =
{ WorkspacePeekFoundDirectory.Directory = workspace.rootPath.Value
Fsprojs = fsprojs |> Array.ofList }
Fsprojs = fsprojs |> List.map (fun p -> { Path = p; CompileItems = [||] }) |> Array.ofList }

return WorkspacePeekFound.Directory wdir
}
Expand Down Expand Up @@ -651,8 +650,8 @@ module Project =

let projs =
match x with
| WorkspacePeekFound.Directory dir -> dir.Fsprojs
| WorkspacePeekFound.Solution sln -> sln.Items |> Array.collect foldFsproj |> Array.map fst
| WorkspacePeekFound.Directory dir -> dir.Fsprojs |> Array.map (fun f -> (f.Path, f.CompileItems))
| WorkspacePeekFound.Solution sln -> sln.Items |> Array.collect foldFsproj |> Array.map (fun (p, _) -> (p, [||]))

match x with
| WorkspacePeekFound.Solution _ -> setAnyProjectContext true
Expand All @@ -661,17 +660,25 @@ module Project =

if lazyLoadWorkspace then
//TODO: Register a file open event handler and load the project on demand
let fsFileToProj = Dictionary<string, string>()
for (proj, compileItems) in projs do
for compileItem in compileItems do
fsFileToProj.[compileItem] <- proj

let openFileHandler (e: TextDocument) =

match tryFindInWorkspace e.uri.path with
| Some(ProjectLoadingState.Loaded _) -> ()
| Some(ProjectLoadingState.Loading _) -> ()
| _ -> LanguageService.workspaceLoad [ e.uri.path ] |> ignore
| _ -> LanguageService.workspaceLoad [ fsFileToProj[e.uri.path] ] |> ignore

// workspace.onDidOpenTextDocument $ (openFileHandler, (), context.subscriptions) |> ignore
workspace.onDidOpenTextDocument.Invoke(unbox openFileHandler)|> context.Subscribe
Promise.lift()
workspace.onDidOpenTextDocument.Invoke(unbox openFileHandler)
|> context.Subscribe

Promise.lift ()
else
projs |> List.ofArray |> LanguageService.workspaceLoad |> Promise.map ignore
projs |> Array.map(fun (p, _) -> p) |> List.ofArray |> LanguageService.workspaceLoad |> Promise.map ignore


let initWorkspace (context: ExtensionContext) =
Expand Down

0 comments on commit 0f51003

Please sign in to comment.