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


TypeScript URI.with方法代码示例

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


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

示例1:

				savePromise = textFileService.save(resource).then((result) => {
					if (result) {
						return resource.with({ scheme: Schemas.file });
					}

					return null;
				});
开发者ID:developers23,项目名称:vscode,代码行数:7,代码来源:fileCommands.ts

示例2:

				savePromise = textFileService.save(resource, options).then((result) => {
					if (result) {
						return resource.with({ scheme: Schemas.file });
					}

					return undefined;
				});
开发者ID:joelday,项目名称:vscode,代码行数:7,代码来源:fileCommands.ts

示例3: dirname

export function dirname(resource: URI): URI {
	let dirname = paths.dirname(resource.path, '/');
	if (resource.authority && dirname.length && dirname.charCodeAt(0) !== CharCode.Slash) {
		return null; // If a URI contains an authority component, then the path component must either be empty or begin with a CharCode.Slash ("/") character
	}
	return resource.with({
		path: dirname
	});
}
开发者ID:developers23,项目名称:vscode,代码行数:9,代码来源:resources.ts

示例4: addGAParameters

export async function addGAParameters(telemetryService: ITelemetryService, environmentService: IEnvironmentService, uri: URI, origin: string, experiment = '1'): Promise<URI> {
	if (environmentService.isBuilt && !environmentService.isExtensionDevelopment && !environmentService.args['disable-telemetry'] && !!product.enableTelemetry) {
		if (uri.scheme === 'https' && uri.authority === 'code.visualstudio.com') {
			const info = await telemetryService.getTelemetryInfo();

			return uri.with({ query: `${uri.query ? uri.query + '&' : ''}utm_source=VsCode&utm_medium=${encodeURIComponent(origin)}&utm_campaign=${encodeURIComponent(info.instanceId)}&utm_content=${encodeURIComponent(experiment)}` });
		}
	}
	return uri;
}
开发者ID:PKRoma,项目名称:vscode,代码行数:10,代码来源:telemetryNodeUtils.ts

示例5: joinPath

export function joinPath(resource: URI, pathFragment: string): URI {
	let joinedPath: string;
	if (resource.scheme === Schemas.file) {
		joinedPath = URI.file(paths.join(fsPath(resource), pathFragment)).path;
	} else {
		joinedPath = paths.join(resource.path, pathFragment);
	}
	return resource.with({
		path: joinedPath
	});
}
开发者ID:donaldpipowitch,项目名称:vscode,代码行数:11,代码来源:resources.ts

示例6: normalizePath

export function normalizePath(resource: URI): URI {
	let normalizedPath: string;
	if (resource.scheme === Schemas.file) {
		normalizedPath = URI.file(paths.normalize(fsPath(resource))).path;
	} else {
		normalizedPath = paths.normalize(resource.path);
	}
	return resource.with({
		path: normalizedPath
	});
}
开发者ID:donaldpipowitch,项目名称:vscode,代码行数:11,代码来源:resources.ts

示例7: dirname

export function dirname(resource: URI): URI | null {
	if (resource.path.length === 0) {
		return resource;
	}
	if (resource.scheme === Schemas.file) {
		return URI.file(paths.dirname(fsPath(resource)));
	}
	let dirname = paths.dirname(resource.path, '/');
	if (resource.authority && dirname.length && dirname.charCodeAt(0) !== CharCode.Slash) {
		return null; // If a URI contains an authority component, then the path component must either be empty or begin with a CharCode.Slash ("/") character
	}
	return resource.with({
		path: dirname
	});
}
开发者ID:VishalMadhvani,项目名称:vscode,代码行数:15,代码来源:resources.ts

示例8: getPathLabel

export function getPathLabel(resource: URI | string, userHomeProvider: IUserHomeProvider, rootProvider?: IWorkspaceFolderProvider): string {
	if (!resource) {
		return null;
	}

	if (typeof resource === 'string') {
		resource = URI.file(resource);
	}

	// return early if we can resolve a relative path label from the root
	const baseResource = rootProvider ? rootProvider.getWorkspaceFolder(resource) : null;
	if (baseResource) {
		const hasMultipleRoots = rootProvider.getWorkspace().folders.length > 1;

		let pathLabel: string;
		if (isEqual(baseResource.uri, resource, !isLinux)) {
			pathLabel = ''; // no label if paths are identical
		} else {
			pathLabel = normalize(ltrim(resource.path.substr(baseResource.uri.path.length), sep), true);
		}

		if (hasMultipleRoots) {
			const rootName = (baseResource && baseResource.name) ? baseResource.name : pathsBasename(baseResource.uri.fsPath);
			pathLabel = pathLabel ? (rootName + ' • ' + pathLabel) : rootName; // always show root basename if there are multiple
		}

		return pathLabel;
	}

	// return if the resource is neither file:// nor untitled:// and no baseResource was provided
	if (resource.scheme !== Schemas.file && resource.scheme !== Schemas.untitled) {
		return resource.with({ query: null, fragment: null }).toString(true);
	}

	// convert c:\something => C:\something
	if (hasDriveLetter(resource.fsPath)) {
		return normalize(normalizeDriveLetter(resource.fsPath), true);
	}

	// normalize and tildify (macOS, Linux only)
	let res = normalize(resource.fsPath, true);
	if (!isWindows && userHomeProvider) {
		res = tildify(res, userHomeProvider.userHome);
	}

	return res;
}
开发者ID:developers23,项目名称:vscode,代码行数:47,代码来源:labels.ts

示例9:

				.then(info => {
					return uri.with({ query: `${uri.query ? uri.query + '&' : ''}utm_source=VsCode&utm_medium=${encodeURIComponent(origin)}&utm_campaign=${encodeURIComponent(info.instanceId)}&utm_content=${encodeURIComponent(experiment)}` });
				});
开发者ID:developers23,项目名称:vscode,代码行数:3,代码来源:telemetryNodeUtils.ts


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