mirror of
https://github.com/salexdv/bsl_console.git
synced 2024-11-24 08:33:29 +02:00
Реализация подсказки директив компиляции closes #300
This commit is contained in:
parent
851fbd36c2
commit
04fd6b2b30
@ -3477,6 +3477,34 @@ class bslHelper {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fills array of completion for compile directives
|
||||||
|
*
|
||||||
|
* @param {array} suggestions array of suggestions for provideCompletionItems
|
||||||
|
*/
|
||||||
|
getCompilerDirectivesCompetition(suggestions) {
|
||||||
|
|
||||||
|
for (const [key, value] of Object.entries(bslGlobals.compilerDirectives)) {
|
||||||
|
|
||||||
|
if ((key == 'ru' && !engLang) || (key == 'en' && engLang)) {
|
||||||
|
|
||||||
|
for (const [directive, empty] of Object.entries(value)) {
|
||||||
|
|
||||||
|
suggestions.push({
|
||||||
|
label: directive,
|
||||||
|
kind: monaco.languages.CompletionItemKind.Enum,
|
||||||
|
insertText: directive,
|
||||||
|
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills completions for object's methods and properties
|
* Fills completions for object's methods and properties
|
||||||
* into expressions like 'Types = New Array; Types.Cou<-(unt)'
|
* into expressions like 'Types = New Array; Types.Cou<-(unt)'
|
||||||
@ -3643,6 +3671,47 @@ class bslHelper {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if compile directives is needed
|
||||||
|
*
|
||||||
|
* @returns {bool}
|
||||||
|
*/
|
||||||
|
requireCompilerDirectives(triggerCharacter) {
|
||||||
|
|
||||||
|
if (triggerCharacter && triggerCharacter == '&' && this.column == 2) {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
if (this.wordData) {
|
||||||
|
const range = new monaco.Range(
|
||||||
|
this.lineNumber,
|
||||||
|
this.wordData.startColumn - 1,
|
||||||
|
this.lineNumber,
|
||||||
|
this.wordData.startColumn
|
||||||
|
);
|
||||||
|
return (this.wordData.startColumn == 2 && this.model.getValueInRange(range) == '&')
|
||||||
|
}
|
||||||
|
else if (this.column == 2) {
|
||||||
|
|
||||||
|
const range = new monaco.Range(
|
||||||
|
this.lineNumber,
|
||||||
|
1,
|
||||||
|
this.lineNumber,
|
||||||
|
2
|
||||||
|
);
|
||||||
|
return (this.model.getValueInRange(range) == '&')
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Completion provider for code-mode
|
* Completion provider for code-mode
|
||||||
*
|
*
|
||||||
@ -3656,9 +3725,10 @@ class bslHelper {
|
|||||||
let suggestions = [];
|
let suggestions = [];
|
||||||
|
|
||||||
if (context.triggerCharacter && context.triggerCharacter == ' ') {
|
if (context.triggerCharacter && context.triggerCharacter == ' ') {
|
||||||
|
|
||||||
this.getClassCompletion(suggestions, bslGlobals.classes, true);
|
this.getClassCompletion(suggestions, bslGlobals.classes, true);
|
||||||
|
}
|
||||||
|
else if (this.requireCompilerDirectives(context.triggerCharacter)) {
|
||||||
|
this.getCompilerDirectivesCompetition(suggestions);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ define([], function () {
|
|||||||
bsl: {
|
bsl: {
|
||||||
languageDef: bsl_language,
|
languageDef: bsl_language,
|
||||||
completionProvider: {
|
completionProvider: {
|
||||||
triggerCharacters: ['.', '"', ' '],
|
triggerCharacters: ['.', '"', ' ', '&'],
|
||||||
provideCompletionItems: function (model, position, context, token) {
|
provideCompletionItems: function (model, position, context, token) {
|
||||||
resetSuggestWidgetDisplay();
|
resetSuggestWidgetDisplay();
|
||||||
let bsl = new bslHelper(model, position);
|
let bsl = new bslHelper(model, position);
|
||||||
|
Loading…
Reference in New Issue
Block a user