Support nested repositories
This commit is contained in:
Родитель
663fdb7240
Коммит
e1bebf60e4
|
@ -49,6 +49,19 @@ function cloneObj(obj) {
|
|||
}
|
||||
return r;
|
||||
}
|
||||
function mergeObjects(target) {
|
||||
var sources = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
sources[_i - 1] = arguments[_i];
|
||||
}
|
||||
sources.forEach(function (source) {
|
||||
for (var key in source) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
});
|
||||
return target;
|
||||
}
|
||||
exports.mergeObjects = mergeObjects;
|
||||
var CAPTURING_REGEX_SOURCE = /\$(\d+)|\${(\d+):\/(downcase|upcase)}/;
|
||||
var RegexSource = (function () {
|
||||
function RegexSource() {
|
||||
|
@ -279,8 +292,7 @@ $load('./rule', function(require, module, exports) {
|
|||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var utils_1 = require('./utils');
|
||||
var BACK_REFERENCING_END = /\\(\d+)/;
|
||||
|
@ -664,6 +676,9 @@ var RuleFactory = (function () {
|
|||
return new MatchRule(desc.id, desc.name, desc.match, RuleFactory._compileCaptures(desc.captures, helper, repository));
|
||||
}
|
||||
if (!desc.begin) {
|
||||
if (desc.repository) {
|
||||
repository = utils_1.mergeObjects({}, repository, desc.repository);
|
||||
}
|
||||
return new IncludeOnlyRule(desc.id, desc.name, desc.contentName, RuleFactory._compilePatterns(desc.patterns, helper, repository));
|
||||
}
|
||||
return new BeginEndRule(desc.id, desc.name, desc.contentName, desc.begin, RuleFactory._compileCaptures(desc.beginCaptures || desc.captures, helper, repository), desc.end, RuleFactory._compileCaptures(desc.endCaptures || desc.captures, helper, repository), desc.applyEndPatternLast, RuleFactory._compilePatterns(desc.patterns, helper, repository));
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*--------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {RegexSource} from './utils';
|
||||
import {RegexSource, mergeObjects} from './utils';
|
||||
import {IRawGrammar, IRawRepository, IRawRule, IRawPattern, IRawCaptures} from './types';
|
||||
import {OnigScanner, IOnigCaptureIndex} from 'oniguruma';
|
||||
|
||||
|
@ -502,6 +502,9 @@ export class RuleFactory {
|
|||
}
|
||||
|
||||
if (!desc.begin) {
|
||||
if (desc.repository) {
|
||||
repository = mergeObjects({}, repository, desc.repository);
|
||||
}
|
||||
return new IncludeOnlyRule(
|
||||
desc.id,
|
||||
desc.name,
|
||||
|
|
|
@ -39,6 +39,8 @@ export interface IRawRule {
|
|||
endCaptures?: IRawCaptures;
|
||||
patterns?: IRawPattern[];
|
||||
|
||||
repository?: IRawRepository;
|
||||
|
||||
applyEndPatternLast?:boolean;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,15 @@ function cloneObj(obj:any): any {
|
|||
return r;
|
||||
}
|
||||
|
||||
export function mergeObjects(target:any, ...sources:any[]): any {
|
||||
sources.forEach(source => {
|
||||
for (let key in source) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
});
|
||||
return target;
|
||||
}
|
||||
|
||||
let CAPTURING_REGEX_SOURCE = /\$(\d+)|\${(\d+):\/(downcase|upcase)}/;
|
||||
|
||||
export class RegexSource {
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -68,5 +68,78 @@
|
|||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"grammars": [
|
||||
"fixtures/markdown.plist"
|
||||
],
|
||||
"grammarPath": "fixtures/markdown.plist",
|
||||
"lines": [
|
||||
{
|
||||
"line": "## This is *great* stuff",
|
||||
"tokens": [
|
||||
{
|
||||
"value": "##",
|
||||
"scopes": [
|
||||
"text.html.markdown",
|
||||
"markup.heading.${1/(#)(#)?(#)?(#)?(#)?(#)?/${6:?6:${5:?5:${4:?4:${3:?3:${2:?2:1}}}}}/}.markdown",
|
||||
"punctuation.definition.heading.markdown"
|
||||
]
|
||||
},
|
||||
{
|
||||
"value": " ",
|
||||
"scopes": [
|
||||
"text.html.markdown",
|
||||
"markup.heading.${1/(#)(#)?(#)?(#)?(#)?(#)?/${6:?6:${5:?5:${4:?4:${3:?3:${2:?2:1}}}}}/}.markdown"
|
||||
]
|
||||
},
|
||||
{
|
||||
"value": "This is ",
|
||||
"scopes": [
|
||||
"text.html.markdown",
|
||||
"markup.heading.${1/(#)(#)?(#)?(#)?(#)?(#)?/${6:?6:${5:?5:${4:?4:${3:?3:${2:?2:1}}}}}/}.markdown",
|
||||
"entity.name.section.markdown"
|
||||
]
|
||||
},
|
||||
{
|
||||
"value": "*",
|
||||
"scopes": [
|
||||
"text.html.markdown",
|
||||
"markup.heading.${1/(#)(#)?(#)?(#)?(#)?(#)?/${6:?6:${5:?5:${4:?4:${3:?3:${2:?2:1}}}}}/}.markdown",
|
||||
"entity.name.section.markdown",
|
||||
"markup.italic.markdown",
|
||||
"punctuation.definition.italic.markdown"
|
||||
]
|
||||
},
|
||||
{
|
||||
"value": "great",
|
||||
"scopes": [
|
||||
"text.html.markdown",
|
||||
"markup.heading.${1/(#)(#)?(#)?(#)?(#)?(#)?/${6:?6:${5:?5:${4:?4:${3:?3:${2:?2:1}}}}}/}.markdown",
|
||||
"entity.name.section.markdown",
|
||||
"markup.italic.markdown"
|
||||
]
|
||||
},
|
||||
{
|
||||
"value": "*",
|
||||
"scopes": [
|
||||
"text.html.markdown",
|
||||
"markup.heading.${1/(#)(#)?(#)?(#)?(#)?(#)?/${6:?6:${5:?5:${4:?4:${3:?3:${2:?2:1}}}}}/}.markdown",
|
||||
"entity.name.section.markdown",
|
||||
"markup.italic.markdown",
|
||||
"punctuation.definition.italic.markdown"
|
||||
]
|
||||
},
|
||||
{
|
||||
"value": " stuff",
|
||||
"scopes": [
|
||||
"text.html.markdown",
|
||||
"markup.heading.${1/(#)(#)?(#)?(#)?(#)?(#)?/${6:?6:${5:?5:${4:?4:${3:?3:${2:?2:1}}}}}/}.markdown",
|
||||
"entity.name.section.markdown"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
Загрузка…
Ссылка в новой задаче