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

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

        return change.localItem;
    }
	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);
			}
		});
	});
        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;
            }
        });
Example #6
0
    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);
                }
            });
        }
    });
Example #7
0
 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);
Example #8
0
    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);
    });
Example #9
0
	const onGitChange = filterEvent(onWorkspaceChange, uri => /^\.git\//.test(workspace.asRelativePath(uri)));
 var references = data.references.filter(ref => {
     var relPath = vscode.workspace.asRelativePath(ref.fileName);
     return !relPath.startsWith("..");
 });
Example #11
0
 let picks = locations.map(l => ({
     label: `${vscode.workspace.asRelativePath(l.uri)}:${l.range.start.line + 1}`,
     description: l.uri.fsPath,
     location: l
 }));
Example #12
0
export function asRelativePath(
  pathOrUri: string | IVSCodeUri): string {
  return vscode.workspace.asRelativePath(pathOrUri);
}
Example #13
0
		client.execute('projectInfo', { file, needFileNameList: true }).then(res => {

			let {configFileName, fileNames} = res.body;

			if (projectHinted[configFileName] === true) {
				return;
			}

			if (!configFileName) {
				currentHint = {
					message: localize('hintCreate', "Have a project and experience better IntelliSense and code navigation."),
					option: {
						title: localize('cmdCreate', "Create jsconfig.json-file..."),
						execute: () => {
							client.logTelemetry('js.hintProjectCreation.accepted');
							projectHinted[configFileName] = true;
							item.hide();

							return vscode.workspace.openTextDocument(vscode.Uri.parse('untitled://' + vscode.workspace.rootPath + '/jsconfig.json'))
								.then(vscode.window.showTextDocument)
								.then(editor => editor.edit(builder => builder.insert(new vscode.Position(0, 0), defaultConfig)));
						}
					}
				};
				item.text = '$(light-bulb)';
				item.tooltip = localize('hint.tooltip', "Have a project and have better IntelliSense, better symbol search, and much more.");
				item.color = 'white';
				item.show();
				client.logTelemetry('js.hintProjectCreation');

			} else if (fileNames.length > fileLimit) {

				let largeRoots = computeLargeRoots(configFileName, fileNames).map(f => `'/${f}/'`).join(', ');

				currentHint = {
					message: localize('hintExclude', "'{0}' is a large project. For better performance exclude folders with many files, like: {1}...",
						vscode.workspace.asRelativePath(configFileName),
						largeRoots),
					option: {
						title: localize('open', "Configure excludes..."),
						execute: () => {
							client.logTelemetry('js.hintProjectExcludes.accepted');
							projectHinted[configFileName] = true;
							item.hide();

							return vscode.workspace.openTextDocument(configFileName)
								.then(vscode.window.showTextDocument);
						}
					}
				};
				item.tooltip = currentHint.message;
				item.text = localize('large.label', "Configure Excludes");
				item.tooltip = localize('large.tooltip', "Too many files in a project might result in bad performance. Exclude folders with many files, like: {0}...", largeRoots);
				item.color = '#0CFF00';
				item.show();
				client.logTelemetry('js.hintProjectExcludes');

			} else {
				item.hide();
			}
		}).catch(err => {
Example #14
0
		return workspace.findFiles('*.js', null).then((res) => {
			assert.equal(res.length, 1);
			assert.equal(basename(workspace.asRelativePath(res[0])), 'far.js');
		});