Merge pull request #12856 from maxunbearable/improvement/tbel-utils-autcompletes
Implemented tbel utils autocompletes and highlights
This commit is contained in:
commit
16538c7d74
@ -79,4 +79,10 @@
|
|||||||
background: #f3f3f3;
|
background: #f3f3f3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ace_tb {
|
||||||
|
&.ace_tbel-utils-func {
|
||||||
|
color: rgb(49, 132, 149);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,6 +50,7 @@ import { JsFuncModulesComponent } from '@shared/components/js-func-modules.compo
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { map, Observable, of } from 'rxjs';
|
import { map, Observable, of } from 'rxjs';
|
||||||
import { catchError } from 'rxjs/operators';
|
import { catchError } from 'rxjs/operators';
|
||||||
|
import { tbelUtilsAutocompletes, tbelUtilsFuncHighlightRules } from '@shared/models/ace/tbel-utils.models';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-js-func',
|
selector: 'tb-js-func',
|
||||||
@ -560,6 +561,9 @@ export class JsFuncComponent implements OnInit, OnChanges, OnDestroy, ControlVal
|
|||||||
break;
|
break;
|
||||||
case 'scriptLanguage':
|
case 'scriptLanguage':
|
||||||
this.updatedScriptLanguage();
|
this.updatedScriptLanguage();
|
||||||
|
this.updateHighlightRules();
|
||||||
|
this.updateCompleters();
|
||||||
|
this.updateJsWorkerGlobals();
|
||||||
break;
|
break;
|
||||||
case 'disableUndefinedCheck':
|
case 'disableUndefinedCheck':
|
||||||
case 'globalVariables':
|
case 'globalVariables':
|
||||||
@ -576,10 +580,11 @@ export class JsFuncComponent implements OnInit, OnChanges, OnDestroy, ControlVal
|
|||||||
|
|
||||||
private updateHighlightRules(): void {
|
private updateHighlightRules(): void {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (!!this.highlightRules && !!this.jsEditor.session.$mode) {
|
if (!!this.jsEditor.session.$mode) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const newMode = new this.jsEditor.session.$mode.constructor();
|
const newMode = new this.jsEditor.session.$mode.constructor();
|
||||||
newMode.$highlightRules = new newMode.HighlightRules();
|
newMode.$highlightRules = new newMode.HighlightRules();
|
||||||
|
if (!!this.highlightRules) {
|
||||||
for(const group in this.highlightRules) {
|
for(const group in this.highlightRules) {
|
||||||
if(!!newMode.$highlightRules.$rules[group]) {
|
if(!!newMode.$highlightRules.$rules[group]) {
|
||||||
newMode.$highlightRules.$rules[group].unshift(...this.highlightRules[group]);
|
newMode.$highlightRules.$rules[group].unshift(...this.highlightRules[group]);
|
||||||
@ -587,8 +592,12 @@ export class JsFuncComponent implements OnInit, OnChanges, OnDestroy, ControlVal
|
|||||||
newMode.$highlightRules.$rules[group] = this.highlightRules[group];
|
newMode.$highlightRules.$rules[group] = this.highlightRules[group];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (this.scriptLanguage === ScriptLanguage.TBEL) {
|
||||||
|
newMode.$highlightRules.$rules.start = [...tbelUtilsFuncHighlightRules, ...newMode.$highlightRules.$rules.start];
|
||||||
|
}
|
||||||
const identifierRule = newMode.$highlightRules.$rules.no_regex.find(rule => rule.token?.includes('identifier'));
|
const identifierRule = newMode.$highlightRules.$rules.no_regex.find(rule => rule.token?.includes('identifier'));
|
||||||
if (identifierRule) {
|
if (identifierRule && identifierRule.next === 'no_regex') {
|
||||||
identifierRule.next = 'start';
|
identifierRule.next = 'start';
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@ -641,6 +650,9 @@ export class JsFuncComponent implements OnInit, OnChanges, OnDestroy, ControlVal
|
|||||||
if (modulesCompleter) {
|
if (modulesCompleter) {
|
||||||
completers.push(modulesCompleter);
|
completers.push(modulesCompleter);
|
||||||
}
|
}
|
||||||
|
if (this.scriptLanguage === ScriptLanguage.TBEL) {
|
||||||
|
completers.push(tbelUtilsAutocompletes);
|
||||||
|
}
|
||||||
completers.push(...this.initialCompleters);
|
completers.push(...this.initialCompleters);
|
||||||
this.jsEditor.completers = completers;
|
this.jsEditor.completers = completers;
|
||||||
});
|
});
|
||||||
|
|||||||
1319
ui-ngx/src/app/shared/models/ace/tbel-utils.models.ts
Normal file
1319
ui-ngx/src/app/shared/models/ace/tbel-utils.models.ts
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user