本文整理匯總了TypeScript中vscode.workspace.asRelativePath方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript workspace.asRelativePath方法的具體用法?TypeScript workspace.asRelativePath怎麽用?TypeScript workspace.asRelativePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vscode.workspace
的用法示例。
在下文中一共展示了workspace.asRelativePath方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
resources.forEach(resource => {
// sln files
if (hasCsProjFiles && /\.sln$/.test(resource.fsPath)) {
targets.push({
label: paths.basename(resource.fsPath),
description: workspace.asRelativePath(paths.dirname(resource.fsPath)),
resource,
target: resource,
directory: Uri.file(paths.dirname(resource.fsPath))
});
}
// project.json files
if (/project.json$/.test(resource.fsPath)) {
const dirname = paths.dirname(resource.fsPath);
hasProjectJson = true;
hasProjectJsonAtRoot = hasProjectJsonAtRoot || dirname === root.fsPath;
targets.push({
label: paths.basename(resource.fsPath),
description: workspace.asRelativePath(paths.dirname(resource.fsPath)),
resource,
target: Uri.file(dirname),
directory: Uri.file(dirname)
});
}
});
示例2: function
let disposable = vscode.commands.registerCommand('extension.railsGoToSpec', () => {
// The code you place here will be executed every time your command is executed
// Display a message box to the user
var editor = vscode.window.activeTextEditor;
if (!editor) {
return; // No open text editor
}
let document = editor.document;
let fileName: string = document.fileName;
let related: string = resolver.getRelated(fileName);
let relative: string = vscode.workspace.asRelativePath(related);
let fileExists: boolean = fs.existsSync(related);
let dirname: string = path.dirname(related);
//console.log('fileExists', fileExists);
if (fileExists) {
openFile(related);
} else {
prompt(relative, function() {
mkdirp.sync(dirname);
fs.closeSync(fs.openSync(related, 'w'));
openFile(related);
});
}
});
示例3: GetRelativePath
public static GetRelativePath(change: IPendingChange): string {
if (change && change.localItem && workspace) {
return workspace.asRelativePath(change.localItem);
}
return change.localItem;
}
示例4:
let d3 = server.onUnresolvedDependencies(message => {
let info = `There are unresolved dependencies from '${vscode.workspace.asRelativePath(message.FileName) }'. Please execute the restore command to continue.`;
return vscode.window.showInformationMessage(info, 'Restore').then(value => {
if (value) {
dotnetRestoreForProject(server, message.FileName);
}
});
});
示例5:
resources.forEach(resource => {
// Add .sln files if there are .csproj files
if (hasCsProjFiles && isSolution(resource)) {
hasSlnFile = true;
targets.push({
label: path.basename(resource.fsPath),
description: vscode.workspace.asRelativePath(path.dirname(resource.fsPath)),
target: resource.fsPath,
directory: path.dirname(resource.fsPath),
kind: LaunchTargetKind.Solution
});
}
// Add project.json files
if (isProjectJson(resource)) {
const dirname = path.dirname(resource.fsPath);
hasProjectJson = true;
hasProjectJsonAtRoot = hasProjectJsonAtRoot || dirname === folderPath;
targets.push({
label: path.basename(resource.fsPath),
description: vscode.workspace.asRelativePath(path.dirname(resource.fsPath)),
target: dirname,
directory: dirname,
kind: LaunchTargetKind.ProjectJson
});
}
// Discover if there is any CSX file
if (!hasCSX && isCsx(resource)) {
hasCSX = true;
}
// Discover if there is any Cake file
if (!hasCake && isCake(resource)) {
hasCake = true;
}
//Discover if there is any cs file
if (!hasCs && isCs(resource)) {
hasCs = true;
}
});
示例6: dotnetRestoreForProject
let d3 = server.onUnresolvedDependencies(message => {
let csharpConfig = vscode.workspace.getConfiguration('csharp');
if (!csharpConfig.get<boolean>('suppressDotnetRestoreNotification')) {
let info = `There are unresolved dependencies from '${vscode.workspace.asRelativePath(message.FileName) }'. Please execute the restore command to continue.`;
return vscode.window.showInformationMessage(info, 'Restore').then(value => {
if (value) {
dotnetRestoreForProject(server, message.FileName);
}
});
}
});
示例7:
file = ((file: string) => {
const relFile = vscode.workspace.asRelativePath(file);
const herePos = relFile.indexOf("./");
if (vscode.workspace.rootPath === null && herePos === 0) {
vscode.window.showErrorMessage("To use relative paths please open a workspace!");
}
if (relFile !== file || herePos === 0) {
return vscode.workspace.rootPath + '/' + relFile;
}
else {
return file;
}
})(file);
示例8: function
let openfile = vscode.commands.registerCommand('svgviewer.openfile', async function (uri) {
if (!(uri instanceof vscode.Uri)) {
return;
}
let document = await vscode.workspace.openTextDocument(uri);
if (checkNoSvg(document, false)) {
vscode.window.showWarningMessage("Selected file is not an SVG document - no properties to preview.");
return;
}
let fName = vscode.workspace.asRelativePath(document.fileName);
let fileUriProvider = fileUriProviders.get(fName);
if (fileUriProvider == undefined) {
let fileUri = getSvgUri(uri);
let fileProvider = new SvgFileContentProvider(context, fileUri, document.fileName);
let fileRegistration = vscode.workspace.registerTextDocumentContentProvider('svg-preview', fileProvider);
fileUriProvider = { uri: fileUri, provider: fileProvider, registration: fileRegistration };
fileUriProviders.set(fName, fileUriProvider);
} else {
fileUriProvider.provider.update(fileUriProvider.uri);
}
return openPreview(fileUriProvider.uri, fName);
});
示例9: filterEvent
const onGitChange = filterEvent(onWorkspaceChange, uri => /^\.git\//.test(workspace.asRelativePath(uri)));
示例10:
var references = data.references.filter(ref => {
var relPath = vscode.workspace.asRelativePath(ref.fileName);
return !relPath.startsWith("..");
});