diff --git a/Extension/cpp_snippets.json b/Extension/cpp_snippets.json deleted file mode 100644 index ccb7dc811f..0000000000 --- a/Extension/cpp_snippets.json +++ /dev/null @@ -1,140 +0,0 @@ -{ - "class": { - "prefix": "class", - "body": "\nclass ${1:${TM_FILENAME_BASE}}\n{\nprivate:\n\t${2:/* data */}\npublic:\n\t${1}(${3:/* args */});\n\t~${1}();\n};\n\n${1}::${1}(${3})\n{\n}\n\n${1}::~${1}()\n{\n}\n", - "description": "Code snippet for class", - "scope": "source.c++, source.objc++" - }, - "classi": { - "prefix": "classi", - "body": "\nclass ${1:${TM_FILENAME_BASE}}\n{\nprivate:\n\t${2:/* data */}\npublic:\n\t${1}(${3:/* args */}) { $0}\n\t~${1}() { }\n};", - "description": "Code snippet for class with inlined constructor/destructor", - "scope": "source.c++, source.objc++" - }, - "classt": { - "prefix": "classt", - "body": "\ntemplate\nclass ${1:${TM_FILENAME_BASE}}\n{\nprivate:\n\tT ${2:/* data */}\npublic:\n\t${1}(T ${3:/* args */});\n};\n", - "description": "Code snippet for class template", - "scope": "source.c++, source.objc++" - }, - "struct": { - "prefix": "struct", - "body": "\nstruct ${1:${TM_FILENAME_BASE}}\n{\n\t${0:/* data */}\n};\n", - "description": "Code snippet for struct", - "scope": "source.c, source.objc, source.c++, source.objc++" - }, - "union": { - "prefix": "union", - "body": "\nunion ${1:${TM_FILENAME_BASE}}\n{\n\t${0:/* data */}\n};\n", - "description": "Code snippet for union", - "scope": "source.c, source.objc, source.c++, source.objc++" - }, - "if": { - "prefix": "if", - "body": "\nif (${1:/* condition */}) {\n\t${0:/* code */}\n}\n", - "description": "Code snippet for if()", - "scope": "source.c, source.objc, source.c++, source.objc++" - }, - "ifel": { - "prefix": "ifel", - "body": "\nif (${1:/* condition */}) {\n\t${2:/* code */}\n}\nelse {\n\t${0:/* code */}\n}\n", - "description": "Code snippet for if() else", - "scope": "source.c, source.objc, source.c++, source.objc++" - }, - "ifelif": { - "prefix": "ifelif", - "body": "\nif (${1:/* condition */}) {\n\t${2:/* code */}\n}\nelse if(${3:/* condition */}) {\n\t${4:/* code */}\n}\nelse {\n\t${0:/* code */}\n}\n", - "description": "Code snippet for if() else if() else", - "scope": "source.c, source.objc, source.c++, source.objc++" - }, - "else": { - "prefix": "else", - "body": "\nelse\n{\n\t${0:/* code */}\n}\n", - "description": "Code snippet for else", - "scope": "source.c, source.objc, source.c++, source.objc++" - }, - "elif": { - "prefix": "elif", - "body": "\nelse if (${1:/* condition */})\n{\n\t${0:/* code */}\n}\n", - "description": "Code snippet for else if ()", - "scope": "source.c, source.objc, source.c++, source.objc++" - }, - "switch": { - "prefix": "switch", - "body": "\nswitch (${1:expression})\n{\n\tcase ${2:/* constant-expression */}:\n\t\t${3:/* code */}\n\t\tbreak;\n\n\tdefault:\n\t\tbreak;\n}", - "description": "Code snippet for switch", - "scope": "source.c, source.objc, source.c++, source.objc++" - }, - "main": { - "prefix": "main", - "body": "main(int argc, char const *argv[])\n{\n\t${1:/* code */}\n\treturn 0;\n}\n", - "description": "Code snippet for main()", - "scope": "source.c, source.objc, source.c++, source.objc++" - }, - "do": { - "prefix": "do_", - "body": "\ndo\n{\n\t${0:/* code */}\n} while (${1:/* condition */});\n", - "description": "Code snippet for do while loop", - "scope": "source.c, source.objc, source.c++, source.objc++" - }, - "for": { - "prefix": "for", - "body": "\nfor(${1:size_t} ${2:i} = 0; $2 < ${3:count}; ${4:$2++})\n{\n\t${0:/* code */}\n}\n", - "description": "Code snippet for for loop", - "scope": "source.c, source.objc, source.c++, source.objc++" - }, - "forr": { - "prefix": "forr", - "body": "\nfor(int ${1:i} = ${2:length} - 1; $1 >= 0; ${3:$1--})\n{\n\t${0:/* code */}\n}\n", - "description": "Code snippet for reverse for loop", - "scope": "source.c, source.objc, source.c++, source.objc++" - }, - "foreach": { - "prefix": "foreach", - "body": "\nfor(${1:object} = ${2:var} in ${3:collection})\n{\n\t${0:/* code */}\n}\n", - "description": "Code snippet for foreach loop", - "scope": "source.c, source.objc, source.c++, source.objc++" - }, - "forrange": { - "prefix": "forrange", - "body": "\nfor(auto&& ${1:i} : ${2:v})\n{\n\t$0\n}\n", - "description": "Code snippet for range-based forloop", - "scope": "source.c, source.objc, source.c++, source.objc++" - }, - "while": { - "prefix": "while", - "body": "\nwhile(${1:/* condition */}){\n\t${2:/* code */}\n}\n", - "description": "Code snippet for while loop", - "scope": "source.c, source.objc, source.c++, source.objc++" - }, - "ifd": { - "prefix": "ifnd", - "body": "\n#if defined($1)\n\n${0}\n\n#endif // $1\n", - "description": "Code snippet for if defined()", - "scope": "source.c, source.objc, source.c++, source.objc++" - }, - "ifnd": { - "prefix": "ifnd", - "body": "\n#if !defined($1)\n#define ${1:MACRO}\n\n${0}\n\n#endif // $1\n", - "description": "Code snippet for if !defined()", - "scope": "source.c, source.objc, source.c++, source.objc++" - }, - "mitl": { - "prefix": "mitl", - "body": "\n// The MIT License (MIT)\n\n// Copyright (c) ${1:YEAR} ${2:NAME}\n\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the \"Software\"),\n// to deal in the Software without restriction, including without limitation\n// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n// and/or sell copies of the Software, and to permit persons to whom the\n// Software is furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n// DEALINGS IN THE SOFTWARE.\n\n${0:/* code */}\n", - "description": "Code snippet for MIT License", - "scope": "" - }, - "namesp": { - "prefix": "namesp", - "body": "\nnamespace ${1:name}\n{\n\t$0\n} // $1\n", - "description": "Code snippet for namespace", - "scope": "source.c++, source.objc++" - }, - "try": { - "prefix": "try", - "body": "\ntry\n{\n\t${1:/* code */}\n}\ncatch(${2:const std::exception& e})\n{\n\t${0:std::cerr << e.what() << '\\n';}\n}\n", - "description": "Code snippet for try catch block", - "scope": "source.c++, source.objc++, source.c++11" - } -} diff --git a/Extension/package.json b/Extension/package.json index 31e351de8c..7021c397fc 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -505,11 +505,6 @@ "title": "%c_cpp.command.navigate.title%", "category": "C/C++" }, - { - "command": "C_Cpp.ToggleSnippets", - "title": "%c_cpp.command.toggleSnippets.title%", - "category": "C/C++" - }, { "command": "C_Cpp.ToggleErrorSquiggles", "title": "%c_cpp.command.toggleErrorSquiggles.title%", @@ -1372,17 +1367,7 @@ "[c]": { "editor.wordBasedSuggestions": false } - }, - "snippets": [ - { - "language": "cpp", - "path": "./cpp_snippets.json" - }, - { - "language": "c", - "path": "./cpp_snippets.json" - } - ] + } }, "scripts": { "compile": "npm run vscode:prepublish", diff --git a/Extension/package.nls.it.json b/Extension/package.nls.it.json index 5624f96154..e6735b8399 100644 --- a/Extension/package.nls.it.json +++ b/Extension/package.nls.it.json @@ -6,7 +6,6 @@ "c_cpp.command.peekDeclaration.title": "Visualizza dichiarazione", "c_cpp.command.switchHeaderSource.title": "Visualizza Header/Sorgente", "c_cpp.command.navigate.title": "Naviga...", - "c_cpp.command.toggleSnippets.title": "Attiva/Disattiva frammenti di codice", "c_cpp.command.toggleErrorSquiggles.title": "Attiva/Disattiva sottolineamento errori", "c_cpp.command.toggleIncludeFallback.title": "Attiva/Disattiva motore di fallback IntelliSense negli errori di inclusione", "c_cpp.command.toggleDimInactiveRegions.title": "Attiva/Disattiva colorazione regioni inattive", diff --git a/Extension/package.nls.json b/Extension/package.nls.json index 04f3be5b26..07190b6125 100644 --- a/Extension/package.nls.json +++ b/Extension/package.nls.json @@ -6,7 +6,6 @@ "c_cpp.command.peekDeclaration.title": "Peek declaration", "c_cpp.command.switchHeaderSource.title": "Switch Header/Source", "c_cpp.command.navigate.title": "Navigate...", - "c_cpp.command.toggleSnippets.title": "Toggle snippets", "c_cpp.command.toggleErrorSquiggles.title": "Toggle error squiggles", "c_cpp.command.toggleIncludeFallback.title": "Toggle IntelliSense engine fallback on include errors", "c_cpp.command.toggleDimInactiveRegions.title": "Toggle inactive region colorization", diff --git a/Extension/src/LanguageServer/extension.ts b/Extension/src/LanguageServer/extension.ts index d8d087c362..d6de0a0d76 100644 --- a/Extension/src/LanguageServer/extension.ts +++ b/Extension/src/LanguageServer/extension.ts @@ -395,7 +395,6 @@ function registerCommands(): void { disposables.push(vscode.commands.registerCommand('C_Cpp.ConfigurationEdit', onEditConfiguration)); disposables.push(vscode.commands.registerCommand('C_Cpp.AddToIncludePath', onAddToIncludePath)); disposables.push(vscode.commands.registerCommand('C_Cpp.ToggleErrorSquiggles', onToggleSquiggles)); - disposables.push(vscode.commands.registerCommand('C_Cpp.ToggleSnippets', onToggleSnippets)); disposables.push(vscode.commands.registerCommand('C_Cpp.ToggleIncludeFallback', onToggleIncludeFallback)); disposables.push(vscode.commands.registerCommand('C_Cpp.ToggleDimInactiveRegions', onToggleDimInactiveRegions)); disposables.push(vscode.commands.registerCommand('C_Cpp.ShowReleaseNotes', onShowReleaseNotes)); @@ -542,47 +541,6 @@ function onToggleSquiggles(): void { settings.toggleSetting("errorSquiggles", "Enabled", "Disabled"); } -function onToggleSnippets(): void { - onActivationEvent(); - - // This will apply to all clients as it's a global toggle. It will require a reload. - const snippetsCatName: string = "Snippets"; - let newPackageJson: any = util.getRawPackageJson(); - - if (newPackageJson.categories.findIndex(cat => cat === snippetsCatName) === -1) { - // Add the Snippet category and snippets node. - - newPackageJson.categories.push(snippetsCatName); - newPackageJson.contributes.snippets = [{"language": "cpp", "path": "./cpp_snippets.json"}, {"language": "c", "path": "./cpp_snippets.json"}]; - - fs.writeFile(util.getPackageJsonPath(), util.stringifyPackageJson(newPackageJson), () => { - showReloadPrompt("Reload Window to finish enabling C++ snippets"); - }); - - } else { - // Remove the category and snippets node. - let ndxCat: number = newPackageJson.categories.indexOf(snippetsCatName); - if (ndxCat !== -1) { - newPackageJson.categories.splice(ndxCat, 1); - } - - delete newPackageJson.contributes.snippets; - - fs.writeFile(util.getPackageJsonPath(), util.stringifyPackageJson(newPackageJson), () => { - showReloadPrompt("Reload Window to finish disabling C++ snippets"); - }); - } -} - -function showReloadPrompt(msg: string): void { - let reload: string = "Reload"; - vscode.window.showInformationMessage(msg, reload).then(value => { - if (value === reload) { - vscode.commands.executeCommand("workbench.action.reloadWindow"); - } - }); - } - function onToggleIncludeFallback(): void { onActivationEvent(); // This only applies to the active client. diff --git a/Extension/src/commands.ts b/Extension/src/commands.ts index de78bfe03b..de94515aa9 100644 --- a/Extension/src/commands.ts +++ b/Extension/src/commands.ts @@ -24,7 +24,6 @@ class TemporaryCommandRegistrar { "C_Cpp.ToggleErrorSquiggles", "C_Cpp.ToggleIncludeFallback", "C_Cpp.ToggleDimInactiveRegions", - "C_Cpp.ToggleSnippets", "C_Cpp.ShowReleaseNotes", "C_Cpp.ResetDatabase", "C_Cpp.PauseParsing", diff --git a/Extension/src/main.ts b/Extension/src/main.ts index 1b599130bd..039b595104 100644 --- a/Extension/src/main.ts +++ b/Extension/src/main.ts @@ -339,7 +339,6 @@ function rewriteManifest(): Promise { "onCommand:C_Cpp.ToggleErrorSquiggles", "onCommand:C_Cpp.ToggleIncludeFallback", "onCommand:C_Cpp.ToggleDimInactiveRegions", - "onCommand:C_Cpp.ToggleSnippets", "onCommand:C_Cpp.ShowReleaseNotes", "onCommand:C_Cpp.ResetDatabase", "onCommand:C_Cpp.PauseParsing",