• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript uri.URI类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: save

function save(
	resource: URI,
	isSaveAs: boolean,
	options: ISaveOptions,
	editorService: IEditorService,
	fileService: IFileService,
	untitledEditorService: IUntitledEditorService,
	textFileService: ITextFileService,
	editorGroupService: IEditorGroupsService
): TPromise<any> {

	function ensureForcedSave(options?: ISaveOptions): ISaveOptions {
		if (!options) {
			options = { force: true };
		} else {
			options.force = true;
		}

		return options;
	}

	if (resource && (fileService.canHandleResource(resource) || resource.scheme === Schemas.untitled)) {

		// Save As (or Save untitled with associated path)
		if (isSaveAs || resource.scheme === Schemas.untitled) {
			let encodingOfSource: string;
			if (resource.scheme === Schemas.untitled) {
				encodingOfSource = untitledEditorService.getEncoding(resource);
			} else if (fileService.canHandleResource(resource)) {
				const textModel = textFileService.models.get(resource);
				encodingOfSource = textModel && textModel.getEncoding(); // text model can be null e.g. if this is a binary file!
			}

			let viewStateOfSource: IEditorViewState;
			const activeTextEditorWidget = getCodeEditor(editorService.activeTextEditorWidget);
			if (activeTextEditorWidget) {
				const activeResource = toResource(editorService.activeEditor, { supportSideBySide: true });
				if (activeResource && (fileService.canHandleResource(activeResource) || resource.scheme === Schemas.untitled) && activeResource.toString() === resource.toString()) {
					viewStateOfSource = activeTextEditorWidget.saveViewState();
				}
			}

			// Special case: an untitled file with associated path gets saved directly unless "saveAs" is true
			let savePromise: TPromise<URI>;
			if (!isSaveAs && resource.scheme === Schemas.untitled && untitledEditorService.hasAssociatedFilePath(resource)) {
				savePromise = textFileService.save(resource, options).then((result) => {
					if (result) {
						return resource.with({ scheme: Schemas.file });
					}

					return null;
				});
			}

			// Otherwise, really "Save As..."
			else {

				// Force a change to the file to trigger external watchers if any
				// fixes https://github.com/Microsoft/vscode/issues/59655
				options = ensureForcedSave(options);

				savePromise = textFileService.saveAs(resource, void 0, options);
			}

			return savePromise.then((target) => {
				if (!target || target.toString() === resource.toString()) {
					return void 0; // save canceled or same resource used
				}

				const replacement: IResourceInput = {
					resource: target,
					encoding: encodingOfSource,
					options: {
						pinned: true,
						viewState: viewStateOfSource
					}
				};

				return Promise.all(editorGroupService.groups.map(g =>
					editorService.replaceEditors([{
						editor: { resource },
						replacement
					}], g))).then(() => true);
			});
		}

		// Pin the active editor if we are saving it
		const activeControl = editorService.activeControl;
		const activeEditorResource = activeControl && activeControl.input && activeControl.input.getResource();
		if (activeEditorResource && activeEditorResource.toString() === resource.toString()) {
			activeControl.group.pinEditor(activeControl.input);
		}

		// Just save (force a change to the file to trigger external watchers if any)
		options = ensureForcedSave(options);

		return textFileService.save(resource, options);
	}

	return Promise.resolve(false);
//.........这里部分代码省略.........
开发者ID:DonJayamanne,项目名称:vscode,代码行数:101,代码来源:fileCommands.ts


示例2: test

	test('merging change events', () => {
		let event1 = new ConfigurationChangeEvent().change(['window.zoomLevel', 'files']);
		let event2 = new ConfigurationChangeEvent().change(['window.title'], URI.file('file1')).change(['[markdown]']);

		let actual = event1.change(event2);

		assert.deepEqual(actual.affectedKeys, ['window.zoomLevel', 'files', '[markdown]', 'window.title']);

		assert.ok(actual.affectsConfiguration('window.zoomLevel'));
		assert.ok(actual.affectsConfiguration('window.zoomLevel', URI.file('file1')));
		assert.ok(actual.affectsConfiguration('window.zoomLevel', URI.file('file2')));

		assert.ok(actual.affectsConfiguration('window'));
		assert.ok(actual.affectsConfiguration('window', URI.file('file1')));
		assert.ok(actual.affectsConfiguration('window', URI.file('file2')));

		assert.ok(actual.affectsConfiguration('files'));
		assert.ok(actual.affectsConfiguration('files', URI.file('file1')));
		assert.ok(actual.affectsConfiguration('files', URI.file('file2')));

		assert.ok(actual.affectsConfiguration('window.title'));
		assert.ok(actual.affectsConfiguration('window.title', URI.file('file1')));
		assert.ok(!actual.affectsConfiguration('window.title', URI.file('file2')));

		assert.ok(actual.affectsConfiguration('[markdown]'));
		assert.ok(actual.affectsConfiguration('[markdown]', URI.file('file1')));
		assert.ok(actual.affectsConfiguration('[markdown]', URI.file('file2')));
	});
开发者ID:eamodio,项目名称:vscode,代码行数:28,代码来源:configurationModels.test.ts


示例3: aRawMatch

	function aRawMatch(resource: string, ...matches: ITextSearchResult[]): IFileMatch {
		return { resource: URI.parse(resource), matches };
	}
开发者ID:DonJayamanne,项目名称:vscode,代码行数:3,代码来源:searchResult.test.ts


示例4: test

	test('dirname', () => {
		if (isWindows) {
			assert.equal(dirname(URI.file('c:\\some\\file\\test.txt'))!.toString(), 'file:///c%3A/some/file');
			assert.equal(dirname(URI.file('c:\\some\\file'))!.toString(), 'file:///c%3A/some');
			assert.equal(dirname(URI.file('c:\\some\\file\\'))!.toString(), 'file:///c%3A/some');
			assert.equal(dirname(URI.file('c:\\some'))!.toString(), 'file:///c%3A/');
			assert.equal(dirname(URI.file('C:\\some'))!.toString(), 'file:///c%3A/');
			assert.equal(dirname(URI.file('c:\\'))!.toString(), 'file:///c%3A/');
		} else {
			assert.equal(dirname(URI.file('/some/file/test.txt'))!.toString(), 'file:///some/file');
			assert.equal(dirname(URI.file('/some/file/'))!.toString(), 'file:///some');
			assert.equal(dirname(URI.file('/some/file'))!.toString(), 'file:///some');
		}
		assert.equal(dirname(URI.parse('foo://a/some/file/test.txt'))!.toString(), 'foo://a/some/file');
		assert.equal(dirname(URI.parse('foo://a/some/file/'))!.toString(), 'foo://a/some');
		assert.equal(dirname(URI.parse('foo://a/some/file'))!.toString(), 'foo://a/some');
		assert.equal(dirname(URI.parse('foo://a/some'))!.toString(), 'foo://a/');
		assert.equal(dirname(URI.parse('foo://a/'))!.toString(), 'foo://a/');
		assert.equal(dirname(URI.parse('foo://a'))!.toString(), 'foo://a');

		// does not explode (https://github.com/Microsoft/vscode/issues/41987)
		dirname(URI.from({ scheme: 'file', authority: '/users/someone/portal.h' }));
	});
开发者ID:VishalMadhvani,项目名称:vscode,代码行数:23,代码来源:resources.test.ts


示例5: untitledWorkspacesHome

	@memoize
	get untitledWorkspacesHome(): URI { return URI.file(path.join(this.userDataPath, 'Workspaces')); }
开发者ID:PKRoma,项目名称:vscode,代码行数:2,代码来源:environmentService.ts


示例6:

			return s.map(p => {
				if (/^[^:/?#]+?:\/\//.test(p)) {
					return URI.parse(p);
				}
				return URI.file(path.normalize(p));
			});
开发者ID:PKRoma,项目名称:vscode,代码行数:6,代码来源:environmentService.ts


示例7:

		return downloadService.download(resource, location).then(() => URI.file(location));
开发者ID:VishalMadhvani,项目名称:vscode,代码行数:1,代码来源:commands.ts


示例8:

		test('should use to the workspace if it exists', () => {
			assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, '/userHome/', Uri.file('/foo'), undefined), '/foo');
		});
开发者ID:eamodio,项目名称:vscode,代码行数:3,代码来源:terminalEnvironment.test.ts


示例9: toResource

function toResource(relativePath: string): uri {
	let basePath = getPathFromAmdModule(require, './fixtures/resolver');
	let absolutePath = relativePath ? path.join(basePath, relativePath) : basePath;

	return uri.file(absolutePath);
}
开发者ID:joelday,项目名称:vscode,代码行数:6,代码来源:resolver.test.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript uriIpc.IURITransformer类代码示例发布时间:2022-05-25
下一篇:
TypeScript uri.with函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap