Skip to content

Commit

Permalink
Зеленая подсветка в квадратных скобках #146
Browse files Browse the repository at this point in the history
  • Loading branch information
lintest committed Dec 30, 2022
1 parent f3d6d3b commit c5b9fd6
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/languages/turbo-gherkin/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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" }],
],
Expand Down
5 changes: 5 additions & 0 deletions src/languages/turbo-gherkin/matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Section {

export class KeywordMatcher {

public sppr: boolean = false;
public stepkey: any = {};
public section = new Section;
public keypairs: RegExp[];
Expand Down Expand Up @@ -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) => {
Expand Down
6 changes: 6 additions & 0 deletions src/languages/turbo-gherkin/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 });
}
Expand Down
1 change: 1 addition & 0 deletions test/demo/editor-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions test/demo/example.feature
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
Если в окне предупреждения нет текста "Нужный} текст" тогда
Попытка
Если в панели открытых есть команда "Записать[Закрыть]" Тогда
И видеовставка картинки [ТекстДиктора]
Исключение
И видеовставка картинки "ИмяКартинки[ТекстДиктора]"
* Проверка шагов
Expand Down

0 comments on commit c5b9fd6

Please sign in to comment.