vscode#tasks TypeScript Examples

The following examples show how to use vscode#tasks. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: extension.ts    From vscode-crestron-splus with GNU General Public License v3.0 5 votes vote down vote up
export function activate(context: ExtensionContext) {

    if (workspace.workspaceFolders === undefined) {
        let fileName = window.activeTextEditor.document.uri.path;
        let fileFolder = fileName.slice(0, fileName.lastIndexOf("/") + 1);
        commands.executeCommand("vscode.openFolder", Uri.parse(fileFolder));
    }

    let localhelp_command = commands.registerCommand("splus.localHelp", () => {
        callShellCommand(workspace.getConfiguration("splus").helpLocation);
    });

    let webhelp_command = commands.registerCommand("splus.webHelp", openWebHelp);

    function rebuildTaskList(): void {
        if (taskProvider) {
            taskProvider.dispose();
            taskProvider = undefined;
        }
        if (!taskProvider && window.activeTextEditor.document.languageId === "splus-source") {
            let splusPromise: Thenable<Task[]> | undefined = undefined;
            taskProvider = tasks.registerTaskProvider('splus', {
                provideTasks: () => {
                    if (!splusPromise) {
                        splusPromise = getCompileTasks();
                    }

                    return splusPromise;
                },
                resolveTask: () => {
                    return undefined;
                }
            })
        }
    }

    let thisFormatProvider = new formattingProvider(formatProvider);
    languages.registerDocumentFormattingEditProvider({ scheme: 'file', language: 'splus-source' }, thisFormatProvider);

    context.subscriptions.push(localhelp_command);
    context.subscriptions.push(webhelp_command);

    workspace.onDidChangeConfiguration(rebuildTaskList);
    workspace.onDidOpenTextDocument(rebuildTaskList);
    workspace.onDidSaveTextDocument(rebuildTaskList);
    window.onDidChangeActiveTextEditor(rebuildTaskList);

    rebuildTaskList();
}