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


TypeScript workspace.asRelativePath方法代码示例

本文整理汇总了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)
			});
		}
	});
开发者ID:0xdeafcafe,项目名称:omnisharp-vscode,代码行数:29,代码来源:launchTargetFinder.ts

示例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);
		});
	}

	});
开发者ID:sporto,项目名称:rails-go-to-spec-vscode,代码行数:29,代码来源:extension.ts

示例3: GetRelativePath

    public static GetRelativePath(change: IPendingChange): string {
        if (change && change.localItem && workspace) {
            return workspace.asRelativePath(change.localItem);
        }

        return change.localItem;
    }
开发者ID:Microsoft,项目名称:vsts-vscode,代码行数:7,代码来源:uihelper.ts

示例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);
			}
		});
	});
开发者ID:0xdeafcafe,项目名称:omnisharp-vscode,代码行数:10,代码来源:omnisharpStatus.ts

示例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;
            }
        });
开发者ID:gregg-miskelly,项目名称:omnisharp-vscode,代码行数:43,代码来源:launcher.ts

示例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);
                }
            });
        }
    });
开发者ID:tmat,项目名称:omnisharp-vscode,代码行数:12,代码来源:status.ts

示例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);
开发者ID:stevensona,项目名称:shader-toy,代码行数:13,代码来源:extension.ts

示例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);
    });
开发者ID:kexi,项目名称:vscode-svgviewer,代码行数:23,代码来源:extension.ts

示例9: filterEvent

	const onGitChange = filterEvent(onWorkspaceChange, uri => /^\.git\//.test(workspace.asRelativePath(uri)));
开发者ID:diarmaidm,项目名称:vscode,代码行数:1,代码来源:main.ts

示例10:

 var references = data.references.filter(ref => {
     var relPath = vscode.workspace.asRelativePath(ref.fileName);
     return !relPath.startsWith("..");
 });
开发者ID:maiamatheus,项目名称:pythonVSCode,代码行数:4,代码来源:renameProvider.ts


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