mirror of
https://github.com/Microsoft/vscode
synced 2024-09-21 03:30:00 +00:00
Reduce usage of richEditSupport
This commit is contained in:
parent
a89447cca9
commit
3719c2f686
|
@ -131,52 +131,63 @@ export class RichEditSupport implements IRichEditSupport {
|
|||
|
||||
export class LanguageConfigurationRegistryImpl {
|
||||
|
||||
// private _entries: {[languageId:string]:RichEditSupport;};
|
||||
private _entries: {[languageId:string]:RichEditSupport;};
|
||||
|
||||
private _onDidChange: Emitter<void> = new Emitter<void>();
|
||||
public onDidChange: Event<void> = this._onDidChange.event;
|
||||
|
||||
constructor() {
|
||||
// this._entries = Object.create(null);
|
||||
this._entries = Object.create(null);
|
||||
}
|
||||
|
||||
// public register(languageId:string, configuration:IRichLanguageConfiguration): void {
|
||||
// console.log('TODO!');
|
||||
// }
|
||||
public register(languageId:string, configuration:IRichLanguageConfiguration): void {
|
||||
let previous = this._entries[languageId] || null;
|
||||
this._entries[languageId] = new RichEditSupport(languageId, previous, configuration);
|
||||
this._onDidChange.fire(void 0);
|
||||
}
|
||||
|
||||
private _getRichEditSupport(mode:IMode): IRichEditSupport {
|
||||
return /*this._entries[mode.getId()] || */mode.richEditSupport;
|
||||
}
|
||||
|
||||
public getElectricCharacterSupport(mode:IMode): IRichEditElectricCharacter {
|
||||
if (!mode.richEditSupport) {
|
||||
let value = this._getRichEditSupport(mode);
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
return mode.richEditSupport.electricCharacter || null;
|
||||
return value.electricCharacter || null;
|
||||
}
|
||||
|
||||
public getComments(mode:IMode): ICommentsConfiguration {
|
||||
if (!mode.richEditSupport) {
|
||||
let value = this._getRichEditSupport(mode);
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
return mode.richEditSupport.comments || null;
|
||||
return value.comments || null;
|
||||
}
|
||||
|
||||
public getCharacterPairSupport(mode:IMode): IRichEditCharacterPair {
|
||||
if (!mode.richEditSupport) {
|
||||
let value = this._getRichEditSupport(mode);
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
return mode.richEditSupport.characterPair || null;
|
||||
return value.characterPair || null;
|
||||
}
|
||||
|
||||
public getWordDefinition(mode:IMode): RegExp {
|
||||
if (!mode.richEditSupport) {
|
||||
let value = this._getRichEditSupport(mode);
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
return mode.richEditSupport.wordDefinition || null;
|
||||
return value.wordDefinition || null;
|
||||
}
|
||||
|
||||
public getOnEnterSupport(mode:IMode): IRichEditOnEnter {
|
||||
if (!mode.richEditSupport) {
|
||||
let value = this._getRichEditSupport(mode);
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
return mode.richEditSupport.onEnter || null;
|
||||
return value.onEnter || null;
|
||||
}
|
||||
|
||||
public getRawEnterActionAtPosition(model:ITokenizedModel, lineNumber:number, column:number): IEnterAction {
|
||||
|
@ -232,10 +243,11 @@ export class LanguageConfigurationRegistryImpl {
|
|||
}
|
||||
|
||||
public getBracketsSupport(mode:IMode): IRichEditBrackets {
|
||||
if (!mode.richEditSupport) {
|
||||
let value = this._getRichEditSupport(mode);
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
return mode.richEditSupport.brackets || null;
|
||||
return value.brackets || null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,12 +81,7 @@ export class NullMode implements modes.IMode {
|
|||
|
||||
public static ID = 'vs.editor.modes.nullMode';
|
||||
|
||||
public richEditSupport: modes.IRichEditSupport;
|
||||
|
||||
constructor() {
|
||||
this.richEditSupport = {
|
||||
wordDefinition: NullMode.DEFAULT_WORD_REGEXP
|
||||
};
|
||||
}
|
||||
|
||||
public getId():string {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import {RichEditSupport} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {createOnEnterAsserter, executeMonarchTokenizationTests} from 'vs/editor/test/common/modesUtil';
|
||||
import {ILanguage, IRichLanguageConfiguration} from '../types';
|
||||
|
||||
|
@ -36,8 +35,7 @@ export function testTokenization(name:string, language: ILanguage, tests:ITestIt
|
|||
export function testOnEnter(name:string, conf: IRichLanguageConfiguration, callback:(assertOnEnter: IOnEnterAsserter)=>void): void {
|
||||
suite(name, () => {
|
||||
test('onEnter', () => {
|
||||
var richEditSupport = new RichEditSupport('test', null, conf);
|
||||
callback(createOnEnterAsserter('test', richEditSupport));
|
||||
callback(createOnEnterAsserter('test', conf));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,10 +9,13 @@ import {AbstractState} from 'vs/editor/common/modes/abstractState';
|
|||
import {TokenizationSupport} from 'vs/editor/common/modes/supports/tokenizationSupport';
|
||||
|
||||
export class MockMode implements IMode {
|
||||
|
||||
private static instanceCount = 0;
|
||||
private _id:string;
|
||||
|
||||
constructor(id:string = 'mockMode') {
|
||||
if (typeof id === 'undefined') {
|
||||
id = 'mockMode' + (++MockMode.instanceCount);
|
||||
}
|
||||
this._id = id;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import {createTokenizationSupport} from 'vs/editor/common/modes/monarch/monarchL
|
|||
import {ILanguage} from 'vs/editor/common/modes/monarch/monarchTypes';
|
||||
import {createMockModeService} from 'vs/editor/test/common/servicesTestUtils';
|
||||
import {MockMode} from 'vs/editor/test/common/mocks/mockMode';
|
||||
import {RichEditSupport, IRichLanguageConfiguration} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
|
||||
export interface ITestItem {
|
||||
line: string;
|
||||
|
@ -47,13 +48,14 @@ export interface IOnEnterAsserter {
|
|||
indentsOutdents(oneLineAboveText:string, beforeText:string, afterText:string): void;
|
||||
}
|
||||
|
||||
export function createOnEnterAsserter(modeId:string, richEditSupport: modes.IRichEditSupport): IOnEnterAsserter {
|
||||
export function createOnEnterAsserter(modeId:string, conf: IRichLanguageConfiguration): IOnEnterAsserter {
|
||||
var assertOne = (oneLineAboveText:string, beforeText:string, afterText:string, expected: modes.IndentAction) => {
|
||||
var model = new Model(
|
||||
[ oneLineAboveText, beforeText + afterText ].join('\n'),
|
||||
Model.DEFAULT_CREATION_OPTIONS,
|
||||
new MockMode(modeId)
|
||||
);
|
||||
var richEditSupport = new RichEditSupport(modeId, null, conf);
|
||||
var actual = richEditSupport.onEnter.onEnter(model, { lineNumber: 2, column: beforeText.length + 1 });
|
||||
if (expected === modes.IndentAction.None) {
|
||||
assert.equal(actual, null, oneLineAboveText + '\\n' + beforeText + '|' + afterText);
|
||||
|
|
|
@ -17,7 +17,7 @@ import {AbstractState} from 'vs/editor/common/modes/abstractState';
|
|||
import {IMarker} from 'vs/platform/markers/common/markers';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IThreadService, ThreadAffinity} from 'vs/platform/thread/common/thread';
|
||||
import {RichEditSupport} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {RichEditSupport, IRichLanguageConfiguration} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {TokenizationSupport} from 'vs/editor/common/modes/supports/tokenizationSupport';
|
||||
import {wireCancellationToken} from 'vs/base/common/async';
|
||||
|
||||
|
@ -278,6 +278,29 @@ export class State extends AbstractState {
|
|||
|
||||
export class CSSMode extends AbstractMode {
|
||||
|
||||
public static LANG_CONFIG:IRichLanguageConfiguration = {
|
||||
// TODO@Martin: This definition does not work with umlauts for example
|
||||
wordPattern: /(#?-?\d*\.\d\w*%?)|((::|[@#.!:])?[\w-?]+%?)|::|[@#.!:]/g,
|
||||
|
||||
comments: {
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
],
|
||||
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"', notIn: ['string'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string'] }
|
||||
]
|
||||
};
|
||||
|
||||
public tokenizationSupport: modes.ITokenizationSupport;
|
||||
public richEditSupport: modes.IRichEditSupport;
|
||||
public inplaceReplaceSupport:modes.IInplaceReplaceSupport;
|
||||
|
@ -299,28 +322,7 @@ export class CSSMode extends AbstractMode {
|
|||
getInitialState: () => new State(this, States.Selector, false, null, false, 0)
|
||||
}, false, false);
|
||||
|
||||
this.richEditSupport = new RichEditSupport(this.getId(), null, {
|
||||
// TODO@Martin: This definition does not work with umlauts for example
|
||||
wordPattern: /(#?-?\d*\.\d\w*%?)|((::|[@#.!:])?[\w-?]+%?)|::|[@#.!:]/g,
|
||||
|
||||
comments: {
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
],
|
||||
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"', notIn: ['string'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string'] }
|
||||
]
|
||||
});
|
||||
this.richEditSupport = new RichEditSupport(this.getId(), null, CSSMode.LANG_CONFIG);
|
||||
|
||||
this.inplaceReplaceSupport = this;
|
||||
this.configSupport = this;
|
||||
|
|
|
@ -32,7 +32,7 @@ suite('CSS Colorizing', () => {
|
|||
);
|
||||
|
||||
tokenizationSupport = mode.tokenizationSupport;
|
||||
assertOnEnter = modesUtil.createOnEnterAsserter(mode.getId(), mode.richEditSupport);
|
||||
assertOnEnter = modesUtil.createOnEnterAsserter(mode.getId(), CSSMode.LANG_CONFIG);
|
||||
wordDefinition = LanguageConfigurationRegistry.getWordDefinition(mode);
|
||||
})();
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import handlebarsTokenTypes = require('vs/languages/handlebars/common/handlebars
|
|||
import htmlWorker = require('vs/languages/html/common/htmlWorker');
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IModeService} from 'vs/editor/common/services/modeService';
|
||||
import {RichEditSupport} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {RichEditSupport, IRichLanguageConfiguration} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {createWordRegExp} from 'vs/editor/common/modes/abstractMode';
|
||||
import {ILeavingNestedModeData} from 'vs/editor/common/modes/supports/tokenizationSupport';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
|
@ -107,6 +107,49 @@ export class HandlebarsState extends htmlMode.State {
|
|||
|
||||
export class HandlebarsMode extends htmlMode.HTMLMode<htmlWorker.HTMLWorker> {
|
||||
|
||||
public static LANG_CONFIG:IRichLanguageConfiguration = {
|
||||
wordPattern: createWordRegExp('#-?%'),
|
||||
|
||||
comments: {
|
||||
blockComment: ['<!--', '-->']
|
||||
},
|
||||
|
||||
brackets: [
|
||||
['<!--', '-->'],
|
||||
['{{', '}}']
|
||||
],
|
||||
|
||||
__electricCharacterSupport: {
|
||||
embeddedElectricCharacters: ['*', '}', ']', ')']
|
||||
},
|
||||
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
],
|
||||
|
||||
surroundingPairs: [
|
||||
{ open: '<', close: '>' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
],
|
||||
|
||||
onEnterRules: [
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${htmlMode.EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
afterText: /^<\/(\w[\w\d]*)\s*>$/i,
|
||||
action: { indentAction: modes.IndentAction.IndentOutdent }
|
||||
},
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${htmlMode.EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
action: { indentAction: modes.IndentAction.Indent }
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
constructor(
|
||||
descriptor:modes.IModeDescriptor,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
|
@ -151,49 +194,7 @@ export class HandlebarsMode extends htmlMode.HTMLMode<htmlWorker.HTMLWorker> {
|
|||
}
|
||||
|
||||
protected _createRichEditSupport(): modes.IRichEditSupport {
|
||||
return new RichEditSupport(this.getId(), null, {
|
||||
|
||||
wordPattern: createWordRegExp('#-?%'),
|
||||
|
||||
comments: {
|
||||
blockComment: ['<!--', '-->']
|
||||
},
|
||||
|
||||
brackets: [
|
||||
['<!--', '-->'],
|
||||
['{{', '}}']
|
||||
],
|
||||
|
||||
__electricCharacterSupport: {
|
||||
embeddedElectricCharacters: ['*', '}', ']', ')']
|
||||
},
|
||||
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
],
|
||||
|
||||
surroundingPairs: [
|
||||
{ open: '<', close: '>' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
],
|
||||
|
||||
onEnterRules: [
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${htmlMode.EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
afterText: /^<\/(\w[\w\d]*)\s*>$/i,
|
||||
action: { indentAction: modes.IndentAction.IndentOutdent }
|
||||
},
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${htmlMode.EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
action: { indentAction: modes.IndentAction.Indent }
|
||||
}
|
||||
],
|
||||
});
|
||||
return new RichEditSupport(this.getId(), null, HandlebarsMode.LANG_CONFIG);
|
||||
}
|
||||
|
||||
public getInitialState() : modes.IState {
|
||||
|
|
|
@ -16,7 +16,7 @@ import {IModeService} from 'vs/editor/common/services/modeService';
|
|||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import * as htmlTokenTypes from 'vs/languages/html/common/htmlTokenTypes';
|
||||
import {EMPTY_ELEMENTS} from 'vs/languages/html/common/htmlEmptyTagsShared';
|
||||
import {RichEditSupport} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {RichEditSupport, IRichLanguageConfiguration} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {TokenizationSupport, IEnteringNestedModeData, ILeavingNestedModeData, ITokenizationCustomization} from 'vs/editor/common/modes/supports/tokenizationSupport';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {wireCancellationToken} from 'vs/base/common/async';
|
||||
|
@ -285,6 +285,48 @@ export class State extends AbstractState {
|
|||
|
||||
export class HTMLMode<W extends htmlWorker.HTMLWorker> extends AbstractMode implements ITokenizationCustomization {
|
||||
|
||||
public static LANG_CONFIG:IRichLanguageConfiguration = {
|
||||
wordPattern: createWordRegExp('#-?%'),
|
||||
|
||||
comments: {
|
||||
blockComment: ['<!--', '-->']
|
||||
},
|
||||
|
||||
brackets: [
|
||||
['<!--', '-->'],
|
||||
['<', '>'],
|
||||
],
|
||||
|
||||
__electricCharacterSupport: {
|
||||
embeddedElectricCharacters: ['*', '}', ']', ')']
|
||||
},
|
||||
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
],
|
||||
|
||||
surroundingPairs: [
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
],
|
||||
|
||||
onEnterRules: [
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
afterText: /^<\/([_:\w][_:\w-.\d]*)\s*>$/i,
|
||||
action: { indentAction: modes.IndentAction.IndentOutdent }
|
||||
},
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
action: { indentAction: modes.IndentAction.Indent }
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
public tokenizationSupport: modes.ITokenizationSupport;
|
||||
public richEditSupport: modes.IRichEditSupport;
|
||||
public configSupport: modes.IConfigurationSupport;
|
||||
|
@ -373,48 +415,7 @@ export class HTMLMode<W extends htmlWorker.HTMLWorker> extends AbstractMode impl
|
|||
}
|
||||
|
||||
protected _createRichEditSupport(): modes.IRichEditSupport {
|
||||
return new RichEditSupport(this.getId(), null, {
|
||||
|
||||
wordPattern: createWordRegExp('#-?%'),
|
||||
|
||||
comments: {
|
||||
blockComment: ['<!--', '-->']
|
||||
},
|
||||
|
||||
brackets: [
|
||||
['<!--', '-->'],
|
||||
['<', '>'],
|
||||
],
|
||||
|
||||
__electricCharacterSupport: {
|
||||
embeddedElectricCharacters: ['*', '}', ']', ')']
|
||||
},
|
||||
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
],
|
||||
|
||||
surroundingPairs: [
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
],
|
||||
|
||||
onEnterRules: [
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
afterText: /^<\/([_:\w][_:\w-.\d]*)\s*>$/i,
|
||||
action: { indentAction: modes.IndentAction.IndentOutdent }
|
||||
},
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
action: { indentAction: modes.IndentAction.Indent }
|
||||
}
|
||||
],
|
||||
});
|
||||
return new RichEditSupport(this.getId(), null, HTMLMode.LANG_CONFIG);
|
||||
}
|
||||
|
||||
// TokenizationSupport
|
||||
|
|
|
@ -16,11 +16,31 @@ import {OneWorkerAttr, AllWorkersAttr} from 'vs/platform/thread/common/threadSer
|
|||
import {IThreadService, ThreadAffinity} from 'vs/platform/thread/common/thread';
|
||||
import {IJSONContributionRegistry, Extensions, ISchemaContributions} from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {RichEditSupport} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {RichEditSupport, IRichLanguageConfiguration} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {wireCancellationToken} from 'vs/base/common/async';
|
||||
|
||||
export class JSONMode extends AbstractMode {
|
||||
|
||||
public static LANG_CONFIG:IRichLanguageConfiguration = {
|
||||
wordPattern: createWordRegExp('.-'),
|
||||
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']']
|
||||
],
|
||||
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}', notIn: ['string'] },
|
||||
{ open: '[', close: ']', notIn: ['string'] },
|
||||
{ open: '"', close: '"', notIn: ['string'] }
|
||||
]
|
||||
};
|
||||
|
||||
public tokenizationSupport: modes.ITokenizationSupport;
|
||||
public richEditSupport: modes.IRichEditSupport;
|
||||
public configSupport:modes.IConfigurationSupport;
|
||||
|
@ -40,26 +60,7 @@ export class JSONMode extends AbstractMode {
|
|||
|
||||
this.tokenizationSupport = tokenization.createTokenizationSupport(this, true);
|
||||
|
||||
this.richEditSupport = new RichEditSupport(this.getId(), null, {
|
||||
|
||||
wordPattern: createWordRegExp('.-'),
|
||||
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']']
|
||||
],
|
||||
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}', notIn: ['string'] },
|
||||
{ open: '[', close: ']', notIn: ['string'] },
|
||||
{ open: '"', close: '"', notIn: ['string'] }
|
||||
]
|
||||
});
|
||||
this.richEditSupport = new RichEditSupport(this.getId(), null, JSONMode.LANG_CONFIG);
|
||||
|
||||
modes.HoverProviderRegistry.register(this.getId(), {
|
||||
provideHover: (model, position, token): Thenable<modes.Hover> => {
|
||||
|
|
|
@ -33,7 +33,7 @@ suite('JSON - tokenization', () => {
|
|||
);
|
||||
|
||||
tokenizationSupport = mode.tokenizationSupport;
|
||||
assertOnEnter = modesUtil.createOnEnterAsserter(mode.getId(), mode.richEditSupport);
|
||||
assertOnEnter = modesUtil.createOnEnterAsserter(mode.getId(), jsonMode.JSONMode.LANG_CONFIG);
|
||||
|
||||
})();
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import {IModelService} from 'vs/editor/common/services/modelService';
|
|||
import {IEditorWorkerService} from 'vs/editor/common/services/editorWorkerService';
|
||||
import {wireCancellationToken} from 'vs/base/common/async';
|
||||
import {createTokenizationSupport} from 'vs/editor/common/modes/monarch/monarchLexer';
|
||||
import {RichEditSupport} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {RichEditSupport, IRichLanguageConfiguration} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
|
||||
export var language: Types.ILanguage = <Types.ILanguage> {
|
||||
defaultToken: '',
|
||||
|
@ -168,6 +168,24 @@ export var language: Types.ILanguage = <Types.ILanguage> {
|
|||
|
||||
export class LESSMode extends AbstractMode {
|
||||
|
||||
public static LANG_CONFIG:IRichLanguageConfiguration = {
|
||||
// TODO@Martin: This definition does not work with umlauts for example
|
||||
wordPattern: /(#?-?\d*\.\d\w*%?)|([@#!.:]?[\w-?]+%?)|[@#!.]/g,
|
||||
comments: {
|
||||
blockComment: ['/*', '*/'],
|
||||
lineComment: '//'
|
||||
},
|
||||
brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']],
|
||||
autoClosingPairs: [
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: '{', close: '}', notIn: ['string', 'comment'] },
|
||||
{ open: '[', close: ']', notIn: ['string', 'comment'] },
|
||||
{ open: '(', close: ')', notIn: ['string', 'comment'] },
|
||||
{ open: '<', close: '>', notIn: ['string', 'comment'] },
|
||||
]
|
||||
};
|
||||
|
||||
public inplaceReplaceSupport:modes.IInplaceReplaceSupport;
|
||||
public configSupport:modes.IConfigurationSupport;
|
||||
public tokenizationSupport: modes.ITokenizationSupport;
|
||||
|
@ -231,23 +249,7 @@ export class LESSMode extends AbstractMode {
|
|||
|
||||
this.tokenizationSupport = createTokenizationSupport(modeService, this, lexer);
|
||||
|
||||
this.richEditSupport = new RichEditSupport(this.getId(), null, {
|
||||
// TODO@Martin: This definition does not work with umlauts for example
|
||||
wordPattern: /(#?-?\d*\.\d\w*%?)|([@#!.:]?[\w-?]+%?)|[@#!.]/g,
|
||||
comments: {
|
||||
blockComment: ['/*', '*/'],
|
||||
lineComment: '//'
|
||||
},
|
||||
brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']],
|
||||
autoClosingPairs: [
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: '{', close: '}', notIn: ['string', 'comment'] },
|
||||
{ open: '[', close: ']', notIn: ['string', 'comment'] },
|
||||
{ open: '(', close: ')', notIn: ['string', 'comment'] },
|
||||
{ open: '<', close: '>', notIn: ['string', 'comment'] },
|
||||
]
|
||||
});
|
||||
this.richEditSupport = new RichEditSupport(this.getId(), null, LESSMode.LANG_CONFIG);
|
||||
}
|
||||
|
||||
public creationDone(): void {
|
||||
|
|
|
@ -63,7 +63,7 @@ suite('LESS-tokenization', () => {
|
|||
);
|
||||
|
||||
tokenizationSupport = mode.tokenizationSupport;
|
||||
assertOnEnter = modesUtil.createOnEnterAsserter(mode.getId(), mode.richEditSupport);
|
||||
assertOnEnter = modesUtil.createOnEnterAsserter(mode.getId(), LESSMode.LANG_CONFIG);
|
||||
})();
|
||||
|
||||
test('', () => {
|
||||
|
|
|
@ -20,7 +20,7 @@ import {IConfigurationService} from 'vs/platform/configuration/common/configurat
|
|||
import {IEditorWorkerService} from 'vs/editor/common/services/editorWorkerService';
|
||||
import {AbstractMode, ModeWorkerManager} from 'vs/editor/common/modes/abstractMode';
|
||||
import {createTokenizationSupport} from 'vs/editor/common/modes/monarch/monarchLexer';
|
||||
import {RichEditSupport} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {RichEditSupport, IRichLanguageConfiguration} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {wireCancellationToken} from 'vs/base/common/async';
|
||||
|
||||
export const language =
|
||||
|
@ -199,6 +199,14 @@ export const language =
|
|||
|
||||
export class MarkdownMode extends AbstractMode implements Modes.IEmitOutputSupport {
|
||||
|
||||
public static LANG_CONFIG:IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
blockComment: ['<!--', '-->',]
|
||||
},
|
||||
brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']],
|
||||
autoClosingPairs: []
|
||||
};
|
||||
|
||||
public emitOutputSupport: Modes.IEmitOutputSupport;
|
||||
public configSupport:Modes.IConfigurationSupport;
|
||||
public tokenizationSupport: Modes.ITokenizationSupport;
|
||||
|
@ -226,13 +234,7 @@ export class MarkdownMode extends AbstractMode implements Modes.IEmitOutputSuppo
|
|||
|
||||
this.tokenizationSupport = createTokenizationSupport(modeService, this, lexer);
|
||||
|
||||
this.richEditSupport = new RichEditSupport(this.getId(), null, {
|
||||
comments: {
|
||||
blockComment: ['<!--', '-->',]
|
||||
},
|
||||
brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']],
|
||||
autoClosingPairs: []
|
||||
});
|
||||
this.richEditSupport = new RichEditSupport(this.getId(), null, MarkdownMode.LANG_CONFIG);
|
||||
|
||||
Modes.SuggestRegistry.register(this.getId(), {
|
||||
triggerCharacters: [],
|
||||
|
|
|
@ -10,7 +10,7 @@ import Modes = require('vs/editor/common/modes');
|
|||
import {AbstractMode, isDigit, createWordRegExp} from 'vs/editor/common/modes/abstractMode';
|
||||
import {AbstractState} from 'vs/editor/common/modes/abstractState';
|
||||
import {IModeService} from 'vs/editor/common/services/modeService';
|
||||
import {RichEditSupport} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {RichEditSupport, IRichLanguageConfiguration} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {TokenizationSupport, ILeavingNestedModeData, ITokenizationCustomization} from 'vs/editor/common/modes/supports/tokenizationSupport';
|
||||
import {TextualSuggestSupport} from 'vs/editor/common/modes/supports/suggestSupport';
|
||||
import {IEditorWorkerService} from 'vs/editor/common/services/editorWorkerService';
|
||||
|
@ -452,6 +452,29 @@ export class PHPEnterHTMLState extends PHPState {
|
|||
|
||||
export class PHPMode extends AbstractMode implements ITokenizationCustomization {
|
||||
|
||||
public static LANG_CONFIG:IRichLanguageConfiguration = {
|
||||
wordPattern: createWordRegExp('$_'),
|
||||
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
],
|
||||
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}', notIn: ['string.php'] },
|
||||
{ open: '[', close: ']', notIn: ['string.php'] },
|
||||
{ open: '(', close: ')', notIn: ['string.php'] },
|
||||
{ open: '"', close: '"', notIn: ['string.php'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string.php'] }
|
||||
]
|
||||
};
|
||||
|
||||
public tokenizationSupport: Modes.ITokenizationSupport;
|
||||
public richEditSupport: Modes.IRichEditSupport;
|
||||
|
||||
|
@ -468,28 +491,7 @@ export class PHPMode extends AbstractMode implements ITokenizationCustomization
|
|||
|
||||
this.tokenizationSupport = new TokenizationSupport(this, this, true, false);
|
||||
|
||||
this.richEditSupport = new RichEditSupport(this.getId(), null, {
|
||||
wordPattern: createWordRegExp('$_'),
|
||||
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
],
|
||||
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}', notIn: ['string.php'] },
|
||||
{ open: '[', close: ']', notIn: ['string.php'] },
|
||||
{ open: '(', close: ')', notIn: ['string.php'] },
|
||||
{ open: '"', close: '"', notIn: ['string.php'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string.php'] }
|
||||
]
|
||||
});
|
||||
this.richEditSupport = new RichEditSupport(this.getId(), null, PHPMode.LANG_CONFIG);
|
||||
|
||||
if (editorWorkerService) {
|
||||
Modes.SuggestRegistry.register(this.getId(), new TextualSuggestSupport(editorWorkerService, configurationService), true);
|
||||
|
|
|
@ -75,7 +75,7 @@ suite('Syntax Highlighting - PHP', () => {
|
|||
);
|
||||
|
||||
tokenizationSupport = mode.tokenizationSupport;
|
||||
assertOnEnter = modesUtil.createOnEnterAsserter(mode.getId(), mode.richEditSupport);
|
||||
assertOnEnter = modesUtil.createOnEnterAsserter(mode.getId(), PHPMode.LANG_CONFIG);
|
||||
wordDefinition = LanguageConfigurationRegistry.getWordDefinition(mode);
|
||||
})();
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import razorTokenTypes = require('vs/languages/razor/common/razorTokenTypes');
|
|||
import {RAZORWorker} from 'vs/languages/razor/common/razorWorker';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IModeService} from 'vs/editor/common/services/modeService';
|
||||
import {RichEditSupport} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {RichEditSupport, IRichLanguageConfiguration} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {ILeavingNestedModeData} from 'vs/editor/common/modes/supports/tokenizationSupport';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {wireCancellationToken} from 'vs/base/common/async';
|
||||
|
@ -56,6 +56,48 @@ class RAZORState extends htmlMode.State {
|
|||
|
||||
export class RAZORMode extends htmlMode.HTMLMode<RAZORWorker> {
|
||||
|
||||
public static LANG_CONFIG:IRichLanguageConfiguration = {
|
||||
wordPattern: createWordRegExp('#?%'),
|
||||
|
||||
comments: {
|
||||
blockComment: ['<!--', '-->']
|
||||
},
|
||||
|
||||
brackets: [
|
||||
['<!--', '-->'],
|
||||
['{', '}'],
|
||||
['(', ')']
|
||||
],
|
||||
|
||||
__electricCharacterSupport: {
|
||||
embeddedElectricCharacters: ['*', '}', ']', ')']
|
||||
},
|
||||
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
],
|
||||
|
||||
onEnterRules: [
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${htmlMode.EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
afterText: /^<\/(\w[\w\d]*)\s*>$/i,
|
||||
action: { indentAction: modes.IndentAction.IndentOutdent }
|
||||
},
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${htmlMode.EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
action: { indentAction: modes.IndentAction.Indent }
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
constructor(
|
||||
descriptor:modes.IModeDescriptor,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
|
@ -104,48 +146,7 @@ export class RAZORMode extends htmlMode.HTMLMode<RAZORWorker> {
|
|||
}
|
||||
|
||||
protected _createRichEditSupport(): modes.IRichEditSupport {
|
||||
return new RichEditSupport(this.getId(), null, {
|
||||
|
||||
wordPattern: createWordRegExp('#?%'),
|
||||
|
||||
comments: {
|
||||
blockComment: ['<!--', '-->']
|
||||
},
|
||||
|
||||
brackets: [
|
||||
['<!--', '-->'],
|
||||
['{', '}'],
|
||||
['(', ')']
|
||||
],
|
||||
|
||||
__electricCharacterSupport: {
|
||||
embeddedElectricCharacters: ['*', '}', ']', ')']
|
||||
},
|
||||
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
],
|
||||
|
||||
onEnterRules: [
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${htmlMode.EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
afterText: /^<\/(\w[\w\d]*)\s*>$/i,
|
||||
action: { indentAction: modes.IndentAction.IndentOutdent }
|
||||
},
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${htmlMode.EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
action: { indentAction: modes.IndentAction.Indent }
|
||||
}
|
||||
],
|
||||
});
|
||||
return new RichEditSupport(this.getId(), null, RAZORMode.LANG_CONFIG);
|
||||
}
|
||||
|
||||
public getInitialState(): modes.IState {
|
||||
|
|
|
@ -21,7 +21,7 @@ import {IModelService} from 'vs/editor/common/services/modelService';
|
|||
import {IEditorWorkerService} from 'vs/editor/common/services/editorWorkerService';
|
||||
import {wireCancellationToken} from 'vs/base/common/async';
|
||||
import {createTokenizationSupport} from 'vs/editor/common/modes/monarch/monarchLexer';
|
||||
import {RichEditSupport} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {RichEditSupport, IRichLanguageConfiguration} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
|
||||
export var language = <Types.ILanguage>{
|
||||
defaultToken: '',
|
||||
|
@ -270,6 +270,24 @@ export var language = <Types.ILanguage>{
|
|||
|
||||
export class SASSMode extends AbstractMode {
|
||||
|
||||
public static LANG_CONFIG:IRichLanguageConfiguration = {
|
||||
// TODO@Martin: This definition does not work with umlauts for example
|
||||
wordPattern: /(#?-?\d*\.\d\w*%?)|([@#!.:]?[\w-?]+%?)|[@#!.]/g,
|
||||
comments: {
|
||||
blockComment: ['/*', '*/'],
|
||||
lineComment: '//'
|
||||
},
|
||||
brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']],
|
||||
autoClosingPairs: [
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: '{', close: '}', notIn: ['string', 'comment'] },
|
||||
{ open: '[', close: ']', notIn: ['string', 'comment'] },
|
||||
{ open: '(', close: ')', notIn: ['string', 'comment'] },
|
||||
{ open: '<', close: '>', notIn: ['string', 'comment'] },
|
||||
]
|
||||
};
|
||||
|
||||
public inplaceReplaceSupport:modes.IInplaceReplaceSupport;
|
||||
public configSupport:modes.IConfigurationSupport;
|
||||
public tokenizationSupport: modes.ITokenizationSupport;
|
||||
|
@ -332,23 +350,7 @@ export class SASSMode extends AbstractMode {
|
|||
|
||||
this.tokenizationSupport = createTokenizationSupport(modeService, this, lexer);
|
||||
|
||||
this.richEditSupport = new RichEditSupport(this.getId(), null, {
|
||||
// TODO@Martin: This definition does not work with umlauts for example
|
||||
wordPattern: /(#?-?\d*\.\d\w*%?)|([@#!.:]?[\w-?]+%?)|[@#!.]/g,
|
||||
comments: {
|
||||
blockComment: ['/*', '*/'],
|
||||
lineComment: '//'
|
||||
},
|
||||
brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']],
|
||||
autoClosingPairs: [
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: '{', close: '}', notIn: ['string', 'comment'] },
|
||||
{ open: '[', close: ']', notIn: ['string', 'comment'] },
|
||||
{ open: '(', close: ')', notIn: ['string', 'comment'] },
|
||||
{ open: '<', close: '>', notIn: ['string', 'comment'] },
|
||||
]
|
||||
});
|
||||
this.richEditSupport = new RichEditSupport(this.getId(), null, SASSMode.LANG_CONFIG);
|
||||
}
|
||||
|
||||
public creationDone(): void {
|
||||
|
|
|
@ -41,7 +41,7 @@ suite('Sass Colorizer', () => {
|
|||
);
|
||||
|
||||
tokenizationSupport = mode.tokenizationSupport;
|
||||
assertOnEnter = modesUtil.createOnEnterAsserter(mode.getId(), mode.richEditSupport);
|
||||
assertOnEnter = modesUtil.createOnEnterAsserter(mode.getId(), SASS.SASSMode.LANG_CONFIG);
|
||||
|
||||
})();
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import * as modes from 'vs/editor/common/modes';
|
|||
import * as lifecycle from 'vs/base/common/lifecycle';
|
||||
import {createTokenizationSupport2, Language} from 'vs/languages/typescript/common/tokenization';
|
||||
import {createWordRegExp} from 'vs/editor/common/modes/abstractMode';
|
||||
import {RichEditSupport, IRichLanguageConfiguration} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {IRichLanguageConfiguration} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {IModelService} from 'vs/editor/common/services/modelService';
|
||||
import {IModeService} from 'vs/editor/common/services/modeService';
|
||||
import {IMarkerService} from 'vs/platform/markers/common/markers';
|
||||
|
@ -38,7 +38,7 @@ function setupMode(modelService:IModelService, markerService:IMarkerService, mod
|
|||
disposables.push(modeService.registerTokenizationSupport2(modeId, createTokenizationSupport2(language)));
|
||||
}
|
||||
|
||||
const richEditConfiguration:IRichLanguageConfiguration = {
|
||||
export const richEditConfiguration:IRichLanguageConfiguration = {
|
||||
wordPattern: createWordRegExp('$'),
|
||||
|
||||
comments: {
|
||||
|
@ -95,10 +95,6 @@ const richEditConfiguration:IRichLanguageConfiguration = {
|
|||
]
|
||||
};
|
||||
|
||||
export function createRichEditSupport(modeId:string): RichEditSupport {
|
||||
return new RichEditSupport(modeId, null, richEditConfiguration);
|
||||
}
|
||||
|
||||
let isActivated = false;
|
||||
export function activate(ctx:ServicesAccessor): void {
|
||||
if (isActivated) {
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
import modesUtil = require('vs/editor/test/common/modesUtil');
|
||||
import {createTokenizationSupport2, Language} from 'vs/languages/typescript/common/tokenization';
|
||||
import {createRichEditSupport} from 'vs/languages/typescript/common/mode';
|
||||
import {richEditConfiguration} from 'vs/languages/typescript/common/mode';
|
||||
|
||||
suite('TS/JS - syntax highlighting', () => {
|
||||
|
||||
var tokenizationSupport = createTokenizationSupport2(Language.EcmaScript5);
|
||||
var assertOnEnter = modesUtil.createOnEnterAsserter('javascript', createRichEditSupport('javascript'));
|
||||
var assertOnEnter = modesUtil.createOnEnterAsserter('javascript', richEditConfiguration);
|
||||
|
||||
test('onEnter', function() {
|
||||
assertOnEnter.nothing('', '', 'var f = function() {');
|
||||
|
|
|
@ -18,7 +18,7 @@ import * as modes from 'vs/editor/common/modes';
|
|||
import {IEditorWorkerService} from 'vs/editor/common/services/editorWorkerService';
|
||||
import {AbstractMode, ModeWorkerManager} from 'vs/editor/common/modes/abstractMode';
|
||||
import {createTokenizationSupport} from 'vs/editor/common/modes/monarch/monarchLexer';
|
||||
import {RichEditSupport} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {RichEditSupport, IRichLanguageConfiguration} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {wireCancellationToken} from 'vs/base/common/async';
|
||||
|
||||
export const language: types.ILanguage = {
|
||||
|
@ -46,6 +46,18 @@ export const language: types.ILanguage = {
|
|||
|
||||
export class OutputMode extends AbstractMode {
|
||||
|
||||
public static LANG_CONFIG:IRichLanguageConfiguration = {
|
||||
brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']],
|
||||
autoClosingPairs: [
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: '{', close: '}', notIn: ['string', 'comment'] },
|
||||
{ open: '[', close: ']', notIn: ['string', 'comment'] },
|
||||
{ open: '(', close: ')', notIn: ['string', 'comment'] },
|
||||
{ open: '<', close: '>', notIn: ['string', 'comment'] },
|
||||
]
|
||||
};
|
||||
|
||||
public tokenizationSupport: modes.ITokenizationSupport;
|
||||
public richEditSupport: modes.IRichEditSupport;
|
||||
|
||||
|
@ -64,17 +76,7 @@ export class OutputMode extends AbstractMode {
|
|||
|
||||
this.tokenizationSupport = createTokenizationSupport(modeService, this, lexer);
|
||||
|
||||
this.richEditSupport = new RichEditSupport(this.getId(), null, {
|
||||
brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']],
|
||||
autoClosingPairs: [
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: '{', close: '}', notIn: ['string', 'comment'] },
|
||||
{ open: '[', close: ']', notIn: ['string', 'comment'] },
|
||||
{ open: '(', close: ')', notIn: ['string', 'comment'] },
|
||||
{ open: '<', close: '>', notIn: ['string', 'comment'] },
|
||||
]
|
||||
});
|
||||
this.richEditSupport = new RichEditSupport(this.getId(), null, OutputMode.LANG_CONFIG);
|
||||
|
||||
modes.LinkProviderRegistry.register(this.getId(), {
|
||||
provideLinks: (model, token): Thenable<modes.ILink[]> => {
|
||||
|
|
Loading…
Reference in a new issue