当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript vscode.tasks类代码示例

本文整理汇总了TypeScript中vscode.tasks的典型用法代码示例。如果您正苦于以下问题:TypeScript tasks类的具体用法?TypeScript tasks怎么用?TypeScript tasks使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了tasks类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: activate

export function activate(activationEventOccurred: boolean): void {
    if (realActivationOccurred) {
        return; // Occurs if multiple delayed commands occur before the real commands are registered.
    }

    // Activate immediately if an activation event occurred in the previous workspace session.
    // If onActivationEvent doesn't occur, it won't auto-activate next time.
    activatedPreviously = new PersistentWorkspaceState("activatedPreviously", false);
    if (activatedPreviously.Value) {
        activatedPreviously.Value = false;
        realActivation();
    }

    if (tempCommands.length === 0) { // Only needs to be added once.
        tempCommands.push(vscode.workspace.onDidOpenTextDocument(d => onDidOpenTextDocument(d)));
    }

    // Check if an activation event has already occurred.
    if (activationEventOccurred) {
        onActivationEvent();
        return;
    }

    taskProvider = vscode.tasks.registerTaskProvider(taskSourceStr, {
        provideTasks: () => {
            return getBuildTasks(false);
        },
        resolveTask(task: vscode.Task): vscode.Task {
            // Currently cannot implement because VS Code does not call this. Can implement custom output file directory when enabled.
            return undefined;
        }
    });
    vscode.tasks.onDidStartTask(event => {
        if (event.execution.task.source === taskSourceStr) {
            telemetry.logLanguageServerEvent('buildTaskStarted');
        }
    });

    // handle "workspaceContains:/.vscode/c_cpp_properties.json" activation event.
    if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) {
        for (let i: number = 0; i < vscode.workspace.workspaceFolders.length; ++i) {
            let config: string = path.join(vscode.workspace.workspaceFolders[i].uri.fsPath, ".vscode/c_cpp_properties.json");
            if (fs.existsSync(config)) {
                onActivationEvent();
                return;
            }
        }
    }

    // handle "onLanguage:cpp" and "onLanguage:c" activation events.
    if (vscode.workspace.textDocuments !== undefined && vscode.workspace.textDocuments.length > 0) {
        for (let i: number = 0; i < vscode.workspace.textDocuments.length; ++i) {
            let document: vscode.TextDocument = vscode.workspace.textDocuments[i];
            if (document.languageId === "cpp" || document.languageId === "c") {
                onActivationEvent();
                return;
            }
        }
    }
}
开发者ID:swyphcosmo,项目名称:vscode-cpptools,代码行数:60,代码来源:extension.ts

示例2: runTest

function runTest(sourceUri: string, className: string, methodName: string): Thenable<TaskExecution> {
    let file = Uri.parse(sourceUri).fsPath;
    file = Path.relative(workspace.rootPath, file);
	let kind: JavaTestTask = {
		type: 'java.task.test',
        className: className,
        methodName: methodName,
    }
    var shell;
    let config = workspace.getConfiguration('java')
    // Run method or class
    if (methodName != null) {
        let command = config.get('testMethod') as string[]
        if (command.length == 0) {
            window.showErrorMessage('Set "java.testMethod" in .vscode/settings.json')
            shell = new ShellExecution('echo', ['Set "java.testMethod" in .vscode/settings.json, for example ["mvn", "test", "-Dtest=${class}#${method}"]'])
        } else {
            shell = templateCommand(command, file, className, methodName)
        }
    } else {
        let command = config.get('testClass') as string[]
        if (command.length == 0) {
            window.showErrorMessage('Set "java.testClass" in .vscode/settings.json')
            shell = new ShellExecution('echo', ['Set "java.testClass" in .vscode/settings.json, for example ["mvn", "test", "-Dtest=${class}"]'])
        } else {
            shell = templateCommand(command, file, className, methodName)
        }
    }
	let workspaceFolder = workspace.getWorkspaceFolder(Uri.parse(sourceUri))
	let task = new Task(kind, workspaceFolder, 'Java Test', 'Java Language Server', shell)
	return tasks.executeTask(task)
}
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:32,代码来源:extension.ts

示例3: activate

