當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。