vscode#TaskScope TypeScript Examples

The following examples show how to use vscode#TaskScope. 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 6 votes vote down vote up
function getBuildTask(doc: TextDocument, buildType: BuildType): Task {
    let [label, buildCommand] = getBuildParameters(doc.fileName, buildType);

    let taskDef: TaskDefinition = {
        type: "shell",
        label: label,
        command: buildCommand,
        problemMatcher: ["$splusCC"],
        presentation: {
            panel: "shared",
            focus: true,
            clear: true
        }
    }

    let executable = 'C:\\Windows\\System32\\cmd.exe';
    let command = new ShellExecution("\"" + taskDef.command + "\"", { executable: executable, shellArgs: ['/c'] });
    let task = new Task(taskDef, TaskScope.Workspace, taskDef.label, "Crestron S+", command, taskDef.problemMatcher);
    task.group = TaskGroup.Build;
    task.definition = taskDef;
    task.presentationOptions = taskDef.presentation;

    return task;
}
Example #2
Source File: extension.ts    From vscode-crestron-splus with GNU General Public License v3.0 4 votes vote down vote up
async function getCompileTasks(): Promise<Task[]> {
    let result: Task[] = [];
    let editor = window.activeTextEditor;
    let doc = editor.document;
    let emptyTasks: Task[] = [];

    let workspaceFolder = workspace.getWorkspaceFolder(doc.uri)
    if (!workspaceFolder) {
        return emptyTasks;
    }

    let workspaceRoot = workspaceFolder.uri.fsPath;
    if (!workspaceRoot) {
        return emptyTasks;
    }

    try {
        let sSharpLibRegEx = /(#(?:USER|CRESTRON)_SIMPLSHARP_LIBRARY)\s*\"([\w\.\-]*)\"/gmi;
        let sSharpIncludeRegEx = /#INCLUDEPATH\s*\"([\w\.\-]*)\"/gmi;

        let sSharpLibs = doc.getText().match(sSharpLibRegEx);
        let sSharpIncludes = doc.getText().match(sSharpIncludeRegEx);

        let enable2SeriesCompile = workspace.getConfiguration("splus").enable2series === true;
        let enable3SeriesCompile = workspace.getConfiguration("splus").enable3series === true;
        let enable4SeriesCompile = workspace.getConfiguration("splus").enable4series === true;

        if (sSharpLibs && sSharpLibs.length > 0) {
            sSharpLibs.forEach((regexMatch: string) => {
                let fileName = "";
                let tokens = regexMatch.match(/\S+/g)
                if (tokens.length > 1)
                    fileName = tokens[1].slice(1, -1);

                let thisFileDir = doc.fileName.slice(0, doc.fileName.lastIndexOf("\\") + 1);

                if (fs.existsSync(thisFileDir + "SPlsWork\\" + fileName + ".dll")) {
                    let buildCommand = getApiCommand(fileName, thisFileDir);

                    let taskDef: TaskDefinition = {
                        type: "shell",
                        label: "Generate API file for " + fileName,
                        command: buildCommand,
                        problemMatcher: [],
                        presentation: {
                            panel: "shared",
                            focus: true,
                            clear: true
                        }
                    }

                    let executable = 'C:\\Windows\\System32\\cmd.exe';
                    let command = new ShellExecution("\"" + taskDef.command + "\"", { executable: executable, shellArgs: ['/c'] });
                    let task = new Task(taskDef, TaskScope.Workspace, taskDef.label, 'Crestron S+', command, taskDef.problemMatcher);
                    task.group = TaskGroup.Build;
                    task.definition = taskDef;
                    task.presentationOptions = taskDef.presentation;

                    result.push(task);
                }
            })
        }

        if (enable2SeriesCompile) {
            result.push(getBuildTask(doc, BuildType.Series2)); // compile 2 series
            if (enable3SeriesCompile) {
                result.push(getBuildTask(doc, BuildType.Series2 | BuildType.Series3)); // compile 2 & 3 series
            }
        }

        if (enable3SeriesCompile) {
            result.push(getBuildTask(doc, BuildType.Series3)); // compile 3 series
            if (enable4SeriesCompile) {
                result.push(getBuildTask(doc, BuildType.Series3 | BuildType.Series4)); // compile 3 & 4 series
            }
        }

        if (enable4SeriesCompile) {
            result.push(getBuildTask(doc, BuildType.Series4)); // compile 4 series
        }

        // likely do not need 2 & 4 series compile option...
        if (enable2SeriesCompile && enable3SeriesCompile && enable4SeriesCompile) {
            result.push(getBuildTask(doc, BuildType.All));
        }

        return result;
    }
    catch (err) {
        let channel = getOutputChannel();
        console.log(err);

        if (err.stderr) {
            channel.appendLine(err.stderr);
        }

        if (err.stdout) {
            channel.appendLine(err.stdout);
        }

        channel.appendLine('SIMPL+ compile failed');
        channel.show(true);
        return emptyTasks;
    }
}