本文整理汇总了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;
});
示例2:
savePromise = textFileService.save(resource, options).then((result) => {
if (result) {
return resource.with({ scheme: Schemas.file });
}
return undefined;
});
示例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
});
}
示例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;
}
示例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
});
}
示例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
});
}
示例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
});
}
示例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;
}
示例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)}` });
});