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


TypeScript modes.DocumentSymbolProviderRegistry類代碼示例

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


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

示例1: getDocumentSymbols

export function getDocumentSymbols(model: IModel): TPromise<IOutline> {

	let entries: SymbolInformation[] = [];

	let promises = DocumentSymbolProviderRegistry.all(model).map(support => {

		return asWinJsPromise((token) => {
			return support.provideDocumentSymbols(model, token);
		}).then(result => {
			if (Array.isArray(result)) {
				entries.push(...result);
			}
		}, err => {
			onUnexpectedExternalError(err);
		});
	});

	return TPromise.join(promises).then(() => {
		let flatEntries: SymbolInformation[] = [];
		flatten(flatEntries, entries, '');
		flatEntries.sort(compareEntriesUsingStart);

		return {
			entries: flatEntries,
		};
	});
}
開發者ID:StateFarmIns,項目名稱:vscode,代碼行數:27,代碼來源:quickOpen.ts

示例2: getDocumentSymbols

export function getDocumentSymbols(model: ITextModel, flat: boolean, token: CancellationToken): Promise<DocumentSymbol[]> {

	let roots: DocumentSymbol[] = [];

	let promises = DocumentSymbolProviderRegistry.all(model).map(support => {

		return Promise.resolve(support.provideDocumentSymbols(model, token)).then(result => {
			if (Array.isArray(result)) {
				roots.push(...result);
			}
		}, err => {
			onUnexpectedExternalError(err);
		});
	});

	return Promise.all(promises).then(() => {
		let flatEntries: DocumentSymbol[] = [];
		if (token.isCancellationRequested) {
			return flatEntries;
		}
		if (flat) {
			flatten(flatEntries, roots, '');
		} else {
			flatEntries = roots;
		}
		flatEntries.sort(compareEntriesUsingStart);
		return flatEntries;
	});
}
開發者ID:PKRoma,項目名稱:vscode,代碼行數:29,代碼來源:quickOpen.ts

示例3: test

	test('OutlineModel#create, cached/cancel', async function () {

		let model = TextModel.createFromString('foo', undefined, undefined, URI.file('/fome/path.foo'));
		let isCancelled = false;

		let reg = DocumentSymbolProviderRegistry.register({ pattern: '**/path.foo' }, {
			provideDocumentSymbols(d, token) {
				return new Promise(resolve => {
					token.onCancellationRequested(_ => {
						isCancelled = true;
						resolve(null);
					});
				});
			}
		});

		assert.equal(isCancelled, false);
		let s1 = new CancellationTokenSource();
		OutlineModel.create(model, s1.token);
		let s2 = new CancellationTokenSource();
		OutlineModel.create(model, s2.token);

		s1.cancel();
		assert.equal(isCancelled, false);

		s2.cancel();
		assert.equal(isCancelled, true);

		reg.dispose();
	});
開發者ID:burhandodhy,項目名稱:azuredatastudio,代碼行數:30,代碼來源:outlineModel.test.ts

示例4: supported

	public supported(accessor:ServicesAccessor, editor:ICommonCodeEditor): boolean {
		if (!super.supported(accessor, editor)) {
			return false;
		}

		return DocumentSymbolProviderRegistry.has(editor.getModel());
	}
開發者ID:aarondandy,項目名稱:vscode,代碼行數:7,代碼來源:quickOutline.ts

示例5: constructor

	constructor(
		editor: ICommonCodeEditor,
		contextKeyService: IContextKeyService
	) {
		super();
		this._editor = editor;

		this._langId = EditorContextKeys.languageId.bindTo(contextKeyService);
		this._hasCompletionItemProvider = EditorContextKeys.hasCompletionItemProvider.bindTo(contextKeyService);
		this._hasCodeActionsProvider = EditorContextKeys.hasCodeActionsProvider.bindTo(contextKeyService);
		this._hasCodeLensProvider = EditorContextKeys.hasCodeLensProvider.bindTo(contextKeyService);
		this._hasDefinitionProvider = EditorContextKeys.hasDefinitionProvider.bindTo(contextKeyService);
		this._hasImplementationProvider = EditorContextKeys.hasImplementationProvider.bindTo(contextKeyService);
		this._hasTypeDefinitionProvider = EditorContextKeys.hasTypeDefinitionProvider.bindTo(contextKeyService);
		this._hasHoverProvider = EditorContextKeys.hasHoverProvider.bindTo(contextKeyService);
		this._hasDocumentHighlightProvider = EditorContextKeys.hasDocumentHighlightProvider.bindTo(contextKeyService);
		this._hasDocumentSymbolProvider = EditorContextKeys.hasDocumentSymbolProvider.bindTo(contextKeyService);
		this._hasReferenceProvider = EditorContextKeys.hasReferenceProvider.bindTo(contextKeyService);
		this._hasRenameProvider = EditorContextKeys.hasRenameProvider.bindTo(contextKeyService);
		this._hasDocumentFormattingProvider = EditorContextKeys.hasDocumentFormattingProvider.bindTo(contextKeyService);
		this._hasDocumentSelectionFormattingProvider = EditorContextKeys.hasDocumentSelectionFormattingProvider.bindTo(contextKeyService);
		this._hasSignatureHelpProvider = EditorContextKeys.hasSignatureHelpProvider.bindTo(contextKeyService);
		this._isInWalkThrough = EditorContextKeys.isInEmbeddedEditor.bindTo(contextKeyService);

		const update = () => this._update();

		// update when model/mode changes
		this._register(editor.onDidChangeModel(update));
		this._register(editor.onDidChangeModelLanguage(update));

		// update when registries change
		this._register(modes.SuggestRegistry.onDidChange(update));
		this._register(modes.CodeActionProviderRegistry.onDidChange(update));
		this._register(modes.CodeLensProviderRegistry.onDidChange(update));
		this._register(modes.DefinitionProviderRegistry.onDidChange(update));
		this._register(modes.ImplementationProviderRegistry.onDidChange(update));
		this._register(modes.TypeDefinitionProviderRegistry.onDidChange(update));
		this._register(modes.HoverProviderRegistry.onDidChange(update));
		this._register(modes.DocumentHighlightProviderRegistry.onDidChange(update));
		this._register(modes.DocumentSymbolProviderRegistry.onDidChange(update));
		this._register(modes.ReferenceProviderRegistry.onDidChange(update));
		this._register(modes.RenameProviderRegistry.onDidChange(update));
		this._register(modes.DocumentFormattingEditProviderRegistry.onDidChange(update));
		this._register(modes.DocumentRangeFormattingEditProviderRegistry.onDidChange(update));
		this._register(modes.SignatureHelpProviderRegistry.onDidChange(update));

		update();
	}
