當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript vscode.Disposable類代碼示例

本文整理匯總了TypeScript中vscode.Disposable的典型用法代碼示例。如果您正苦於以下問題:TypeScript Disposable類的具體用法?TypeScript Disposable怎麽用?TypeScript Disposable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Disposable類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: 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);
}
開發者ID:peterblazejewicz,項目名稱:omnisharp-vscode,代碼行數:34,代碼來源:commands.ts

示例2: 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
    );
}
開發者ID:martinandersen3d,項目名稱:funcList,代碼行數:28,代碼來源:extension.ts

示例3: 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);
    }
開發者ID:chrisleaman,項目名稱:vscode-gitlens,代碼行數:32,代碼來源:lineHoverController.ts

示例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);
        }
    }
開發者ID:chrisleaman,項目名稱:vscode-gitlens,代碼行數:34,代碼來源:vsls.ts

示例5: 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),
		);
	});
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:7,代碼來源:formatting.ts

示例6: 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);
    }
開發者ID:eamodio,項目名稱:vscode-git-codelens,代碼行數:33,代碼來源:blameAnnotationProvider.ts

示例7: registerDiagnosticProvider

export function registerDiagnosticProvider(selector: vscode.DocumentSelector, provider: DiagnosticProvider, name: string) : vscode.Disposable {
    let collection: vscode.DiagnosticCollection = vscode.languages.createDiagnosticCollection(name);
    let cancellers = new Map<string, vscode.CancellationTokenSource>();
    let subsctiptions: vscode.Disposable[] = [];
    vscode.workspace.onDidChangeTextDocument((change) => {
        if (!vscode.languages.match(selector, change.document)) return;
        const uri = change.document.uri;
        const uriStr = uri.toString();
        if (cancellers.has(uriStr)) {
            cancellers.get(uriStr).dispose();
        }
        cancellers.set(uriStr, new vscode.CancellationTokenSource);
        delay(cancellers.get(uriStr).token).then(() => {
            cancellers.get(uriStr).dispose();
            cancellers.set(uriStr, new vscode.CancellationTokenSource);
            return provider.provideDiagnostic(change.document, cancellers.get(uriStr).token);
        }).then((diagnostics) => {
            cancellers.get(uriStr).dispose();
            cancellers.delete(uriStr);
            collection.set(uri, diagnostics);
        }, (_) => { /* do nothing */ });
    }, null, subsctiptions);
    return {
        dispose() {
            collection.dispose();
            for (let canceller of Array.from(cancellers.values())) {
                canceller.dispose();
            }
            vscode.Disposable.from(...subsctiptions).dispose();
        }
    };
}
開發者ID:alloy,項目名稱:vscode-clang,代碼行數:32,代碼來源:diagnostic.ts

示例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);
}
開發者ID:appTimesTV,項目名稱:vscode-cpptools,代碼行數:31,代碼來源:extension.ts

示例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);
}
開發者ID:tmat,項目名稱:omnisharp-vscode,代碼行數:25,代碼來源:changeForwarding.ts

示例10: onPanelDisposed

  private onPanelDisposed() {
    if (this.disposablePanel) {
      this.disposablePanel.dispose();
    }

    this.panel = undefined;
  }
開發者ID:Manu-sh,項目名稱:dotfiles,代碼行數:7,代碼來源:Webview.ts


注:本文中的vscode.Disposable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。