vscode plug-in development notes

https://code.visualstudio.com/api/get-started/your-first-extensionnpm install -g yo generator-codeyo code
Select ts or js for normal development.
The results are as follows. The contributions.commands node of package.json controls the command life, and
contributes.menus defines the menu
extension.ts . Register events inside

export function activate(context: vscode.ExtensionContext) {

    context.subscriptions.push(vscode.commands.registerCommand('extension.sqltool.execSql', () => {
    //  vscode.window.showInformationMessage('not implemention!');

    const editor = vscode.window.activeTextEditor;

        if (editor) {
    const document = editor.document;
            const inputText = document.getText();
    editor.edit(editBuilder => {
                const start = new vscode.Position(0, 0);
                const end = new vscode.Position(document.lineCount, 0);
                const range = new vscode.Range(start, end);
                editBuilder.replace(range, '处理后的结果');
            });
}
    }));

}
image.png
image.png

tsc -watch -p ./Converting ts code to js code and monitoring it in real time npm run compilehas the same effect
. The actual definition of running the extension is as follows

image.png

If it does not work, you should update the new version of vscode.

https://astexplorer.net/ can be combined with babel to replace the code content, but I think simple things are complicated. I used row scanning to complete a stored procedure that is directly converted into sql code.

publish extension

npm install -g @vscode/vscevsve publish
获取tokenhttps://marketplace.visualstudio.com/manage/publishers/https://dev.azure.com/lozn/_usersSettings/tokens

image.png
image.png

https://marketplace.visualstudio.com/manage/publishers/lozn

Guess you like

Origin blog.csdn.net/u010042660/article/details/132510187