本文整理汇总了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;未经允许,请勿转载。 |
请发表评论