提交 1a6d368c 编写于 作者: A Alex Dima

Define IRichLanguageConfiguration clearly (do not generate it through Monarch)

上级 e036c0e7
......@@ -215,8 +215,6 @@ export function createCustomMode(language:ILanguage): TPromise<modes.IMode> {
startup.initStaticServicesIfNecessary();
let staticPlatformServices = ensureStaticPlatformServices(null);
let modeService = staticPlatformServices.modeService;
let modelService = staticPlatformServices.modelService;
let editorWorkerService = staticPlatformServices.editorWorkerService;
let modeId = language.name;
let name = language.name;
......@@ -230,7 +228,7 @@ export function createCustomMode(language:ILanguage): TPromise<modes.IMode> {
if (mode.getId() !== modeId) {
return;
}
modeService.registerMonarchDefinition(modelService, editorWorkerService, modeId, language);
modeService.registerMonarchDefinition(modeId, language);
disposable.dispose();
});
......
......@@ -23,6 +23,8 @@ import {Position} from 'vs/editor/common/core/position';
import {Range} from 'vs/editor/common/core/range';
import {CancellationToken} from 'vs/base/common/cancellation';
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';
export function register(language:ILanguageExtensionPoint): void {
ModesRegistry.registerLanguage(language);
......@@ -295,7 +297,7 @@ export function registerMonarchStandaloneLanguage(language:ILanguageExtensionPoi
ModesRegistry.registerLanguage(language);
ExtensionsRegistry.registerOneTimeActivationEventListener('onLanguage:' + language.id, () => {
require([defModule], (value:{language:ILanguage}) => {
require([defModule], (value:{language:ILanguage;conf:IRichLanguageConfiguration}) => {
if (!value.language) {
console.error('Expected ' + defModule + ' to export a `language`');
return;
......@@ -304,10 +306,14 @@ export function registerMonarchStandaloneLanguage(language:ILanguageExtensionPoi
startup.initStaticServicesIfNecessary();
let staticPlatformServices = ensureStaticPlatformServices(null);
let modeService = staticPlatformServices.modeService;
let modelService = staticPlatformServices.modelService;
let editorWorkerService = staticPlatformServices.editorWorkerService;
modeService.registerMonarchDefinition(modelService, editorWorkerService, language.id, value.language);
let lexer = compile(value.language);
modeService.registerTokenizationSupport(language.id, (mode) => {
return createTokenizationSupport(modeService, mode, lexer);
});
modeService.registerRichEditSupport(language.id, value.conf);
}, (err) => {
console.error('Cannot find module ' + defModule, err);
});
......
......@@ -11,8 +11,6 @@ import {ServiceIdentifier, createDecorator} from 'vs/platform/instantiation/comm
import * as modes from 'vs/editor/common/modes';
import {ILanguage} from 'vs/editor/common/modes/monarch/monarchTypes';
import {IRichLanguageConfiguration} from 'vs/editor/common/modes/supports/richEditSupport';
import {IEditorWorkerService} from 'vs/editor/common/services/editorWorkerService';
import {IModelService} from 'vs/editor/common/services/modelService';
export var IModeService = createDecorator<IModeService>('modeService');
......@@ -76,5 +74,5 @@ export interface IModeService {
registerRichEditSupport(modeId: string, support: IRichLanguageConfiguration): IDisposable;
registerTokenizationSupport(modeId: string, callback: (mode: modes.IMode) => modes.ITokenizationSupport): IDisposable;
registerTokenizationSupport2(modeId: string, support: modes.TokensProvider): IDisposable;
registerMonarchDefinition(modelService: IModelService, editorWorkerService: IEditorWorkerService, modeId:string, language:ILanguage): IDisposable;
registerMonarchDefinition(modeId:string, language:ILanguage): IDisposable;
}
......@@ -26,10 +26,8 @@ import {createRichEditSupport} from 'vs/editor/common/modes/monarch/monarchDefin
import {createTokenizationSupport} from 'vs/editor/common/modes/monarch/monarchLexer';
import {ILanguage} from 'vs/editor/common/modes/monarch/monarchTypes';
import {IRichLanguageConfiguration, RichEditSupport} from 'vs/editor/common/modes/supports/richEditSupport';
import {IEditorWorkerService} from 'vs/editor/common/services/editorWorkerService';
import {LanguagesRegistry} from 'vs/editor/common/services/languagesRegistry';
import {ILanguageExtensionPoint, IValidLanguageExtensionPoint, IModeLookupResult, IModeService} from 'vs/editor/common/services/modeService';
import {IModelService} from 'vs/editor/common/services/modelService';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import {AbstractState} from 'vs/editor/common/modes/abstractState';
import {Token} from 'vs/editor/common/modes/supports';
......@@ -438,7 +436,7 @@ export class ModeServiceImpl implements IModeService {
);
}
public registerMonarchDefinition(modelService: IModelService, editorWorkerService:IEditorWorkerService, modeId:string, language:ILanguage): IDisposable {
public registerMonarchDefinition(modeId:string, language:ILanguage): IDisposable {
var lexer = compile(objects.clone(language));
return this.doRegisterMonarchDefinition(modeId, lexer);
}
......@@ -649,7 +647,7 @@ export class MainThreadModeServiceImpl extends ModeServiceImpl {
return super._createMode(modeId);
}
public registerMonarchDefinition(modelService: IModelService, editorWorkerService:IEditorWorkerService, modeId:string, language:ILanguage): IDisposable {
public registerMonarchDefinition(modeId:string, language:ILanguage): IDisposable {
this._getModeServiceWorkerHelper().registerMonarchDefinition(modeId, language);
var lexer = compile(objects.clone(language));
return super.doRegisterMonarchDefinition(modeId, lexer);
......@@ -691,6 +689,6 @@ export class ModeServiceWorkerHelper {
}
public registerMonarchDefinition(modeId:string, language:ILanguage): void {
this._modeService.registerMonarchDefinition(null, null, modeId, language);
this._modeService.registerMonarchDefinition(modeId, language);
}
}
......@@ -5,7 +5,25 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
blockComment: ['/*', '*/'],
lineComment: 'REM'
},
brackets: [['{','}'], ['[',']'], ['(',')']],
autoClosingPairs: [
{ open: '"', close: '"', notIn: ['string', 'comment'] },
{ open: '{', close: '}', notIn: ['string', 'comment'] },
{ open: '[', close: ']', notIn: ['string', 'comment'] },
{ open: '(', close: ')', notIn: ['string', 'comment'] },
],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'Batch',
......
......@@ -5,7 +5,27 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#%\^\&\*\(\)\=\$\-\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/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'] },
],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'CoffeeScript',
......
......@@ -5,7 +5,25 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '//',
blockComment: ['/*', '*/'],
},
brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']],
autoClosingPairs: [
{ open: '"', close: '"', notIn: ['string', 'comment'] },
{ open: '{', close: '}', notIn: ['string', 'comment'] },
{ open: '[', close: ']', notIn: ['string', 'comment'] },
{ open: '(', close: ')', notIn: ['string', 'comment'] },
],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'C++',
......
......@@ -5,7 +5,27 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
comments: {
lineComment: '//',
blockComment: ['/*', '*/'],
},
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'] },
],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: '',
......
......@@ -5,7 +5,27 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '//',
blockComment: ['/*', '*/'],
},
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'] },
],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage>{
displayName: 'Dockerfile',
......
......@@ -5,7 +5,25 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '//',
blockComment: ['(*', '*)'],
},
brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']],
autoClosingPairs: [
{ open: '{', close: '}', notIn: ['string', 'comment'] },
{ open: '[', close: ']', notIn: ['string', 'comment'] },
{ open: '(', close: ')', notIn: ['string', 'comment'] },
{ open: '"', close: '"', notIn: ['string', 'comment'] }
],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'F#',
......
......@@ -5,7 +5,25 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '//',
blockComment: ['/*', '*/'],
},
brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']],
autoClosingPairs: [
{ open: '{', close: '}', notIn: ['string', 'comment'] },
{ open: '[', close: ']', notIn: ['string', 'comment'] },
{ open: '(', close: ')', notIn: ['string', 'comment'] },
{ open: '"', close: '"', notIn: ['string', 'comment'] }
],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
......
......@@ -5,7 +5,27 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '#',
blockComment: ['#', ' '],
},
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'] },
],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'Ini',
......
......@@ -5,7 +5,26 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '//',
blockComment: ['/*', '*/'],
},
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'] },
],
__electricCharacterSupport: {
caseInsensitive: true,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'Jade',
......
......@@ -5,7 +5,29 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
// the default separators except `@$`
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
comments: {
lineComment: '//',
blockComment: ['/*', '*/'],
},
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'] },
],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'Java',
......
......@@ -5,7 +5,26 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '--',
blockComment: ['--[[', ']]'],
},
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'] },
],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'Lua',
......
......@@ -5,7 +5,27 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '//',
blockComment: ['/*', '*/'],
},
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'] },
],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'Objective-C',
......
......@@ -5,7 +5,26 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
// the default separators except `$-`
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#%\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
comments: {
lineComment: '#',
blockComment: ['<#', '#>'],
},
brackets: [['{','}'], ['[',']'], ['(',')']],
autoClosingPairs: [
{ open: '{', close: '}', notIn: ['string', 'comment'] },
{ open: '[', close: ']', notIn: ['string', 'comment'] },
{ open: '(', close: ')', notIn: ['string', 'comment'] },
],
__electricCharacterSupport: {
caseInsensitive: true,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'PowerShell',
......
......@@ -5,7 +5,26 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '#',
blockComment: ['\'\'\'', '\'\'\''],
},
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'] },
],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: '',
......
......@@ -5,7 +5,26 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '#',
blockComment: ['', ''],
},
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'] },
],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'R',
......
......@@ -5,7 +5,26 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '#',
blockComment: ['=begin', '=end'],
},
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'] },
],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: ['d']
}
};
/*
* Ruby language definition
......
......@@ -5,7 +5,25 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '--',
blockComment: ['/*', '*/'],
},
brackets: [['[',']'],['(',')']],
autoClosingPairs: [
{ open: '"', close: '"', notIn: ['string', 'comment'] },
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
{ open: '[', close: ']', notIn: ['string', 'comment'] },
{ open: '(', close: ')', notIn: ['string', 'comment'] },
],
__electricCharacterSupport: {
caseInsensitive: true,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'SQL',
......
......@@ -4,7 +4,27 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '//',
blockComment: ['/*', '*/'],
},
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'] },
],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'Swift',
......
......@@ -77,3 +77,68 @@ export interface ILanguageBracket {
// tokenType?: string; // The type of the token. Matches from 'open' or 'close' will be expanded, e.g. 'keyword.$1'.
// // Only used to auto-(un)indent a closing bracket.
// }
export type CharacterPair = [string, string];
export interface CommentRule {
lineComment?: string;
blockComment?: CharacterPair;
}
export interface IIndentationRules {
decreaseIndentPattern: RegExp;
increaseIndentPattern: RegExp;
indentNextLinePattern?: RegExp;
unIndentedLinePattern?: RegExp;
}
export interface IOnEnterRegExpRules {
beforeText: RegExp;
afterText?: RegExp;
action: IEnterAction;
}
export interface IEnterAction {
indentAction:IndentAction;
appendText?:string;
removeText?:number;
}
export enum IndentAction {
None,
Indent,
IndentOutdent,
Outdent
}
export interface IAutoClosingPair {
open:string;
close:string;
}
export interface IAutoClosingPairConditional extends IAutoClosingPair {
notIn?: string[];
}
export interface IDocComment {
scope: string; // What tokens should be used to detect a doc comment (e.g. 'comment.documentation').
open: string; // The string that starts a doc comment (e.g. '/**')
lineStart: string; // The string that appears at the start of each line, except the first and last (e.g. ' * ').
close?: string; // The string that appears on the last line and closes the doc comment (e.g. ' */').
}
export interface IBracketElectricCharacterContribution {
docComment?: IDocComment;
caseInsensitive?: boolean;
embeddedElectricCharacters?: string[];
}
export interface IRichLanguageConfiguration {
comments?: CommentRule;
brackets?: CharacterPair[];
wordPattern?: RegExp;
indentationRules?: IIndentationRules;
onEnterRules?: IOnEnterRegExpRules[];
autoClosingPairs?: IAutoClosingPairConditional[];
surroundingPairs?: IAutoClosingPair[];
__electricCharacterSupport?: IBracketElectricCharacterContribution;
}
......@@ -5,7 +5,53 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '\'',
blockComment: ['/*', '*/'],
},
brackets: [
['{','}'],['[',']'],['(',')'],['<','>'],
['addhandler','end addhandler'],
['class','end class'],
['enum','end enum'],
['event','end event'],
['function','end function'],
['get','end get'],
['if','end if'],
['interface','end interface'],
['module','end module'],
['namespace','end namespace'],
['operator','end operator'],
['property','end property'],
['raiseevent','end raiseevent'],
['removehandler','end removehandler'],
['select','end select'],
['set','end set'],
['structure','end structure'],
['sub','end sub'],
['synclock','end synclock'],
['try','end try'],
['while','end while'],
['with','end with'],
['using','end using'],
['do','loop'],
['for','next']
],
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'] },
],
__electricCharacterSupport: {
caseInsensitive: true,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'VB',
......
......@@ -5,7 +5,23 @@
'use strict';
import {ILanguage} from './types';
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '',
blockComment: ['<!--', '-->'],
},
brackets: [['{','}'],['[',']'],['(',')'],['<','>']],
autoClosingPairs: [
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
{ open: '"', close: '"', notIn: ['string', 'comment'] },
],
__electricCharacterSupport: {
caseInsensitive: true,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'XML',
......
......@@ -92,7 +92,7 @@ export class MockModeService implements IModeService {
registerTokenizationSupport2(modeId: string, support: modes.TokensProvider): IDisposable {
throw new Error('Not implemented');
}
registerMonarchDefinition(modelService: IModelService, editorWorkerService: IEditorWorkerService, modeId:string, language:ILanguage): IDisposable {
registerMonarchDefinition(modeId:string, language:ILanguage): IDisposable {
throw new Error('Not implemented');
}
}
......@@ -20,7 +20,6 @@ import {IThreadService, ThreadAffinity} from 'vs/platform/thread/common/thread';
import {IModelService} from 'vs/editor/common/services/modelService';
import {IEditorWorkerService} from 'vs/editor/common/services/editorWorkerService';
import {wireCancellationToken} from 'vs/base/common/async';
import {createRichEditSupport} from 'vs/editor/common/modes/monarch/monarchDefinition';
import {createTokenizationSupport} from 'vs/editor/common/modes/monarch/monarchLexer';
import {RichEditSupport} from 'vs/editor/common/modes/supports/richEditSupport';
......@@ -241,7 +240,27 @@ export class LESSMode extends AbstractMode {
this.tokenizationSupport = createTokenizationSupport(modeService, this, lexer);
this.richEditSupport = new RichEditSupport(this.getId(), null, createRichEditSupport(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'] },
],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: []
}
});
}
public creationDone(): void {
......
......@@ -19,7 +19,6 @@ import {IThreadService} from 'vs/platform/thread/common/thread';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import {IEditorWorkerService} from 'vs/editor/common/services/editorWorkerService';
import {AbstractMode, ModeWorkerManager} from 'vs/editor/common/modes/abstractMode';
import {createRichEditSupport} from 'vs/editor/common/modes/monarch/monarchDefinition';
import {createTokenizationSupport} from 'vs/editor/common/modes/monarch/monarchLexer';
import {RichEditSupport} from 'vs/editor/common/modes/supports/richEditSupport';
import {wireCancellationToken} from 'vs/base/common/async';
......@@ -233,7 +232,17 @@ export class MarkdownMode extends AbstractMode implements Modes.IEmitOutputSuppo
this.tokenizationSupport = createTokenizationSupport(modeService, this, lexer);
this.richEditSupport = new RichEditSupport(this.getId(), null, createRichEditSupport(lexer));
this.richEditSupport = new RichEditSupport(this.getId(), null, {
comments: {
blockComment: ['<!--', '-->',]
},
brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']],
autoClosingPairs: [],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: []
}
});
Modes.SuggestRegistry.register(this.getId(), {
triggerCharacters: [],
......
......@@ -20,7 +20,6 @@ import {IThreadService, ThreadAffinity} from 'vs/platform/thread/common/thread';
import {IModelService} from 'vs/editor/common/services/modelService';
import {IEditorWorkerService} from 'vs/editor/common/services/editorWorkerService';
import {wireCancellationToken} from 'vs/base/common/async';
import {createRichEditSupport} from 'vs/editor/common/modes/monarch/monarchDefinition';
import {createTokenizationSupport} from 'vs/editor/common/modes/monarch/monarchLexer';
import {RichEditSupport} from 'vs/editor/common/modes/supports/richEditSupport';
......@@ -342,7 +341,27 @@ export class SASSMode extends AbstractMode {
this.tokenizationSupport = createTokenizationSupport(modeService, this, lexer);
this.richEditSupport = new RichEditSupport(this.getId(), null, createRichEditSupport(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'] },
],
__electricCharacterSupport: {
caseInsensitive: false,
embeddedElectricCharacters: []
}
});
}
public creationDone(): void {
......
......@@ -17,7 +17,6 @@ import URI from 'vs/base/common/uri';
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 {createRichEditSupport} from 'vs/editor/common/modes/monarch/monarchDefinition';
import {createTokenizationSupport} from 'vs/editor/common/modes/monarch/monarchLexer';
import {RichEditSupport} from 'vs/editor/common/modes/supports/richEditSupport';
import {wireCancellationToken} from 'vs/base/common/async';
......@@ -66,7 +65,21 @@ export class OutputMode extends AbstractMode {
this.tokenizationSupport = createTokenizationSupport(modeService, this, lexer);
this.richEditSupport = new RichEditSupport(this.getId(), null, createRichEditSupport(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'] },
],
__electricCharacterSupport: {
caseInsensitive: true,
embeddedElectricCharacters: []
}
});
modes.LinkProviderRegistry.register(this.getId(), {
provideLinks: (model, token): Thenable<modes.ILink[]> => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册