提交 170db15a 编写于 作者: A Alex Dima

Fixes #8173: Adopt vscode-textmate with fast plist parser, make fast plist...

Fixes #8173: Adopt vscode-textmate with fast plist parser, make fast plist parser disableable via editor.useExperimentalParser
上级 97d27d0e
......@@ -418,9 +418,9 @@
"resolved": "https://registry.npmjs.org/vscode-debugprotocol/-/vscode-debugprotocol-1.10.0.tgz"
},
"vscode-textmate": {
"version": "1.1.0",
"from": "vscode-textmate@1.1.0",
"resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-1.1.0.tgz"
"version": "1.2.0",
"from": "vscode-textmate@1.2.0",
"resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-1.2.0.tgz"
},
"windows-mutex": {
"version": "0.2.0",
......
......@@ -29,7 +29,7 @@
"sax": "1.1.2",
"semver": "4.3.6",
"vscode-debugprotocol": "1.10.0",
"vscode-textmate": "1.1.0",
"vscode-textmate": "1.2.0",
"winreg": "1.2.0",
"xterm": "git+https://github.com/sourcelair/xterm.js.git#39c4356",
"yauzl": "2.3.1"
......
......@@ -14,6 +14,7 @@ import {LineTokens, Token} from 'vs/editor/common/modes/supports';
import {IModeService} from 'vs/editor/common/services/modeService';
import {IGrammar, Registry} from 'vscode-textmate';
import {ModeTransition} from 'vs/editor/common/core/modeTransition';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
export interface ITMSyntaxExtensionPoint {
language: string;
......@@ -54,6 +55,10 @@ let grammarsExtPoint = ExtensionsRegistry.registerExtensionPoint<ITMSyntaxExtens
}
});
interface MyEditorConfig {
useExperimentalParser: boolean;
}
export class MainProcessTextMateSyntax {
private _grammarRegistry: Registry;
private _modeService: IModeService;
......@@ -61,12 +66,21 @@ export class MainProcessTextMateSyntax {
private _injections: { [scopeName:string]: string[]; };
constructor(
@IModeService modeService: IModeService
@IModeService modeService: IModeService,
@IConfigurationService configurationService: IConfigurationService
) {
this._modeService = modeService;
this._scopeNameToFilePath = {};
this._injections = {};
let editorConfig = configurationService.getConfiguration<MyEditorConfig>('editor');
let useExperimentalParser = true;
if (typeof editorConfig.useExperimentalParser !== 'undefined') {
if (Boolean(editorConfig.useExperimentalParser) === false) {
useExperimentalParser = false;
}
}
this._grammarRegistry = new Registry({
getFilePath: (scopeName:string) => {
return this._scopeNameToFilePath[scopeName];
......@@ -74,7 +88,7 @@ export class MainProcessTextMateSyntax {
getInjections: (scopeName:string) => {
return this._injections[scopeName];
}
});
}, useExperimentalParser);
grammarsExtPoint.setHandler((extensions) => {
for (let i = 0; i < extensions.length; i++) {
......
......@@ -10,7 +10,7 @@ declare module "vscode-textmate" {
*/
export interface IGrammarLocator {
getFilePath(scopeName:string): string;
getInjections(scopeName:string): string[];
getInjections?(scopeName:string): string[];
}
/**
......@@ -18,10 +18,10 @@ export interface IGrammarLocator {
*/
export class Registry {
public static readGrammarInfo(path:string, callback:(err:any, grammarInfo:IGrammarInfo)=>void): void;
public static readGrammarInfoSync(path:string): IGrammarInfo;
public static readGrammarInfo(path:string, callback:(err:any, grammarInfo:IGrammarInfo)=>void, useExperimentalParser?:boolean): void;
public static readGrammarInfoSync(path:string, useExperimentalParser?:boolean): IGrammarInfo;
constructor(locator?:IGrammarLocator);
constructor(locator?:IGrammarLocator, useExperimentalParser?:boolean);
/**
* Load the grammar for `scopeName` and all referenced included grammars asynchronously.
......@@ -77,6 +77,7 @@ export interface StackElement {
ruleId: number;
enterPos: number;
endRule: string;
whileRule: string;
scopeName: string;
contentName: string;
......@@ -84,4 +85,5 @@ export interface StackElement {
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册