modeService.ts 3.5 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
'use strict';

import {createDecorator, ServiceIdentifier} from 'vs/platform/instantiation/common/instantiation';
import {TPromise} from 'vs/base/common/winjs.base';
import Modes = require('vs/editor/common/modes');
import Supports = require ('vs/editor/common/modes/supports');
import MonarchTypes = require('vs/editor/common/modes/monarch/monarchTypes');
import {IOnEnterSupportOptions} from 'vs/editor/common/modes/supports/onEnter';
import {IDisposable} from 'vs/base/common/lifecycle';
14
import {IRichEditConfiguration} from 'vs/editor/common/modes/supports/richEditSupport';
15
import {IDeclarationContribution} from 'vs/editor/common/modes/supports/declarationSupport';
16
import {IReferenceContribution} from 'vs/editor/common/modes/supports/referenceSupport';
17
import {IParameterHintsContribution} from 'vs/editor/common/modes/supports/parameterHintsSupport';
E
Erich Gamma 已提交
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

export var IModeService = createDecorator<IModeService>('modeService');

export interface IModeLookupResult {
	modeId: string;
	isInstantiated: boolean;
}

export interface IModeService {
	serviceId: ServiceIdentifier<any>;

	configureMode(modeName: string, options: any): void;
	configureModeById(modeId: string, options: any): void;
	configureAllModes(config:any): void;
	getConfigurationForMode(modeId:string): any;

	// --- instantiation
	lookup(commaSeparatedMimetypesOrCommaSeparatedIds: string): IModeLookupResult[];
	getMode(commaSeparatedMimetypesOrCommaSeparatedIds: string): Modes.IMode;
	getOrCreateMode(commaSeparatedMimetypesOrCommaSeparatedIds: string): TPromise<Modes.IMode>;
	getOrCreateModeByLanguageName(languageName: string): TPromise<Modes.IMode>;
	getOrCreateModeByFilenameOrFirstLine(filename: string, firstLine?:string): TPromise<Modes.IMode>;

	registerCodeLensSupport(modeId: string, support: Modes.ICodeLensSupport): IDisposable;
42
	registerDeclarativeDeclarationSupport(modeId: string, contribution: IDeclarationContribution): IDisposable;
E
Erich Gamma 已提交
43 44 45 46 47
	registerExtraInfoSupport(modeId: string, support: Modes.IExtraInfoSupport): IDisposable;
	registerFormattingSupport(modeId: string, support: Modes.IFormattingSupport): IDisposable;
	registerInplaceReplaceSupport(modeId: string, support: Modes.IInplaceReplaceSupport): IDisposable;
	registerOccurrencesSupport(modeId: string, support: Modes.IOccurrencesSupport): IDisposable;
	registerOutlineSupport(modeId: string, support: Modes.IOutlineSupport): IDisposable;
48
	registerDeclarativeParameterHintsSupport(modeId: string, support: IParameterHintsContribution): IDisposable;
E
Erich Gamma 已提交
49
	registerQuickFixSupport(modeId: string, support: Modes.IQuickFixSupport): IDisposable;
50
	registerDeclarativeReferenceSupport(modeId: string, contribution: IReferenceContribution): IDisposable;
E
Erich Gamma 已提交
51 52 53
	registerRenameSupport(modeId: string, support: Modes.IRenameSupport): IDisposable;
	registerDeclarativeSuggestSupport(modeId: string, declaration: Supports.ISuggestContribution): IDisposable;
	registerTokenizationSupport(modeId: string, callback: (mode: Modes.IMode) => Modes.ITokenizationSupport): IDisposable;
54
	registerRichEditSupport(modeId: string, support: IRichEditConfiguration): IDisposable;
E
Erich Gamma 已提交
55 56 57

	registerMonarchDefinition(modeId:string, language:MonarchTypes.ILanguage): IDisposable;
}