329
return undefined;
330
}
332
console.warn(`[${languageId}]: language configuration: expected \`onEnterRules\` to be an array.`);
333
return undefined;
334
}
336
>
let result: OnEnterRule[] | undefined = undefined;
337
>
for (let i = 0, len = source.length; i < len; i++) {
338
>
const onEnterRule = source[i];
339
>
if (!types.isObject(onEnterRule)) {
340
console.warn(`[${languageId}]: language configuration: expected \`onEnterRules[${i}]\` to be an object.`);
341
continue;
342
}
344
console.warn(`[${languageId}]: language configuration: expected \`onEnterRules[${i}].action\` to be an object.`);
345
continue;
346
}
348
>
if (onEnterRule.action.indent === 'none') {
349
>
indentAction = IndentAction.None;
350
>
} else if (onEnterRule.action.indent === 'indent') {
351
>
indentAction = IndentAction.Indent;
352
>
} else if (onEnterRule.action.indent === 'indentOutdent') {
353
>
indentAction = IndentAction.IndentOutdent;
354
>
} else if (onEnterRule.action.indent === 'outdent') {
355
>
indentAction = IndentAction.Outdent;
356
>
} else {
357
console.warn(`[${languageId}]: language configuration: expected \`onEnterRules[${i}].action.indent\` to be 'none', 'indent', 'indentOutdent' or 'outdent'.`);
358
continue;
359
}
361
>
if (onEnterRule.action.appendText) {
362
>
if (typeof onEnterRule.action.appendText === 'string') {
363
>
action.appendText = onEnterRule.action.appendText;
364
>
} else {
365
console.warn(`[${languageId}]: language configuration: expected \`onEnterRules[${i}].action.appendText\` to be undefined or a string.`);
366
}
368
>
if (onEnterRule.action.removeText) {
369
>
if (typeof onEnterRule.action.removeText === 'number') {
370
>
action.removeText = onEnterRule.action.removeText;
371
>
} else {
372
console.warn(`[${languageId}]: language configuration: expected \`onEnterRules[${i}].action.removeText\` to be undefined or a number.`);
373
}
375
>
const beforeText = this._parseRegex(languageId, `onEnterRules[${i}].beforeText`, onEnterRule.beforeText);
376
>
if (!beforeText) {
377
continue;
378
}
380
>
if (onEnterRule.afterText) {
381
>
const afterText = this._parseRegex(languageId, `onEnterRules[${i}].afterText`, onEnterRule.afterText);
382
>
if (afterText) {
383
>
resultingOnEnterRule.afterText = afterText;
384
>
}
385
>
}
386
>
if (onEnterRule.previousLineText) {
387
>
const previousLineText = this._parseRegex(languageId, `onEnterRules[${i}].previousLineText`, onEnterRule.previousLineText);
388
>
if (previousLineText) {
389
>
resultingOnEnterRule.previousLineText = previousLineText;
390
>
}
391
>
}
392
>
result = result || [];
393
>
result.push(resultingOnEnterRule);
394
>
}
395
>
396
>
return result;
397
}
398