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


TypeScript IWorkspaceContextService.getWorkspace方法代码示例

本文整理汇总了TypeScript中vs/platform/workspace/common/workspace.IWorkspaceContextService.getWorkspace方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IWorkspaceContextService.getWorkspace方法的具体用法?TypeScript IWorkspaceContextService.getWorkspace怎么用?TypeScript IWorkspaceContextService.getWorkspace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vs/platform/workspace/common/workspace.IWorkspaceContextService的用法示例。


在下文中一共展示了IWorkspaceContextService.getWorkspace方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: startWatching

	public startWatching(): () => void {
		if (this.contextService.getWorkspace().folders[0].uri.scheme !== Schemas.file) {
			return () => { };
		}
		let basePath: string = normalize(this.contextService.getWorkspace().folders[0].uri.fsPath);

		if (basePath && basePath.indexOf('\\\\') === 0 && endsWith(basePath, sep)) {
			// for some weird reason, node adds a trailing slash to UNC paths
			// we never ever want trailing slashes as our base path unless
			// someone opens root ("/").
			// See also https://github.com/nodejs/io.js/issues/1765
			basePath = rtrim(basePath, sep);
		}

		const watcher = new OutOfProcessWin32FolderWatcher(
			basePath,
			this.ignored,
			events => this.onRawFileEvents(events),
			error => this.onError(error),
			this.verboseLogging
		);

		return () => {
			this.isDisposed = true;
			watcher.dispose();
		};
	}
开发者ID:DonJayamanne,项目名称:vscode,代码行数:27,代码来源:watcherService.ts

示例2: revealResourcesInOS

function revealResourcesInOS(resources: URI[], windowsService: IWindowsService, notificationService: INotificationService, workspaceContextService: IWorkspaceContextService): void {
	if (resources.length) {
		sequence(resources.map(r => () => windowsService.showItemInFolder(paths.normalize(r.fsPath, true))));
	} else if (workspaceContextService.getWorkspace().folders.length) {
		windowsService.showItemInFolder(paths.normalize(workspaceContextService.getWorkspace().folders[0].uri.fsPath, true));
	} else {
		notificationService.info(nls.localize('openFileToReveal', "Open a file first to reveal"));
	}
}
开发者ID:jinlongchen2018,项目名称:vscode,代码行数:9,代码来源:fileCommands.ts

示例3: loadExperiments

export function loadExperiments(contextService: IWorkspaceContextService, storageService: IStorageService, configurationService: IConfigurationService): ITelemetryExperiments {

	const key = 'experiments.randomness';
	let valueString = storageService.get(key);
	if (!valueString) {
		valueString = Math.random().toString();
		storageService.store(key, valueString);
	}

	const random1 = parseFloat(valueString);
	let [random2, showNewUserWatermark] = splitRandom(random1);
	let [random3, openUntitledFile] = splitRandom(random2);
	let [, openGettingStarted] = splitRandom(random3);

	const newUserDuration = 24 * 60 * 60 * 1000;
	const firstSessionDate = storageService.get('telemetry.firstSessionDate');
	const isNewUser = !firstSessionDate || Date.now() - Date.parse(firstSessionDate) < newUserDuration;
	if (!isNewUser || !!contextService.getWorkspace()) {
		showNewUserWatermark = defaultExperiments.showNewUserWatermark;
		openUntitledFile = defaultExperiments.openUntitledFile;
	}

	const isNewSession = !storageService.get('telemetry.lastSessionDate');
	const now = Date.now();
	if (!(isNewSession && now >= beginGettingStartedExp && now < endGettingStartedExp)) {
		openGettingStarted = undefined;
	}

	return applyOverrides(configurationService, {
		showNewUserWatermark,
		openUntitledFile,
		openGettingStarted
	});
}
开发者ID:sandy081,项目名称:vscode,代码行数:34,代码来源:telemetry.ts

示例4: getRootPath

export function getRootPath(contextService: IWorkspaceContextService): string {
	let isWorkspace = contextService.getWorkbenchState() === WorkbenchState.WORKSPACE;
	if (isWorkspace) {
		return contextService.getWorkspace().folders[0].uri.fsPath;
	}

	return undefined;
}
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:8,代码来源:pathUtilities.ts

示例5: constructor

	// Optional workspaceRoot there to be used in tests.
	constructor(
		private editorService: IWorkbenchEditorService,
		contextService: IWorkspaceContextService,
		environmentService: IEnvironmentService,
		workspaceRoot: URI = null,
		envVariables: { [key: string]: string } = process.env
	) {
		super();
		let fsPath = '';
		if (workspaceRoot || (contextService && contextService.getWorkspace())) {
			fsPath = workspaceRoot ? workspaceRoot.fsPath : contextService.getWorkspace().resource.fsPath;
		}
		this._workspaceRoot = Paths.normalize(fsPath, true);
		this._execPath = environmentService.execPath;
		Object.keys(envVariables).forEach(key => {
			this[`env.${key}`] = envVariables[key];
		});
	}
开发者ID:GYGit,项目名称:vscode,代码行数:19,代码来源:systemVariables.ts

示例6: defaultWorkspacePath

export function defaultWorkspacePath(contextService: IWorkspaceContextService, historyService: IHistoryService, environmentService: IEnvironmentService): string {

	// Check for current workspace config file first...
	if (contextService.getWorkbenchState() === WorkbenchState.WORKSPACE && !isUntitledWorkspace(contextService.getWorkspace().configuration.fsPath, environmentService)) {
		return dirname(contextService.getWorkspace().configuration.fsPath);
	}

	// ...then fallback to default folder path
	return defaultFolderPath(contextService, historyService);
}
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:10,代码来源:workspaceCommands.ts

示例7: getEncodingOverrides

	private getEncodingOverrides(): IEncodingOverride[] {
		const encodingOverride: IEncodingOverride[] = [];

		// Global settings
		encodingOverride.push({ parent: uri.file(this.environmentService.appSettingsHome), encoding: encoding.UTF8 });

		// Workspace files
		encodingOverride.push({ extension: WORKSPACE_EXTENSION, encoding: encoding.UTF8 });

		// Folder Settings
		this.contextService.getWorkspace().folders.forEach(folder => {
			encodingOverride.push({ parent: joinPath(folder.uri, '.vscode'), encoding: encoding.UTF8 });
		});

		return encodingOverride;
	}
开发者ID:joelday,项目名称:vscode,代码行数:16,代码来源:encoding.ts


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