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


TypeScript URI.toString方法代码示例

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


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

示例1: getMultiSelectedResources

export function getMultiSelectedResources(resource: URI | object, listService: IListService, editorService: IEditorService): URI[] {
	const list = listService.lastFocusedList;
	if (list && list.isDOMFocused()) {
		// Explorer
		if (list instanceof Tree) {
			const selection = list.getSelection().map((fs: ExplorerItem) => fs.resource);
			const focus = list.getFocus();
			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 = list.getSelectedElements().filter(s => s instanceof OpenEditor).map((oe: OpenEditor) => oe.getResource());
			const focusedElements = list.getFocusedElements();
			const focus = focusedElements.length ? focusedElements[0] : undefined;
			const mainUriStr = URI.isUri(resource) ? resource.toString() : (focus instanceof OpenEditor) ? focus.getResource().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:ramesius,项目名称:vscode,代码行数:31,代码来源:files.ts

示例2: assertResolve

	function assertResolve(u1: URI, path: string, expected: URI) {
		const actual = resolvePath(u1, path);
		assertEqualURI(actual, expected, `from ${u1.toString()} and ${path}`);

		if (!isAbsolute(path)) {
			let expectedPath = isWindows ? toSlashes(path) : path;
			expectedPath = startsWith(expectedPath, './') ? expectedPath.substr(2) : expectedPath;
			assert.equal(relativePath(u1, actual), expectedPath, `relativePath (${u1.toString()}) on actual (${actual.toString()}) should be to path (${expectedPath})`);
		}
	}
开发者ID:eamodio,项目名称:vscode,代码行数:10,代码来源:resources.test.ts

示例3: isEqual

export function isEqual(first: URI | undefined, second: URI | undefined, ignoreCase = hasToIgnoreCase(first)): boolean {
	const identityEquals = (first === second);
	if (identityEquals) {
		return true;
	}

	if (!first || !second) {
		return false;
	}

	if (ignoreCase) {
		return equalsIgnoreCase(first.toString(), second.toString());
	}

	return first.toString() === second.toString();
}
开发者ID:donaldpipowitch,项目名称:vscode,代码行数:16,代码来源:resources.ts

示例4:

		return data.document.save().then(() => {
			assert.equal(saved.toString(), 'foo:bar');

			data.dispose();

			return data.document.save().then(() => {
				assert.ok(false, 'expected failure');
			}, err => {
				assert.ok(err);
			});
		});
开发者ID:DonJayamanne,项目名称:vscode,代码行数:11,代码来源:extHostDocumentData.test.ts

示例5: 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

示例6: function

CommandsRegistry.registerCommand('_workbench.previewHtml', function (
	accessor: ServicesAccessor,
	resource: URI | string,
	position?: EditorViewColumn,
	label?: string
) {
	const uri = resource instanceof URI ? resource : URI.parse(resource);
	label = label || uri.fsPath;

	let input: HtmlInput;

	const editorGroupService = accessor.get(IEditorGroupsService);

	let targetGroup: IEditorGroup = editorGroupService.getGroup(viewColumnToEditorGroup(editorGroupService, position));
	if (!targetGroup) {
		targetGroup = editorGroupService.activeGroup;
	}

	// Find already opened HTML input if any
	if (targetGroup) {
		const editors = targetGroup.editors;
		for (let i = 0; i < editors.length; i++) {
			const editor = editors[i];
			const editorResource = editor.getResource();
			if (editor instanceof HtmlInput && editorResource && editorResource.toString() === resource.toString()) {
				input = editor;
				break;
			}
		}
	}

	const extensionsWorkbenchService = accessor.get(IExtensionsWorkbenchService);

	const inputOptions: HtmlInputOptions = {
		allowScripts: true,
		allowSvgs: true,
		svgWhiteList: extensionsWorkbenchService.allowedBadgeProviders
	};

	// Otherwise, create new input and open it
	if (!input) {
		input = accessor.get(IInstantiationService).createInstance(HtmlInput, label, '', uri, inputOptions);
	} else {
		input.setName(label); // make sure to use passed in label
	}

	return accessor.get(IEditorService)
		.openEditor(input, { pinned: true }, viewColumnToEditorGroup(editorGroupService, position))
		.then(editor => true);
});
开发者ID:developers23,项目名称:vscode,代码行数:50,代码来源:html.contribution.ts

示例7: getStoredWorkspaceFolder

export function getStoredWorkspaceFolder(folderURI: URI, folderName: string | undefined, targetConfigFolderURI: URI, useSlashForPath = !isWindows): IStoredWorkspaceFolder {

	if (folderURI.scheme !== targetConfigFolderURI.scheme) {
		return { name: folderName, uri: folderURI.toString(true) };
	}

	let folderPath: string | undefined;
	if (isEqualOrParent(folderURI, targetConfigFolderURI)) {
		// use relative path
		folderPath = relativePath(targetConfigFolderURI, folderURI) || '.'; // always uses forward slashes
		if (isWindows && folderURI.scheme === Schemas.file && !useSlashForPath) {
			// Windows gets special treatment:
			// - use backslahes unless slash is used by other existing folders
			folderPath = folderPath.replace(/\//g, '\\');
		}
	} else {
		// use absolute path
		if (folderURI.scheme === Schemas.file) {
			folderPath = folderURI.fsPath;
			if (isWindows) {
				// Windows gets special treatment:
				// - normalize all paths to get nice casing of drive letters
				// - use backslahes unless slash is used by other existing folders
				folderPath = normalizeDriveLetter(folderPath);
				if (useSlashForPath) {
					folderPath = toSlashes(folderPath);
				}
			}
		} else {
			if (!isEqualAuthority(folderURI.authority, targetConfigFolderURI.authority)) {
				return { name: folderName, uri: folderURI.toString(true) };
			}
			folderPath = folderURI.path;
		}
	}
	return { name: folderName, path: folderPath };
}
开发者ID:PKRoma,项目名称:vscode,代码行数:37,代码来源:workspaces.ts

示例8:

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

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

				return Promise.all(editorGroupService.groups.map(g =>
					editorService.replaceEditors([{
						editor: { resource },
						replacement
					}], g))).then(() => true);
			});
开发者ID:joelday,项目名称:vscode,代码行数:20,代码来源:fileCommands.ts

示例9: test

	test('Uri#parse can break path-component #45515', function () {
		let uri: URI;
		uri = URI.from({ scheme: 's', authority: 'a', path: '/o%2f' });
		assert.equal(uri.toString(), 's://a/o%2f');
		uri = URI.from({ scheme: 's', authority: 'a', path: '/o%2fü' });
		assert.equal(uri.toString(), 's://a/o%2f%C3%BC');
		uri = URI.from({ scheme: 's', authority: 'a', path: '/o%2f%' });
		assert.equal(uri.toString(), 's://a/o%2f%25');

		uri = URI.file('/test with %25/c#code');
		assert.equal(uri.path, '/test with %25/c#code');
		assert.equal(uri.toString(), 'file:///test%20with%20%25/c%23code');

		uri = URI.from({
			scheme: 'http',
			authority: 'a',
			path: '/o/products%2FzVNZkudXJyq8bPGTXUxx%2FBetterave-Sesame.jpg'
		});
		assert.equal(uri.path, '/o/products%2FzVNZkudXJyq8bPGTXUxx%2FBetterave-Sesame.jpg');
		assert.equal(uri.toString(), 'http://a/o/products%2FzVNZkudXJyq8bPGTXUxx%2FBetterave-Sesame.jpg');

		assert.equal(URI.parse(uri.toString()).path, '/o/products%2FzVNZkudXJyq8bPGTXUxx%2FBetterave-Sesame.jpg');
		assert.equal(uri.toString(), URI.parse(uri.toString()).toString()); // identity

		uri = URI.parse('s://a/p%2ft%c3%bc');
		assert.equal(uri.path, '/p%2ftü');

		uri = URI.parse('s://a/%c3%bcp%2f-REST');
		assert.equal(uri.path, '/üp%2f-REST');

		uri = URI.parse('s://a/%c3%bcp%2fd%c3%b6wn');
		assert.equal(uri.path, '/üp%2fdöwn');

		//https://github.com/microsoft/vscode/issues/25852
		uri = URI.parse('http://www.test.com/path/service?authId=CN%3DQ10');
		assert.equal(uri.query, 'authId=CN%3DQ10');
		assert.equal(uri.toString(), 'http://www.test.com/path/service?authId=CN%3DQ10');
	});
开发者ID:PKRoma,项目名称:vscode,代码行数:38,代码来源:uri.test.ts

示例10: getEncodedDebugData

	public static getEncodedDebugData(modelUri: uri): { name: string, path: string, sessionId: string, sourceReference: number } {
		let path: string;
		let sourceReference: number;
		let sessionId: string;

		switch (modelUri.scheme) {
			case Schemas.file:
				path = paths.normalize(modelUri.fsPath, true);
				break;
			case DEBUG_SCHEME:
				path = modelUri.path;
				if (modelUri.query) {
					const keyvalues = modelUri.query.split('&');
					for (let keyvalue of keyvalues) {
						const pair = keyvalue.split('=');
						if (pair.length === 2) {
							switch (pair[0]) {
								case 'session':
									sessionId = decodeURIComponent(pair[1]);
									break;
								case 'ref':
									sourceReference = parseInt(pair[1]);
									break;
							}
						}
					}
				}
				break;
			default:
				path = modelUri.toString();
				break;
		}

		return {
			name: resources.basenameOrAuthority(modelUri),
			path,
			sourceReference,
			sessionId
		};
	}
开发者ID:DonJayamanne,项目名称:vscode,代码行数:40,代码来源:debugSource.ts


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