refactoring

This commit is contained in:
mpetrov 2025-03-04 17:39:10 +02:00
parent 2134a17f46
commit 69f0aa9691
5 changed files with 8 additions and 17 deletions

View File

@ -44,7 +44,8 @@ import {
CalculatedFieldTestScriptDialogData,
getCalculatedFieldArgumentsEditorCompleter,
getCalculatedFieldArgumentsHighlights,
CalculatedFieldTypeTranslations, CalculatedFieldType,
CalculatedFieldTypeTranslations,
CalculatedFieldType,
} from '@shared/models/calculated-field.models';
import {
CalculatedFieldDebugDialogComponent,

View File

@ -36,7 +36,6 @@ import {
AceHighlightRules,
dotOperatorHighlightRule,
endGroupHighlightRule,
identifierRe
} from '@shared/models/ace/ace.models';
import { HelpLinks, ValueType } from '@shared/models/constants';
import { formPropertyCompletions } from '@shared/models/dynamic-form.models';
@ -925,6 +924,8 @@ export class ScadaSymbolElement {
}
const identifierRe = /[a-zA-Z$_\u00a1-\uffff][a-zA-Z\d$_\u00a1-\uffff]*/;
const scadaSymbolCtxObjectHighlightRule: AceHighlightRule = {
token: 'tb.scada-symbol-ctx',
regex: /\bctx\b/,

View File

@ -587,6 +587,10 @@ export class JsFuncComponent implements OnInit, OnChanges, OnDestroy, ControlVal
newMode.$highlightRules.$rules[group] = this.highlightRules[group];
}
}
const identifierRule = newMode.$highlightRules.$rules.no_regex.find(rule => rule.token?.includes('identifier'));
if (identifierRule) {
identifierRule.next = 'start';
}
// @ts-ignore
this.jsEditor.session.$onChangeMode(newMode);
}

View File

@ -376,7 +376,4 @@ export const endGroupHighlightRule: AceHighlightRule = {
next: 'no_regex'
};
export const identifierRe = /[a-zA-Z$_\u00a1-\uffff][a-zA-Z\d$_\u00a1-\uffff]*/;

View File

@ -33,7 +33,6 @@ import {
AceHighlightRules,
dotOperatorHighlightRule,
endGroupHighlightRule,
identifierRe
} from '@shared/models/ace/ace.models';
export interface CalculatedField extends Omit<BaseData<CalculatedFieldId>, 'label'>, HasVersion, HasEntityDebugSettings, HasTenantId, ExportableEntity<CalculatedFieldId> {
@ -536,17 +535,6 @@ export const getCalculatedFieldArgumentsHighlights = (
? 'calculatedFieldRollingArgumentValue'
: 'calculatedFieldSingleArgumentValue'
})),
no_regex: [
{
token: 'tb.identifier',
regex: identifierRe,
},
{
token: 'tb.paren.lparen',
regex: '\\(',
next: 'start'
}
],
...calculatedFieldSingleArgumentValueHighlightRules,
...calculatedFieldRollingArgumentValueHighlightRules,
...calculatedFieldTimeWindowArgumentValueHighlightRules