当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript URI.isUri方法代码示例

本文整理汇总了TypeScript中vs/base/common/uri.URI.isUri方法的典型用法代码示例。如果您正苦于以下问题:TypeScript URI.isUri方法的具体用法?TypeScript URI.isUri怎么用?TypeScript URI.isUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vs/base/common/uri.URI的用法示例。


在下文中一共展示了URI.isUri方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getResourceForCommand

export function getResourceForCommand(resource: URI | object | undefined, listService: IListService, editorService: IEditorService): URI | undefined {
	if (URI.isUri(resource)) {
		return resource;
	}

	let list = listService.lastFocusedList;
	if (list && list.getHTMLElement() === document.activeElement) {
		let focus: unknown;
		if (list instanceof List) {
			const focused = list.getFocusedElements();
			if (focused.length) {
				focus = focused[0];
			}
		} else if (list instanceof WorkbenchAsyncDataTree) {
			const focused = list.getFocus();
			if (focused.length) {
				focus = focused[0];
			}
		}

		if (focus instanceof ExplorerItem) {
			return focus.resource;
		} else if (focus instanceof OpenEditor) {
			return focus.getResource();
		}
	}

	return editorService.activeEditor ? toResource(editorService.activeEditor, { supportSideBySide: SideBySideEditor.MASTER }) : undefined;
}
开发者ID:PKRoma,项目名称:vscode,代码行数:29,代码来源:files.ts

示例2: getResourceForCommand

export function getResourceForCommand(resource: URI | object, listService: IListService, editorService: IEditorService): URI {
	if (URI.isUri(resource)) {
		return resource;
	}

	let list = listService.lastFocusedList;
	if (list && list.getHTMLElement() === document.activeElement) {
		let focus: any;
		if (list instanceof List) {
			const focused = list.getFocusedElements();
			if (focused.length) {
				focus = focused[0];
			}
		} else {
			focus = list.getFocus();
		}

		if (focus instanceof ExplorerItem) {
			return focus.resource;
		} else if (focus instanceof OpenEditor) {
			return focus.getResource();
		}
	}

	return toResource(editorService.activeEditor, { supportSideBySide: true });
}
开发者ID:DonJayamanne,项目名称:vscode,代码行数:26,代码来源:files.ts

示例3: getMultiSelectedResources

export function getMultiSelectedResources(resource: URI | object | undefined, listService: IListService, editorService: IEditorService): Array<URI> {
	const list = listService.lastFocusedList;
	if (list && list.getHTMLElement() === document.activeElement) {
		// Explorer
		if (list instanceof WorkbenchAsyncDataTree) {
			const selection = list.getSelection().map((fs: ExplorerItem) => fs.resource);
			const focusedElements = list.getFocus();
			const focus = focusedElements.length ? focusedElements[0] : undefined;
			const mainUriStr = URI.isUri(resource) ? resource.toString() : focus instanceof ExplorerItem ? focus.resource.toString() : undefined;
			// If the resource is passed it has to be a part of the returned context.
			// We only respect the selection if it contains the focused element.
			if (selection.some(s => URI.isUri(s) && s.toString() === mainUriStr)) {
				return selection;
			}
		}

		// Open editors view
		if (list instanceof List) {
			const selection = coalesce(list.getSelectedElements().filter(s => s instanceof OpenEditor).map((oe: OpenEditor) => oe.getResource()));
			const focusedElements = list.getFocusedElements();
			const focus = focusedElements.length ? focusedElements[0] : undefined;
			let mainUriStr: string | undefined = undefined;
			if (URI.isUri(resource)) {
				mainUriStr = resource.toString();
			} else if (focus instanceof OpenEditor) {
				const focusedResource = focus.getResource();
				mainUriStr = focusedResource ? focusedResource.toString() : undefined;
			}
			// We only respect the selection if it contains the main element.
			if (selection.some(s => s.toString() === mainUriStr)) {
				return selection;
			}
		}
	}

	const result = getResourceForCommand(resource, listService, editorService);
	return !!result ? [result] : [];
}
开发者ID:eamodio,项目名称:vscode,代码行数:38,代码来源:files.ts

示例4: isTextChange

		function isTextChange(thing: [URI, types.TextEdit[]] | [URI?, URI?, { overwrite?: boolean }?]): thing is [URI, types.TextEdit[]] {
			const [f, s] = thing;
			return URI.isUri(f) && Array.isArray(s);
		}
开发者ID:eamodio,项目名称:vscode,代码行数:4,代码来源:extHostTypes.test.ts

示例5:

		let p = Event.toPromise(emitter.event).then(a => {
			assert.equal(a.length, 1);
			assert.equal(a[0].toString(), 'aa:bb');
			assert.ok(URI.isUri(a[0]));
		});
开发者ID:VishalMadhvani,项目名称:vscode,代码行数:5,代码来源:extHostDiagnostics.test.ts

示例6:

			if (selection.some(s => URI.isUri(s) && s.toString() === mainUriStr)) {
开发者ID:ramesius,项目名称:vscode,代码行数:1,代码来源:files.ts

示例7: isFileChange

		function isFileChange(thing: [URI, types.TextEdit[]] | [URI, URI, { overwrite?: boolean }]): thing is [URI, URI, { overwrite?: boolean }] {
			const [f, s] = thing;
			return URI.isUri(f) && URI.isUri(s);
		}
开发者ID:KTXSoftware,项目名称:KodeStudio,代码行数:4,代码来源:extHostTypes.test.ts


注:本文中的vs/base/common/uri.URI.isUri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。