本文整理汇总了TypeScript中vscode.window.createOutputChannel方法的典型用法代码示例。如果您正苦于以下问题:TypeScript window.createOutputChannel方法的具体用法?TypeScript window.createOutputChannel怎么用?TypeScript window.createOutputChannel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode.window
的用法示例。
在下文中一共展示了window.createOutputChannel方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: activate
export async function activate(context: ExtensionContext): Promise<GitExtension> {
const disposables: Disposable[] = [];
context.subscriptions.push(new Disposable(() => Disposable.from(...disposables).dispose()));
const outputChannel = window.createOutputChannel('Git');
commands.registerCommand('git.showOutput', () => outputChannel.show());
disposables.push(outputChannel);
const { name, version, aiKey } = require('../package.json') as { name: string, version: string, aiKey: string };
const telemetryReporter = new TelemetryReporter(name, version, aiKey);
deactivateTasks.push(() => telemetryReporter.dispose());
const config = workspace.getConfiguration('git', null);
const enabled = config.get<boolean>('enabled');
if (!enabled) {
const onConfigChange = filterEvent(workspace.onDidChangeConfiguration, e => e.affectsConfiguration('git'));
const onEnabled = filterEvent(onConfigChange, () => workspace.getConfiguration('git', null).get<boolean>('enabled') === true);
await eventToPromise(onEnabled);
}
try {
const model = await createModel(context, outputChannel, telemetryReporter, disposables);
return createGitExtension(model);
} catch (err) {
if (!/Git installation not found/.test(err.message || '')) {
throw err;
}
console.warn(err.message);
outputChannel.appendLine(err.message);
await warnAboutMissingGit();
return createGitExtension();
}
}
示例2: activate
export async function activate(context: vscode.ExtensionContext): Promise<{ initializationFinished: Promise<void> }> {
const extensionId = 'ms-vscode.csharp';
const extension = vscode.extensions.getExtension(extensionId);
const extensionVersion = extension.packageJSON.version;
const aiKey = extension.packageJSON.contributes.debuggers[0].aiKey;
const reporter = new TelemetryReporter(extensionId, extensionVersion, aiKey);
util.setExtensionPath(extension.extensionPath);
_channel = vscode.window.createOutputChannel('C#');
let logger = new Logger(text => _channel.append(text));
let runtimeDependenciesExist = await ensureRuntimeDependencies(extension, logger, reporter);
// activate language services
let omniSharpPromise = OmniSharp.activate(context, reporter, _channel);
// register JSON completion & hover providers for project.json
context.subscriptions.push(addJSONProviders());
let coreClrDebugPromise = Promise.resolve();
if (runtimeDependenciesExist) {
// activate coreclr-debug
coreClrDebugPromise = coreclrdebug.activate(extension, context, reporter, logger, _channel);
}
return {
initializationFinished: Promise.all([omniSharpPromise, coreClrDebugPromise])
.then(promiseResult => {
// This promise resolver simply swallows the result of Promise.all. When we decide we want to expose this level of detail
// to other extensions then we will design that return type and implement it here.
})
};
}
示例3:
.then(target => {
if(target == undefined) {
return; // e.g. if the user presses escape button
}
// Move the selected option to be the first element in order to keep the last selected option at the top of the list
options.splice(options.indexOf(target), 1);
options.unshift(target);
// Show output channel
let runChannel: vscode.OutputChannel = vscode.window.createOutputChannel(`Run on ${project.platform()}`);
runChannel.clear();
runChannel.show(vscode.ViewColumn.Two);
// Execute run command
let emulator: boolean = (target === 'emulator');
return project.run(emulator)
.then(tnsProcess => {
tnsProcess.on('error', err => {
vscode.window.showErrorMessage('Unexpected error executing NativeScript Run command.');
});
tnsProcess.stderr.on('data', data => {
runChannel.append(data);
});
tnsProcess.stdout.on('data', data => {
runChannel.append(data);
});
tnsProcess.on('exit', exitCode => {
tnsProcess.stdout.removeAllListeners('data');
tnsProcess.stderr.removeAllListeners('data');
});
tnsProcess.on('close', exitCode => {
runChannel.hide();
});
});
});
示例4: createOutputChannel
public createOutputChannel(name: string): OutputChannel {
return vscode.window.createOutputChannel(name);
}
示例5: activate
export function activate(): void {
const outputChannel = vscode.window.createOutputChannel('search-rg');
const provider = new RipgrepSearchProvider(outputChannel);
vscode.workspace.registerSearchProvider('file', provider);
}
示例6: activate
export function activate(context: vscode.ExtensionContext, reporter: TelemetryReporter) {
_reporter = reporter;
_channel = vscode.window.createOutputChannel('coreclr-debug');
_util = new CoreClrDebugUtil(context.extensionPath, _channel);
if (CoreClrDebugUtil.existsSync(_util.installCompleteFilePath())) {
console.log('.NET Core Debugger tools already installed');
return;
}
if (!isOnPath('dotnet')) {
const getDotNetMessage = "Get .NET CLI tools";
vscode.window.showErrorMessage("The .NET CLI tools cannot be located. .NET Core debugging will not be enabled. Make sure .NET CLI tools are installed and are on the path.",
getDotNetMessage).then(value => {
if (value === getDotNetMessage) {
let open = require('open');
open("http://dotnet.github.io/getting-started/");
}
});
return;
}
let installer = new debugInstall.DebugInstaller(_util);
_util.createInstallLog();
let runtimeId = getPlatformRuntimeId();
let statusBarMessage = vscode.window.setStatusBarMessage("Downloading and configuring the .NET Core Debugger...");
let installStage = "installBegin";
let installError = "";
writeInstallBeginFile().then(() => {
return installer.install(runtimeId);
}).then(() => {
installStage = "completeSuccess";
statusBarMessage.dispose();
vscode.window.setStatusBarMessage('Successfully installed .NET Core Debugger.');
})
.catch((error: debugInstall.InstallError) => {
const viewLogMessage = "View Log";
vscode.window.showErrorMessage('Error while installing .NET Core Debugger.', viewLogMessage).then(value => {
if (value === viewLogMessage) {
_channel.show(vscode.ViewColumn.Three);
}
});
statusBarMessage.dispose();
installStage = error.installStage;
installError = error.installError;
}).then(() => {
// log telemetry and delete install begin file
logTelemetry('Acquisition', {installStage: installStage, installError: installError});
try {
deleteInstallBeginFile();
} catch (err) {
// if this throws there's really nothing we can do
}
_util.closeInstallLog();
});
}
示例7: Promise
return new Promise(async (res, rej) => {
progress.report({ message: 'Starting Test Resolver' });
outputChannel = vscode.window.createOutputChannel('TestResolver');
let isResolved = false;
async function processError(message: string) {
outputChannel.appendLine(message);
if (!isResolved) {
isResolved = true;
outputChannel.show();
const result = await vscode.window.showErrorMessage(message, { modal: true }, ...getActions());
if (result) {
await result.execute();
}
rej(vscode.RemoteAuthorityResolverError.NotAvailable(message, true));
}
}
let lastProgressLine = '';
function processOutput(output: string) {
outputChannel.append(output);
for (let i = 0; i < output.length; i++) {
const chr = output.charCodeAt(i);
if (chr === CharCode.LineFeed) {
const match = lastProgressLine.match(/Extension host agent listening on (\d+)/);
if (match) {
isResolved = true;
res(new vscode.ResolvedAuthority('localhost', parseInt(match[1], 10))); // success!
}
lastProgressLine = '';
} else if (chr === CharCode.Backspace) {
lastProgressLine = lastProgressLine.substr(0, lastProgressLine.length - 1);
} else {
lastProgressLine += output.charAt(i);
}
}
}
if (_authority === 'test+error' || vscode.workspace.getConfiguration('testresolver').get('error') === true) {
processError('Unable to start the Test Resolver.');
return;
}
const { updateUrl, commit, quality, serverDataFolderName, dataFolderName } = getProductConfiguration();
const serverCommand = process.platform === 'win32' ? 'server.bat' : 'server.sh';
const commandArgs = ['--port=0', '--disable-telemetry'];
const env = getNewEnv();
const remoteDataDir = process.env['TESTRESOLVER_DATA_FOLDER'] || path.join(os.homedir(), serverDataFolderName || `${dataFolderName}-testresolver`);
env['VSCODE_AGENT_FOLDER'] = remoteDataDir;
outputChannel.appendLine(`Using data folder at ${remoteDataDir}`);
if (!commit) { // dev mode
const vscodePath = path.resolve(path.join(context.extensionPath, '..', '..'));
const serverCommandPath = path.join(vscodePath, 'resources', 'server', 'bin-dev', serverCommand);
extHostProcess = cp.spawn(serverCommandPath, commandArgs, { env, cwd: vscodePath });
} else {
const serverBin = path.join(remoteDataDir, 'bin');
progress.report({ message: 'Installing VSCode Server' });
const serverLocation = await downloadAndUnzipVSCodeServer(updateUrl, commit, quality, serverBin);
outputChannel.appendLine(`Using server build at ${serverLocation}`);
extHostProcess = cp.spawn(path.join(serverLocation, serverCommand), commandArgs, { env, cwd: serverLocation });
}
extHostProcess.stdout.on('data', (data: Buffer) => processOutput(data.toString()));
extHostProcess.stderr.on('data', (data: Buffer) => processOutput(data.toString()));
extHostProcess.on('error', (error: Error) => processError(`server failed with error:\n${error.message}`));
extHostProcess.on('close', (code: number) => processError(`server closed unexpectedly.\nError code: ${code}`));
});
示例8:
import { OutputChannel, window as Window } from 'vscode';
const outputChannel: OutputChannel = Window.createOutputChannel('npm');
export { outputChannel };
示例9: activate
export function activate(context: ExtensionContext) {
// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
console.log('Congratulations, your extension "rest-client" is now active!');
let outChannel = window.createOutputChannel('REST');
let statusBarItem = window.createStatusBarItem(StatusBarAlignment.Left)
let restClientSettings = new RestClientSettings();
// The command has been defined in the package.json file
// Now provide the implementation of the command with registerCommand
// The commandId parameter must match the command field in package.json
let disposable = commands.registerCommand('rest-client.request', () => {
let editor = window.activeTextEditor;
if (!editor || !editor.document) {
return;
}
// Get selected text of selected lines or full document
let selectedText: string;
if (editor.selection.isEmpty) {
selectedText = editor.document.getText();
} else {
selectedText = editor.document.getText(editor.selection);
}
if (selectedText === '') {
return;
}
if (restClientSettings.clearOutput) {
outChannel.clear();
}
// clear status bar
statusBarItem.text = `$(cloud-upload)`;
statusBarItem.show();
// parse http request
let httpRequest = RequestParser.parseHttpRequest(selectedText);
if (!httpRequest) {
return;
}
// set http request
let httpClient = new HttpClient(restClientSettings);
httpClient.send(httpRequest)
.then(response => {
let output = `HTTP/${response.httpVersion} ${response.statusCode} ${response.statusMessage}\n`
for (var header in response.headers) {
if (response.headers.hasOwnProperty(header)) {
var value = response.headers[header];
output += `${header}: ${value}\n`
}
}
let body = response.body;
let contentType = response.headers['content-type'];
if (contentType) {
let type = MimeUtility.parse(contentType).type;
if (type === 'application/json') {
body = JSON.stringify(JSON.parse(body), null, 4);
}
}
output += `\n${body}`;
outChannel.appendLine(`${output}\n`);
outChannel.show(true);
statusBarItem.text = ` $(clock) ${response.elapsedMillionSeconds}ms`;
statusBarItem.tooltip = 'duration';
})
.catch(error => {
statusBarItem.text = '';
outChannel.appendLine(`${error}\n`);
outChannel.show(true);
});
});
context.subscriptions.push(disposable);
}
示例10: getOutputChannel
export function getOutputChannel(): vscode.OutputChannel {
if (outputChannel == undefined) {
outputChannel = vscode.window.createOutputChannel("C/C++");
}
return outputChannel;
}