├── .eslintrc.json ├── .gitignore ├── .vscode ├── extensions.json ├── launch.json └── settings.json ├── .vscodeignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── extension.js ├── flutter-print-1.6.1.vsix ├── images ├── .directory ├── cover-logo.png ├── debug-print.gif ├── delete-log.gif ├── log-inspect.gif ├── log-print.gif ├── logo.png ├── print-object.gif ├── print-variable.gif ├── print.gif └── use-debug-print-setting.png ├── jsconfig.json ├── message.js ├── package.json ├── test ├── extension.test.js └── index.js └── vsc-extension-quickstart.md /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": false, 4 | "commonjs": true, 5 | "es6": true, 6 | "node": true 7 | }, 8 | "parserOptions": { 9 | "ecmaFeatures": { 10 | "jsx": true 11 | }, 12 | "sourceType": "module" 13 | }, 14 | "rules": { 15 | "no-const-assign": "warn", 16 | "no-this-before-super": "warn", 17 | "no-undef": "warn", 18 | "no-unreachable": "warn", 19 | "no-unused-vars": "warn", 20 | "constructor-super": "warn", 21 | "valid-typeof": "warn" 22 | } 23 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "dbaeumer.vscode-eslint" 6 | ] 7 | } -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | { 3 | "version": "0.1.0", 4 | "configurations": [ 5 | { 6 | "name": "Launch Extension", 7 | "type": "extensionHost", 8 | "request": "launch", 9 | "runtimeExecutable": "${execPath}", 10 | "args": ["--extensionDevelopmentPath=${workspaceRoot}" ], 11 | "stopOnEntry": false 12 | }, 13 | { 14 | "name": "Launch Tests", 15 | "type": "extensionHost", 16 | "request": "launch", 17 | "runtimeExecutable": "${execPath}", 18 | "args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/test" ], 19 | "stopOnEntry": false 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "typescript.tsdk": "./node_modules/typescript/lib" // we want to use the TS server from our node_modules folder to control its version 4 | } -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | test/** 4 | .gitignore 5 | jsconfig.json 6 | vsc-extension-quickstart.md 7 | .eslintrc.json 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the Flutter Print extension will be documented in this file. 4 | 5 | ## [1.6.1] 6 | 7 | - Updated the badges in README.md. 8 | 9 | ## [1.6.0] 10 | 11 | - Simplified extension shortcuts. 12 | 13 | ## [1.5.1] 14 | 15 | - Internal extension fix. 16 | 17 | ## [1.5.0] 18 | 19 | - Added notification message for extension updates. 20 | 21 | ## [1.4.1] 22 | 23 | - Added fix for when no text is selected. 24 | 25 | ## [1.4.0] 26 | 27 | - Added `useDebugPrint` setting to define when debugPrint or print instruction will be used. 28 | 29 | ## [1.3.0] 30 | 31 | - Updated the README.md. 32 | 33 | ## [1.2.3] 34 | 35 | - Updated the extension documentation. 36 | 37 | ## [1.2.2] 38 | 39 | - Added new command inpect statement through custom Log class. 40 | 41 | ## [1.2.1] 42 | 43 | - Added new commands to activationEvents. 44 | 45 | ## [1.2.0] 46 | 47 | - Added new shortcuts for use custom Log class. 48 | 49 | ## [1.1.0] 50 | 51 | - Added new shortcuts. 52 | 53 | ## [1.0.3] 54 | 55 | - Chage quotes to single. 56 | 57 | ## [1.0.0] 58 | 59 | - Initial release. 60 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | VSCode extension Flutter Print 2 | Copyright (c) 2021 Ricardo Emerson 3 | All rights reserved. 4 | 5 | MIT License 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 |
3 | 4 | Flutter Print 5 | 6 |

