├── .gitignore ├── bird.jpg ├── issues.md ├── .vscodeignore ├── .vscode ├── extensions.json ├── tasks.json ├── settings.json └── launch.json ├── README.md ├── src ├── test │ ├── suite │ │ ├── extension.test.ts │ │ └── index.ts │ └── runTest.ts ├── getFileName.ts ├── tmp │ ├── extension.js.map │ └── extension.ts └── extension.ts ├── .eslintrc.json ├── tsconfig.json └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | dist 3 | node_modules 4 | .vscode-test/ 5 | *.vsix 6 | -------------------------------------------------------------------------------- /bird.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bbird-21/42-Cpp-Copilot/HEAD/bird.jpg -------------------------------------------------------------------------------- /issues.md: -------------------------------------------------------------------------------- 1 | 1) Register another command that run manually CppCopilot on the focus window and search if the correspondig exist, if not, create it, and initialize it 2 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | src/** 4 | .gitignore 5 | .yarnrc 6 | vsc-extension-quickstart.md 7 | **/tsconfig.json 8 | **/.eslintrc.json 9 | **/*.map 10 | **/*.ts 11 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "dbaeumer.vscode-eslint" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 42 CPP Copilot 2 | 3 | This extension improve your experience in the CPP Pool. It helps you to implement automatically canonical class in C++. 4 | 5 | ## Install 6 | Launch Quick Open with Ctrl+P or ⌘+P and enter 7 | `ext install bbird21.42cpp-copilot` 8 | 9 | ## Usage 10 | Launch Quick Open with Ctrl+P or ⌘+P and enter 11 | `cppCopilot` 12 | 13 | **Enjoy!** 14 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // See https://go.microsoft.com/fwlink/?LinkId=733558 2 | // for the documentation about the tasks.json format 3 | { 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "npm", 8 | "script": "watch", 9 | "problemMatcher": "$tsc-watch", 10 | "isBackground": true, 11 | "presentation": { 12 | "reveal": "never" 13 | }, 14 | "group": { 15 | "kind": "build", 16 | "isDefault": true 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "files.exclude": { 4 | "out": false // set this to true to hide the "out" folder with the compiled JS files 5 | }, 6 | "search.exclude": { 7 | "out": true // set this to false to include "out" folder in search results 8 | }, 9 | // Turn off tsc task auto detection since we have the necessary tasks as npm scripts 10 | "typescript.tsc.autoDetect": "off" 11 | } -------------------------------------------------------------------------------- /src/test/suite/extension.test.ts: -------------------------------------------------------------------------------- 1 | import * as assert from 'assert'; 2 | 3 | // You can import and use all API from the 'vscode' module 4 | // as well as import your extension to test it 5 | import * as vscode from 'vscode'; 6 | // import * as myExtension from '../../extension'; 7 | 8 | suite('Extension Test Suite', () => { 9 | vscode.window.showInformationMessage('Start all tests.'); 10 | 11 | test('Sample test', () => { 12 | assert.strictEqual(-1, [1, 2, 3].indexOf(5)); 13 | assert.strictEqual(-1, [1, 2, 3].indexOf(0)); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "parserOptions": { 5 | "ecmaVersion": 6, 6 | "sourceType": "module" 7 | }, 8 | "plugins": [ 9 | "@typescript-eslint" 10 | ], 11 | "rules": { 12 | "@typescript-eslint/naming-convention": "warn", 13 | "@typescript-eslint/semi": "warn", 14 | "curly": "warn", 15 | "eqeqeq": "warn", 16 | "no-throw-literal": "warn", 17 | "semi": "off" 18 | }, 19 | "ignorePatterns": [ 20 | "out", 21 | "dist", 22 | "**/*.d.ts" 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "ES5", 5 | "outDir": "out", 6 | "lib": [ 7 | "ES6" 8 | ], 9 | "sourceMap": true, 10 | "rootDir": "src", 11 | "strict": true /* enable all strict type-checking options */ 12 | /* Additional Checks */ 13 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 14 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 15 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 16 | }, 17 | "files": [ 18 | "src/extension.ts", 19 | "src/getFileName.ts" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /src/getFileName.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode' 2 | 3 | export function getFileName() { 4 | // Get the currently active text editor 5 | const editor = vscode.window.activeTextEditor; 6 | 7 | if (editor) { 8 | // Get the URI (Uniform Resource Identifier) of the currently opened file 9 | const fileUri = editor.document.uri; 10 | 11 | // Get the filename from the URI 12 | const fileName = vscode.workspace.asRelativePath(fileUri); 13 | 14 | return (fileName); 15 | } 16 | else 17 | return ('No active text editor'); 18 | } 19 | 20 | export function capitalizeFirstLetter(string : string) : string { 21 | 22 | return ( string.charAt(0).toUpperCase() + string.slice(1).toLowerCase() ); 23 | } -------------------------------------------------------------------------------- /src/test/runTest.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | 3 | import { runTests } from '@vscode/test-electron'; 4 | 5 | async function main() { 6 | try { 7 | // The folder containing the Extension Manifest package.json 8 | // Passed to `--extensionDevelopmentPath` 9 | const extensionDevelopmentPath = path.resolve(__dirname, '../../'); 10 | 11 | // The path to test runner 12 | // Passed to --extensionTestsPath 13 | const extensionTestsPath = path.resolve(__dirname, './suite/index'); 14 | 15 | // Download VS Code, unzip it and run the integration test 16 | await runTests({ extensionDevelopmentPath, extensionTestsPath }); 17 | } catch (err) { 18 | console.error('Failed to run tests', err); 19 | process.exit(1); 20 | } 21 | } 22 | 23 | main(); 24 | -------------------------------------------------------------------------------- /src/test/suite/index.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | import * as Mocha from 'mocha'; 3 | import * as glob from 'glob'; 4 | 5 | export function run(): Promise { 6 | // Create the mocha test 7 | const mocha = new Mocha({ 8 | ui: 'tdd', 9 | color: true 10 | }); 11 | 12 | const testsRoot = path.resolve(__dirname, '..'); 13 | 14 | return new Promise((c, e) => { 15 | const testFiles = new glob.Glob("**/**.test.js", { cwd: testsRoot }); 16 | const testFileStream = testFiles.stream(); 17 | 18 | testFileStream.on("data", (file) => { 19 | mocha.addFile(path.resolve(testsRoot, file)); 20 | }); 21 | testFileStream.on("error", (err) => { 22 | e(err); 23 | }); 24 | testFileStream.on("end", () => { 25 | try { 26 | // Run the mocha test 27 | mocha.run(failures => { 28 | if (failures > 0) { 29 | e(new Error(`${failures} tests failed.`)); 30 | } else { 31 | c(); 32 | } 33 | }); 34 | } catch (err) { 35 | console.error(err); 36 | e(err); 37 | } 38 | }); 39 | }); 40 | } 41 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Run Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "args": [ 13 | "--extensionDevelopmentPath=${workspaceFolder}" 14 | ], 15 | "outFiles": [ 16 | "${workspaceFolder}/out/**/*.js" 17 | ], 18 | "preLaunchTask": "${defaultBuildTask}" 19 | }, 20 | { 21 | "name": "Extension Tests", 22 | "type": "extensionHost", 23 | "request": "launch", 24 | "args": [ 25 | "--extensionDevelopmentPath=${workspaceFolder}", 26 | "--extensionTestsPath=${workspaceFolder}/out/test/suite/index" 27 | ], 28 | "outFiles": [ 29 | "${workspaceFolder}/out/test/**/*.js" 30 | ], 31 | "preLaunchTask": "${defaultBuildTask}" 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "42cpp-copilot", 3 | "publisher": "bbird21", 4 | "displayName": "42 CPP Copilot", 5 | "description": "Automate the creation of your canonical classes with 42 Cpp Copilot", 6 | "icon": "bird.jpg", 7 | "version": "0.0.3", 8 | "engines": { 9 | "vscode": "^1.82.0" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/Tako-21/42-Cpp-Copilot" 14 | }, 15 | "homepage": "https://github.com/Tako-21/42-Cpp-Copilot", 16 | "categories": [ 17 | "Other" 18 | ], 19 | "activationEvents": [], 20 | "main": "./out/extension.js", 21 | "contributes": { 22 | "commands": [ 23 | { 24 | "command": "cppCopilot", 25 | "title": "cppCopilot" 26 | } 27 | ] 28 | }, 29 | "scripts": { 30 | "vscode:prepublish": "npm run compile", 31 | "compile": "tsc -p ./", 32 | "watch": "tsc -watch -p ./", 33 | "pretest": "npm run compile && npm run lint", 34 | "lint": "eslint src --ext ts", 35 | "test": "node ./out/test/runTest.js" 36 | }, 37 | "devDependencies": { 38 | "@types/vscode": "^1.82.0", 39 | "@types/mocha": "^10.0.2", 40 | "@types/node": "18.x", 41 | "@typescript-eslint/eslint-plugin": "^6.7.3", 42 | "@typescript-eslint/parser": "^6.7.3", 43 | "eslint": "^8.50.0", 44 | "glob": "^10.3.3", 45 | "mocha": "^10.2.0", 46 | "typescript": "^5.2.2", 47 | "@vscode/test-electron": "^2.3.4" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/tmp/extension.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"extension_cpy.js","sourceRoot":"","sources":["extension_cpy.ts"],"names":[],"mappings":";;;AACA,6DAA6D;AAC7D,8EAA8E;AAC9E,iCAAiC;AACjC,+CAAmE;AAElE,4EAA4E;AAE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AE,CAAC,CAAC,EAC5C,aAAa,CAAC,CAAC;gBACf,WAAW,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAC5C,OAAO,CAAC,CAAC;gBACT,WAAW,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAC5C,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;gBACvB,WAAW,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAC5C,KAAK,CAAC,CAAC;YACR,CAAC,CAAC,CAAC;YAEH,yBAAyB;YACzB,MAAM,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;QAEH,oGAAoG;QACpG,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,sDAAsD;IACtD,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACzC,CAAC;AArED,4BAqEC;AAED,wDAAwD;AAGzD,2DAA2D;AAC3D,SAAgB,UAAU,KAAI,CAAC;AAA/B,gCAA+B"} -------------------------------------------------------------------------------- /src/extension.ts: -------------------------------------------------------------------------------- 1 | import vscode = require('vscode') 2 | 3 | import { 4 | ExtensionContext, TextEdit, TextEditorEdit, TextDocument, Position, Range 5 | } from 'vscode' 6 | 7 | 8 | import { 9 | capitalizeFirstLetter, 10 | getFileName, 11 | } from './getFileName' 12 | 13 | import { fileURLToPath } from 'url'; 14 | 15 | const createNewFile = (filename: string, cpp_content: string, uri: vscode.Uri) => { 16 | const ws = vscode.workspace.workspaceFolders; // List of all workspaces open in editor. 17 | if ( !ws || ws.length === 0 ) 18 | return ; 19 | 20 | const path = uri.fsPath.slice(0, uri.fsPath.length - filename.concat(".hpp").length); 21 | const wsedit = new vscode.WorkspaceEdit(); // Workspace API management. 22 | const newFileUri = vscode.Uri.joinPath(vscode.Uri.parse(path), filename.concat(".cpp")); // Create the uri of the new file. 23 | const fs_content = new TextEncoder().encode(cpp_content); // Content of the file. 24 | wsedit.createFile(newFileUri); // Creation of the file. 25 | vscode.workspace.fs.writeFile(newFileUri, fs_content); // Writting to the file. 26 | } 27 | 28 | const cppCopilot = (context: vscode.ExtensionContext) => { 29 | 30 | 31 | const watcher = vscode.workspace.createFileSystemWatcher('**/*.hpp'); 32 | watcher.onDidCreate(async (uri) => { 33 | 34 | // Open the newly created document 35 | const doc = await vscode.workspace.openTextDocument(uri); 36 | // Show the document in the editor 37 | const editor = await vscode.window.showTextDocument(doc); 38 | 39 | if ( doc == undefined ) { 40 | return ; 41 | } 42 | if ( doc.getText().trim() !== '') { 43 | console.log("file is not empty"); 44 | return ; 45 | } 46 | // Here verify if the filename begin with a capital letter. 47 | const split_filename = uri.fsPath.split('/'); 48 | const filename = split_filename[split_filename.length - 1].split('.')[0]; 49 | const cppContent = 50 | `#include "${filename}.hpp"\n 51 | ${filename}::${filename}() {\n\n}\n 52 | ${filename}::~${filename}() {\n\n}\n 53 | ${filename}::${filename} ( const ${filename}& cpy ) { 54 | *this = cpy;\n}\n 55 | ${filename}& ${filename}::operator= ( const ${filename}& cpy ) { 56 | return *this;\n}\n` 57 | 58 | createNewFile(filename, cppContent, uri); 59 | // Define the content to insert at the beginning of the document 60 | const hppContent = 61 | `#ifndef __${filename.toUpperCase()}__ 62 | #define __${filename.toUpperCase()}__\n\n 63 | class ${(filename)} {\n 64 | public:\n 65 | ${filename}( void ); 66 | ~${filename}(); 67 | ${filename} ( const ${filename}& cpy ); 68 | ${filename}& operator= ( const ${filename}& cpy );\n 69 | private:\n};\n 70 | #endif /* __${filename.toLocaleUpperCase()}__ */`; 71 | 72 | // Insert the content at the beginning of the document 73 | editor.edit((editBuilder) => { 74 | editBuilder.insert(new vscode.Position(0, 0), hppContent); 75 | }); 76 | 77 | // Save the document 78 | await editor.document.save(); 79 | // Register the watcher subscription 80 | // context.subscriptions.push(watcher); 81 | }); 82 | }; 83 | 84 | export function activate(context: vscode.ExtensionContext) { 85 | let disposable = vscode.commands.registerCommand('cppCopilot', cppCopilot); 86 | context.subscriptions.push(disposable); 87 | } 88 | 89 | // This method is called when your extension is deactivated 90 | export function deactivate() {} 91 | -------------------------------------------------------------------------------- /src/tmp/extension.ts: -------------------------------------------------------------------------------- 1 | 2 | // The module 'vscode' contains the VS Code extensibility API 3 | // Import the module and reference it with the alias vscode in your code below 4 | import * as vscode from 'vscode'; 5 | import { capitalizeFirstLetter, getFileName } from './getFileName'; 6 | 7 | // vscode.window.showInformationMessage('Hello World from File Extension!'); 8 | 9 | export function activate(context: vscode.ExtensionContext) { 10 | console.log('Félicitations, votre extension "file-extension" est maintenant active !'); 11 | 12 | // Crée une commande "file-extension.helloWorld" 13 | let disposable2 = vscode.commands.registerCommand('file-extension', () => { 14 | 15 | 16 | let filename = getFileName().toUpperCase().split('.')[0]; 17 | 18 | vscode.window.showInformationMessage(filename); 19 | // Crée un écouteur de système de fichiers qui surveille les fichiers .ts 20 | const watcher = vscode.workspace.createFileSystemWatcher('**/*.hpp'); 21 | 22 | // Lorsqu'un fichier .cpp est créé 23 | watcher.onDidCreate(async (uri) => { 24 | // Ouvre le document nouvellement créé 25 | const document = await vscode.workspace.openTextDocument(uri); 26 | 27 | // Affiche le document dans l'éditeur 28 | const editor = await vscode.window.showTextDocument(document); 29 | 30 | // Insère "Hello World" au début du fichier 31 | editor.edit((editBuilder) => { 32 | editBuilder.insert(new vscode.Position(0, 0), 33 | "#ifndef __"); 34 | editBuilder.insert(new vscode.Position(0, 0), 35 | filename.concat("__")); 36 | editBuilder.insert(new vscode.Position(0, 0), 37 | "\n#define __"); 38 | editBuilder.insert(new vscode.Position(0, 0), 39 | filename.concat("__")); 40 | editBuilder.insert(new vscode.Position(0, 0), 41 | "\n\nclass "); 42 | editBuilder.insert(new vscode.Position(0, 0), 43 | capitalizeFirstLetter(filename)); 44 | editBuilder.insert(new vscode.Position(0, 0), 45 | " {\n"); 46 | editBuilder.insert(new vscode.Position(0, 0), 47 | "\n\npublic :\n\n\t"); 48 | editBuilder.insert(new vscode.Position(0, 0), 49 | capitalizeFirstLetter(filename)); 50 | editBuilder.insert(new vscode.Position(0, 0), 51 | "( void );\n\t~"); 52 | editBuilder.insert(new vscode.Position(0, 0), 53 | filename); 54 | editBuilder.insert(new vscode.Position(0, 0), 55 | "( void )\n\n"); 56 | editBuilder.insert(new vscode.Position(0, 0), 57 | "private : \n\n};"); 58 | editBuilder.insert(new vscode.Position(0, 0), 59 | "\n\n#endif "); 60 | editBuilder.insert(new vscode.Position(0, 0), 61 | "/* __"); 62 | editBuilder.insert(new vscode.Position(0, 0), 63 | filename.concat("__")); 64 | editBuilder.insert(new vscode.Position(0, 0), 65 | " */"); 66 | }); 67 | 68 | // Enregistre le document 69 | await editor.document.save(); 70 | }); 71 | 72 | // Ajoute le watcher aux abonnements de l'extension pour qu'il soit disposé lors de la désactivation 73 | context.subscriptions.push(watcher); 74 | }); 75 | 76 | // Ajoute la commande aux abonnements de l'extensiona 77 | context.subscriptions.push(disposable2); 78 | } 79 | // vscode.window.showInformationMessage('Hello Kiwi !'); 80 | 81 | 82 | // This method is called when your extension is deactivated 83 | export function deactivate() {} 84 | --------------------------------------------------------------------------------