Skip to content

Commit

Permalink
Выделение директив компилятора красным #145
Browse files Browse the repository at this point in the history
  • Loading branch information
lintest committed Dec 25, 2022
1 parent 8792a2d commit 5ecd6a0
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 0 deletions.
20 changes: 20 additions & 0 deletions example/VAEditorSample/Forms/MainForm/Ext/Form/Module.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,25 @@ Function GetMetatags()

EndFunction

&AtClient
Function GetDirectives()

words = "
|#Если
|#ИначеЕсли
|#Иначе
|#КонецЕсли
|";

split = "
|";

Directives = StrSplit(words, split, False);

Return JsonDump(Directives);

EndFunction

&AtServer
Function VanessaStepList(language)

Expand Down Expand Up @@ -817,6 +836,7 @@ Procedure VanessaEditorDocumentComplete(Item)
Provider.setKeywords(GetKeywords());
Provider.setElements(GetElements());
Provider.setVariables(GetVariables());
Provider.setDirectives(GetDirectives());
Provider.setMessages(MessagesJSON);
LoadStepsAll(Undefined);

Expand Down
2 changes: 2 additions & 0 deletions src/languages/turbo-gherkin/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export class GherkinLanguage {
this.tokenizer.keyword.push([provider.matcher.import, { token: "keyword", next: "@operator" }]);
this.tokenizer.keyword.push([provider.matcher.step, { token: "keyword", next: "@operator" }]);
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" }])
}

tokenizer = {
Expand Down
6 changes: 6 additions & 0 deletions src/languages/turbo-gherkin/matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class KeywordMatcher {
public section = new Section;
public keypairs: RegExp[];
public metatags: RegExp;
public directives: RegExp;
public primary: RegExp;
public import: RegExp;
public step: RegExp;
Expand Down Expand Up @@ -98,6 +99,11 @@ export class KeywordMatcher {
this.metatags = this.regex(metatags);
}

public setDirectives(words: string[]) {
this.directives = words.length === 0 ?
null : this.regex(words, "(\\s+.*$|$)");
}

public setKeypairs(keypairs: any) {
this.keypairs = [];
Object.keys(keypairs).forEach((key: string) => {
Expand Down
12 changes: 12 additions & 0 deletions src/languages/turbo-gherkin/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export class VanessaGherkinProvider {
public get keypairs(): any { return this._keypairs; }

private _metatags: string[] = ["try", "except", "попытка", "исключение"];
private _directives: string[] = [];
private _keypairs: any = {};
private _errorLinks = [];
private _matcher: KeywordMatcher;
Expand All @@ -76,6 +77,10 @@ export class VanessaGherkinProvider {
return this._locale;
}

public get directives(): string[] {
return this._directives;
}

public setErrorLinks = (arg: string): void => {
const commands = JSON.parse(arg)
this.clearArray(this.errorLinks);
Expand Down Expand Up @@ -113,6 +118,13 @@ export class VanessaGherkinProvider {
worker.postMessage({ type: MessageType.SetMetatags, data: this.metatags });
}

public setDirectives = (arg: string): void => {
this._directives = [];
let list = JSON.parse(arg);
list.forEach((w: string) => this._directives.push(w));
this.matcher?.setDirectives(this.directives);
}

public setMessages = (arg: string): void => {
worker.postMessage({ type: MessageType.SetMessages, data: arg });
}
Expand Down
3 changes: 3 additions & 0 deletions test/demo/editor-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ export function show() {
soundHint: "Озвучить"
}

const directives = ["#Если", "#Иначе", "#ИначеЕсли", "#КонецЕсли"]

const keypairs = { if: ['then'], Если: ['Тогда'] }

provider.setDirectives(JSON.stringify(directives))
provider.setElements(JSON.stringify(elements))
provider.setKeypairs(JSON.stringify(keypairs))
provider.setMessages(JSON.stringify(messages))
Expand Down
6 changes: 6 additions & 0 deletions test/demo/example.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@
И вот почему видеовставка картинки "ИмяКартинки" "ТекстДиктора"
И это значит что в таблице "$ИмяТаблицы$" есть колонка с именем '$ИмяРеквизита$'
Если в панели открытых есть команда "ЗаписатьИЗакрыть" Тогда

#Если ЭтоКлиент Тогда
Если в панели открытых есть команда "ЗаписатьИЗакрыть" Тогда
#Иначе
Если Версия платформы ">=" "8.3.6" Тогда
#КонецЕсли

0 comments on commit 5ecd6a0

Please sign in to comment.