Merge from master

This commit is contained in:
Raj Musuku
2019-02-21 17:56:04 -08:00
parent 5a146e34fa
commit 666ae11639
11482 changed files with 119352 additions and 255574 deletions

View File

@@ -3,11 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { TPromise } from 'vs/base/common/winjs.base';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
export const IIssueService = createDecorator<IIssueService>('issueService');
@@ -22,7 +18,7 @@ export interface WindowData {
zoomLevel: number;
}
export enum IssueType {
export const enum IssueType {
Bug,
PerformanceIssue,
FeatureRequest,
@@ -45,9 +41,20 @@ export interface IssueReporterStyles extends WindowStyles {
sliderActiveColor: string;
}
export interface IssueReporterExtensionData {
name: string;
publisher: string;
version: string;
id: string;
isTheme: boolean;
displayName: string | undefined;
repositoryUrl: string | undefined;
bugsUrl: string | undefined;
}
export interface IssueReporterData extends WindowData {
styles: IssueReporterStyles;
enabledExtensions: ILocalExtension[];
enabledExtensions: IssueReporterExtensionData[];
issueType?: IssueType;
}
@@ -74,11 +81,12 @@ export interface ProcessExplorerStyles extends WindowStyles {
}
export interface ProcessExplorerData extends WindowData {
pid: number;
styles: ProcessExplorerStyles;
}
export interface IIssueService {
_serviceBrand: any;
openReporter(data: IssueReporterData): TPromise<void>;
openProcessExplorer(data: ProcessExplorerData): TPromise<void>;
openReporter(data: IssueReporterData): Thenable<void>;
openProcessExplorer(data: ProcessExplorerData): Thenable<void>;
}

View File

@@ -3,27 +3,27 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { TPromise, Promise } from 'vs/base/common/winjs.base';
import { localize } from 'vs/nls';
import * as objects from 'vs/base/common/objects';
import { parseArgs } from 'vs/platform/environment/node/argv';
import { IIssueService, IssueReporterData, IssueReporterFeatures, ProcessExplorerData } from 'vs/platform/issue/common/issue';
import { BrowserWindow, ipcMain, screen } from 'electron';
import { ILaunchService } from 'vs/code/electron-main/launch';
import { getPerformanceInfo, PerformanceInfo, getSystemInfo, SystemInfo } from 'vs/code/electron-main/diagnostics';
import { BrowserWindow, ipcMain, screen, Event, dialog } from 'electron';
import { ILaunchService } from 'vs/platform/launch/electron-main/launchService';
import { PerformanceInfo, SystemInfo, IDiagnosticsService } from 'vs/platform/diagnostics/electron-main/diagnosticsService';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { isMacintosh, IProcessEnvironment } from 'vs/base/common/platform';
import { ILogService } from 'vs/platform/log/common/log';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { IWindowState } from 'vs/platform/windows/electron-main/windows';
const DEFAULT_BACKGROUND_COLOR = '#1E1E1E';
export class IssueService implements IIssueService {
_serviceBrand: any;
_issueWindow: BrowserWindow;
_issueParentWindow: BrowserWindow;
_processExplorerWindow: BrowserWindow;
_issueWindow: BrowserWindow | null;
_issueParentWindow: BrowserWindow | null;
_processExplorerWindow: BrowserWindow | null;
_processExplorerParentWindow: BrowserWindow | null;
constructor(
private machineId: string,
@@ -31,132 +31,190 @@ export class IssueService implements IIssueService {
@IEnvironmentService private environmentService: IEnvironmentService,
@ILaunchService private launchService: ILaunchService,
@ILogService private logService: ILogService,
) { }
openReporter(data: IssueReporterData): TPromise<void> {
ipcMain.on('issueSystemInfoRequest', event => {
this.getSystemInformation().then(msg => {
event.sender.send('issueSystemInfoResponse', msg);
});
});
ipcMain.on('issuePerformanceInfoRequest', event => {
this.getPerformanceInfo().then(msg => {
event.sender.send('issuePerformanceInfoResponse', msg);
});
});
ipcMain.on('workbenchCommand', (event, arg) => {
this._issueParentWindow.webContents.send('vscode:runAction', { id: arg, from: 'issueReporter' });
});
this._issueParentWindow = BrowserWindow.getFocusedWindow();
const position = this.getWindowPosition(this._issueParentWindow, 700, 800);
if (!this._issueWindow) {
this._issueWindow = new BrowserWindow({
width: position.width,
height: position.height,
minWidth: 300,
minHeight: 200,
x: position.x,
y: position.y,
title: localize('issueReporter', "Issue Reporter"),
backgroundColor: data.styles.backgroundColor || DEFAULT_BACKGROUND_COLOR,
webPreferences: {
disableBlinkFeatures: 'Auxclick'
}
});
this._issueWindow.setMenuBarVisibility(false); // workaround for now, until a menu is implemented
// Modified when testing UI
const features: IssueReporterFeatures = {};
this.logService.trace('issueService#openReporter: opening issue reporter');
this._issueWindow.loadURL(this.getIssueReporterPath(data, features));
this._issueWindow.on('close', () => this._issueWindow = null);
this._issueParentWindow.on('closed', () => {
if (this._issueWindow) {
this._issueWindow.close();
this._issueWindow = null;
}
});
}
this._issueWindow.focus();
return TPromise.as(null);
@IDiagnosticsService private diagnosticsService: IDiagnosticsService,
@IWindowsService private windowsService: IWindowsService
) {
this.registerListeners();
}
openProcessExplorer(data: ProcessExplorerData): TPromise<void> {
ipcMain.on('windowsInfoRequest', event => {
this.launchService.getMainProcessInfo().then(info => {
event.sender.send('windowsInfoResponse', info.windows);
private registerListeners(): void {
ipcMain.on('vscode:issueSystemInfoRequest', (event: Event) => {
this.getSystemInformation().then(msg => {
event.sender.send('vscode:issueSystemInfoResponse', msg);
});
});
// Create as singleton
if (!this._processExplorerWindow) {
const parentWindow = BrowserWindow.getFocusedWindow();
const position = this.getWindowPosition(parentWindow, 800, 300);
this._processExplorerWindow = new BrowserWindow({
skipTaskbar: true,
resizable: true,
width: position.width,
height: position.height,
minWidth: 300,
minHeight: 200,
x: position.x,
y: position.y,
backgroundColor: data.styles.backgroundColor,
title: localize('processExplorer', "Process Explorer"),
webPreferences: {
disableBlinkFeatures: 'Auxclick'
}
ipcMain.on('vscode:issuePerformanceInfoRequest', (event: Event) => {
this.getPerformanceInfo().then(msg => {
event.sender.send('vscode:issuePerformanceInfoResponse', msg);
});
});
this._processExplorerWindow.setMenuBarVisibility(false);
const windowConfiguration = {
appRoot: this.environmentService.appRoot,
nodeCachedDataDir: this.environmentService.nodeCachedDataDir,
windowId: this._processExplorerWindow.id,
userEnv: this.userEnv,
machineId: this.machineId,
data
ipcMain.on('vscode:issueReporterConfirmClose', (_) => {
const messageOptions = {
message: localize('confirmCloseIssueReporter', "Your input will not be saved. Are you sure you want to close this window?"),
type: 'warning',
buttons: [
localize('yes', "Yes"),
localize('cancel', "Cancel")
]
};
const environment = parseArgs(process.argv);
const config = objects.assign(environment, windowConfiguration);
for (let key in config) {
if (config[key] === void 0 || config[key] === null || config[key] === '') {
delete config[key]; // only send over properties that have a true value
if (this._issueWindow) {
dialog.showMessageBox(this._issueWindow, messageOptions, (response) => {
if (response === 0) {
if (this._issueWindow) {
this._issueWindow.destroy();
this._issueWindow = null;
}
}
});
}
});
ipcMain.on('vscode:workbenchCommand', (_, commandInfo) => {
const { id, from, args } = commandInfo;
let parentWindow: BrowserWindow | null;
switch (from) {
case 'issueReporter':
parentWindow = this._issueParentWindow;
break;
case 'processExplorer':
parentWindow = this._processExplorerParentWindow;
break;
default:
throw new Error(`Unexpected command source: ${from}`);
}
if (parentWindow) {
parentWindow.webContents.send('vscode:runAction', { id, from, args });
}
});
ipcMain.on('vscode:openExternal', (_, arg) => {
this.windowsService.openExternal(arg);
});
ipcMain.on('vscode:closeIssueReporter', (event: Event) => {
if (this._issueWindow) {
this._issueWindow.close();
}
});
ipcMain.on('windowsInfoRequest', (event: Event) => {
this.launchService.getMainProcessInfo().then(info => {
event.sender.send('vscode:windowsInfoResponse', info.windows);
});
});
}
openReporter(data: IssueReporterData): Promise<void> {
return new Promise(_ => {
if (!this._issueWindow) {
this._issueParentWindow = BrowserWindow.getFocusedWindow();
if (this._issueParentWindow) {
const position = this.getWindowPosition(this._issueParentWindow, 700, 800);
this._issueWindow = new BrowserWindow({
width: position.width,
height: position.height,
minWidth: 300,
minHeight: 200,
x: position.x,
y: position.y,
title: localize('issueReporter', "Issue Reporter"),
backgroundColor: data.styles.backgroundColor || DEFAULT_BACKGROUND_COLOR
});
this._issueWindow.setMenuBarVisibility(false); // workaround for now, until a menu is implemented
// Modified when testing UI
const features: IssueReporterFeatures = {};
this.logService.trace('issueService#openReporter: opening issue reporter');
this._issueWindow.loadURL(this.getIssueReporterPath(data, features));
this._issueWindow.on('close', () => this._issueWindow = null);
this._issueParentWindow.on('closed', () => {
if (this._issueWindow) {
this._issueWindow.close();
this._issueWindow = null;
}
});
}
}
this._processExplorerWindow.loadURL(`${require.toUrl('vs/code/electron-browser/processExplorer/processExplorer.html')}?config=${encodeURIComponent(JSON.stringify(config))}`);
this._processExplorerWindow.on('close', () => this._processExplorerWindow = void 0);
parentWindow.on('close', () => {
if (this._processExplorerWindow) {
this._processExplorerWindow.close();
this._processExplorerWindow = null;
}
});
}
// Focus
this._processExplorerWindow.focus();
return TPromise.as(null);
if (this._issueWindow) {
this._issueWindow.focus();
}
});
}
private getWindowPosition(parentWindow: BrowserWindow, defaultWidth: number, defaultHeight: number) {
openProcessExplorer(data: ProcessExplorerData): Promise<void> {
return new Promise(_ => {
// Create as singleton
if (!this._processExplorerWindow) {
this._processExplorerParentWindow = BrowserWindow.getFocusedWindow();
if (this._processExplorerParentWindow) {
const position = this.getWindowPosition(this._processExplorerParentWindow, 800, 300);
this._processExplorerWindow = new BrowserWindow({
skipTaskbar: true,
resizable: true,
width: position.width,
height: position.height,
minWidth: 300,
minHeight: 200,
x: position.x,
y: position.y,
backgroundColor: data.styles.backgroundColor,
title: localize('processExplorer', "Process Explorer")
});
this._processExplorerWindow.setMenuBarVisibility(false);
const windowConfiguration = {
appRoot: this.environmentService.appRoot,
nodeCachedDataDir: this.environmentService.nodeCachedDataDir,
windowId: this._processExplorerWindow.id,
userEnv: this.userEnv,
machineId: this.machineId,
data
};
const environment = parseArgs(process.argv);
const config = objects.assign(environment, windowConfiguration);
for (let key in config) {
if (config[key] === void 0 || config[key] === null || config[key] === '') {
delete config[key]; // only send over properties that have a true value
}
}
this._processExplorerWindow.loadURL(`${require.toUrl('vs/code/electron-browser/processExplorer/processExplorer.html')}?config=${encodeURIComponent(JSON.stringify(config))}`);
this._processExplorerWindow.on('close', () => this._processExplorerWindow = null);
this._processExplorerParentWindow.on('close', () => {
if (this._processExplorerWindow) {
this._processExplorerWindow.close();
this._processExplorerWindow = null;
}
});
}
}
// Focus
if (this._processExplorerWindow) {
this._processExplorerWindow.focus();
}
});
}
private getWindowPosition(parentWindow: BrowserWindow, defaultWidth: number, defaultHeight: number): IWindowState {
// We want the new window to open on the same display that the parent is in
let displayToUse: Electron.Display;
let displayToUse: Electron.Display | undefined;
const displays = screen.getAllDisplays();
// Single Display
@@ -184,16 +242,14 @@ export class IssueService implements IIssueService {
}
}
let state = {
const state: IWindowState = {
width: defaultWidth,
height: defaultHeight,
x: undefined,
y: undefined
height: defaultHeight
};
const displayBounds = displayToUse.bounds;
state.x = displayBounds.x + (displayBounds.width / 2) - (state.width / 2);
state.y = displayBounds.y + (displayBounds.height / 2) - (state.height / 2);
state.x = displayBounds.x + (displayBounds.width / 2) - (state.width! / 2);
state.y = displayBounds.y + (displayBounds.height / 2) - (state.height! / 2);
if (displayBounds.width > 0 && displayBounds.height > 0 /* Linux X11 sessions sometimes report wrong display bounds */) {
if (state.x < displayBounds.x) {
@@ -212,11 +268,11 @@ export class IssueService implements IIssueService {
state.y = displayBounds.y; // prevent window from falling out of the screen to the bottom
}
if (state.width > displayBounds.width) {
if (state.width! > displayBounds.width) {
state.width = displayBounds.width; // prevent window from exceeding display bounds width
}
if (state.height > displayBounds.height) {
if (state.height! > displayBounds.height) {
state.height = displayBounds.height; // prevent window from exceeding display bounds height
}
}
@@ -224,18 +280,18 @@ export class IssueService implements IIssueService {
return state;
}
private getSystemInformation(): TPromise<SystemInfo> {
private getSystemInformation(): Promise<SystemInfo> {
return new Promise((resolve, reject) => {
this.launchService.getMainProcessInfo().then(info => {
resolve(getSystemInfo(info));
resolve(this.diagnosticsService.getSystemInfo(info));
});
});
}
private getPerformanceInfo(): TPromise<PerformanceInfo> {
private getPerformanceInfo(): Promise<PerformanceInfo> {
return new Promise((resolve, reject) => {
this.launchService.getMainProcessInfo().then(info => {
getPerformanceInfo(info)
this.diagnosticsService.getPerformanceInfo(info)
.then(diagnosticInfo => {
resolve(diagnosticInfo);
})
@@ -247,7 +303,11 @@ export class IssueService implements IIssueService {
});
}
private getIssueReporterPath(data: IssueReporterData, features: IssueReporterFeatures) {
private getIssueReporterPath(data: IssueReporterData, features: IssueReporterFeatures): string {
if (!this._issueWindow) {
throw new Error('Issue window has been disposed');
}
const windowConfiguration = {
appRoot: this.environmentService.appRoot,
nodeCachedDataDir: this.environmentService.nodeCachedDataDir,

View File

@@ -3,35 +3,27 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { TPromise } from 'vs/base/common/winjs.base';
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
import { IIssueService, IssueReporterData, ProcessExplorerData } from './issue';
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc';
import { IIssueService, IssueReporterData, ProcessExplorerData } from '../common/issue';
import { Event } from 'vs/base/common/event';
export interface IIssueChannel extends IChannel {
call(command: 'openIssueReporter', arg: IssueReporterData): TPromise<void>;
call(command: 'getStatusInfo'): TPromise<any>;
call(command: string, arg?: any): TPromise<any>;
}
export class IssueChannel implements IIssueChannel {
export class IssueChannel implements IServerChannel {
constructor(private service: IIssueService) { }
listen<T>(event: string): Event<T> {
throw new Error('No event found');
listen<T>(_, event: string): Event<T> {
throw new Error(`Event not found: ${event}`);
}
call(command: string, arg?: any): TPromise<any> {
call(_, command: string, arg?: any): Thenable<any> {
switch (command) {
case 'openIssueReporter':
return this.service.openReporter(arg);
case 'openProcessExplorer':
return this.service.openProcessExplorer(arg);
}
return undefined;
throw new Error(`Call not found: ${command}`);
}
}
@@ -39,13 +31,13 @@ export class IssueChannelClient implements IIssueService {
_serviceBrand: any;
constructor(private channel: IIssueChannel) { }
constructor(private channel: IChannel) { }
openReporter(data: IssueReporterData): TPromise<void> {
openReporter(data: IssueReporterData): Thenable<void> {
return this.channel.call('openIssueReporter', data);
}
openProcessExplorer(data: ProcessExplorerData): TPromise<void> {
openProcessExplorer(data: ProcessExplorerData): Thenable<void> {
return this.channel.call('openProcessExplorer', data);
}
}