export function activate(context: vscode.ExtensionContext) {
  let taskCommand: string = null;
  let problemMatcher: string = null;
  const outputChannel = vscode.window.createOutputChannel("phpunit");
  const PHPUnitTestRunner: TestRunner = new TestRunner(outputChannel, {
    setTaskCommand: (command: string, matcher?: string) => {
      taskCommand = command;
      problemMatcher = matcher;
    }
  });

  context.subscriptions.push(
    vscode.commands.registerCommand("phpunit.Test", () => {
      PHPUnitTestRunner.run("test");
    })
  );

  context.subscriptions.push(
    vscode.commands.registerCommand("phpunit.TestNearest", () => {
      PHPUnitTestRunner.run("nearest-test");
    })
  );

  context.subscriptions.push(
    vscode.commands.registerCommand("phpunit.TestDirectory", () => {
      PHPUnitTestRunner.run("directory");
    })
  );

  context.subscriptions.push(
    vscode.commands.registerCommand("phpunit.RerunLastTest", () => {
      PHPUnitTestRunner.run("rerun-last-test");
    })
  );

  context.subscriptions.push(
    vscode.commands.registerCommand("phpunit.TestingStop", () => {
      PHPUnitTestRunner.stop();
    })
  );

  context.subscriptions.push(
    vscode.tasks.registerTaskProvider("phpunit", {
      provideTasks: () => {
        return [
          new vscode.Task(
            { type: "phpunit", task: "run" },
            vscode.TaskScope.Workspace,
            "run",
            "phpunit",
            new vscode.ShellExecution(taskCommand),
            problemMatcher || "$phpunit"
          )
        ];
      },
      resolveTask: undefined
    })
  );
}
开发者ID:elonmallin,项目名称:vscode-phpunit,代码行数:59,代码来源:extension.ts

示例4: runScript

export function runScript(script: string, document: TextDocument) {
	let uri = document.uri;
	let folder = workspace.getWorkspaceFolder(uri);
	if (folder) {
		let task = createTask(script, `run ${script}`, folder, uri);
		tasks.executeTask(task);
	}
}
开发者ID:DonJayamanne,项目名称:vscode,代码行数:8,代码来源:tasks.ts

示例5: runScriptFromHover

	public runScriptFromHover(args: any) {
		let script = args.script;
		let documentUri = args.documentUri;
		let folder = workspace.getWorkspaceFolder(documentUri);
		if (folder) {
			let task = createTask(script, `run ${script}`, folder, documentUri);
			tasks.executeTask(task);
		}
	}
开发者ID:developers23,项目名称:vscode,代码行数:9,代码来源:scriptHover.ts

示例6: activateTaskProvider

export function activateTaskProvider(target: WorkspaceFolder): Disposable {
    const provider: TaskProvider = {
        provideTasks: function () {
            // npm or others parse their task definitions. So they need to provide 'autoDetect' feature.
            //  e,g, https://github.com/Microsoft/vscode/blob/de7e216e9ebcad74f918a025fc5fe7bdbe0d75b2/extensions/npm/src/main.ts
            // However, cargo.toml does not support to define a new task like them.
            // So we are not 'autoDetect' feature and the setting for it.
            return getCargoTasks(target);
        },
        resolveTask(_task: Task): Task | undefined {
            return undefined;
        }
    };

    return tasks.registerTaskProvider('cargo', provider);
}
开发者ID:digitaltoad,项目名称:dotfiles,代码行数:16,代码来源:tasks.ts

示例7: runCommand

export function runCommand(folder: WorkspaceFolder, cmd: Cmd): Thenable<TaskExecution> {
    const config: TaskConfigItem = {
        definition: {
            label: 'run Cargo command',
            type: 'cargo',
            command: cmd.binary,
            args: cmd.args,
            env: cmd.env,
        },
        problemMatcher: ['$rustc'],
        group: TaskGroup.Build,
        presentationOptions: {
            reveal: TaskRevealKind.Always,
            panel: TaskPanelKind.Dedicated,
        },
    };
    const task = createTask(config, folder);
    return tasks.executeTask(task);
}
开发者ID:digitaltoad,项目名称:dotfiles,代码行数:19,代码来源:tasks.ts

示例8: activate

export function activate(_context: vscode.ExtensionContext): void {
	let workspaceRoot = vscode.workspace.rootPath;
	if (!workspaceRoot) {
		return;
	}
	let pattern = path.join(workspaceRoot, 'Rakefile');
	let rakePromise: Thenable<vscode.Task[]> | undefined = undefined;
	let fileWatcher = vscode.workspace.createFileSystemWatcher(pattern);
	fileWatcher.onDidChange(() => rakePromise = undefined);
	fileWatcher.onDidCreate(() => rakePromise = undefined);
	fileWatcher.onDidDelete(() => rakePromise = undefined);
	taskProvider = vscode.tasks.registerTaskProvider('rake', {
		provideTasks: () => {
			if (!rakePromise) {
				rakePromise = getRakeTasks();
			}
			return rakePromise;
		},
		resolveTask(_task: vscode.Task): vscode.Task | undefined {
			return undefined;
		}
	});
}
开发者ID:voodoos,项目名称:vscode-extension-samples,代码行数:23,代码来源:extension.ts

