Skip to content

Commit

Permalink
reenable build commands, and make debug commands more reactive
Browse files Browse the repository at this point in the history
  • Loading branch information
baronfel committed Aug 19, 2023
1 parent 2c0e40a commit ba0db66
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 152 deletions.
84 changes: 33 additions & 51 deletions release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,53 +155,43 @@
},
{
"command": "MSBuild.buildCurrent",
"title": "MSBuild: Build current project",
"when": "fsharp.debugger.available"
"title": "MSBuild: Build current project"
},
{
"command": "MSBuild.buildSelected",
"title": "MSBuild: Build project",
"when": "fsharp.debugger.available"
"title": "MSBuild: Build project"
},
{
"command": "MSBuild.rebuildCurrent",
"title": "MSBuild: Rebuild current project",
"when": "fsharp.debugger.available"
"title": "MSBuild: Rebuild current project"
},
{
"command": "MSBuild.rebuildSelected",
"title": "MSBuild: Rebuild project",
"when": "fsharp.debugger.available"
"title": "MSBuild: Rebuild project"
},
{
"command": "MSBuild.cleanCurrent",
"title": "MSBuild: Clean current project",
"when": "fsharp.debugger.available"
"title": "MSBuild: Clean current project"
},
{
"command": "MSBuild.cleanSelected",
"title": "MSBuild: Clean project",
"when": "fsharp.debugger.available"
"title": "MSBuild: Clean project"
},
{
"command": "MSBuild.restoreSelected",
"title": "MSBuild: Restore project",
"when": "fsharp.debugger.available"
"title": "MSBuild: Restore project"
},
{
"command": "MSBuild.buildCurrentSolution",
"title": "MSBuild: Build current solution",
"when": "fsharp.debugger.available"
"title": "MSBuild: Build current solution"
},
{
"command": "MSBuild.rebuildCurrentSolution",
"title": "MSBuild: Rebuild current solution",
"when": "fsharp.debugger.available"
"title": "MSBuild: Rebuild current solution"
},
{
"command": "MSBuild.cleanCurrentSolution",
"title": "MSBuild: Clean current solution",
"when": "fsharp.debugger.available"
"title": "MSBuild: Clean current solution"
},
{
"command": "fsharp.explorer.moveUp",
Expand Down Expand Up @@ -294,43 +284,35 @@
},
{
"command": "fsharp.explorer.msbuild.build",
"title": "Build",
"enablement": "fsharp.debugger.available"
"title": "Build"
},
{
"command": "fsharp.explorer.msbuild.rebuild",
"title": "Rebuild",
"enablement": "fsharp.debugger.available"
"title": "Rebuild"
},
{
"command": "fsharp.explorer.msbuild.clean",
"title": "Clean",
"enablement": "fsharp.debugger.available"
"title": "Clean"
},
{
"command": "fsharp.explorer.msbuild.restore",
"title": "Restore",
"enablement": "fsharp.debugger.available"
"title": "Restore"
},
{
"command": "fsharp.explorer.solution.build",
"title": "Build",
"enablement": "fsharp.debugger.available"
"title": "Build"
},
{
"command": "fsharp.explorer.solution.rebuild",
"title": "Rebuild",
"enablement": "fsharp.debugger.available"
"title": "Rebuild"
},
{
"command": "fsharp.explorer.solution.clean",
"title": "Clean",
"enablement": "fsharp.debugger.available"
"title": "Clean"
},
{
"command": "fsharp.explorer.solution.restore",
"title": "Restore",
"enablement": "fsharp.debugger.available"
"title": "Restore"
},
{
"command": "fsharp.explorer.project.run",
Expand Down Expand Up @@ -988,12 +970,12 @@
{
"command": "MSBuild.buildCurrent",
"key": "ctrl\u002Balt\u002Bb",
"when": "fsharp.project.any \u0026\u0026 editorFocus \u0026\u0026 editorLangId == \u0027fsharp\u0027 \u0026\u0026 fsharp.debugger.available"
"when": "fsharp.project.any \u0026\u0026 editorFocus \u0026\u0026 editorLangId == \u0027fsharp\u0027"
},
{
"command": "MSBuild.buildCurrentSolution",
"key": "ctrl\u002Balt\u002Bshift\u002Bb",
"when": "fsharp.project.any \u0026\u0026 fsharp.debugger.available"
"when": "fsharp.project.any"
},
{
"command": "fsharp.openInfoPanel",
Expand Down Expand Up @@ -1185,59 +1167,59 @@
},
{
"command": "MSBuild.buildCurrent",
"when": "fsharp.project.any \u0026\u0026 editorLangId == \u0027fsharp\u0027 \u0026\u0026 fsharp.debugger.available"
"when": "fsharp.project.any \u0026\u0026 editorLangId == \u0027fsharp\u0027"
},
{
"command": "MSBuild.rebuildCurrent",
"when": "fsharp.project.any \u0026\u0026 editorLangId == \u0027fsharp\u0027 \u0026\u0026 fsharp.debugger.available"
"when": "fsharp.project.any \u0026\u0026 editorLangId == \u0027fsharp\u0027"
},
{
"command": "MSBuild.cleanCurrent",
"when": "fsharp.project.any \u0026\u0026 editorLangId == \u0027fsharp\u0027 \u0026\u0026 fsharp.debugger.available"
"when": "fsharp.project.any \u0026\u0026 editorLangId == \u0027fsharp\u0027"
},
{
"command": "fsharp.clearCache",
"when": "fsharp.project.any"
},
{
"command": "MSBuild.buildSelected",
"when": "fsharp.project.any \u0026\u0026 fsharp.debugger.available"
"when": "fsharp.project.any"
},
{
"command": "MSBuild.rebuildSelected",
"when": "fsharp.project.any \u0026\u0026 fsharp.debugger.available"
"when": "fsharp.project.any"
},
{
"command": "MSBuild.cleanSelected",
"when": "fsharp.project.any \u0026\u0026 fsharp.debugger.available"
"when": "fsharp.project.any"
},
{
"command": "MSBuild.restoreSelected",
"when": "fsharp.project.any \u0026\u0026 fsharp.debugger.available"
"when": "fsharp.project.any"
},
{
"command": "MSBuild.buildCurrentSolution",
"when": "fsharp.project.any \u0026\u0026 fsharp.debugger.available"
"when": "fsharp.project.any"
},
{
"command": "MSBuild.rebuildCurrentSolution",
"when": "fsharp.project.any \u0026\u0026 fsharp.debugger.available"
"when": "fsharp.project.any"
},
{
"command": "MSBuild.cleanCurrentSolution",
"when": "fsharp.project.any \u0026\u0026 fsharp.debugger.available"
"when": "fsharp.project.any"
},
{
"command": "fsharp.runDefaultProject",
"when": "fsharp.project.any \u0026\u0026 fsharp.debugger.available"
"when": "fsharp.project.any"
},
{
"command": "fsharp.debugDefaultProject",
"when": "fsharp.project.any \u0026\u0026 fsharp.debugger.available"
},
{
"command": "fsharp.chooseDefaultProject",
"when": "fsharp.project.any \u0026\u0026 fsharp.debugger.available"
"when": "fsharp.project.any"
},
{
"command": "fsharp.NewProject",
Expand Down Expand Up @@ -1286,7 +1268,7 @@
{
"command": "fsharp.runDefaultProject",
"group": "fsharp",
"when": "fsharp.project.any \u0026\u0026 config.FSharp.enableTouchBar \u0026\u0026 fsharp.debugger.available"
"when": "fsharp.project.any \u0026\u0026 config.FSharp.enableTouchBar"
},
{
"command": "fsharp.NewProject",
Expand Down
94 changes: 48 additions & 46 deletions src/Components/Debugger.fs
Original file line number Diff line number Diff line change
Expand Up @@ -336,34 +336,39 @@ module Debugger =
{ new DebugConfigurationProvider with
override x.provideDebugConfigurations(folder: option<WorkspaceFolder>, token: option<CancellationToken>) =
let generate () =
promise {
logger.Info("Evaluating launch settings configurations for %O", folder)
let projects = Project.getLoaded ()
let! msbuildTasks = tasks.fetchTasks (msbuildTasksFilter)

let tasks =
projects
|> List.collect (fun (p: Project) ->
[ let projectFile = node.path.basename p.Project

let buildTaskForProject =
msbuildTasks
|> Seq.tryFind (fun t ->
t.group = Some vscode.TaskGroup.Build && t.name = projectFile)
// emit configurations for any launchsettings for this project
match readSettingsForProject p with
| Some launchSettings ->
yield! configsForProject (p, launchSettings, buildTaskForProject)
| None -> ()
// emit a default configuration for this project if it is an executable
match defaultConfigForProject (p, buildTaskForProject) with
| Some p -> yield p
| None -> () ])

return ResizeArray tasks
}

generate () // this bix/unbox is a hack because JS types
match CSharpExtension.tryFindCSharpExtension () with
| false ->
CSharpExtension.warnAboutMissingCSharpExtension ()
promise { return ResizeArray() }
| true ->
promise {
logger.Info("Evaluating launch settings configurations for %O", folder)
let projects = Project.getLoaded ()
let! msbuildTasks = tasks.fetchTasks (msbuildTasksFilter)

let tasks =
projects
|> List.collect (fun (p: Project) ->
[ let projectFile = node.path.basename p.Project

let buildTaskForProject =
msbuildTasks
|> Seq.tryFind (fun t ->
t.group = Some vscode.TaskGroup.Build && t.name = projectFile)
// emit configurations for any launchsettings for this project
match readSettingsForProject p with
| Some launchSettings ->
yield! configsForProject (p, launchSettings, buildTaskForProject)
| None -> ()
// emit a default configuration for this project if it is an executable
match defaultConfigForProject (p, buildTaskForProject) with
| Some p -> yield p
| None -> () ])

return ResizeArray tasks
}

generate () // this box/unbox is a hack because JS types
|> box
|> unbox

Expand All @@ -387,26 +392,23 @@ module Debugger =

let activate (c: ExtensionContext) =

match CSharpExtension.tryFindCSharpExtension () with
| false -> CSharpExtension.warnAboutMissingCSharpExtension ()
| true ->
commands.registerCommand ("fsharp.runDefaultProject", (buildAndRunDefault) |> objfy2)
|> c.Subscribe
commands.registerCommand ("fsharp.runDefaultProject", (buildAndRunDefault) |> objfy2)
|> c.Subscribe

commands.registerCommand ("fsharp.debugDefaultProject", (buildAndDebugDefault) |> objfy2)
|> c.Subscribe
commands.registerCommand ("fsharp.debugDefaultProject", (buildAndDebugDefault) |> objfy2)
|> c.Subscribe

commands.registerCommand ("fsharp.chooseDefaultProject", (chooseDefaultProject) |> objfy2)
|> c.Subscribe
commands.registerCommand ("fsharp.chooseDefaultProject", (chooseDefaultProject) |> objfy2)
|> c.Subscribe

logger.Info "registering debug provider"
logger.Info "registering debug provider"

debug.registerDebugConfigurationProvider (
"coreclr",
launchSettingProvider,
DebugConfigurationProviderTriggerKind.Dynamic
)
|> c.Subscribe
debug.registerDebugConfigurationProvider (
"coreclr",
launchSettingProvider,
DebugConfigurationProviderTriggerKind.Dynamic
)
|> c.Subscribe

context <- Some c
startup <- c.workspaceState.get<Project> "defaultProject"
context <- Some c
startup <- c.workspaceState.get<Project> "defaultProject"
Loading

0 comments on commit ba0db66

Please sign in to comment.