From 170db15a2b628da4ad8234ef0bd16689cf9ff431 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Thu, 30 Jun 2016 19:05:40 +0200 Subject: [PATCH] Fixes #8173: Adopt vscode-textmate with fast plist parser, make fast plist parser disableable via editor.useExperimentalParser --- npm-shrinkwrap.json | 6 +++--- package.json | 2 +- src/vs/editor/node/textMate/TMSyntax.ts | 18 ++++++++++++++++-- .../editor/node/textMate/vscode-textmate.d.ts | 10 ++++++---- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 1060b801c6baf..45ea98f20401c 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -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", diff --git a/package.json b/package.json index 6ed7a931adbe0..0992dad67db65 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/vs/editor/node/textMate/TMSyntax.ts b/src/vs/editor/node/textMate/TMSyntax.ts index 9a4940a7f1804..83497c04d8c59 100644 --- a/src/vs/editor/node/textMate/TMSyntax.ts +++ b/src/vs/editor/node/textMate/TMSyntax.ts @@ -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('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++) { diff --git a/src/vs/editor/node/textMate/vscode-textmate.d.ts b/src/vs/editor/node/textMate/vscode-textmate.d.ts index 9a61ada1bddf9..2b037c0bdd698 100644 --- a/src/vs/editor/node/textMate/vscode-textmate.d.ts +++ b/src/vs/editor/node/textMate/vscode-textmate.d.ts @@ -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