示例9: activate


//.........这里部分代码省略.........
	// This is registered with VS Code further down, so it's metadata can be collected from all
	// registered providers.
	const rankingCodeActionProvider = new RankingCodeActionProvider();

	const triggerCharacters = ".(${'\"/\\".split("");
	context.subscriptions.push(vs.languages.registerHoverProvider(activeFileFilters, hoverProvider));
	formattingEditProvider.registerDocumentFormatter(activeFileFilters);
	context.subscriptions.push(vs.languages.registerCompletionItemProvider(activeFileFilters, completionItemProvider, ...triggerCharacters));
	context.subscriptions.push(vs.languages.registerDefinitionProvider(activeFileFilters, referenceProvider));
	context.subscriptions.push(vs.languages.registerReferenceProvider(activeFileFilters, referenceProvider));
	context.subscriptions.push(vs.languages.registerDocumentHighlightProvider(activeFileFilters, documentHighlightProvider));
	rankingCodeActionProvider.registerProvider(new AssistCodeActionProvider(activeFileFilters, analyzer));
	rankingCodeActionProvider.registerProvider(new FixCodeActionProvider(activeFileFilters, analyzer));
	rankingCodeActionProvider.registerProvider(new RefactorCodeActionProvider(activeFileFilters, analyzer));
	context.subscriptions.push(vs.languages.registerRenameProvider(activeFileFilters, renameProvider));

	// Some actions only apply to Dart.
	formattingEditProvider.registerTypingFormatter(DART_MODE, "}", ";");
	context.subscriptions.push(vs.languages.registerCodeActionsProvider(DART_MODE, sourceCodeActionProvider, sourceCodeActionProvider.metadata));

	rankingCodeActionProvider.registerProvider(new IgnoreLintCodeActionProvider(activeFileFilters));
	context.subscriptions.push(vs.languages.registerImplementationProvider(DART_MODE, implementationProvider));
	if (config.showTestCodeLens) {
		const codeLensProvider = new TestCodeLensProvider(analyzer);
		context.subscriptions.push(codeLensProvider);
		context.subscriptions.push(vs.languages.registerCodeLensProvider(DART_MODE, codeLensProvider));
	}

	// Register the ranking provider from VS Code now that it has all of its delegates.
	context.subscriptions.push(vs.languages.registerCodeActionsProvider(activeFileFilters, rankingCodeActionProvider, rankingCodeActionProvider.metadata));

	// Task handlers.
	if (config.previewBuildRunnerTasks) {
		context.subscriptions.push(vs.tasks.registerTaskProvider("pub", new PubBuildRunnerTaskProvider(sdks)));
	}

	// Snippets are language-specific
	context.subscriptions.push(vs.languages.registerCompletionItemProvider(DART_MODE, new SnippetCompletionItemProvider("snippets/dart.json", (_) => true)));
	context.subscriptions.push(vs.languages.registerCompletionItemProvider(DART_MODE, new SnippetCompletionItemProvider("snippets/flutter.json", (uri) => util.isInsideFlutterProject(uri))));

	context.subscriptions.push(vs.languages.setLanguageConfiguration(DART_MODE.language, new DartLanguageConfiguration()));
	const statusReporter = new AnalyzerStatusReporter(analyzer, workspaceContext, analytics);

	// Set up diagnostics.
	const diagnostics = vs.languages.createDiagnosticCollection("dart");
	context.subscriptions.push(diagnostics);
	const diagnosticsProvider = new DartDiagnosticProvider(analyzer, diagnostics);

	// Set the roots, handling project changes that might affect SDKs.
	context.subscriptions.push(vs.workspace.onDidChangeWorkspaceFolders((f) => recalculateAnalysisRoots()));
	// TODO: Currently calculating analysis roots requires the version to check if
	// we need the package workaround. In future if we stop supporting server < 1.20.1 we
	// can unwrap this call so that it'll start sooner.
	const serverConnected = analyzer.registerForServerConnected((sc) => {
		serverConnected.dispose();
		if (vs.workspace.workspaceFolders)
			recalculateAnalysisRoots();
	});

	// Hook editor changes to send updated contents to analyzer.
	context.subscriptions.push(new FileChangeHandler(analyzer));

	// Fire up Flutter daemon if required.
	if (workspaceContext.hasAnyFlutterMobileProjects) {
		flutterDaemon = new FlutterDaemon(path.join(sdks.flutter, flutterPath), sdks.flutter);
		context.subscriptions.push(flutterDaemon);
开发者ID:DanTup,项目名称:Dart-Code,代码行数:67,代码来源:extension.ts


注:本文中的vscode.tasks类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。