From e19a65aaa3709b9aca7ee58d7732433c443fb974 Mon Sep 17 00:00:00 2001 From: Roman Safronov Date: Wed, 19 Jul 2017 09:29:27 -0400 Subject: [PATCH 1/3] Added API to access markers As of now there is no public API to access markers. This PR adds method `editor.getModelMarkers`. Should resolve https://github.com/Microsoft/monaco-editor/issues/30. --- src/vs/editor/standalone/browser/standaloneEditor.ts | 10 ++++++++++ src/vs/monaco.d.ts | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/vs/editor/standalone/browser/standaloneEditor.ts b/src/vs/editor/standalone/browser/standaloneEditor.ts index 9d42854a03d8b..a516a1342bba0 100644 --- a/src/vs/editor/standalone/browser/standaloneEditor.ts +++ b/src/vs/editor/standalone/browser/standaloneEditor.ts @@ -194,6 +194,15 @@ export function setModelMarkers(model: editorCommon.IModel, owner: string, marke } } +/** + * Get markers for owner ant/or resource + * @returns {IMarkerData[]} list of markers + * @param filter + */ +export function getModelMarkers(filter: { owner?: string, resource?: URI, take?: number }): IMarkerData[] { + return StaticServices.markerService.get().read(filter); +} + /** * Get the model that has `uri` if it exists. */ @@ -331,6 +340,7 @@ export function createMonacoEditorAPI(): typeof monaco.editor { createModel: createModel, setModelLanguage: setModelLanguage, setModelMarkers: setModelMarkers, + getModelMarkers: getModelMarkers, getModels: getModels, getModel: getModel, onDidCreateModel: onDidCreateModel, diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index e8e339f61b6c0..a1b510b57b54e 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -833,6 +833,17 @@ declare module monaco.editor { */ export function setModelMarkers(model: IModel, owner: string, markers: IMarkerData[]): void; + /** + * Get markers for owner ant/or resource + * @returns {IMarkerData[]} list of markers + * @param filter + */ + export function getModelMarkers(filter: { + owner?: string; + resource?: Uri; + take?: number; + }): IMarkerData[]; + /** * Get the model that has `uri` if it exists. */ From 53a0e27cc27b676cd4ce89dd6a39fdfa2b6613ba Mon Sep 17 00:00:00 2001 From: rsafronov Date: Thu, 20 Jul 2017 19:04:52 -0400 Subject: [PATCH 2/3] Fixed comments from @jrieken --- build/monaco/monaco.d.ts.recipe | 2 +- .../editor/standalone/browser/standaloneEditor.ts | 4 ++-- src/vs/monaco.d.ts | 15 ++++++++++++++- src/vs/platform/markers/common/markers.ts | 4 ++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/build/monaco/monaco.d.ts.recipe b/build/monaco/monaco.d.ts.recipe index 1a3f3c6143124..096f516afcf27 100644 --- a/build/monaco/monaco.d.ts.recipe +++ b/build/monaco/monaco.d.ts.recipe @@ -67,7 +67,7 @@ export interface ICommandHandler { } #include(vs/platform/contextkey/common/contextkey): IContextKey #include(vs/editor/standalone/browser/standaloneServices): IEditorOverrideServices -#include(vs/platform/markers/common/markers): IMarkerData +#include(vs/platform/markers/common/markers): IMarker, IMarkerData #include(vs/editor/standalone/browser/colorizer): IColorizerOptions, IColorizerElementOptions #include(vs/base/common/scrollable): ScrollbarVisibility #include(vs/platform/theme/common/themeService): ThemeColor diff --git a/src/vs/editor/standalone/browser/standaloneEditor.ts b/src/vs/editor/standalone/browser/standaloneEditor.ts index a516a1342bba0..8da3d14ddc378 100644 --- a/src/vs/editor/standalone/browser/standaloneEditor.ts +++ b/src/vs/editor/standalone/browser/standaloneEditor.ts @@ -19,7 +19,7 @@ import { Colorizer, IColorizerElementOptions, IColorizerOptions } from 'vs/edito import { SimpleEditorService, SimpleEditorModelResolverService } from 'vs/editor/standalone/browser/simpleServices'; import * as modes from 'vs/editor/common/modes'; import { IWebWorkerOptions, MonacoWebWorker, createWebWorker as actualCreateWebWorker } from 'vs/editor/common/services/webWorker'; -import { IMarkerData } from 'vs/platform/markers/common/markers'; +import { IMarkerData, IMarker } from 'vs/platform/markers/common/markers'; import { DiffNavigator } from 'vs/editor/browser/widget/diffNavigator'; import { IEditorService } from 'vs/platform/editor/common/editor'; import { ICommandService } from 'vs/platform/commands/common/commands'; @@ -199,7 +199,7 @@ export function setModelMarkers(model: editorCommon.IModel, owner: string, marke * @returns {IMarkerData[]} list of markers * @param filter */ -export function getModelMarkers(filter: { owner?: string, resource?: URI, take?: number }): IMarkerData[] { +export function getModelMarkers(filter: { owner?: string, resource?: URI, take?: number }): IMarker[] { return StaticServices.markerService.get().read(filter); } diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index a1b510b57b54e..27efff2ab6a9b 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -842,7 +842,7 @@ declare module monaco.editor { owner?: string; resource?: Uri; take?: number; - }): IMarkerData[]; + }): IMarker[]; /** * Get the model that has `uri` if it exists. @@ -1040,6 +1040,19 @@ declare module monaco.editor { [index: string]: any; } + export interface IMarker { + owner: string; + resource: Uri; + severity: Severity; + code?: string; + message: string; + source?: string; + startLineNumber: number; + startColumn: number; + endLineNumber: number; + endColumn: number; + } + /** * A structure defining a problem/warning/etc. */ diff --git a/src/vs/platform/markers/common/markers.ts b/src/vs/platform/markers/common/markers.ts index 0687762f540fa..e0eba169bc5d4 100644 --- a/src/vs/platform/markers/common/markers.ts +++ b/src/vs/platform/markers/common/markers.ts @@ -9,8 +9,6 @@ import Severity from 'vs/base/common/severity'; import Event from 'vs/base/common/event'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; -export const IMarkerService = createDecorator('markerService'); - export interface IMarkerService { _serviceBrand: any; @@ -114,3 +112,5 @@ export namespace IMarkerData { return result.join('¦'); } } + +export const IMarkerService = createDecorator('markerService'); From a6e21c6f63190545e2d88cfeb7f56782447cb6a5 Mon Sep 17 00:00:00 2001 From: rsafronov Date: Thu, 20 Jul 2017 19:52:26 -0400 Subject: [PATCH 3/3] Fixed: unused import (it failed the build) --- .../workbench/parts/preferences/browser/preferencesWidgets.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/parts/preferences/browser/preferencesWidgets.ts b/src/vs/workbench/parts/preferences/browser/preferencesWidgets.ts index 930a871d08410..7f15c197c2435 100644 --- a/src/vs/workbench/parts/preferences/browser/preferencesWidgets.ts +++ b/src/vs/workbench/parts/preferences/browser/preferencesWidgets.ts @@ -17,7 +17,7 @@ import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition, OverlayWidgetPosit import * as editorCommon from 'vs/editor/common/editorCommon'; import { InputBox, IInputOptions } from 'vs/base/browser/ui/inputbox/inputBox'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { IContextViewService, IContextMenuService, ContextSubMenu } from 'vs/platform/contextview/browser/contextView'; +import { IContextViewService, IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { ISettingsGroup, IPreferencesService, getSettingsTargetName } from 'vs/workbench/parts/preferences/common/preferences'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';