本文整理汇总了TypeScript中vscode.Disposable.from方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Disposable.from方法的具体用法?TypeScript Disposable.from怎么用?TypeScript Disposable.from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode.Disposable
的用法示例。
在下文中一共展示了Disposable.from方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: registerCommands
export default function registerCommands(server: OmniSharpServer, reporter: TelemetryReporter, channel: vscode.OutputChannel) {
let d1 = vscode.commands.registerCommand('o.restart', () => restartOmniSharp(server));
let d2 = vscode.commands.registerCommand('o.pickProjectAndStart', () => pickProjectAndStart(server));
let d3 = vscode.commands.registerCommand('o.showOutput', () => server.getChannel().show(vscode.ViewColumn.Three));
let d4 = vscode.commands.registerCommand('dotnet.restore', () => dotnetRestoreAllProjects(server));
// register empty handler for csharp.installDebugger
// running the command activates the extension, which is all we need for installation to kickoff
let d5 = vscode.commands.registerCommand('csharp.downloadDebugger', () => { });
// register process picker for attach
let attachItemsProvider = DotNetAttachItemsProviderFactory.Get();
let attacher = new AttachPicker(attachItemsProvider);
let d6 = vscode.commands.registerCommand('csharp.listProcess', () => attacher.ShowAttachEntries());
// Register command for generating tasks.json and launch.json assets.
let d7 = vscode.commands.registerCommand('dotnet.generateAssets', () => generateAssets(server));
// Register command for remote process picker for attach
let d8 = vscode.commands.registerCommand('csharp.listRemoteProcess', (args) => RemoteAttachPicker.ShowAttachEntries(args));
// Register command for adapter executable command.
let d9 = vscode.commands.registerCommand('csharp.coreclrAdapterExecutableCommand', (args) => getAdapterExecutionCommand(channel));
let d10 = vscode.commands.registerCommand('csharp.clrAdapterExecutableCommand', (args) => getAdapterExecutionCommand(channel));
return vscode.Disposable.from(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10);
}
示例2: ConfigurationDependentRegistration
return new ConfigurationDependentRegistration(modeId, 'format.enable', () => {
const formattingProvider = new TypeScriptFormattingProvider(client, fileConfigurationManager);
return vscode.Disposable.from(
vscode.languages.registerOnTypeFormattingEditProvider(selector, formattingProvider, ';', '}', '\n'),
vscode.languages.registerDocumentRangeFormattingEditProvider(selector, formattingProvider),
);
});
示例3: activate
export function activate(context: ExtensionContext)
{
const provider = new ContentProvider();
const providerRegistrations = Disposable.from(
workspace.registerTextDocumentContentProvider(ContentProvider.scheme, provider)
);
const commandRegistration = commands.registerTextEditorCommand('editor.printFunctions', editor => {
return provider.newDocument(editor);
});
let contextMenuSwitchSort = commands.registerCommand('contextmenu.switchSort', () => {
provider.updateDocument(true);
});
let contextMenuRefresh = commands.registerCommand('contextmenu.refresh', () => {
provider.updateDocument(false);
});
context.subscriptions.push(
provider,
commandRegistration,
contextMenuSwitchSort,
contextMenuRefresh,
providerRegistrations
);
}
示例4: initialize
private async initialize() {
try {
// If we have a vsls: workspace open, we might be a guest, so wait until live share transitions into a mode
if (
workspace.workspaceFolders !== undefined &&
workspace.workspaceFolders.some(f => f.uri.scheme === DocumentSchemes.Vsls)
) {
setCommandContext(CommandContext.Readonly, true);
this._waitForReady = new Promise(resolve => (this._onReady = resolve));
}
this._api = getApi();
const api = await this._api;
if (api == null) {
setCommandContext(CommandContext.Vsls, false);
// Tear it down if we can't talk to live share
if (this._onReady !== undefined) {
this._onReady();
this._waitForReady = undefined;
}
return;
}
setCommandContext(CommandContext.Vsls, true);
this._disposable = Disposable.from(
api.onDidChangeSession(e => this.onLiveShareSessionChanged(api, e), this)
);
}
catch (ex) {
Logger.error(ex);
}
}
示例5: registerCommands
export default function registerCommands(server: OmniSharpServer, eventStream: EventStream, platformInfo: PlatformInformation) {
let d1 = vscode.commands.registerCommand('o.restart', () => restartOmniSharp(server));
let d2 = vscode.commands.registerCommand('o.pickProjectAndStart', () => pickProjectAndStart(server));
let d3 = vscode.commands.registerCommand('o.showOutput', () => eventStream.post(new CommandShowOutput()));
let d4 = vscode.commands.registerCommand('dotnet.restore', fileName => {
if (fileName) {
dotnetRestoreForProject(server, fileName, eventStream);
}
else {
dotnetRestoreAllProjects(server, eventStream);
}
});
// register empty handler for csharp.installDebugger
// running the command activates the extension, which is all we need for installation to kickoff
let d5 = vscode.commands.registerCommand('csharp.downloadDebugger', () => { });
// register process picker for attach
let attachItemsProvider = DotNetAttachItemsProviderFactory.Get();
let attacher = new AttachPicker(attachItemsProvider);
let d6 = vscode.commands.registerCommand('csharp.listProcess', async () => attacher.ShowAttachEntries());
// Register command for generating tasks.json and launch.json assets.
let d7 = vscode.commands.registerCommand('dotnet.generateAssets', async () => generateAssets(server));
// Register command for remote process picker for attach
let d8 = vscode.commands.registerCommand('csharp.listRemoteProcess', async (args) => RemoteAttachPicker.ShowAttachEntries(args));
// Register command for adapter executable command.
let d9 = vscode.commands.registerCommand('csharp.coreclrAdapterExecutableCommand', async (args) => getAdapterExecutionCommand(platformInfo, eventStream));
let d10 = vscode.commands.registerCommand('csharp.clrAdapterExecutableCommand', async (args) => getAdapterExecutionCommand(platformInfo, eventStream));
return vscode.Disposable.from(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10);
}
示例6: register
private register(editor: TextEditor | undefined) {
this.unregister();
if (editor === undefined) return;
const cfg = Container.config.hovers;
if (!cfg.enabled || !cfg.currentLine.enabled || (!cfg.currentLine.details && !cfg.currentLine.changes)) return;
const subscriptions = [];
if (cfg.currentLine.changes) {
subscriptions.push(
languages.registerHoverProvider(
{ pattern: editor.document.uri.fsPath },
{
provideHover: this.provideChangesHover.bind(this)
}
)
);
}
if (cfg.currentLine.details) {
subscriptions.push(
languages.registerHoverProvider(
{ pattern: editor.document.uri.fsPath },
{
provideHover: this.provideDetailsHover.bind(this)
}
)
);
}
this._hoverProviderDisposable = Disposable.from(...subscriptions);
}
示例7: registerHoverProviders
registerHoverProviders(providers: { details: boolean; changes: boolean }) {
if (
!Container.config.hovers.enabled ||
!Container.config.hovers.annotations.enabled ||
(!providers.details && !providers.changes)
) {
return;
}
const subscriptions: Disposable[] = [];
if (providers.changes) {
subscriptions.push(
languages.registerHoverProvider(
{ pattern: this.document.uri.fsPath },
{
provideHover: this.provideChangesHover.bind(this)
}
)
);
}
if (providers.details) {
subscriptions.push(
languages.registerHoverProvider(
{ pattern: this.document.uri.fsPath },
{
provideHover: this.provideDetailsHover.bind(this)
}
)
);
}
this._hoverProviderDisposable = Disposable.from(...subscriptions);
}
示例8: initialize
export function initialize(): void {
// Activate Process Picker Commands
let attachItemsProvider: AttachItemsProvider = NativeAttachItemsProviderFactory.Get();
let attacher: AttachPicker = new AttachPicker(attachItemsProvider);
disposables.push(vscode.commands.registerCommand('extension.pickNativeProcess', () => attacher.ShowAttachEntries()));
let remoteAttacher: RemoteAttachPicker = new RemoteAttachPicker();
disposables.push(vscode.commands.registerCommand('extension.pickRemoteNativeProcess', (any) => remoteAttacher.ShowAttachEntries(any)));
// Activate ConfigurationProvider
let configurationProvider: IConfigurationAssetProvider = ConfigurationAssetProviderFactory.getConfigurationProvider();
// On non-windows platforms, the cppvsdbg debugger will not be registered for initial configurations.
// This will cause it to not show up on the dropdown list.
if (os.platform() === 'win32') {
disposables.push(vscode.debug.registerDebugConfigurationProvider('cppvsdbg', new CppVsDbgConfigurationProvider(configurationProvider)));
}
disposables.push(vscode.debug.registerDebugConfigurationProvider('cppdbg', new CppDbgConfigurationProvider(configurationProvider)));
configurationProvider.getConfigurationSnippets();
const launchJsonDocumentSelector: vscode.DocumentSelector = [{
language: 'jsonc',
pattern: '**/launch.json'
}];
// ConfigurationSnippetProvider needs to be initiallized after configurationProvider calls getConfigurationSnippets.
disposables.push(vscode.languages.registerCompletionItemProvider(launchJsonDocumentSelector, new ConfigurationSnippetProvider(configurationProvider)));
// Activate Adapter Commands
registerAdapterExecutableCommands();
vscode.Disposable.from(...disposables);
}
示例9: forwardFileChanges
function forwardFileChanges(server: OmniSharpServer): Disposable {
function onFileSystemEvent(changeType: FileChangeType): (Uri) => void {
return function(uri: Uri)
{
if (!server.isRunning()) {
return;
}
let req = { FileName: uri.fsPath, changeType};
serverUtils.filesChanged(server, [req]).catch(err => {
console.warn(`[o] failed to forward file change event for ${uri.fsPath}`, err);
return err;
});
};
}
const watcher = workspace.createFileSystemWatcher('**/*.*');
let d1 = watcher.onDidCreate(onFileSystemEvent(FileChangeType.Create));
let d2 = watcher.onDidDelete(onFileSystemEvent(FileChangeType.Delete));
let d3 = watcher.onDidChange(onFileSystemEvent(FileChangeType.Change));
return Disposable.from(watcher, d1, d2, d3);
}
示例10: forwardChanges
export default function forwardChanges(server: OmnisharpServer): Disposable {
// combine file watching and text document watching
return Disposable.from(
forwardDocumentChanges(server),
forwardFileChanges(server));
}