make Kiss-VSCode compilation errors navigable

This commit is contained in:
2021-11-29 16:20:56 -07:00
parent e0603097e3
commit 260cc3d52a
3 changed files with 30 additions and 8 deletions

View File

@@ -22,7 +22,7 @@
// If there's a build error when testing, throw a test failure // If there's a build error when testing, throw a test failure
(throw errorMessage) (throw errorMessage)
// If there's a build error at runtime, tell the user // If there's a build error at runtime, tell the user
(Vscode.window.showErrorMessage errorMessage)) (showCompileError errorMessage))
}] }]
// Choose where to find the custom config // Choose where to find the custom config

View File

@@ -23,7 +23,7 @@
(awaitLet [chosenItem (_quickPick (for string strings (quickPickItem string)))] (awaitLet [chosenItem (_quickPick (for string strings (quickPickItem string)))]
(when chosenItem chosenItem.label))) (when chosenItem chosenItem.label)))
(function quickPickMap [:Map<String,Dynamic> stringMap] (function :js.lib.Promise.Thenable<Dynamic> quickPickMap [:Map<String,Dynamic> stringMap]
(awaitLet [chosenItem (_quickPick (for =>key value stringMap (quickPickItem key (Std.string value))))] (awaitLet [chosenItem (_quickPick (for =>key value stringMap (quickPickItem key (Std.string value))))]
(when chosenItem (dictGet stringMap chosenItem.label)))) (when chosenItem (dictGet stringMap chosenItem.label))))
@@ -41,6 +41,7 @@
// Other // Other
(defAlias &call showTextDocument Vscode.window.showTextDocument) (defAlias &call showTextDocument Vscode.window.showTextDocument)
(defAlias &call openTextDocument Vscode.workspace.openTextDocument)
// Macros for implementing commands in Kiss // Macros for implementing commands in Kiss
@@ -69,11 +70,31 @@
options ,options options ,options
result (ChildProcess.spawnSync command args options)] result (ChildProcess.spawnSync command args options)]
(if result.error (if result.error
// TODO i can't remember if this needs to be a throw for some reason, {(,onError "Error $result.error from $command ${args}: $result.stdout $result.stderr")(return)}
// but it seems like it's supposed to be (,onError ...)(return) like below
(throw "Error $result.error from $command ${args}: $result.stdout $result.stderr")
(case result.status (case result.status
(0 null) (0 null)
(errCode (errCode
(,onError "Error code $errCode from $command ${args}: $result.stdout $result.stderr") (,onError "Error code $errCode from $command ${args}: $result.stdout $result.stderr")
(return)))))) (return))
(null (,onError "result status is null from $command ${args}: $result.stdout $result.stderr"))))))
(function :Void showCompileError [errorMessage]
(ifLet [compileErrors (R.distinctMatches
(R.group
(R.namedGroup "file"
(R.repeat (R.oneOf R.anyLetter R.anyDigit (R.escape "/")) 1) // filename
(R.escape ".kiss:")
(R.repeat R.anyDigit 1) // line
(R.escape ":")
(R.optional
(R.group
(R.repeat R.anyDigit 1) // column
(R.escape ":"))))
(R.repeat R.anyChar 1))
errorMessage)]
{
(Vscode.window.showErrorMessage errorMessage)
(awaitLet [chosen (quickPickMap (for match compileErrors =>match.match match))]
(executeCommand "workbench.action.quickOpen" (substr (chosen.namedGroup "file") 0 -1)))
}
(Vscode.window.showErrorMessage errorMessage)))

View File

@@ -4,8 +4,9 @@
(function :ChildProcessSpawnSyncOptions options [] (object cwd (let [path (kvLibpath)] (path.substr 0 (- path.length 1))))) (function :ChildProcessSpawnSyncOptions options [] (object cwd (let [path (kvLibpath)] (path.substr 0 (- path.length 1)))))
(function handleUpdateFailure [error] (function handleUpdateFailure [error]
(errorMessage "Error updating Kiss-VSCode: $error") (showCompileError "Error updating Kiss-VSCode: $error")
(throw error)) (object)
**(throw error))
(function :Void updateKissVscode [&opt _] (function :Void updateKissVscode [&opt _]
(trySpawnSync "haxe" ["build.hxml"] (options) handleUpdateFailure) (trySpawnSync "haxe" ["build.hxml"] (options) handleUpdateFailure)