From c5b9fd66d4ff48bfe1bbdb69954bda21551d20a7 Mon Sep 17 00:00:00 2001 From: Kandrashin Denis Date: Fri, 30 Dec 2022 21:21:11 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B5=D0=BB=D0=B5=D0=BD=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D1=81=D0=B2=D0=B5=D1=82=D0=BA=D0=B0=20=D0=B2?= =?UTF-8?q?=20=D0=BA=D0=B2=D0=B0=D0=B4=D1=80=D0=B0=D1=82=D0=BD=D1=8B=D1=85?= =?UTF-8?q?=20=D1=81=D0=BA=D0=BE=D0=B1=D0=BA=D0=B0=D1=85=20=20#146?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/languages/turbo-gherkin/configuration.ts | 22 +++++++++++++++++++- src/languages/turbo-gherkin/matcher.ts | 5 +++++ src/languages/turbo-gherkin/provider.ts | 6 ++++++ test/demo/editor-demo.ts | 1 + test/demo/example.feature | 1 + 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/languages/turbo-gherkin/configuration.ts b/src/languages/turbo-gherkin/configuration.ts index 273d8b5..59a3ebe 100644 --- a/src/languages/turbo-gherkin/configuration.ts +++ b/src/languages/turbo-gherkin/configuration.ts @@ -42,6 +42,19 @@ export class GherkinLanguage { this.tokenizer.feature[0] = [provider.matcher.primary, { token: "metatag.php", next: "@root" }]; if (provider.matcher.directives) this.tokenizer.section.push([provider.matcher.directives, { token: "metatag", next: "@operator" }]) + if (provider.matcher.sppr) { + this.tokenizer.common.push([/\[/, "comment", "@string_bracket"]); + this.tokenizer.string.forEach(item => { + if (item[1] && item[1].token === "constant") { + item[1].token = 'comment'; + } + }); + this.tokenizer.index.forEach(item => { + if (item[1] && item[1].token === "constant") { + item[1].token = 'comment'; + } + }); + } } tokenizer = { @@ -161,9 +174,16 @@ export class GherkinLanguage { [/>/, "string", "@pop"] ], + string_bracket: [ + { include: "@eol" }, + [/[^\]\\\{\[\$]+/, "comment"], + { include: "@string" }, + [/\]/, "comment", "@pop"] + ], + index: [ { include: "@eol" }, - [/[^\\\]]+/, "constant"], + [/[^\\\]]+/, {token: "constant"}], { include: "@escapes" }, [/\]/, { bracket: "@close", next: "@pop", token: "constant" }], ], diff --git a/src/languages/turbo-gherkin/matcher.ts b/src/languages/turbo-gherkin/matcher.ts index ea9b00c..386725a 100644 --- a/src/languages/turbo-gherkin/matcher.ts +++ b/src/languages/turbo-gherkin/matcher.ts @@ -9,6 +9,7 @@ class Section { export class KeywordMatcher { + public sppr: boolean = false; public stepkey: any = {}; public section = new Section; public keypairs: RegExp[]; @@ -104,6 +105,10 @@ export class KeywordMatcher { null : this.regex(words); } + public setSPPR(value: boolean) { + this.sppr = value; + } + public setKeypairs(keypairs: any) { this.keypairs = []; Object.keys(keypairs).forEach((key: string) => { diff --git a/src/languages/turbo-gherkin/provider.ts b/src/languages/turbo-gherkin/provider.ts index 06f06b2..bead960 100644 --- a/src/languages/turbo-gherkin/provider.ts +++ b/src/languages/turbo-gherkin/provider.ts @@ -66,6 +66,7 @@ export class VanessaGherkinProvider { private _directives: string[] = []; private _keypairs: any = {}; private _errorLinks = []; + private _sppr: boolean = false; private _matcher: KeywordMatcher; private _locale: string; @@ -125,6 +126,11 @@ export class VanessaGherkinProvider { this.matcher?.setDirectives(this.directives); } + public setSPPR = (arg: boolean): void => { + this._sppr = arg; + this.matcher?.setSPPR(arg); + } + public setMessages = (arg: string): void => { worker.postMessage({ type: MessageType.SetMessages, data: arg }); } diff --git a/test/demo/editor-demo.ts b/test/demo/editor-demo.ts index 36d87e0..26ec150 100644 --- a/test/demo/editor-demo.ts +++ b/test/demo/editor-demo.ts @@ -36,6 +36,7 @@ export function show() { provider.setKeypairs(JSON.stringify(keypairs)) provider.setMessages(JSON.stringify(messages)) provider.setVariables(JSON.stringify(variables)) + provider.setSPPR(true) const welcome: WelcomeParams = { title: "Vanessa Automation", diff --git a/test/demo/example.feature b/test/demo/example.feature index 1896490..02b4ba1 100644 --- a/test/demo/example.feature +++ b/test/demo/example.feature @@ -38,6 +38,7 @@ Если в окне предупреждения нет текста "Нужный} текст" тогда Попытка Если в панели открытых есть команда "Записать[Закрыть]" Тогда + И видеовставка картинки [ТекстДиктора] Исключение И видеовставка картинки "ИмяКартинки[ТекстДиктора]" * Проверка шагов