vscode#Task TypeScript Examples
The following examples show how to use
vscode#Task.
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 |
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 | 5 votes |
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();
}
Example #3
Source File: extension.ts From vscode-crestron-splus with GNU General Public License v3.0 | 4 votes |
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;
}
}