提交 9eff529e 编写于 作者: A Alex Dima

Add Error List

上级 9f66e9cd
......@@ -37,6 +37,8 @@ exports.collectModules= function(excludes) {
createModuleDescription('vs/workbench/parts/debug/browser/debugViewlet', excludes),
createModuleDescription('vs/workbench/parts/debug/browser/repl', excludes),
createModuleDescription('vs/workbench/parts/errorList/browser/errorList', excludes),
createModuleDescription('vs/workbench/services/search/node/searchApp', []),
createModuleDescription('vs/workbench/services/files/node/watcher/unix/watcherApp', []),
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import nls = require('vs/nls');
import platform = require('vs/platform/platform');
import panel = require('vs/workbench/browser/panel');
import {ERROR_LIST_PANEL_ID} from 'vs/workbench/parts/errorList/browser/errorListConstants';
import {IAction, Action} from 'vs/base/common/actions';
import {IPartService} from 'vs/workbench/services/part/common/partService';
import {IPanelService} from 'vs/workbench/services/panel/common/panelService';
import {TPromise} from 'vs/base/common/winjs.base';
import {IWorkbenchActionRegistry, Extensions as ActionExtensions} from 'vs/workbench/common/actionRegistry';
import {SyncActionDescriptor} from 'vs/platform/actions/common/actions';
import {KeyMod, KeyCode} from 'vs/base/common/keyCodes';
class ToggleErrorListAction extends Action {
public static ID = 'workbench.action.errorList.toggle';
public static LABEL = nls.localize('toggleErrorList', "Toggle Error List");
constructor(id: string, label: string,
@IPartService private partService: IPartService,
@IPanelService private panelService: IPanelService
) {
super(id, label);
}
public run(event?: any): TPromise<any> {
const panel = this.panelService.getActivePanel();
if (panel && panel.getId() === ERROR_LIST_PANEL_ID) {
this.partService.setPanelHidden(true);
return TPromise.as(null);
}
return this.panelService.openPanel(ERROR_LIST_PANEL_ID, true);
}
}
// register panel
(<panel.PanelRegistry>platform.Registry.as(panel.Extensions.Panels)).registerPanel(new panel.PanelDescriptor(
'vs/workbench/parts/errorList/browser/errorList',
'ErrorList',
ERROR_LIST_PANEL_ID,
nls.localize('errorListPanel', "Error List"),
'errorList'
));
// register toggle output action globally
let actionRegistry = <IWorkbenchActionRegistry>platform.Registry.as(ActionExtensions.WorkbenchActions);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleErrorListAction, ToggleErrorListAction.ID, ToggleErrorListAction.LABEL, {
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_A,
linux: {
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_A
}
}), nls.localize('viewCategory', "View"));
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./media/errorList';
import { TPromise } from 'vs/base/common/winjs.base';
import lifecycle = require('vs/base/common/lifecycle');
import { Panel } from 'vs/workbench/browser/panel';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import builder = require('vs/base/browser/builder');
import {ERROR_LIST_PANEL_ID} from 'vs/workbench/parts/errorList/browser/errorListConstants';
import {IMarkerService, IMarker} from 'vs/platform/markers/common/markers';
import { List } from 'vs/base/browser/ui/list/listWidget';
import { IRenderer, IDelegate, IFocusChangeEvent, ISelectionChangeEvent } from 'vs/base/browser/ui/list/list';
import { append, addClass, removeClass, toggleClass, emmet as $, hide, show } from 'vs/base/browser/dom';
import Severity from 'vs/base/common/severity';
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
import * as errors from 'vs/base/common/errors';
import * as paths from 'vs/base/common/paths';
interface IMarkerTemplateData {
icon: HTMLElement;
label: HTMLElement;
file: HTMLElement;
line: HTMLElement;
column: HTMLElement;
}
class Renderer implements IRenderer<IMarker, IMarkerTemplateData> {
constructor() {
}
get templateId(): string {
return 'errorListItem';
}
renderTemplate(container: HTMLElement): IMarkerTemplateData {
const data = <IMarkerTemplateData>Object.create(null);
data.icon = append(container, $('.icon'));
data.label = append(container, $('span.label'));
data.column = append(container, $('.column'));
data.line = append(container, $('.line'));
data.file = append(container, $('.file'));
return data;
}
disposeTemplate(templateData: IMarkerTemplateData): void {
// Nothing to do here
}
renderElement(element: IMarker, index: number, templateData: IMarkerTemplateData): void {
templateData.icon.className = 'icon ' + Renderer.iconClassNameFor(element);
templateData.label.textContent = element.message;
templateData.file.textContent = paths.basename(element.resource.fsPath);
templateData.line.textContent = String(element.startLineNumber);
templateData.column.textContent = String(element.startColumn);
}
private static iconClassNameFor(element: IMarker): string {
switch (element.severity) {
case Severity.Ignore:
return 'info';
case Severity.Info:
return 'info';
case Severity.Warning:
return 'warning';
case Severity.Error:
return 'error';
}
return '';
}
}
const HEIGHT = 22;
class Delegate implements IDelegate<IMarker> {
constructor(private listProvider: () => List<IMarker>) { }
getHeight(element: IMarker): number {
return HEIGHT;
}
getTemplateId(element: IMarker): string {
return 'errorListItem';
}
}
export class ErrorList extends Panel {
private toDispose: lifecycle.IDisposable[];
private list: List<IMarker>;
private delegate: IDelegate<IMarker>;
private markerService: IMarkerService;
private _editorService: IWorkbenchEditorService;
constructor(
@IMarkerService markerService: IMarkerService,
@ITelemetryService telemetryService: ITelemetryService,
@IWorkbenchEditorService editorService: IWorkbenchEditorService
) {
super(ERROR_LIST_PANEL_ID, telemetryService);
this.markerService = markerService;
this._editorService = editorService;
this.toDispose = [];
}
public create(parent: builder.Builder): TPromise<void> {
super.create(parent);
addClass(parent.getHTMLElement(), 'new-error-list');
let renderer: IRenderer<IMarker, IMarkerTemplateData> = new Renderer();
this.delegate = new Delegate(() => this.list);
this.list = new List(parent.getHTMLElement(), this.delegate, [renderer]);
this.toDispose.push(this.markerService.onMarkerChanged((changedResources) => {
this._onMarkersChanged();
}));
this.toDispose.push(this.list.onSelectionChange((e) => {
if (!e.elements.length) {
return;
}
let el = e.elements[0];
this._editorService.openEditor({
resource: el.resource,
options: {
selection: {
startLineNumber: el.startLineNumber,
startColumn: el.startColumn,
endLineNumber: el.endLineNumber,
endColumn: el.endColumn
}
}
}).done(null, errors.onUnexpectedError);
}));
this._onMarkersChanged();
return TPromise.as(null);
}
private _onMarkersChanged(): void {
let allMarkers = this.markerService.read().slice(0);
allMarkers.sort((a, b) => {
if (a.severity === b.severity) {
let aRes = a.resource.toString();
let bRes = b.resource.toString();
if (aRes === bRes) {
if (a.startLineNumber === b.startLineNumber) {
return a.startColumn - b.startColumn;
}
return a.startLineNumber - b.startLineNumber;
}
if (aRes < bRes) {
return -1;
}
if (aRes > bRes) {
return 1;
}
}
return b.severity - a.severity;
});
this.list.splice(0, this.list.length, ...allMarkers);
}
public dispose(): void {
this.toDispose = lifecycle.disposeAll(this.toDispose);
this.list.dispose();
super.dispose();
}
public layout(dimension: builder.Dimension): void {
this.list.layout(dimension.height);
}
}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export const ERROR_LIST_PANEL_ID = 'workbench.panel.errorList';
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
.new-error-list .monaco-list-row {
line-height: 22px;
}
.new-error-list .icon {
float: left;
display: block;
width: 16px;
height: 22px;
margin-right: 4px;
margin-left: 4px;
}
.new-error-list .icon.warning {
background: url('status-warning.svg') center center no-repeat;
}
.new-error-list .icon.error {
background: url('status-error.svg') center center no-repeat;
}
.new-error-list .icon.info:before {
background: url('status-info.svg') center center no-repeat;
}
.vs-dark .new-error-list .icon.warning {
background: url('status-warning-inverse.svg') center center no-repeat;
}
.vs-dark .new-error-list .icon.error {
background: url('status-error-inverse.svg') center center no-repeat;
}
.vs-dark .new-error-list .icon.info:before {
background: url('status-info-inverse.svg') center center no-repeat;
}
.new-error-list .label {
display: block;
float: left;
text-overflow: ellipsis;
overflow: hidden;
/* icon: 16 + 4 + 4 */
/* line: 20 + 4 + 4 */
/* col: 20 + 4 + 4 */
/* file: 100 + 4 + 4 */
max-width: calc(100% - 24px - 28px - 28px - 108px - 20px)
}
.new-error-list .file {
float: right;
margin: 0 4px;
width: 100px;
}
.new-error-list .line {
float: right;
margin: 0 4px;
width: 20px;
text-align: center;
}
.new-error-list .column {
float: right;
margin: 0 4px;
margin-right: 20px;
width: 20px;
text-align: center;
}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" height="16" width="16"><circle cx="8" cy="8" r="6" fill="#1E1E1E"/><path d="M8 3C5.238 3 3 5.238 3 8s2.238 5 5 5 5-2.238 5-5-2.238-5-5-5zm3 7l-1 1-2-2-2 2-1-1 2-2.027L5 6l1-1 2 2 2-2 1 1-2 1.973L11 10z" fill="#F48771"/><path fill="#252526" d="M11 6l-1-1-2 2-2-2-1 1 2 1.973L5 10l1 1 2-2 2 2 1-1-2-2.027z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" enable-background="new 0 0 16 16" height="16" width="16"><circle cx="8" cy="8" r="6" fill="#F6F6F6"/><path d="M8 3C5.238 3 3 5.238 3 8s2.238 5 5 5 5-2.238 5-5-2.238-5-5-5zm3 7l-1 1-2-2-2 2-1-1 2-2.027L5 6l1-1 2 2 2-2 1 1-2 1.973L11 10z" fill="#E51400"/><path fill="#fff" d="M11 6l-1-1-2 2-2-2-1 1 2 1.973L5 10l1 1 2-2 2 2 1-1-2-2.027z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" enable-background="new 0 0 16 16" height="16" width="16"><circle cx="8.5" cy="7.5" r="5.5" fill="#1E1E1E"/><path d="M8.5 3C6.015 3 4 5.015 4 7.5S6.015 12 8.5 12 13 9.985 13 7.5 10.985 3 8.5 3zm.5 8H8V6h1v5zm0-6H8V4h1v1z" fill="#1BA1E2"/><path d="M8 6h1v5H8V6zm0-2v1h1V4H8z" fill="#252526"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" height="16" width="16"><path fill="#F6F6F6" d="M7.5 2L2 12l2 2h9l2-2L9.5 2z"/><path d="M9 3H8l-4.5 9 1 1h8l1-1L9 3zm0 9H8v-1h1v1zm0-2H8V6h1v4z" fill="#fc0"/><path d="M9 10H8V6h1v4zm0 1H8v1h1v-1z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" height="16" width="16"><path fill="#1E1E1E" d="M7.5 2L2 12l2 2h9l2-2L9.5 2z"/><path d="M9 3H8l-4.5 9 1 1h8l1-1L9 3zm0 9H8v-1h1v1zm0-2H8V6h1v4z" fill="#fc0"/><path d="M9 10H8V6h1v4zm0 1H8v1h1v-1z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" enable-background="new 0 0 16 16" height="16" width="16"><path fill="#F6F6F6" d="M7.5 2L2 12l2 2h9l2-2L9.5 2z"/><path d="M9 3H8l-4.5 9 1 1h8l1-1L9 3zm0 9H8v-1h1v1zm0-2H8V6h1v4z" fill="#fc0"/><path d="M9 10H8V6h1v4zm0 1H8v1h1v-1z"/></svg>
\ No newline at end of file
......@@ -48,6 +48,8 @@ define([
'vs/workbench/parts/debug/electron-browser/debug.contribution',
'vs/workbench/parts/errorList/browser/errorList.contribution',
'vs/workbench/parts/html/browser/html.contribution',
'vs/workbench/parts/extensions/electron-browser/extensions.contribution',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册