Less memory consumption - adopt vscode-textmate@2.0.1 (#7912)
This commit is contained in:
parent
9d50ac3f78
commit
f7748b3132
6
npm-shrinkwrap.json
generated
6
npm-shrinkwrap.json
generated
|
@ -418,9 +418,9 @@
|
|||
"resolved": "https://registry.npmjs.org/vscode-debugprotocol/-/vscode-debugprotocol-1.10.0.tgz"
|
||||
},
|
||||
"vscode-textmate": {
|
||||
"version": "1.2.0",
|
||||
"from": "vscode-textmate@1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-1.2.0.tgz"
|
||||
"version": "2.0.1",
|
||||
"from": "vscode-textmate@2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-2.0.1.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.2.0",
|
||||
"vscode-textmate": "2.0.1",
|
||||
"winreg": "1.2.0",
|
||||
"xterm": "git+https://github.com/sourcelair/xterm.js.git#39c4356",
|
||||
"yauzl": "2.3.1"
|
||||
|
|
|
@ -8,47 +8,21 @@ import {IMode, IState, ITokenizationResult} from 'vs/editor/common/modes';
|
|||
import {AbstractState} from 'vs/editor/common/modes/abstractState';
|
||||
import {StackElement} from 'vscode-textmate';
|
||||
|
||||
function stackElementEquals(a:StackElement, b:StackElement): boolean {
|
||||
if (!a && !b) {
|
||||
return true;
|
||||
}
|
||||
if (!a || !b) {
|
||||
return false;
|
||||
}
|
||||
// Not comparing enterPos since it does not represent state across lines
|
||||
return (
|
||||
a.ruleId === b.ruleId
|
||||
&& a.endRule === b.endRule
|
||||
&& a.scopeName === b.scopeName
|
||||
&& a.contentName === b.contentName
|
||||
);
|
||||
}
|
||||
|
||||
export class TMState implements IState {
|
||||
|
||||
private _mode: IMode;
|
||||
private _parentEmbedderState: IState;
|
||||
private _ruleStack: StackElement[];
|
||||
private _ruleStack: StackElement;
|
||||
|
||||
constructor(mode: IMode, parentEmbedderState: IState, ruleStack: StackElement[]) {
|
||||
constructor(mode: IMode, parentEmbedderState: IState, ruleStack: StackElement) {
|
||||
this._mode = mode;
|
||||
this._parentEmbedderState = parentEmbedderState;
|
||||
this._ruleStack = ruleStack || null;
|
||||
this._ruleStack = ruleStack;
|
||||
}
|
||||
|
||||
public clone():TMState {
|
||||
let parentEmbedderStateClone = AbstractState.safeClone(this._parentEmbedderState);
|
||||
|
||||
let ruleStackClone: StackElement[] = null;
|
||||
if (this._ruleStack) {
|
||||
ruleStackClone = [];
|
||||
for (let i = 0, len = this._ruleStack.length; i < len; i++) {
|
||||
let rule = this._ruleStack[i];
|
||||
ruleStackClone.push(rule.clone());
|
||||
}
|
||||
}
|
||||
|
||||
return new TMState(this._mode, parentEmbedderStateClone, ruleStackClone);
|
||||
return new TMState(this._mode, parentEmbedderStateClone, this._ruleStack);
|
||||
}
|
||||
|
||||
public equals(other:IState):boolean {
|
||||
|
@ -69,16 +43,7 @@ export class TMState implements IState {
|
|||
if (this._ruleStack === null || otherState._ruleStack === null) {
|
||||
return false;
|
||||
}
|
||||
if (this._ruleStack.length !== otherState._ruleStack.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0, len = this._ruleStack.length; i < len; i++) {
|
||||
if (!stackElementEquals(this._ruleStack[i], otherState._ruleStack[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return this._ruleStack.equals(otherState._ruleStack);
|
||||
}
|
||||
|
||||
public getMode():IMode {
|
||||
|
@ -97,11 +62,11 @@ export class TMState implements IState {
|
|||
this._parentEmbedderState = state;
|
||||
}
|
||||
|
||||
public getRuleStack(): StackElement[] {
|
||||
public getRuleStack(): StackElement {
|
||||
return this._ruleStack;
|
||||
}
|
||||
|
||||
public setRuleStack(ruleStack:StackElement[]): void {
|
||||
public setRuleStack(ruleStack:StackElement): void {
|
||||
this._ruleStack = ruleStack;
|
||||
}
|
||||
}
|
22
src/vs/editor/node/textMate/vscode-textmate.d.ts
vendored
22
src/vs/editor/node/textMate/vscode-textmate.d.ts
vendored
|
@ -18,9 +18,6 @@ export interface IGrammarLocator {
|
|||
*/
|
||||
export class Registry {
|
||||
|
||||
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, useExperimentalParser?:boolean);
|
||||
|
||||
/**
|
||||
|
@ -53,18 +50,18 @@ export interface IGrammar {
|
|||
/**
|
||||
* Tokenize `lineText` using previous line state `prevState`.
|
||||
*/
|
||||
tokenizeLine(lineText: string, prevState: StackElement[]): ITokenizeLineResult;
|
||||
tokenizeLine(lineText: string, prevState: StackElement): ITokenizeLineResult;
|
||||
}
|
||||
|
||||
export interface ITokenizeLineResult {
|
||||
tokens: ITMToken[];
|
||||
tokens: IToken[];
|
||||
/**
|
||||
* The `prevState` to be passed on to the next line tokenization.
|
||||
*/
|
||||
ruleStack: StackElement[];
|
||||
ruleStack: StackElement;
|
||||
}
|
||||
|
||||
export interface ITMToken {
|
||||
export interface IToken {
|
||||
startIndex: number;
|
||||
endIndex: number;
|
||||
scopes: string[];
|
||||
|
@ -74,16 +71,9 @@ export interface ITMToken {
|
|||
* Should not be used by consumers, as its shape might change at any time.
|
||||
*/
|
||||
export interface StackElement {
|
||||
ruleId: number;
|
||||
enterPos: number;
|
||||
endRule: string;
|
||||
whileRule: string;
|
||||
scopeName: string;
|
||||
contentName: string;
|
||||
_stackElementBrand: void;
|
||||
|
||||
clone(): StackElement;
|
||||
equals(other:StackElement): boolean;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in a new issue