🆙 Add cms i using 🆙

This commit is contained in:
Remco committed 2025-11-25 22:42:56 +01:00
1 parent 94704e0925
commit d44196149e
35591 files changed
+3601123

No files matched your search

@@ -0,0 +1,4 @@
export declare const DebugFlags: {
InDebugMode: boolean;
};
export declare const UseOnigurumaFindOptions = false;
@@ -0,0 +1,31 @@
import { FontStyle } from "./theme";
export declare type EncodedTokenAttributes = number;
export declare namespace EncodedTokenAttributes {
function toBinaryStr(encodedTokenAttributes: EncodedTokenAttributes): string;
function print(encodedTokenAttributes: EncodedTokenAttributes): void;
function getLanguageId(encodedTokenAttributes: EncodedTokenAttributes): number;
function getTokenType(encodedTokenAttributes: EncodedTokenAttributes): StandardTokenType;
function containsBalancedBrackets(encodedTokenAttributes: EncodedTokenAttributes): boolean;
function getFontStyle(encodedTokenAttributes: EncodedTokenAttributes): number;
function getForeground(encodedTokenAttributes: EncodedTokenAttributes): number;
function getBackground(encodedTokenAttributes: EncodedTokenAttributes): number;
/**
* Updates the fields in `metadata`.
* A value of `0`, `NotSet` or `null` indicates that the corresponding field should be left as is.
*/
function set(encodedTokenAttributes: EncodedTokenAttributes, languageId: number, tokenType: OptionalStandardTokenType, containsBalancedBrackets: boolean | null, fontStyle: FontStyle, foreground: number, background: number): number;
}
export declare const enum StandardTokenType {
Other = 0,
Comment = 1,
String = 2,
RegEx = 3
}
export declare function toOptionalTokenType(standardType: StandardTokenType): OptionalStandardTokenType;
export declare const enum OptionalStandardTokenType {
Other = 0,
Comment = 1,
String = 2,
RegEx = 3,
NotSet = 8
}
@@ -0,0 +1,24 @@
import { OptionalStandardTokenType } from "../encodedTokenAttributes";
import { IEmbeddedLanguagesMap } from "../main";
import { ScopeName } from "../theme";
export declare class BasicScopeAttributes {
readonly languageId: number;
readonly tokenType: OptionalStandardTokenType;
constructor(languageId: number, tokenType: OptionalStandardTokenType);
}
export declare class BasicScopeAttributesProvider {
private readonly _defaultAttributes;
private readonly _embeddedLanguagesMatcher;
constructor(initialLanguageId: number, embeddedLanguages: IEmbeddedLanguagesMap | null);
getDefaultAttributes(): BasicScopeAttributes;
getBasicScopeAttributes(scopeName: ScopeName | null): BasicScopeAttributes;
private static readonly _NULL_SCOPE_METADATA;
private readonly _getBasicScopeAttributes;
/**
* Given a produced TM scope, return the language that token describes or null if unknown.
* e.g. source.html => html, source.css.embedded.html => css, punctuation.definition.tag.html => null
*/
private _scopeToLanguage;
private _toStandardTokenType;
private static STANDARD_TOKEN_TYPE_REGEXP;
}
@@ -0,0 +1,198 @@
import { EncodedTokenAttributes, StandardTokenType } from '../encodedTokenAttributes';
import { IEmbeddedLanguagesMap, IGrammar, IToken, ITokenizeLineResult, ITokenizeLineResult2, ITokenTypeMap, StateStack as StackElementDef } from '../main';
import { Matcher } from '../matcher';
import { IOnigLib, OnigScanner, OnigString } from '../onigLib';
import { IRawGrammar, IRawRepository } from '../rawGrammar';
import { IRuleFactoryHelper, IRuleRegistry, Rule, RuleId } from '../rule';
import { ScopeName, ScopePath, ScopeStack, StyleAttributes } from '../theme';
import { BasicScopeAttributes } from './basicScopesAttributeProvider';
export declare function createGrammar(scopeName: ScopeName, grammar: IRawGrammar, initialLanguage: number, embeddedLanguages: IEmbeddedLanguagesMap | null, tokenTypes: ITokenTypeMap | null, balancedBracketSelectors: BalancedBracketSelectors | null, grammarRepository: IGrammarRepository & IThemeProvider, onigLib: IOnigLib): Grammar;
export interface IThemeProvider {
themeMatch(scopePath: ScopeStack): StyleAttributes | null;
getDefaults(): StyleAttributes;
}
export interface IGrammarRepository {
lookup(scopeName: ScopeName): IRawGrammar | undefined;
injections(scopeName: ScopeName): ScopeName[];
}
export interface Injection {
readonly debugSelector: string;
readonly matcher: Matcher<string[]>;
readonly priority: -1 | 0 | 1;
readonly ruleId: RuleId;
readonly grammar: IRawGrammar;
}
export declare class Grammar implements IGrammar, IRuleFactoryHelper, IOnigLib {
private readonly _rootScopeName;
private readonly balancedBracketSelectors;
private readonly _onigLib;
private _rootId;
private _lastRuleId;
private readonly _ruleId2desc;
private readonly _includedGrammars;
private readonly _grammarRepository;
private readonly _grammar;
private _injections;
private readonly _basicScopeAttributesProvider;
private readonly _tokenTypeMatchers;
get themeProvider(): IThemeProvider;
constructor(_rootScopeName: ScopeName, grammar: IRawGrammar, initialLanguage: number, embeddedLanguages: IEmbeddedLanguagesMap | null, tokenTypes: ITokenTypeMap | null, balancedBracketSelectors: BalancedBracketSelectors | null, grammarRepository: IGrammarRepository & IThemeProvider, _onigLib: IOnigLib);
dispose(): void;
createOnigScanner(sources: string[]): OnigScanner;
createOnigString(sources: string): OnigString;
getMetadataForScope(scope: string): BasicScopeAttributes;
private _collectInjections;
getInjections(): Injection[];
registerRule<T extends Rule>(factory: (id: RuleId) => T): T;
getRule(ruleId: RuleId): Rule;
getExternalGrammar(scopeName: string, repository?: IRawRepository): IRawGrammar | undefined;
tokenizeLine(lineText: string, prevState: StateStack | null, timeLimit?: number): ITokenizeLineResult;
tokenizeLine2(lineText: string, prevState: StateStack | null, timeLimit?: number): ITokenizeLineResult2;
private _tokenize;
}
export declare class AttributedScopeStack {
readonly parent: AttributedScopeStack | null;
readonly scopePath: ScopeStack;
readonly tokenAttributes: EncodedTokenAttributes;
static createRoot(scopeName: ScopeName, tokenAttributes: EncodedTokenAttributes): AttributedScopeStack;
static createRootAndLookUpScopeName(scopeName: ScopeName, tokenAttributes: EncodedTokenAttributes, grammar: Grammar): AttributedScopeStack;
get scopeName(): ScopeName;
private constructor();
equals(other: AttributedScopeStack): boolean;
private static _equals;
private static mergeAttributes;
pushAttributed(scopePath: ScopePath | null, grammar: Grammar): AttributedScopeStack;
private static _pushAttributed;
getScopeNames(): string[];
}
/**
* Represents a "pushed" state on the stack (as a linked list element).
*/
export declare class StateStack implements StackElementDef {
/**
* The previous state on the stack (or null for the root state).
*/
readonly parent: StateStack | null;
/**
* The state (rule) that this element represents.
*/
private readonly ruleId;
/**
* The state has entered and captured \n. This means that the next line should have an anchorPosition of 0.
*/
readonly beginRuleCapturedEOL: boolean;
/**
* The "pop" (end) condition for this state in case that it was dynamically generated through captured text.
*/
readonly endRule: string | null;
/**
* The list of scopes containing the "name" for this state.
*/
readonly nameScopesList: AttributedScopeStack;
/**
* The list of scopes containing the "contentName" (besides "name") for this state.
* This list **must** contain as an element `scopeName`.
*/
readonly contentNameScopesList: AttributedScopeStack;
_stackElementBrand: void;
static NULL: StateStack;
/**
* The position on the current line where this state was pushed.
* This is relevant only while tokenizing a line, to detect endless loops.
* Its value is meaningless across lines.
*/
private _enterPos;
/**
* The captured anchor position when this stack element was pushed.
* This is relevant only while tokenizing a line, to restore the anchor position when popping.
* Its value is meaningless across lines.
*/
private _anchorPos;
/**
* The depth of the stack.
*/
readonly depth: number;
constructor(
/**
* The previous state on the stack (or null for the root state).
*/
parent: StateStack | null,
/**
* The state (rule) that this element represents.
*/
ruleId: RuleId, enterPos: number, anchorPos: number,
/**
* The state has entered and captured \n. This means that the next line should have an anchorPosition of 0.
*/
beginRuleCapturedEOL: boolean,
/**
* The "pop" (end) condition for this state in case that it was dynamically generated through captured text.
*/
endRule: string | null,
/**
* The list of scopes containing the "name" for this state.
*/
nameScopesList: AttributedScopeStack,
/**
* The list of scopes containing the "contentName" (besides "name") for this state.
* This list **must** contain as an element `scopeName`.
*/
contentNameScopesList: AttributedScopeStack);
equals(other: StateStack): boolean;
private static _equals;
/**
* A structural equals check. Does not take into account `scopes`.
*/
private static _structuralEquals;
clone(): StateStack;
private static _reset;
reset(): void;
pop(): StateStack | null;
safePop(): StateStack;
push(ruleId: RuleId, enterPos: number, anchorPos: number, beginRuleCapturedEOL: boolean, endRule: string | null, nameScopesList: AttributedScopeStack, contentNameScopesList: AttributedScopeStack): StateStack;
getEnterPos(): number;
getAnchorPos(): number;
getRule(grammar: IRuleRegistry): Rule;
toString(): string;
private _writeString;
withContentNameScopesList(contentNameScopeStack: AttributedScopeStack): StateStack;
withEndRule(endRule: string): StateStack;
hasSameRuleAs(other: StateStack): boolean;
}
interface TokenTypeMatcher {
readonly matcher: Matcher<string[]>;
readonly type: StandardTokenType;
}
export declare class BalancedBracketSelectors {
private readonly balancedBracketScopes;
private readonly unbalancedBracketScopes;
private allowAny;
constructor(balancedBracketScopes: string[], unbalancedBracketScopes: string[]);
get matchesAlways(): boolean;
get matchesNever(): boolean;
match(scopes: string[]): boolean;
}
export declare class LineTokens {
private readonly balancedBracketSelectors;
private readonly _emitBinaryTokens;
/**
* defined only if `DebugFlags.InDebugMode`.
*/
private readonly _lineText;
/**
* used only if `_emitBinaryTokens` is false.
*/
private readonly _tokens;
/**
* used only if `_emitBinaryTokens` is true.
*/
private readonly _binaryTokens;
private _lastTokenEndIndex;
private readonly _tokenTypeOverrides;
constructor(emitBinaryTokens: boolean, lineText: string, tokenTypeOverrides: TokenTypeMatcher[], balancedBracketSelectors: BalancedBracketSelectors | null);
produce(stack: StateStack, endIndex: number): void;
produceFromScopes(scopesList: AttributedScopeStack, endIndex: number): void;
getResult(stack: StateStack, lineLength: number): IToken[];
getBinaryResult(stack: StateStack, lineLength: number): Uint32Array;
}
export {};
@@ -0,0 +1,68 @@
import { IRawRule } from '../rawGrammar';
import { ScopeName } from '../theme';
import { IGrammarRepository } from './grammar';
export declare type AbsoluteRuleReference = TopLevelRuleReference | TopLevelRepositoryRuleReference;
/**
* References the top level rule of a grammar with the given scope name.
*/
export declare class TopLevelRuleReference {
readonly scopeName: ScopeName;
constructor(scopeName: ScopeName);
toKey(): string;
}
/**
* References a rule of a grammar in the top level repository section with the given name.
*/
export declare class TopLevelRepositoryRuleReference {
readonly scopeName: ScopeName;
readonly ruleName: string;
constructor(scopeName: ScopeName, ruleName: string);
toKey(): string;
}
export declare class ExternalReferenceCollector {
private readonly _references;
private readonly _seenReferenceKeys;
get references(): readonly AbsoluteRuleReference[];
readonly visitedRule: Set<IRawRule>;
add(reference: AbsoluteRuleReference): void;
}
export declare class ScopeDependencyProcessor {
readonly repo: IGrammarRepository;
readonly initialScopeName: ScopeName;
readonly seenFullScopeRequests: Set<string>;
readonly seenPartialScopeRequests: Set<string>;
Q: AbsoluteRuleReference[];
constructor(repo: IGrammarRepository, initialScopeName: ScopeName);
processQueue(): void;
}
export declare type IncludeReference = BaseReference | SelfReference | RelativeReference | TopLevelReference | TopLevelRepositoryReference;
export declare const enum IncludeReferenceKind {
Base = 0,
Self = 1,
RelativeReference = 2,
TopLevelReference = 3,
TopLevelRepositoryReference = 4
}
export declare class BaseReference {
readonly kind = IncludeReferenceKind.Base;
}
export declare class SelfReference {
readonly kind = IncludeReferenceKind.Self;
}
export declare class RelativeReference {
readonly ruleName: string;
readonly kind = IncludeReferenceKind.RelativeReference;
constructor(ruleName: string);
}
export declare class TopLevelReference {
readonly scopeName: ScopeName;
readonly kind = IncludeReferenceKind.TopLevelReference;
constructor(scopeName: ScopeName);
}
export declare class TopLevelRepositoryReference {
readonly scopeName: ScopeName;
readonly ruleName: string;
readonly kind = IncludeReferenceKind.TopLevelRepositoryReference;
constructor(scopeName: ScopeName, ruleName: string);
}
export declare function parseInclude(include: string): IncludeReference;
@@ -0,0 +1 @@
export * from './grammar';
@@ -0,0 +1,27 @@
import type { LineTokens, StateStack } from './grammar';
import { OnigString } from '../onigLib';
import type { AttributedScopeStack, Grammar } from './grammar';
declare class TokenizeStringResult {
readonly stack: StateStack;
readonly stoppedEarly: boolean;
constructor(stack: StateStack, stoppedEarly: boolean);
}
/**
* Tokenize a string
* @param grammar
* @param lineText
* @param isFirstLine
* @param linePos
* @param stack
* @param lineTokens
* @param checkWhileConditions
* @param timeLimit Use `0` to indicate no time limit
* @returns the StackElement or StackElement.TIME_LIMIT_REACHED if the time limit has been reached
*/
export declare function _tokenizeString(grammar: Grammar, lineText: OnigString, isFirstLine: boolean, linePos: number, stack: StateStack, lineTokens: LineTokens, checkWhileConditions: boolean, timeLimit: number): TokenizeStringResult;
export declare class LocalStackElement {
readonly scopes: AttributedScopeStack;
readonly endPos: number;
constructor(scopes: AttributedScopeStack, endPos: number);
}
export {};
@@ -0,0 +1,6 @@
export interface ILocation {
readonly filename: string | null;
readonly line: number;
readonly char: number;
}
export declare function parseJSON(source: string, filename: string | null, withMetadata: boolean): any;
@@ -0,0 +1,197 @@
import { IRawGrammar, IOnigLib } from './types';
export * from './types';
/**
* A single theme setting.
*/
export interface IRawThemeSetting {
readonly name?: string;
readonly scope?: string | string[];
readonly settings: {
readonly fontStyle?: string;
readonly foreground?: string;
readonly background?: string;
};
}
/**
* A TextMate theme.
*/
export interface IRawTheme {
readonly name?: string;
readonly settings: IRawThemeSetting[];
}
/**
* A registry helper that can locate grammar file paths given scope names.
*/
export interface RegistryOptions {
onigLib: Promise<IOnigLib>;
theme?: IRawTheme;
colorMap?: string[];
loadGrammar(scopeName: string): Promise<IRawGrammar | undefined | null>;
getInjections?(scopeName: string): string[] | undefined;
}
/**
* A map from scope name to a language id. Please do not use language id 0.
*/
export interface IEmbeddedLanguagesMap {
[scopeName: string]: number;
}
/**
* A map from selectors to token types.
*/
export interface ITokenTypeMap {
[selector: string]: StandardTokenType;
}
export declare const enum StandardTokenType {
Other = 0,
Comment = 1,
String = 2,
RegEx = 3
}
export interface IGrammarConfiguration {
embeddedLanguages?: IEmbeddedLanguagesMap;
tokenTypes?: ITokenTypeMap;
balancedBracketSelectors?: string[];
unbalancedBracketSelectors?: string[];
}
/**
* The registry that will hold all grammars.
*/
export declare class Registry {
private readonly _options;
private readonly _syncRegistry;
private readonly _ensureGrammarCache;
constructor(options: RegistryOptions);
dispose(): void;
/**
* Change the theme. Once called, no previous `ruleStack` should be used anymore.
*/
setTheme(theme: IRawTheme, colorMap?: string[]): void;
/**
* Returns a lookup array for color ids.
*/
getColorMap(): string[];
/**
* Load the grammar for `scopeName` and all referenced included grammars asynchronously.
* Please do not use language id 0.
*/
loadGrammarWithEmbeddedLanguages(initialScopeName: string, initialLanguage: number, embeddedLanguages: IEmbeddedLanguagesMap): Promise<IGrammar | null>;
/**
* Load the grammar for `scopeName` and all referenced included grammars asynchronously.
* Please do not use language id 0.
*/
loadGrammarWithConfiguration(initialScopeName: string, initialLanguage: number, configuration: IGrammarConfiguration): Promise<IGrammar | null>;
/**
* Load the grammar for `scopeName` and all referenced included grammars asynchronously.
*/
loadGrammar(initialScopeName: string): Promise<IGrammar | null>;
private _doLoadSingleGrammar;
private _loadSingleGrammar;
private _loadGrammar;
/**
* Adds a rawGrammar.
*/
addGrammar(rawGrammar: IRawGrammar, injections?: string[], initialLanguage?: number, embeddedLanguages?: IEmbeddedLanguagesMap | null): Promise<IGrammar>;
/**
* Get the grammar for `scopeName`. The grammar must first be created via `loadGrammar` or `addGrammar`.
*/
private _grammarForScopeName;
}
/**
* A grammar
*/
export interface IGrammar {
/**
* Tokenize `lineText` using previous line state `prevState`.
*/
tokenizeLine(lineText: string, prevState: StackElement | null, timeLimit?: number): ITokenizeLineResult;
/**
* Tokenize `lineText` using previous line state `prevState`.
* The result contains the tokens in binary format, resolved with the following information:
* - language
* - token type (regex, string, comment, other)
* - font style
* - foreground color
* - background color
* e.g. for getting the languageId: `(metadata & MetadataConsts.LANGUAGEID_MASK) >>> MetadataConsts.LANGUAGEID_OFFSET`
*/
tokenizeLine2(lineText: string, prevState: StackElement | null, timeLimit?: number): ITokenizeLineResult2;
}
export interface ITokenizeLineResult {
readonly tokens: IToken[];
/**
* The `prevState` to be passed on to the next line tokenization.
*/
readonly ruleStack: StackElement;
/**
* Did tokenization stop early due to reaching the time limit.
*/
readonly stoppedEarly: boolean;
}
/**
* Helpers to manage the "collapsed" metadata of an entire StackElement stack.
* The following assumptions have been made:
* - languageId < 256 => needs 8 bits
* - unique color count < 512 => needs 9 bits
*
* The binary format is:
* - -------------------------------------------
* 3322 2222 2222 1111 1111 1100 0000 0000
* 1098 7654 3210 9876 5432 1098 7654 3210
* - -------------------------------------------
* xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
* bbbb bbbb ffff ffff fFFF FBTT LLLL LLLL
* - -------------------------------------------
* - L = LanguageId (8 bits)
* - T = StandardTokenType (2 bits)
* - B = Balanced bracket (1 bit)
* - F = FontStyle (4 bits)
* - f = foreground color (9 bits)
* - b = background color (9 bits)
*/
export declare const enum MetadataConsts {
LANGUAGEID_MASK = 255,
TOKEN_TYPE_MASK = 768,
BALANCED_BRACKETS_MASK = 1024,
FONT_STYLE_MASK = 30720,
FOREGROUND_MASK = 16744448,
BACKGROUND_MASK = 4278190080,
LANGUAGEID_OFFSET = 0,
TOKEN_TYPE_OFFSET = 8,
BALANCED_BRACKETS_OFFSET = 10,
FONT_STYLE_OFFSET = 11,
FOREGROUND_OFFSET = 15,
BACKGROUND_OFFSET = 24
}
export interface ITokenizeLineResult2 {
/**
* The tokens in binary format. Each token occupies two array indices. For token i:
* - at offset 2*i => startIndex
* - at offset 2*i + 1 => metadata
*
*/
readonly tokens: Uint32Array;
/**
* The `prevState` to be passed on to the next line tokenization.
*/
readonly ruleStack: StackElement;
/**
* Did tokenization stop early due to reaching the time limit.
*/
readonly stoppedEarly: boolean;
}
export interface IToken {
startIndex: number;
readonly endIndex: number;
readonly scopes: string[];
}
/**
* **IMPORTANT** - Immutable!
*/
export interface StackElement {
_stackElementBrand: void;
readonly depth: number;
clone(): StackElement;
equals(other: StackElement): boolean;
}
export declare const INITIAL: StackElement;
export declare const parseRawGrammar: (content: string, filePath?: string) => IRawGrammar;
@@ -0,0 +1,2 @@
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.vscodetextmate=t():e.vscodetextmate=t()}(this,(function(){return(()=>{"use strict";var e={350:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UseOnigurumaFindOptions=t.DebugFlags=void 0,t.DebugFlags={InDebugMode:"undefined"!=typeof process&&!!process.env.VSCODE_TEXTMATE_DEBUG},t.UseOnigurumaFindOptions=!1},527:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BalancedBracketSelectors=t.LocalStackElement=t.StackElement=t.ScopeListElement=t.StackElementMetadata=t.Grammar=t.ScopeMetadata=t.ScopeDependencyProcessor=t.ScopeDependencyCollector=t.PartialScopeDependency=t.FullScopeDependency=t.createGrammar=void 0;var r=n(878),o=n(792),i=n(736),s=n(350),a="undefined"==typeof performance?function(){return Date.now()}:function(){return performance.now()};t.createGrammar=function(e,t,n,r,o,i,s,a){return new C(e,t,n,r,o,i,s,a)};var c=function(e){this.scopeName=e};t.FullScopeDependency=c;var u=function(){function e(e,t){this.scopeName=e,this.include=t}return e.prototype.toKey=function(){return this.scopeName+"#"+this.include},e}();t.PartialScopeDependency=u;var l=function(){function e(){this.full=[],this.partial=[],this.visitedRule=new Set,this._seenFull=new Set,this._seenPartial=new Set}return e.prototype.add=function(e){e instanceof c?this._seenFull.has(e.scopeName)||(this._seenFull.add(e.scopeName),this.full.push(e)):this._seenPartial.has(e.toKey())||(this._seenPartial.add(e.toKey()),this.partial.push(e))},e}();function h(e,t,n,o,i){for(var s=0,a=o;s<a.length;s++){var l=a[s];if(!e.visitedRule.has(l)){e.visitedRule.add(l);var p=l.repository?r.mergeObjects({},i,l.repository):i;Array.isArray(l.patterns)&&h(e,t,n,l.patterns,p);var d=l.include;if(d)if("$base"===d||d===t.scopeName)g(e,t,t);else if("$self"===d||d===n.scopeName)g(e,t,n);else if("#"===d.charAt(0))f(e,t,n,d.substring(1),p);else{var m=d.indexOf("#");if(m>=0){var _=d.substring(0,m),y=d.substring(m+1);_===t.scopeName?f(e,t,t,y,p):_===n.scopeName?f(e,t,n,y,p):e.add(new u(_,d.substring(m+1)))}else e.add(new c(d))}}}}t.ScopeDependencyCollector=l;var p=function(){function e(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests=new Set,this.seenPartialScopeRequests=new Set,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new c(this.initialScopeName)]}return e.prototype.processQueue=function(){var e=this.Q;this.Q=[];for(var t=new l,n=0,r=e;n<r.length;n++){var o=r[n];d(this.repo,this.initialScopeName,t,o)}for(var i=0,s=t.full;i<s.length;i++)o=s[i],this.seenFullScopeRequests.has(o.scopeName)||(this.seenFullScopeRequests.add(o.scopeName),this.Q.push(o));for(var a=0,c=t.partial;a<c.length;a++)o=c[a],this.seenFullScopeRequests.has(o.scopeName)||this.seenPartialScopeRequests.has(o.toKey())||(this.seenPartialScopeRequests.add(o.toKey()),this.Q.push(o))},e}();function d(e,t,n,r){var o=e.lookup(r.scopeName);if(o){r instanceof c?g(n,e.lookup(t),o):f(n,e.lookup(t),o,r.include);var i=e.injections(r.scopeName);if(i)for(var s=0,a=i;s<a.length;s++){var u=a[s];n.add(new c(u))}}else if(r.scopeName===t)throw new Error("No grammar provided for <"+t+">")}function f(e,t,n,r,o){void 0===o&&(o=n.repository),o&&o[r]&&h(e,t,n,[o[r]],o)}function g(e,t,n){if(n.patterns&&Array.isArray(n.patterns)&&h(e,t,n,n.patterns,n.repository),n.injections){var r=[];for(var o in n.injections)r.push(n.injections[o]);h(e,t,n,r,n.repository)}}function m(e,t){if(!e)return!1;if(e===t)return!0;var n=t.length;return e.length>n&&e.substr(0,n)===t&&"."===e[n]}function _(e,t){if(t.length<e.length)return!1;var n=0;return e.every((function(e){for(var r=n;r<t.length;r++)if(m(t[r],e))return n=r+1,!0;return!1}))}function y(e,t,n,r,s){for(var a=i.createMatchers(t,_),c=o.RuleFactory.getCompiledRuleId(n,r,s.repository),u=0,l=a;u<l.length;u++){var h=l[u];e.push({debugSelector:t,matcher:h.matcher,ruleId:c,grammar:s,priority:h.priority})}}t.ScopeDependencyProcessor=p;var v=function(e,t,n,r){this.scopeName=e,this.languageId=t,this.tokenType=n,this.themeData=r};t.ScopeMetadata=v;var b=function(){function e(t,n,r){if(this._initialLanguage=t,this._themeProvider=n,this._cache=new Map,this._defaultMetaData=new v("",this._initialLanguage,8,[this._themeProvider.getDefaults()]),this._embeddedLanguages=Object.create(null),r)for(var o=Object.keys(r),i=0,s=o.length;i<s;i++){var a=o[i],c=r[a];"number"==typeof c&&0!==c?this._embeddedLanguages[a]=c:console.warn("Invalid embedded language found at scope "+a+": <<"+c+">>")}var u=Object.keys(this._embeddedLanguages).map((function(t){return e._escapeRegExpCharacters(t)}));0===u.length?this._embeddedLanguagesRegex=null:(u.sort(),u.reverse(),this._embeddedLanguagesRegex=new RegExp("^(("+u.join(")|(")+"))($|\\.)",""))}return e.prototype.onDidChangeTheme=function(){this._cache=new Map,this._defaultMetaData=new v("",this._initialLanguage,8,[this._themeProvider.getDefaults()])},e.prototype.gLine truncated
//# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
{"version":3,"file":"main.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAwB,eAAID,IAE5BD,EAAqB,eAAIC,IAR3B,CASGK,MAAM,WACT,M,sCCNAC,OAAOC,eAAeN,EAAS,aAAc,CAAEO,OAAO,IACtDP,EAAQQ,wBAA0BR,EAAQS,gBAAa,EACvDT,EAAQS,WAAa,CACjBC,YAAiC,oBAAZC,WAA6BA,QAAQC,IAA2B,uBAEzFZ,EAAQQ,yBAA0B,G,cCLlCH,OAAOC,eAAeN,EAAS,aAAc,CAAEO,OAAO,IACtDP,EAAQa,yBAA2Bb,EAAQc,kBAAoBd,EAAQe,aAAef,EAAQgB,iBAAmBhB,EAAQiB,qBAAuBjB,EAAQkB,QAAUlB,EAAQmB,cAAgBnB,EAAQoB,yBAA2BpB,EAAQqB,yBAA2BrB,EAAQsB,uBAAyBtB,EAAQuB,oBAAsBvB,EAAQwB,mBAAgB,EACvV,IAAIC,EAAU,EAAQ,KAClBC,EAAS,EAAQ,KACjBC,EAAY,EAAQ,KACpBC,EAAU,EAAQ,KAClBC,EAC2B,oBAAhBC,YAEA,WAAc,OAAOC,KAAKC,OAG1B,WAAc,OAAOF,YAAYE,OAMhDhC,EAAQwB,cAHR,SAAuBS,EAAWC,EAASC,EAAiBC,EAAmBC,EAAYC,EAA0BC,EAAmBC,GACpI,OAAO,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ated
@@ -0,0 +1,8 @@
export interface MatcherWithPriority<T> {
matcher: Matcher<T>;
priority: -1 | 0 | 1;
}
export interface Matcher<T> {
(matcherInput: T): boolean;
}
export declare function createMatchers<T>(selector: string, matchesName: (names: string[], matcherInput: T) => boolean): MatcherWithPriority<T>[];
@@ -0,0 +1,42 @@
import { OrMask } from "./utils";
export interface IOnigLib {
createOnigScanner(sources: string[]): OnigScanner;
createOnigString(str: string): OnigString;
}
export interface IOnigCaptureIndex {
start: number;
end: number;
length: number;
}
export interface IOnigMatch {
index: number;
captureIndices: IOnigCaptureIndex[];
}
export declare const enum FindOption {
None = 0,
/**
* equivalent of ONIG_OPTION_NOT_BEGIN_STRING: (str) isn't considered as begin of string (* fail \A)
*/
NotBeginString = 1,
/**
* equivalent of ONIG_OPTION_NOT_END_STRING: (end) isn't considered as end of string (* fail \z, \Z)
*/
NotEndString = 2,
/**
* equivalent of ONIG_OPTION_NOT_BEGIN_POSITION: (start) isn't considered as start position of search (* fail \G)
*/
NotBeginPosition = 4,
/**
* used for debugging purposes.
*/
DebugCall = 8
}
export interface OnigScanner {
findNextMatchSync(string: string | OnigString, startPosition: number, options: OrMask<FindOption>): IOnigMatch | null;
dispose?(): void;
}
export interface OnigString {
readonly content: string;
dispose?(): void;
}
export declare function disposeOnigString(str: OnigString): void;
@@ -0,0 +1,2 @@
import { IRawGrammar } from './rawGrammar';
export declare function parseRawGrammar(content: string, filePath?: string | null): IRawGrammar;
@@ -0,0 +1,5 @@
export declare function parseWithLocation(content: string, filename: string | null, locationKeyName: string | null): any;
/**
* A very fast plist parser
*/
export declare function parsePLIST(content: string): any;
@@ -0,0 +1,48 @@
import { RuleId } from "./rule";
export interface ILocation {
readonly filename: string;
readonly line: number;
readonly char: number;
}
export interface ILocatable {
readonly $vscodeTextmateLocation?: ILocation;
}
export interface IRawGrammar extends ILocatable {
repository: IRawRepository;
readonly scopeName: string;
readonly patterns: IRawRule[];
readonly injections?: {
[expression: string]: IRawRule;
};
readonly injectionSelector?: string;
readonly fileTypes?: string[];
readonly name?: string;
readonly firstLineMatch?: string;
}
export interface IRawRepositoryMap {
[name: string]: IRawRule;
$self: IRawRule;
$base: IRawRule;
}
export declare type IRawRepository = IRawRepositoryMap & ILocatable;
export interface IRawRule extends ILocatable {
id?: RuleId;
readonly include?: string;
readonly name?: string;
readonly contentName?: string;
readonly match?: string;
readonly captures?: IRawCaptures;
readonly begin?: string;
readonly beginCaptures?: IRawCaptures;
readonly end?: string;
readonly endCaptures?: IRawCaptures;
readonly while?: string;
readonly whileCaptures?: IRawCaptures;
readonly patterns?: IRawRule[];
readonly repository?: IRawRepository;
readonly applyEndPatternLast?: boolean;
}
export interface IRawCapturesMap {
[captureId: string]: IRawRule;
}
export declare type IRawCaptures = IRawCapturesMap & ILocatable;
@@ -0,0 +1,40 @@
import { BalancedBracketSelectors, IGrammarRepository, IThemeProvider } from './grammar';
import { IRawGrammar } from './rawGrammar';
import { IGrammar, IEmbeddedLanguagesMap, ITokenTypeMap } from './main';
import { ScopeStack, Theme, StyleAttributes, ScopeName } from './theme';
import { IOnigLib } from './onigLib';
export declare class SyncRegistry implements IGrammarRepository, IThemeProvider {
private readonly _onigLibPromise;
private readonly _grammars;
private readonly _rawGrammars;
private readonly _injectionGrammars;
private _theme;
constructor(theme: Theme, _onigLibPromise: Promise<IOnigLib>);
dispose(): void;
setTheme(theme: Theme): void;
getColorMap(): string[];
/**
* Add `grammar` to registry and return a list of referenced scope names
*/
addGrammar(grammar: IRawGrammar, injectionScopeNames?: ScopeName[]): void;
/**
* Lookup a raw grammar.
*/
lookup(scopeName: ScopeName): IRawGrammar | undefined;
/**
* Returns the injections for the given grammar
*/
injections(targetScope: ScopeName): ScopeName[];
/**
* Get the default theme settings
*/
getDefaults(): StyleAttributes;
/**
* Match a scope in the theme.
*/
themeMatch(scopePath: ScopeStack): StyleAttributes | null;
/**
* Lookup a grammar.
*/
grammarForScopeName(scopeName: ScopeName, initialLanguage: number, embeddedLanguages: IEmbeddedLanguagesMap | null, tokenTypes: ITokenTypeMap | null, balancedBracketSelectors: BalancedBracketSelectors | null): Promise<IGrammar | null>;
}
@@ -0,0 +1,163 @@
import { OrMask } from './utils';
import { IOnigLib, IOnigCaptureIndex, FindOption, OnigString } from './onigLib';
import { ILocation, IRawGrammar, IRawRepository, IRawRule } from './rawGrammar';
declare const ruleIdSymbol: unique symbol;
export declare type RuleId = {
__brand: typeof ruleIdSymbol;
};
export declare const endRuleId = -1;
export declare const whileRuleId = -2;
export declare function ruleIdFromNumber(id: number): RuleId;
export declare function ruleIdToNumber(id: RuleId): number;
export interface IRuleRegistry {
getRule(ruleId: RuleId): Rule;
registerRule<T extends Rule>(factory: (id: RuleId) => T): T;
}
export interface IGrammarRegistry {
getExternalGrammar(scopeName: string, repository: IRawRepository): IRawGrammar | null | undefined;
}
export interface IRuleFactoryHelper extends IRuleRegistry, IGrammarRegistry {
}
export declare abstract class Rule {
readonly $location: ILocation | undefined;
readonly id: RuleId;
private readonly _nameIsCapturing;
private readonly _name;
private readonly _contentNameIsCapturing;
private readonly _contentName;
constructor($location: ILocation | undefined, id: RuleId, name: string | null | undefined, contentName: string | null | undefined);
abstract dispose(): void;
get debugName(): string;
getName(lineText: string | null, captureIndices: IOnigCaptureIndex[] | null): string | null;
getContentName(lineText: string, captureIndices: IOnigCaptureIndex[]): string | null;
abstract collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList): void;
abstract compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string | null): CompiledRule;
abstract compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string | null, allowA: boolean, allowG: boolean): CompiledRule;
}
export interface ICompilePatternsResult {
readonly patterns: RuleId[];
readonly hasMissingPatterns: boolean;
}
export declare class CaptureRule extends Rule {
readonly retokenizeCapturedWithRuleId: RuleId | 0;
constructor($location: ILocation | undefined, id: RuleId, name: string | null | undefined, contentName: string | null | undefined, retokenizeCapturedWithRuleId: RuleId | 0);
dispose(): void;
collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList): void;
compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string): CompiledRule;
compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string, allowA: boolean, allowG: boolean): CompiledRule;
}
export declare class MatchRule extends Rule {
private readonly _match;
readonly captures: (CaptureRule | null)[];
private _cachedCompiledPatterns;
constructor($location: ILocation | undefined, id: RuleId, name: string | undefined, match: string, captures: (CaptureRule | null)[]);
dispose(): void;
get debugMatchRegExp(): string;
collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList): void;
compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string): CompiledRule;
compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string, allowA: boolean, allowG: boolean): CompiledRule;
private _getCachedCompiledPatterns;
}
export declare class IncludeOnlyRule extends Rule {
readonly hasMissingPatterns: boolean;
readonly patterns: RuleId[];
private _cachedCompiledPatterns;
constructor($location: ILocation | undefined, id: RuleId, name: string | null | undefined, contentName: string | null | undefined, patterns: ICompilePatternsResult);
dispose(): void;
collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList): void;
compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string): CompiledRule;
compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string, allowA: boolean, allowG: boolean): CompiledRule;
private _getCachedCompiledPatterns;
}
export declare class BeginEndRule extends Rule {
private readonly _begin;
readonly beginCaptures: (CaptureRule | null)[];
private readonly _end;
readonly endHasBackReferences: boolean;
readonly endCaptures: (CaptureRule | null)[];
readonly applyEndPatternLast: boolean;
readonly hasMissingPatterns: boolean;
readonly patterns: RuleId[];
private _cachedCompiledPatterns;
constructor($location: ILocation | undefined, id: RuleId, name: string | null | undefined, contentName: string | null | undefined, begin: string, beginCaptures: (CaptureRule | null)[], end: string | undefined, endCaptures: (CaptureRule | null)[], applyEndPatternLast: boolean | undefined, patterns: ICompilePatternsResult);
dispose(): void;
get debugBeginRegExp(): string;
get debugEndRegExp(): string;
getEndWithResolvedBackReferences(lineText: string, captureIndices: IOnigCaptureIndex[]): string;
collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList): void;
compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string): CompiledRule;
compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string, allowA: boolean, allowG: boolean): CompiledRule;
private _getCachedCompiledPatterns;
}
export declare class BeginWhileRule extends Rule {
private readonly _begin;
readonly beginCaptures: (CaptureRule | null)[];
readonly whileCaptures: (CaptureRule | null)[];
private readonly _while;
readonly whileHasBackReferences: boolean;
readonly hasMissingPatterns: boolean;
readonly patterns: RuleId[];
private _cachedCompiledPatterns;
private _cachedCompiledWhilePatterns;
constructor($location: ILocation | undefined, id: RuleId, name: string | null | undefined, contentName: string | null | undefined, begin: string, beginCaptures: (CaptureRule | null)[], _while: string, whileCaptures: (CaptureRule | null)[], patterns: ICompilePatternsResult);
dispose(): void;
get debugBeginRegExp(): string;
get debugWhileRegExp(): string;
getWhileWithResolvedBackReferences(lineText: string, captureIndices: IOnigCaptureIndex[]): string;
collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList): void;
compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string): CompiledRule;
compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string, allowA: boolean, allowG: boolean): CompiledRule;
private _getCachedCompiledPatterns;
compileWhile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string | null): CompiledRule<RuleId | typeof whileRuleId>;
compileWhileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string | null, allowA: boolean, allowG: boolean): CompiledRule<RuleId | typeof whileRuleId>;
private _getCachedCompiledWhilePatterns;
}
export declare class RuleFactory {
static createCaptureRule(helper: IRuleFactoryHelper, $location: ILocation | undefined, name: string | null | undefined, contentName: string | null | undefined, retokenizeCapturedWithRuleId: RuleId | 0): CaptureRule;
static getCompiledRuleId(desc: IRawRule, helper: IRuleFactoryHelper, repository: IRawRepository): RuleId;
private static _compileCaptures;
private static _compilePatterns;
}
export declare class RegExpSource<TRuleId = RuleId | typeof endRuleId> {
source: string;
readonly ruleId: TRuleId;
hasAnchor: boolean;
readonly hasBackReferences: boolean;
private _anchorCache;
constructor(regExpSource: string, ruleId: TRuleId);
clone(): RegExpSource<TRuleId>;
setSource(newSource: string): void;
resolveBackReferences(lineText: string, captureIndices: IOnigCaptureIndex[]): string;
private _buildAnchorCache;
resolveAnchors(allowA: boolean, allowG: boolean): string;
}
export declare class RegExpSourceList<TRuleId = RuleId | typeof endRuleId> {
private readonly _items;
private _hasAnchors;
private _cached;
private _anchorCache;
constructor();
dispose(): void;
private _disposeCaches;
push(item: RegExpSource<TRuleId>): void;
unshift(item: RegExpSource<TRuleId>): void;
length(): number;
setSource(index: number, newSource: string): void;
compile(onigLib: IOnigLib): CompiledRule<TRuleId>;
compileAG(onigLib: IOnigLib, allowA: boolean, allowG: boolean): CompiledRule<TRuleId>;
private _resolveAnchors;
}
export declare class CompiledRule<TRuleId = RuleId | typeof endRuleId> {
private readonly regExps;
private readonly rules;
private readonly scanner;
constructor(onigLib: IOnigLib, regExps: string[], rules: TRuleId[]);
dispose(): void;
toString(): string;
findNextMatchSync(string: string | OnigString, startPosition: number, options: OrMask<FindOption>): IFindNextMatchResult<TRuleId> | null;
}
export interface IFindNextMatchResult<TRuleId = RuleId | typeof endRuleId> {
ruleId: TRuleId;
captureIndices: IOnigCaptureIndex[];
}
export {};
@@ -0,0 +1,5 @@
import './grammar.test';
import './json.test';
import './matcher.test';
import './themes.test';
import './tokenization.test';
@@ -0,0 +1 @@
export {};
@@ -0,0 +1 @@
export {};
@@ -0,0 +1 @@
export {};
@@ -0,0 +1 @@
export {};
@@ -0,0 +1,2 @@
import { IOnigLib } from '../onigLib';
export declare function getOniguruma(): Promise<IOnigLib>;
@@ -0,0 +1,33 @@
import { IOnigLib } from '../onigLib';
import { RegistryOptions } from '../main';
import { IRawGrammar } from '../rawGrammar';
export interface ILanguageRegistration {
id: string;
extensions: string[];
filenames: string[];
}
export interface IGrammarRegistration {
language: string;
scopeName: string;
path: string;
embeddedLanguages: {
[scopeName: string]: string;
};
grammar?: Promise<IRawGrammar>;
}
export declare class Resolver implements RegistryOptions {
readonly language2id: {
[languages: string]: number;
};
private _lastLanguageId;
private _id2language;
private readonly _grammars;
private readonly _languages;
readonly onigLib: Promise<IOnigLib>;
constructor(grammars: IGrammarRegistration[], languages: ILanguageRegistration[], onigLibPromise: Promise<IOnigLib>);
findLanguageByExtension(fileExtension: string): string | null;
findLanguageByFilename(filename: string): string | null;
findScopeByFilename(filename: string): string | null;
findGrammarByLanguage(language: string): IGrammarRegistration;
loadGrammar(scopeName: string): Promise<IRawGrammar | null>;
}
@@ -0,0 +1,14 @@
import { ThemeData } from './themes.test';
import { Resolver } from './resolver';
export declare class ThemeTest {
private static _readFile;
private static _normalizeNewLines;
private readonly EXPECTED_FILE_PATH;
private readonly tests;
readonly expected: string;
readonly testName: string;
actual: string | null;
constructor(THEMES_TEST_PATH: string, testFile: string, themeDatas: ThemeData[], resolver: Resolver);
evaluate(): Promise<any>;
writeExpected(): void;
}
@@ -0,0 +1,6 @@
import { IGrammar } from '../main';
export interface IThemedToken {
content: string;
color: string;
}
export declare function tokenizeWithTheme(colorMap: string[], fileContents: string, grammar: IGrammar): IThemedToken[];
@@ -0,0 +1,7 @@
import { Registry } from '../main';
import { IRawTheme } from '../theme';
export interface ThemeData {
themeName: string;
theme: IRawTheme;
registry: Registry;
}
@@ -0,0 +1 @@
export {};
@@ -0,0 +1,119 @@
import { OrMask } from './utils';
export declare class Theme {
private readonly _colorMap;
private readonly _defaults;
private readonly _root;
static createFromRawTheme(source: IRawTheme | undefined, colorMap?: string[]): Theme;
static createFromParsedTheme(source: ParsedThemeRule[], colorMap?: string[]): Theme;
private readonly _cachedMatchRoot;
constructor(_colorMap: ColorMap, _defaults: StyleAttributes, _root: ThemeTrieElement);
getColorMap(): string[];
getDefaults(): StyleAttributes;
match(scopePath: ScopeStack | null): StyleAttributes | null;
}
/**
* Identifiers with a binary dot operator.
* Examples: `baz` or `foo.bar`
*/
export declare type ScopeName = string;
/**
* An expression language of ScopeNames with a binary space (to indicate nesting) operator.
* Examples: `foo.bar boo.baz`
*/
export declare type ScopePath = string;
/**
* An expression language of ScopePathStr with a binary comma (to indicate alternatives) operator.
* Examples: `foo.bar boo.baz,quick quack`
*/
export declare type ScopePattern = string;
/**
* A TextMate theme.
*/
export interface IRawTheme {
readonly name?: string;
readonly settings: IRawThemeSetting[];
}
/**
* A single theme setting.
*/
export interface IRawThemeSetting {
readonly name?: string;
readonly scope?: ScopePattern | ScopePattern[];
readonly settings: {
readonly fontStyle?: string;
readonly foreground?: string;
readonly background?: string;
};
}
export declare class ScopeStack {
readonly parent: ScopeStack | null;
readonly scopeName: ScopeName;
static from(first: ScopeName, ...segments: ScopeName[]): ScopeStack;
static from(...segments: ScopeName[]): ScopeStack | null;
constructor(parent: ScopeStack | null, scopeName: ScopeName);
push(scopeName: ScopeName): ScopeStack;
getSegments(): ScopeName[];
toString(): string;
}
export declare class StyleAttributes {
readonly fontStyle: OrMask<FontStyle>;
readonly foregroundId: number;
readonly backgroundId: number;
constructor(fontStyle: OrMask<FontStyle>, foregroundId: number, backgroundId: number);
}
/**
* Parse a raw theme into rules.
*/
export declare function parseTheme(source: IRawTheme | undefined): ParsedThemeRule[];
export declare class ParsedThemeRule {
readonly scope: ScopeName;
readonly parentScopes: ScopeName[] | null;
readonly index: number;
readonly fontStyle: OrMask<FontStyle>;
readonly foreground: string | null;
readonly background: string | null;
constructor(scope: ScopeName, parentScopes: ScopeName[] | null, index: number, fontStyle: OrMask<FontStyle>, foreground: string | null, background: string | null);
}
export declare const enum FontStyle {
NotSet = -1,
None = 0,
Italic = 1,
Bold = 2,
Underline = 4,
Strikethrough = 8
}
export declare function fontStyleToString(fontStyle: OrMask<FontStyle>): string;
export declare class ColorMap {
private readonly _isFrozen;
private _lastColorId;
private _id2color;
private _color2id;
constructor(_colorMap?: string[]);
getId(color: string | null): number;
getColorMap(): string[];
}
export declare class ThemeTrieElementRule {
scopeDepth: number;
parentScopes: ScopeName[] | null;
fontStyle: number;
foreground: number;
background: number;
constructor(scopeDepth: number, parentScopes: ScopeName[] | null, fontStyle: number, foreground: number, background: number);
clone(): ThemeTrieElementRule;
static cloneArr(arr: ThemeTrieElementRule[]): ThemeTrieElementRule[];
acceptOverwrite(scopeDepth: number, fontStyle: number, foreground: number, background: number): void;
}
export interface ITrieChildrenMap {
[segment: string]: ThemeTrieElement;
}
export declare class ThemeTrieElement {
private readonly _mainRule;
private readonly _children;
private readonly _rulesWithParentScopes;
constructor(_mainRule: ThemeTrieElementRule, rulesWithParentScopes?: ThemeTrieElementRule[], _children?: ITrieChildrenMap);
private static _sortBySpecificity;
private static _cmpBySpecificity;
match(scope: ScopeName): ThemeTrieElementRule[];
insert(scopeDepth: number, scope: ScopeName, parentScopes: ScopeName[] | null, fontStyle: number, foreground: number, background: number): void;
private _doInsertHere;
}
@@ -0,0 +1,87 @@
export interface ILocation {
readonly filename: string;
readonly line: number;
readonly char: number;
}
export interface ILocatable {
readonly $vscodeTextmateLocation?: ILocation;
}
export interface IRawGrammar extends ILocatable {
repository: IRawRepository;
readonly scopeName: string;
readonly patterns: IRawRule[];
readonly injections?: {
[expression: string]: IRawRule;
};
readonly injectionSelector?: string;
readonly fileTypes?: string[];
readonly name?: string;
readonly firstLineMatch?: string;
}
export interface IRawRepositoryMap {
[name: string]: IRawRule;
$self: IRawRule;
$base: IRawRule;
}
export declare type IRawRepository = IRawRepositoryMap & ILocatable;
export interface IRawRule extends ILocatable {
id?: number;
readonly include?: string;
readonly name?: string;
readonly contentName?: string;
readonly match?: string;
readonly captures?: IRawCaptures;
readonly begin?: string;
readonly beginCaptures?: IRawCaptures;
readonly end?: string;
readonly endCaptures?: IRawCaptures;
readonly while?: string;
readonly whileCaptures?: IRawCaptures;
readonly patterns?: IRawRule[];
readonly repository?: IRawRepository;
readonly applyEndPatternLast?: boolean;
}
export interface IRawCapturesMap {
[captureId: string]: IRawRule;
}
export declare type IRawCaptures = IRawCapturesMap & ILocatable;
export interface IOnigLib {
createOnigScanner(sources: string[]): OnigScanner;
createOnigString(str: string): OnigString;
}
export interface IOnigCaptureIndex {
start: number;
end: number;
length: number;
}
export interface IOnigMatch {
index: number;
captureIndices: IOnigCaptureIndex[];
}
export declare const enum FindOption {
None = 0,
/**
* equivalent of ONIG_OPTION_NOT_BEGIN_STRING: (str) isn't considered as begin of string (* fail \A)
*/
NotBeginString = 1,
/**
* equivalent of ONIG_OPTION_NOT_END_STRING: (end) isn't considered as end of string (* fail \z, \Z)
*/
NotEndString = 2,
/**
* equivalent of ONIG_OPTION_NOT_BEGIN_POSITION: (start) isn't considered as start position of search (* fail \G)
*/
NotBeginPosition = 4,
/**
* used for debugging purposes.
*/
DebugCall = 8
}
export interface OnigScanner {
findNextMatchSync(string: string | OnigString, startPosition: number, options: number): IOnigMatch | null;
dispose?(): void;
}
export interface OnigString {
readonly content: string;
dispose?(): void;
}
@@ -0,0 +1,26 @@
import { IOnigCaptureIndex } from './onigLib';
export declare function clone<T>(something: T): T;
export declare function mergeObjects(target: any, ...sources: any[]): any;
export declare function basename(path: string): string;
export declare class RegexSource {
static hasCaptures(regexSource: string | null): boolean;
static replaceCaptures(regexSource: string, captureSource: string, captureIndices: IOnigCaptureIndex[]): string;
}
/**
* A union of given const enum values.
*/
export declare type OrMask<T extends number> = number;
export declare function strcmp(a: string, b: string): number;
export declare function strArrCmp(a: string[] | null, b: string[] | null): number;
export declare function isValidHexColor(hex: string): boolean;
/**
* Escapes regular expression characters in a given string
*/
export declare function escapeRegExpCharacters(value: string): string;
export declare class CachedFn<TKey, TValue> {
private readonly fn;
private readonly cache;
constructor(fn: (key: TKey) => TValue);
get(key: TKey): TValue;
}
export declare const performanceNow: () => number;