開發者ID:Chan-PH,項目名稱:vscode,代碼行數:48,代碼來源:editorModeContext.ts

示例6: run

	public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): TPromise<void> {

		let model = editor.getModel();

		if (!DocumentSymbolProviderRegistry.has(model)) {
			return null;
		}

		// Resolve outline
		return getDocumentSymbols(model).then((result: IOutline) => {
			if (result.entries.length === 0) {
				return;
			}

			this._run(editor, result.entries);
		});
	}
開發者ID:BlackstarSoon,項目名稱:vscode,代碼行數:17,代碼來源:quickOutline.ts

示例7: run

	public run(accessor: ServicesAccessor, editor: ICodeEditor): Thenable<void> {

		let model = editor.getModel();

		if (!DocumentSymbolProviderRegistry.has(model)) {
			return null;
		}

		// Resolve outline
		return getDocumentSymbols(model, true, CancellationToken.None).then((result: DocumentSymbol[]) => {
			if (result.length === 0) {
				return;
			}

			this._run(editor, result);
		});
	}
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:17,代碼來源:quickOutline.ts

示例8: getDocumentSymbols

export function getDocumentSymbols(model: ITextModel): TPromise<DocumentSymbol[]> {

	let roots: DocumentSymbol[] = [];

	let promises = DocumentSymbolProviderRegistry.all(model).map(support => {

		return asWinJsPromise(token => support.provideDocumentSymbols(model, token)).then(result => {
			if (Array.isArray(result)) {
				roots.push(...result);
			}
		}, err => {
			onUnexpectedExternalError(err);
		});
	});

	return TPromise.join(promises).then(() => {
		let flatEntries: DocumentSymbol[] = [];
		flatten(flatEntries, roots, '');
		flatEntries.sort(compareEntriesUsingStart);
		return flatEntries;
	});
}
開發者ID:burhandodhy,項目名稱:azuredatastudio,代碼行數:22,代碼來源:quickOpen.ts

示例9: _update

	private _update() {
		const model = this._editor.getModel();
		if (!model) {
			this.reset();
			return;
		}
		this._langId.set(model.getLanguageIdentifier().language);
		this._hasCompletionItemProvider.set(modes.SuggestRegistry.has(model));
		this._hasCodeActionsProvider.set(modes.CodeActionProviderRegistry.has(model));
		this._hasCodeLensProvider.set(modes.CodeLensProviderRegistry.has(model));
		this._hasDefinitionProvider.set(modes.DefinitionProviderRegistry.has(model));
		this._hasImplementationProvider.set(modes.ImplementationProviderRegistry.has(model));
		this._hasTypeDefinitionProvider.set(modes.TypeDefinitionProviderRegistry.has(model));
		this._hasHoverProvider.set(modes.HoverProviderRegistry.has(model));
		this._hasDocumentHighlightProvider.set(modes.DocumentHighlightProviderRegistry.has(model));
		this._hasDocumentSymbolProvider.set(modes.DocumentSymbolProviderRegistry.has(model));
		this._hasReferenceProvider.set(modes.ReferenceProviderRegistry.has(model));
		this._hasRenameProvider.set(modes.RenameProviderRegistry.has(model));
		this._hasSignatureHelpProvider.set(modes.SignatureHelpProviderRegistry.has(model));
		this._hasDocumentFormattingProvider.set(modes.DocumentFormattingEditProviderRegistry.has(model) || modes.DocumentRangeFormattingEditProviderRegistry.has(model));
		this._hasDocumentSelectionFormattingProvider.set(modes.DocumentRangeFormattingEditProviderRegistry.has(model));
		this._isInWalkThrough.set(model.uri.scheme === Schemas.walkThroughSnippet);
	}
開發者ID:Chan-PH,項目名稱:vscode,代碼行數:23,代碼來源:editorModeContext.ts


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