corresponding file support for C/C++
This commit is contained in:
18
package.json
18
package.json
@@ -39,6 +39,11 @@
|
||||
"mac": "Cmd+; Cmd+u",
|
||||
"key": "Ctrl+; Ctrl+u"
|
||||
},
|
||||
{
|
||||
"command": "kiss-vscode.showCorrespondingFile",
|
||||
"mac": "Cmd+; Cmd+f",
|
||||
"key": "Ctrl+; Ctrl+f"
|
||||
},
|
||||
{
|
||||
"command": "kiss-vscode.evalAndPrint",
|
||||
"mac": "Cmd+; Cmd+e",
|
||||
@@ -49,11 +54,6 @@
|
||||
"mac": "Cmd+; Cmd+n",
|
||||
"key": "Ctrl+; Ctrl+n"
|
||||
},
|
||||
{
|
||||
"command": "kiss-vscode.showCorrespondingFile",
|
||||
"mac": "Cmd+; Cmd+f",
|
||||
"key": "Ctrl+; Ctrl+f"
|
||||
},
|
||||
{
|
||||
"command": "kiss-vscode.insertUTestCase",
|
||||
"mac": "Cmd+; Cmd+c",
|
||||
@@ -79,6 +79,10 @@
|
||||
"title": "kiss-vscode: Check test.sh, then update and reinstall the kiss-vscode extension you are editing",
|
||||
"command": "kiss-vscode.testAndUpdateExtension"
|
||||
},
|
||||
{
|
||||
"title": "kiss-vscode: Open the corresponding header/source file to this one",
|
||||
"command": "kiss-vscode.showCorrespondingFile"
|
||||
},
|
||||
{
|
||||
"title": "kiss-vscode: Evaluate and print a kiss expression's value",
|
||||
"command": "kiss-vscode.evalAndPrint"
|
||||
@@ -87,10 +91,6 @@
|
||||
"title": "kiss-vscode: Create a new kiss class",
|
||||
"command": "kiss-vscode.newKissClass"
|
||||
},
|
||||
{
|
||||
"title": "kiss-vscode: Open the corresponding .kiss/.hx file to this one",
|
||||
"command": "kiss-vscode.showCorrespondingFile"
|
||||
},
|
||||
{
|
||||
"title": "kiss-vscode: Generate a UTest test case in this .hx/.kiss file",
|
||||
"command": "kiss-vscode.insertUTestCase"
|
||||
|
@@ -7,5 +7,6 @@
|
||||
(awaitLetCatchThroughErrorMessage)
|
||||
(allowRuntimeConversion)
|
||||
(load "commands/ExtensionTools.kiss")
|
||||
(load "commands/CodeTools.kiss")
|
||||
(load "commands/KissTools.kiss")
|
||||
(load "commands/Lines.kiss"))
|
24
src/commands/CodeTools.kiss
Normal file
24
src/commands/CodeTools.kiss
Normal file
@@ -0,0 +1,24 @@
|
||||
(function correspondingFileUri [:String sourceOrHeaderFile]
|
||||
(let [base
|
||||
(sourceOrHeaderFile.withoutExtension)
|
||||
ext
|
||||
(sourceOrHeaderFile.extension)
|
||||
correspondingExts
|
||||
(case ext
|
||||
// Kiss
|
||||
("hx" ["kiss" "hollywoo"])
|
||||
("kiss" ["hx"])
|
||||
("hollywoo" ["hx"])
|
||||
// C/C++
|
||||
("h" ["c" "cpp"])
|
||||
("hpp" ["cpp"])
|
||||
("cpp" ["h" "hpp"])
|
||||
(otherwise (throw "No corresponding extensions for .$ext")))]
|
||||
(doFor ext correspondingExts
|
||||
(let [uri (Uri.file "${base}.${ext}")]
|
||||
(when (sys.FileSystem.exists uri.fsPath)
|
||||
(return uri))))
|
||||
(throw "No corresponding file for $sourceOrHeaderFile")))
|
||||
|
||||
(defCommand context showCorrespondingFile "Open the corresponding header/source file to this one" "C-; C-f" []
|
||||
(showTextDocument (correspondingFileUri .fileName .document activeTextEditor)))
|
@@ -40,21 +40,6 @@ class ${className} {}
|
||||
(awaitLet [_ (showTextDocument (Uri.file kissFile) (object viewColumn ViewColumn.Beside))]
|
||||
(executeCommand "workbench.action.keepEditor")))))))
|
||||
|
||||
(function correspondingFile [:String kissOrHxFile]
|
||||
(let [base
|
||||
(kissOrHxFile.withoutExtension)
|
||||
ext
|
||||
(kissOrHxFile.extension)
|
||||
correspondingExt
|
||||
(case ext
|
||||
("hx" "kiss")
|
||||
("kiss" "hx")
|
||||
(otherwise (throw "No corresponding file for ${kissOrHxFile}")))]
|
||||
"${base}.${correspondingExt}"))
|
||||
|
||||
(defCommand context showCorrespondingFile "Open the corresponding .kiss/.hx file to this one" "C-; C-f" []
|
||||
(showTextDocument (Uri.file (correspondingFile .fileName .document activeTextEditor))))
|
||||
|
||||
(defCommand context insertUTestCase "Generate a UTest test case in this .hx/.kiss file" "C-; C-c" []
|
||||
(awaitLet [testName (inputBox)
|
||||
&sync testName
|
||||
@@ -64,7 +49,7 @@ class ${className} {}
|
||||
_test${testName}();
|
||||
}
|
||||
")
|
||||
_ (showTextDocument (Uri.file (correspondingFile .fileName .document activeTextEditor)))
|
||||
_ (showTextDocument (correspondingFileUri .fileName .document activeTextEditor))
|
||||
&sync pos (activeTextEditor.document.positionAt .length (activeTextEditor.document.getText))
|
||||
_ (insertAt pos
|
||||
"
|
||||
|
Reference in New Issue
Block a user