Skip to content

Commit

Permalink
Merge pull request #31045 from electroma/fr30_access_to_markers
Browse files Browse the repository at this point in the history
Added API to access editor markers
  • Loading branch information
jrieken authored Jul 21, 2017
2 parents 81e812c + a6e21c6 commit 0b24103
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build/monaco/monaco.d.ts.recipe
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion src/vs/editor/standalone/browser/standaloneEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 }): IMarker[] {
return StaticServices.markerService.get().read(filter);
}

/**
* Get the model that has `uri` if it exists.
*/
Expand Down Expand Up @@ -331,6 +340,7 @@ export function createMonacoEditorAPI(): typeof monaco.editor {
createModel: createModel,
setModelLanguage: setModelLanguage,
setModelMarkers: setModelMarkers,
getModelMarkers: getModelMarkers,
getModels: getModels,
getModel: getModel,
onDidCreateModel: onDidCreateModel,
Expand Down
24 changes: 24 additions & 0 deletions src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}): IMarker[];

/**
* Get the model that has `uri` if it exists.
*/
Expand Down Expand Up @@ -1029,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.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/markers/common/markers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<IMarkerService>('markerService');

export interface IMarkerService {
_serviceBrand: any;

Expand Down Expand Up @@ -114,3 +112,5 @@ export namespace IMarkerData {
return result.join('¦');
}
}

export const IMarkerService = createDecorator<IMarkerService>('markerService');

0 comments on commit 0b24103

Please sign in to comment.