7 | 8 | ## Support 9 | 10 | **Flutter Print** is an extension created for **Visual Studio Code**. If you find it useful, please consider supporting it. 11 | 12 | 13 | 14 | 19 | 24 | 25 |
15 | 16 | Create Widgets and Classes for Flutter Logo 17 | 18 | 20 | 21 | Create Widgets and Classes for Flutter Logo 22 | 23 |
26 | 27 | ## Flutter Print 28 | 29 | Easily insert and remove `debugPrint('variable: $variable');` statement. 30 | 31 | ![Visual Studio Marketplace Version](https://img.shields.io/visual-studio-marketplace/v/ricardo-emerson.flutter-print.svg?style=flat-square) 32 | ![Visual Studio Marketplace Installs](https://img.shields.io/visual-studio-marketplace/i/ricardo-emerson.flutter-print.svg?style=flat-square) 33 | ![Visual Studio Marketplace Downloads](https://img.shields.io/visual-studio-marketplace/d/ricardo-emerson.flutter-print.svg?style=flat-square) 34 | ![Visual Studio Marketplace Rating](https://img.shields.io/visual-studio-marketplace/r/ricardo-emerson.flutter-print.svg?style=flat-square) 35 | [![GitHub](https://img.shields.io/github/stars/ricardoemerson/flutter-print.svg?style=flat-square)](https://github.com/ricardoemerson/flutter-print) 36 | 37 | # Tutorial in Portuguese Brazil. 38 | [![✅ [2022] Como utilizar a extensão Flutter Print para Visual Studio Code?](https://img.youtube.com/vi/Mg_Pg2jQ_p0/0.jpg)](https://www.youtube.com/watch?v=Mg_Pg2jQ_p0) 39 | 40 | # Usage Examples 41 | 42 | > This extension overrides the shortcut for **Select all occurrences of current selection** - `Ctrl+Shift+L` on Windows and Linux and `Cmd+Shift+L` on macOS, however you can still use `Ctrl+F2` to execute same command. 43 | 44 | 45 | ## Settings 46 | 47 | The Flutter Print extension has only one configuration option called `useDebugPrint` which is used to define whether the debugPrint statement will be used instead of the print statement. 48 | 49 | ![Usage](images/use-debug-print-setting.png) 50 | 51 | ## debugPrint for variables or object properties: 52 | 53 | With the extension setting useDebugPrint enabled, select the variable or object properties that you want uses debugPrint statement and press `Ctrl+Shift+L` on Windows, Linux or macOS. 54 | 55 | ![Usage](images/debug-print.gif) 56 | 57 | ## Print for variables or object properties: 58 | 59 | With the extension setting useDebugPrint disabled, select the variable or object properties that you want uses print statement and press `Ctrl+Shift+L` on Windows, Linux or macOS. 60 | 61 | ![Usage](images/print.gif) 62 | 63 | ## Remove all print statements: 64 | 65 | To remove all print statements and press `Win+Shift+D` on Windows and Linux or `Cmd+Shift+D` on macOS. 66 | 67 | ![Usage](images/delete-log.gif) 68 | 69 | 70 | # With Custom Log Class 71 | 72 | Create a custom log class. 73 | 74 | ```dart 75 | import 'dart:developer' as developer; 76 | 77 | class Log { 78 | Log._(); 79 | 80 | static void print(String value, {StackTrace? stackTrace}) { 81 | developer.log(value, name: 'LOG', stackTrace: stackTrace); 82 | } 83 | 84 | static Object? inspect(Object? object) { 85 | return developer.inspect(object); 86 | } 87 | } 88 | 89 | ``` 90 | 91 | ## Log.print() for variables or object properties: 92 | 93 | Select the variable or object properties that you want uses a custom Log.print statement and press `Win+Ctrl+L` on Windows and Linux or `Cmd+Ctrl+L` on macOS. 94 | 95 | ![Usage](images/log-print.gif) 96 | 97 | 98 | ## Log.inspect() for variables: 99 | 100 | Select the variable that you want uses a custom Log.inspect statement and press `Win+Ctrl+L` on Windows and Linux or `Cmd+Ctrl+L` on macOS. 101 | 102 | ![Usage](images/log-inspect.gif) 103 | 104 | 105 | **That's all, Enjoy!** 106 | -------------------------------------------------------------------------------- /extension.js: -------------------------------------------------------------------------------- 1 | const vscode = require('vscode'); 2 | const helperMessage = require('./message.js'); 3 | 4 | const insertText = (val) => { 5 | const editor = vscode.window.activeTextEditor; 6 | 7 | if (!editor) { 8 | vscode.window.showErrorMessage('Can\'t insert log because no document is open'); 9 | return; 10 | } 11 | 12 | const selection = editor.selection; 13 | 14 | const range = new vscode.Range(selection.start, selection.end); 15 | 16 | editor.edit((editBuilder) => { 17 | editBuilder.replace(range, val); 18 | }); 19 | } 20 | 21 | function getAllLogStatements(document, documentText) { 22 | let logStatements = []; 23 | 24 | const logRegex = /print\((.*)\);?/g; 25 | let match; 26 | 27 | while (match = logRegex.exec(documentText)) { 28 | let matchRange = 29 | new vscode.Range( 30 | document.positionAt(match.index), 31 | document.positionAt(match.index + match[0].length) 32 | ); 33 | if (!matchRange.isEmpty) 34 | logStatements.push(matchRange); 35 | } 36 | return logStatements; 37 | } 38 | 39 | function deleteFoundLogStatements(workspaceEdit, docUri, logs) { 40 | logs.forEach((log) => { 41 | workspaceEdit.delete(docUri, log); 42 | }); 43 | 44 | vscode.workspace.applyEdit(workspaceEdit).then(() => { 45 | logs.length > 1 46 | ? vscode.window.showInformationMessage(`${logs.length} print deleted`) 47 | : vscode.window.showInformationMessage(`${logs.length} print deleted`); 48 | }); 49 | } 50 | 51 | function activate(context) { 52 | const previousVersion = context.globalState.get(helperMessage.LAST_VERSION_KEY); 53 | const extensionData = vscode.extensions.getExtension( 54 | 'ricardo-emerson.flutter-print' 55 | ); 56 | const currentVersion = extensionData.packageJSON.version; 57 | 58 | helperMessage.showWelcomeOrWhatsNew(context, currentVersion, previousVersion); 59 | 60 | const insertPrintStatement = vscode.commands.registerCommand('extension.insertPrintStatement', () => { 61 | const editor = vscode.window.activeTextEditor; 62 | if (!editor) { return; } 63 | 64 | const selection = editor.selection; 65 | const text = editor.document.getText(selection); 66 | 67 | const config = vscode.workspace.getConfiguration("flutterPrint"); 68 | const useDebugPrint = config.get("useDebugPrint"); 69 | 70 | text 71 | ? vscode.commands.executeCommand('editor.action.insertLineAfter') 72 | .then(() => { 73 | let logToInsert; 74 | 75 | if (useDebugPrint) { 76 | logToInsert = `debugPrint('${ text }: \${${text}}');`; 77 | } else { 78 | logToInsert = `print('${ text }: \${${text}}');`; 79 | } 80 | 81 | insertText(logToInsert); 82 | }) 83 | : useDebugPrint ? insertText(`debugPrint('');`) : insertText(`print('');`); 84 | 85 | }); 86 | 87 | context.subscriptions.push(insertPrintStatement); 88 | 89 | const insertLogPrintStatement = vscode.commands.registerCommand('extension.insertLogPrintStatement', () => { 90 | const editor = vscode.window.activeTextEditor; 91 | if (!editor) { return; } 92 | 93 | const selection = editor.selection; 94 | const text = editor.document.getText(selection); 95 | 96 | text 97 | ? vscode.commands.executeCommand('editor.action.insertLineAfter') 98 | .then(() => { 99 | const logToInsert = `Log.print('${ text }: \${${text}}');`; 100 | insertText(logToInsert); 101 | }) 102 | : insertText(`Log.print('');`); 103 | 104 | }); 105 | 106 | context.subscriptions.push(insertLogPrintStatement); 107 | 108 | const insertLogInspectStatement = vscode.commands.registerCommand('extension.insertLogInspectStatement', () => { 109 | const editor = vscode.window.activeTextEditor; 110 | if (!editor) { return; } 111 | 112 | const selection = editor.selection; 113 | const text = editor.document.getText(selection); 114 | 115 | text 116 | ? vscode.commands.executeCommand('editor.action.insertLineAfter') 117 | .then(() => { 118 | const logToInsert = `Log.inspect(${ text });`; 119 | insertText(logToInsert); 120 | }) 121 | : insertText(`Log.inspect(${text});`); 122 | 123 | }); 124 | 125 | context.subscriptions.push(insertLogInspectStatement); 126 | 127 | const deleteAllLogStatements = vscode.commands.registerCommand('extension.deleteAllPrintStatements', () => { 128 | const editor = vscode.window.activeTextEditor; 129 | if (!editor) { return; } 130 | 131 | const document = editor.document; 132 | const documentText = editor.document.getText(); 133 | 134 | let workspaceEdit = new vscode.WorkspaceEdit(); 135 | 136 | const logStatements = getAllLogStatements(document, documentText); 137 | 138 | deleteFoundLogStatements(workspaceEdit, document.uri, logStatements); 139 | }); 140 | 141 | context.subscriptions.push(deleteAllLogStatements); 142 | } 143 | exports.activate = activate; 144 | 145 | function deactivate() { 146 | } 147 | 148 | exports.deactivate = deactivate; 149 | -------------------------------------------------------------------------------- /flutter-print-1.6.1.vsix: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardoemerson/flutter-print/2f972bcaebfe92e7d49045a80def94a1d859a548/flutter-print-1.6.1.vsix -------------------------------------------------------------------------------- /images/.directory: -------------------------------------------------------------------------------- 1 | [Dolphin] 2 | SortOrder=1 3 | SortRole=modificationtime 4 | Timestamp=2020,11,2,13,12,21 5 | Version=4 6 | 7 | [Settings] 8 | HiddenFilesShown=true 9 | -------------------------------------------------------------------------------- /images/cover-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardoemerson/flutter-print/2f972bcaebfe92e7d49045a80def94a1d859a548/images/cover-logo.png -------------------------------------------------------------------------------- /images/debug-print.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardoemerson/flutter-print/2f972bcaebfe92e7d49045a80def94a1d859a548/images/debug-print.gif -------------------------------------------------------------------------------- /images/delete-log.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardoemerson/flutter-print/2f972bcaebfe92e7d49045a80def94a1d859a548/images/delete-log.gif -------------------------------------------------------------------------------- /images/log-inspect.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardoemerson/flutter-print/2f972bcaebfe92e7d49045a80def94a1d859a548/images/log-inspect.gif -------------------------------------------------------------------------------- /images/log-print.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardoemerson/flutter-print/2f972bcaebfe92e7d49045a80def94a1d859a548/images/log-print.gif -------------------------------------------------------------------------------- /images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardoemerson/flutter-print/2f972bcaebfe92e7d49045a80def94a1d859a548/images/logo.png -------------------------------------------------------------------------------- /images/print-object.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardoemerson/flutter-print/2f972bcaebfe92e7d49045a80def94a1d859a548/images/print-object.gif -------------------------------------------------------------------------------- /images/print-variable.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardoemerson/flutter-print/2f972bcaebfe92e7d49045a80def94a1d859a548/images/print-variable.gif -------------------------------------------------------------------------------- /images/print.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardoemerson/flutter-print/2f972bcaebfe92e7d49045a80def94a1d859a548/images/print.gif -------------------------------------------------------------------------------- /images/use-debug-print-setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardoemerson/flutter-print/2f972bcaebfe92e7d49045a80def94a1d859a548/images/use-debug-print-setting.png -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "lib": [ 6 | "es6" 7 | ] 8 | }, 9 | "exclude": [ 10 | "node_modules" 11 | ] 12 | } -------------------------------------------------------------------------------- /message.js: -------------------------------------------------------------------------------- 1 | const vscode = require('vscode'); 2 | 3 | const LAST_VERSION_KEY = 4 | 'ricardo-emerson.flutter-print:last-version'; 5 | const PENDING_FOCUS = 'ricardo-emerson.flutter-print:pending-focus'; 6 | 7 | async function showWelcomeOrWhatsNew(context, version, previousVersion) { 8 | if (previousVersion !== version) { 9 | if (vscode.window.state.focused) { 10 | void context.globalState.update(PENDING_FOCUS, undefined); 11 | void context.globalState.update(LAST_VERSION_KEY, version); 12 | void showMessage(version, previousVersion); 13 | } else { 14 | // Save pending on window getting focus 15 | await context.globalState.update(PENDING_FOCUS, true); 16 | const disposable = vscode.window.onDidChangeWindowState(e => { 17 | if (!e.focused) { 18 | return; 19 | } 20 | 21 | disposable.dispose(); 22 | 23 | // If the window is now focused and we are pending the welcome, clear the pending state and show the welcome 24 | if (context.globalState.get(PENDING_FOCUS) === true) { 25 | void context.globalState.update(PENDING_FOCUS, undefined); 26 | void context.globalState.update(LAST_VERSION_KEY, version); 27 | void showMessage(version, previousVersion); 28 | } 29 | }); 30 | 31 | context.subscriptions.push(disposable); 32 | } 33 | } 34 | } 35 | 36 | async function showMessage(version, previousVersion) { 37 | const whatsNew = { title: "What's New" }; 38 | const giveAStar = { title: '★ Give a star' }; 39 | const writeReview = { title: '★ Write a review' }; 40 | const sponsor = { title: '❤ Sponsor' }; 41 | const actions = [giveAStar, writeReview, sponsor]; 42 | 43 | if (previousVersion) { 44 | actions.unshift(whatsNew); 45 | } 46 | 47 | const message = previousVersion 48 | ? `Flutter Print has been updated to v${version}! — check out what's new!` 49 | : 'Thanks for using Flutter Print — have a great day at work! 🖖🏻 Cheers,'; 50 | 51 | const result = await vscode.window.showInformationMessage(message, ...actions); 52 | 53 | if (result !== null) { 54 | if (result === whatsNew) { 55 | await vscode.env.openExternal( 56 | vscode.Uri.parse( 57 | 'https://marketplace.visualstudio.com/items/ricardo-emerson.flutter-print/changelog' 58 | ) 59 | ); 60 | } else if (result === giveAStar) { 61 | await vscode.env.openExternal( 62 | vscode.Uri.parse('https://github.com/ricardoemerson/flutter-print') 63 | ); 64 | } else if (result === writeReview) { 65 | await vscode.env.openExternal( 66 | vscode.Uri.parse( 67 | 'https://marketplace.visualstudio.com/items?itemName=ricardo-emerson.flutter-print&ssr=false#review-details' 68 | ) 69 | ); 70 | } else if (result === sponsor) { 71 | await vscode.env.openExternal( 72 | vscode.Uri.parse('https://www.paypal.com/donate?hosted_button_id=X26H7L6AVMD96') 73 | ); 74 | } 75 | } 76 | } 77 | 78 | module.exports = { 79 | LAST_VERSION_KEY: LAST_VERSION_KEY, 80 | showWelcomeOrWhatsNew: showWelcomeOrWhatsNew, 81 | } 82 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flutter-print", 3 | "displayName": "Flutter Print", 4 | "description": "Help insert and remove print(*) statement", 5 | "version": "1.6.1", 6 | "publisher": "ricardo-emerson", 7 | "repository": "https://github.com/ricardoemerson/flutter-print", 8 | "icon": "images/logo.png", 9 | "engines": { 10 | "vscode": "^1.4.2" 11 | }, 12 | "categories": [ 13 | "Other" 14 | ], 15 | "activationEvents": [ 16 | "onCommand:extension.insertPrintStatement", 17 | "onCommand:extension.insertLogPrintStatement", 18 | "onCommand:extension.insertLogInspectStatement", 19 | "onCommand:extension.deleteAllPrintStatements", 20 | "workspaceContains:pubspec.yaml" 21 | ], 22 | "main": "./extension", 23 | "contributes": { 24 | "commands": [ 25 | { 26 | "command": "extension.insertPrintStatement", 27 | "title": "Insert Flutter Print Statement" 28 | }, 29 | { 30 | "command": "extension.insertLogPrintStatement", 31 | "title": "Insert Flutter Print Statement using Custom Log Class" 32 | }, 33 | { 34 | "command": "extension.insertLogInspectStatement", 35 | "title": "Insert Flutter Inspect Statement using Custom Log Class" 36 | }, 37 | { 38 | "command": "extension.deleteAllPrintStatements", 39 | "title": "Delete all Flutter Print statements" 40 | } 41 | ], 42 | "keybindings": [ 43 | { 44 | "command": "extension.insertPrintStatement", 45 | "key": "shift+ctrl+l", 46 | "mac": "shift+ctrl+l", 47 | "when": "editorTextFocus && editorLangId == dart" 48 | }, 49 | { 50 | "command": "extension.insertLogPrintStatement", 51 | "key": "shift+meta+l", 52 | "mac": "shift+cmd+l", 53 | "when": "editorTextFocus && editorLangId == dart" 54 | }, 55 | { 56 | "command": "extension.insertLogInspectStatement", 57 | "key": "alt+meta+i", 58 | "mac": "alt+cmd+i", 59 | "when": "editorTextFocus && editorLangId == dart" 60 | }, 61 | { 62 | "command": "extension.deleteAllPrintStatements", 63 | "key": "shift+meta+d", 64 | "mac": "shift+cmd+d", 65 | "when": "editorTextFocus && editorLangId == dart" 66 | } 67 | ], 68 | "configuration": { 69 | "title": "Flutter Print", 70 | "properties": { 71 | "flutterPrint.useDebugPrint": { 72 | "type": "boolean", 73 | "default": true, 74 | "markdownDescription": "Defines if will debugPrint or print statement." 75 | } 76 | } 77 | } 78 | }, 79 | "scripts": { 80 | "postinstall": "node ./node_modules/vscode/bin/install", 81 | "test": "node ./node_modules/vscode/bin/test" 82 | }, 83 | "devDependencies": { 84 | "typescript": "^2.0.3", 85 | "vscode": "^1.0.0", 86 | "mocha": "^2.3.3", 87 | "eslint": "^3.6.0", 88 | "@types/node": "^6.0.40", 89 | "@types/mocha": "^2.2.32" 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /test/extension.test.js: -------------------------------------------------------------------------------- 1 | /* global suite, test */ 2 | 3 | // 4 | // Note: This example test is leveraging the Mocha test framework. 5 | // Please refer to their documentation on https://mochajs.org/ for help. 6 | // 7 | 8 | // The module 'assert' provides assertion methods from node 9 | var assert = require('assert'); 10 | 11 | // You can import and use all API from the 'vscode' module 12 | // as well as import your extension to test it 13 | var vscode = require('vscode'); 14 | var myExtension = require('../extension'); 15 | 16 | // Defines a Mocha test suite to group tests of similar kind together 17 | suite("Extension Tests", function() { 18 | 19 | // Defines a Mocha unit test 20 | test("Something 1", function() { 21 | assert.equal(-1, [1, 2, 3].indexOf(5)); 22 | assert.equal(-1, [1, 2, 3].indexOf(0)); 23 | }); 24 | }); -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | // 2 | // PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING 3 | // 4 | // This file is providing the test runner to use when running extension tests. 5 | // By default the test runner in use is Mocha based. 6 | // 7 | // You can provide your own test runner if you want to override it by exporting 8 | // a function run(testRoot: string, clb: (error:Error) => void) that the extension 9 | // host can call to run the tests. The test runner is expected to use print 10 | // to report the results back to the caller. When the tests are finished, return 11 | // a possible error to the callback or null if none. 12 | 13 | var testRunner = require('vscode/lib/testrunner'); 14 | 15 | // You can directly control Mocha options by uncommenting the following lines 16 | // See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info 17 | testRunner.configure({ 18 | ui: 'tdd', // the TDD UI is being used in extension.test.js (suite, test, etc.) 19 | useColors: true // colored output from test results 20 | }); 21 | 22 | module.exports = testRunner; 23 | -------------------------------------------------------------------------------- /vsc-extension-quickstart.md: -------------------------------------------------------------------------------- 1 | # Welcome to your first VS Code Extension 2 | 3 | ## What's in the folder 4 | * This folder contains all of the files necessary for your extension 5 | * `package.json` - this is the manifest file in which you declare your extension and command. 6 | The sample plugin registers a command and defines its title and command name. With this information 7 | VS Code can show the command in the command palette. It doesn’t yet need to load the plugin. 8 | * `extension.js` - this is the main file where you will provide the implementation of your command. 9 | The file exports one function, `activate`, which is called the very first time your extension is 10 | activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. 11 | We pass the function containing the implementation of the command as the second parameter to 12 | `registerCommand`. 13 | 14 | ## Get up and running straight away 15 | * press `F5` to open a new window with your extension loaded 16 | * run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World` 17 | * set breakpoints in your code inside extension.ts to debug your extension 18 | * find output from your extension in the debug console 19 | 20 | ## Make changes 21 | * you can relaunch the extension from the debug toolbar after changing code in `extension.js` 22 | * you can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes 23 | 24 | ## Explore the API 25 | * you can open the full set of our API when you open the file `node_modules/vscode/vscode.d.ts` 26 | 27 | ## Run tests 28 | * open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Launch Tests` 29 | * press `F5` to run the tests in a new window with your extension loaded 30 | * see the output of the test result in the debug console 31 | * make changes to `test/extension.test.js` or create new test files inside the `test` folder 32 | * by convention, the test runner will only consider files matching the name pattern `**.test.js` 33 | * you can create folders inside the `test` folder to structure your tests any way you want --------------------------------------------------------------------------------