本文整理汇总了TypeScript中vs/platform/workspace/common/workspace.IWorkspaceContextService类的典型用法代码示例。如果您正苦于以下问题:TypeScript IWorkspaceContextService类的具体用法?TypeScript IWorkspaceContextService怎么用?TypeScript IWorkspaceContextService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IWorkspaceContextService类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getRootPath
export function getRootPath(contextService: IWorkspaceContextService): string {
let isWorkspace = contextService.getWorkbenchState() === WorkbenchState.WORKSPACE;
if (isWorkspace) {
return contextService.getWorkspace().folders[0].uri.fsPath;
}
return undefined;
}
示例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"));
}
}
示例3: 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);
}
示例4: 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.hasWorkspace()) {
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
});
}
示例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];
});
}
示例6: getSettingsTargetName
export function getSettingsTargetName(target: ConfigurationTarget, resource: URI, workspaceContextService: IWorkspaceContextService): string {
switch (target) {
case ConfigurationTarget.USER:
return localize('userSettingsTarget', "User Settings");
case ConfigurationTarget.WORKSPACE:
return localize('workspaceSettingsTarget', "Workspace Settings");
case ConfigurationTarget.FOLDER:
const root = workspaceContextService.getRoot(resource);
return root ? paths.basename(root.fsPath) : '';
}
}
示例7: 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();
};
}
示例8: registerListeners
private registerListeners(): void {
// Workspace Folder Change
this._register(this.contextService.onDidChangeWorkspaceFolders(() => {
this.encodingOverride = this.getEncodingOverrides();
}));
}
示例9: confirm
public confirm(confirmation: IConfirmation): boolean {
if (!confirmation.primaryButton) {
confirmation.primaryButton = nls.localize({ key: 'yesButton', comment: ['&& denotes a mnemonic'] }, "&&Yes");
}
if (!confirmation.secondaryButton) {
confirmation.secondaryButton = nls.localize('cancelButton', "Cancel");
}
let opts: Electron.Dialog.ShowMessageBoxOptions = {
title: confirmation.title || this.contextService.getConfiguration().env.appName,
message: confirmation.message,
buttons: [
this.mnemonicLabel(confirmation.primaryButton),
this.mnemonicLabel(confirmation.secondaryButton)
],
noLink: true,
cancelId: 1
};
if (confirmation.detail) {
opts.detail = confirmation.detail;
}
let result = this.windowService.getWindow().showMessageBox(opts);
return result === 0 ? true : false;
}
示例10: confirm
public confirm(confirmation: IConfirmation): boolean {
if (!confirmation.primaryButton) {
confirmation.primaryButton = nls.localize('yesButton', "Yes");
}
if (!confirmation.secondaryButton) {
confirmation.secondaryButton = nls.localize('cancelButton', "Cancel");
}
let opts: remote.IMessageBoxOptions = {
title: confirmation.title || this.contextService.getConfiguration().env.appName,
message: confirmation.message,
buttons: [
confirmation.primaryButton,
confirmation.secondaryButton
],
noLink: true,
cancelId: 1
};
if (confirmation.detail) {
opts.detail = confirmation.detail;
}
let result = this.windowService.getWindow().showMessageBox(opts);
return result === 0 ? true : false;
}