[standalone] add markers to code action provider API
This commit is contained in:
parent
b985edc9f5
commit
ddc2726071
4 changed files with 63 additions and 14 deletions
|
@ -69,7 +69,7 @@ export interface ICommandHandler {
|
|||
|
||||
declare module monaco.languages {
|
||||
|
||||
#includeAll(vs/editor/browser/standalone/standaloneLanguages;modes.=>;editorCommon.=>editor.):
|
||||
#includeAll(vs/editor/browser/standalone/standaloneLanguages;modes.=>;editorCommon.=>editor.;IMarkerData=>editor.IMarkerData):
|
||||
#include(vs/editor/common/modes/languageConfigurationRegistry): CommentRule, LanguageConfiguration
|
||||
#include(vs/editor/common/modes/supports/onEnter): IndentationRule, OnEnterRule
|
||||
#include(vs/editor/common/modes/supports/electricCharacter): IBracketElectricCharacterContribution, IDocComment
|
||||
|
|
|
@ -26,6 +26,7 @@ import {toThenable} from 'vs/base/common/async';
|
|||
import {compile} from 'vs/editor/common/modes/monarch/monarchCompile';
|
||||
import {createTokenizationSupport} from 'vs/editor/common/modes/monarch/monarchLexer';
|
||||
import {LanguageConfigurationRegistry} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {IMarkerData} from 'vs/platform/markers/common/markers';
|
||||
|
||||
/**
|
||||
* Register information about a new language.
|
||||
|
@ -148,8 +149,17 @@ export function registerCodeLensProvider(languageId:string, provider:modes.CodeL
|
|||
/**
|
||||
* Register a code action provider (used by e.g. quick fix).
|
||||
*/
|
||||
export function registerCodeActionProvider(languageId:string, provider:modes.CodeActionProvider): IDisposable {
|
||||
return modes.CodeActionProviderRegistry.register(languageId, provider);
|
||||
export function registerCodeActionProvider(languageId:string, provider:CodeActionProvider): IDisposable {
|
||||
return modes.CodeActionProviderRegistry.register(languageId, {
|
||||
provideCodeActions: (model:editorCommon.IReadOnlyModel, range:Range, token: CancellationToken): modes.CodeAction[] | Thenable<modes.CodeAction[]> => {
|
||||
startup.initStaticServicesIfNecessary();
|
||||
var markerService = ensureStaticPlatformServices(null).markerService;
|
||||
let markers = markerService.read({resource: model.uri }).filter(m => {
|
||||
return Range.areIntersectingOrTouching(m, range);
|
||||
});
|
||||
return provider.provideCodeActions(model, range, { markers }, token);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -197,6 +207,31 @@ export function registerCompletionItemProvider(languageId:string, provider:Compl
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains additional diagnostic information about the context in which
|
||||
* a [code action](#CodeActionProvider.provideCodeActions) is run.
|
||||
*/
|
||||
export interface CodeActionContext {
|
||||
|
||||
/**
|
||||
* An array of diagnostics.
|
||||
*
|
||||
* @readonly
|
||||
*/
|
||||
markers: IMarkerData[];
|
||||
}
|
||||
|
||||
/**
|
||||
* The code action interface defines the contract between extensions and
|
||||
* the [light bulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) feature.
|
||||
*/
|
||||
export interface CodeActionProvider {
|
||||
/**
|
||||
* Provide commands for the given document and range.
|
||||
*/
|
||||
provideCodeActions(model:editorCommon.IReadOnlyModel, range:Range, context: CodeActionContext, token: CancellationToken): modes.CodeAction[] | Thenable<modes.CodeAction[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Completion item kinds.
|
||||
*/
|
||||
|
|
|
@ -418,6 +418,7 @@ export interface CodeAction {
|
|||
/**
|
||||
* The code action interface defines the contract between extensions and
|
||||
* the [light bulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) feature.
|
||||
* @internal
|
||||
*/
|
||||
export interface CodeActionProvider {
|
||||
/**
|
||||
|
|
35
src/vs/monaco.d.ts
vendored
35
src/vs/monaco.d.ts
vendored
|
@ -3841,6 +3841,30 @@ declare module monaco.languages {
|
|||
*/
|
||||
export function registerCompletionItemProvider(languageId: string, provider: CompletionItemProvider): IDisposable;
|
||||
|
||||
/**
|
||||
* Contains additional diagnostic information about the context in which
|
||||
* a [code action](#CodeActionProvider.provideCodeActions) is run.
|
||||
*/
|
||||
export interface CodeActionContext {
|
||||
/**
|
||||
* An array of diagnostics.
|
||||
*
|
||||
* @readonly
|
||||
*/
|
||||
markers: editor.IMarkerData[];
|
||||
}
|
||||
|
||||
/**
|
||||
* The code action interface defines the contract between extensions and
|
||||
* the [light bulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) feature.
|
||||
*/
|
||||
export interface CodeActionProvider {
|
||||
/**
|
||||
* Provide commands for the given document and range.
|
||||
*/
|
||||
provideCodeActions(model: editor.IReadOnlyModel, range: Range, context: CodeActionContext, token: CancellationToken): CodeAction[] | Thenable<CodeAction[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Completion item kinds.
|
||||
*/
|
||||
|
@ -4175,17 +4199,6 @@ declare module monaco.languages {
|
|||
score: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* The code action interface defines the contract between extensions and
|
||||
* the [light bulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) feature.
|
||||
*/
|
||||
export interface CodeActionProvider {
|
||||
/**
|
||||
* Provide commands for the given document and range.
|
||||
*/
|
||||
provideCodeActions(model: editor.IReadOnlyModel, range: Range, token: CancellationToken): CodeAction[] | Thenable<CodeAction[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a parameter of a callable-signature. A parameter can
|
||||
* have a label and a doc-comment.
|
||||
|
|
Loading…
Reference in a new issue