mirror of
https://github.com/salexdv/bsl_console.git
synced 2025-02-07 13:31:37 +02:00
Исключение срабатывания подсказок в строковых литералах
This commit is contained in:
parent
424b50cb5e
commit
6378bae98c
@ -37,6 +37,7 @@ class bslHelper {
|
||||
|
||||
this.nameField = engLang ? 'name_en': 'name';
|
||||
this.queryNameField = engLang ? 'query_name_en' : 'query_name';
|
||||
this.token = this.getLastToken();
|
||||
|
||||
}
|
||||
|
||||
@ -50,6 +51,43 @@ class bslHelper {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the token in the current position
|
||||
*
|
||||
* @return {string} name of token
|
||||
*/
|
||||
getLastToken() {
|
||||
|
||||
let token = '';
|
||||
|
||||
let value = this.model.getValueInRange(new monaco.Range(1, 1, this.lineNumber, this.column));
|
||||
let tokens = monaco.editor.tokenize(value, 'bsl');
|
||||
|
||||
if (tokens.length) {
|
||||
|
||||
let last_tokens = tokens[tokens.length - 1];
|
||||
|
||||
if (last_tokens.length)
|
||||
token = last_tokens[last_tokens.length - 1].type;
|
||||
|
||||
}
|
||||
|
||||
return token;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the text in current position
|
||||
* is a literal string or not
|
||||
*
|
||||
* @returns {bool}
|
||||
*/
|
||||
isItStringLiteral() {
|
||||
|
||||
return !!~this.token.search(/(string|query)/);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Find first string which has no pair braces
|
||||
* @param {string} str string for analisis
|
||||
@ -977,8 +1015,9 @@ class bslHelper {
|
||||
// const match = this.model.findPreviousMatch('(?<!\\/\\/.*)' + exp + '\\s?=\\s?(?:new|новый)\\s+(.*?)(?:\\(|;)', this.position, true, false, null, true);
|
||||
const match = this.model.findPreviousMatch(exp + '\\s?=\\s?(?:new|новый)\\s+(.*?)(?:\\(|;)', this.position, true, false, null, true);
|
||||
|
||||
if (match) {
|
||||
className = match.matches[match.matches.length - 1].toLowerCase();
|
||||
if (match) {
|
||||
className = match.matches[match.matches.length - 1];
|
||||
className = className ? className.toLowerCase() : '';
|
||||
}
|
||||
else {
|
||||
className = exp;
|
||||
@ -1541,6 +1580,69 @@ class bslHelper {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Completition provider for code-mode
|
||||
*
|
||||
* @returns {array} array of completition
|
||||
*/
|
||||
getCodeCompletition() {
|
||||
|
||||
let suggestions = [];
|
||||
|
||||
if (!this.requireType()) {
|
||||
|
||||
if (this.lastOperator != '"') {
|
||||
|
||||
this.getRefCompletition(suggestions);
|
||||
|
||||
if (!suggestions.length) {
|
||||
|
||||
if (!this.getClassCompletition(suggestions, bslGlobals.classes)) {
|
||||
|
||||
if (!this.getClassCompletition(suggestions, bslGlobals.systemEnum)) {
|
||||
|
||||
if (!this.getMetadataCompletition(suggestions, bslMetadata)) {
|
||||
|
||||
if (!suggestions.length)
|
||||
this.getVariablesCompetition(suggestions);
|
||||
|
||||
if (engLang)
|
||||
this.getCommonCompletition(suggestions, bslGlobals.keywords, monaco.languages.CompletionItemKind.Keyword, true);
|
||||
else
|
||||
this.getCommonCompletition(suggestions, bslGlobals.keywords, monaco.languages.CompletionItemKind.Keyword, true);
|
||||
|
||||
if (this.requireClass()) {
|
||||
this.getCommonCompletition(suggestions, bslGlobals.classes, monaco.languages.CompletionItemKind.Constructor, false);
|
||||
}
|
||||
else {
|
||||
this.getCommonCompletition(suggestions, bslGlobals.globalfunctions, monaco.languages.CompletionItemKind.Function, true);
|
||||
this.getCommonCompletition(suggestions, bslGlobals.globalvariables, monaco.languages.CompletionItemKind.Class, true);
|
||||
this.getCommonCompletition(suggestions, bslGlobals.systemEnum, monaco.languages.CompletionItemKind.Enum, false);
|
||||
this.getCommonCompletition(suggestions, bslGlobals.customFunctions, monaco.languages.CompletionItemKind.Function, true);
|
||||
this.getCommonCompletition(suggestions, bslMetadata.commonModules, monaco.languages.CompletionItemKind.Module, true);
|
||||
this.getCustomObjectsCompletition(suggestions, bslMetadata.customObjects, monaco.languages.CompletionItemKind.Enum);
|
||||
}
|
||||
|
||||
this.getSnippets(suggestions, snippets);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
this.getTypesCompletition(suggestions, bslGlobals.types, monaco.languages.CompletionItemKind.Enum);
|
||||
}
|
||||
|
||||
return suggestions;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Completition provider
|
||||
*
|
||||
@ -1556,54 +1658,8 @@ class bslHelper {
|
||||
}
|
||||
else {
|
||||
|
||||
if (!this.requireType()) {
|
||||
|
||||
if (this.lastOperator != '"') {
|
||||
|
||||
this.getRefCompletition(suggestions);
|
||||
|
||||
if (!suggestions.length) {
|
||||
|
||||
if (!this.getClassCompletition(suggestions, bslGlobals.classes)) {
|
||||
|
||||
if (!this.getClassCompletition(suggestions, bslGlobals.systemEnum)) {
|
||||
|
||||
if (!this.getMetadataCompletition(suggestions, bslMetadata)) {
|
||||
|
||||
if (!suggestions.length)
|
||||
this.getVariablesCompetition(suggestions);
|
||||
|
||||
if (engLang)
|
||||
this.getCommonCompletition(suggestions, bslGlobals.keywords, monaco.languages.CompletionItemKind.Keyword, true);
|
||||
else
|
||||
this.getCommonCompletition(suggestions, bslGlobals.keywords, monaco.languages.CompletionItemKind.Keyword, true);
|
||||
|
||||
if (this.requireClass()) {
|
||||
this.getCommonCompletition(suggestions, bslGlobals.classes, monaco.languages.CompletionItemKind.Constructor, false);
|
||||
}
|
||||
else {
|
||||
this.getCommonCompletition(suggestions, bslGlobals.globalfunctions, monaco.languages.CompletionItemKind.Function, true);
|
||||
this.getCommonCompletition(suggestions, bslGlobals.globalvariables, monaco.languages.CompletionItemKind.Class, true);
|
||||
this.getCommonCompletition(suggestions, bslGlobals.systemEnum, monaco.languages.CompletionItemKind.Enum, false);
|
||||
this.getCommonCompletition(suggestions, bslGlobals.customFunctions, monaco.languages.CompletionItemKind.Function, true);
|
||||
this.getCommonCompletition(suggestions, bslMetadata.commonModules, monaco.languages.CompletionItemKind.Module, true);
|
||||
this.getCustomObjectsCompletition(suggestions, bslMetadata.customObjects, monaco.languages.CompletionItemKind.Enum);
|
||||
}
|
||||
|
||||
this.getSnippets(suggestions, snippets);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
this.getTypesCompletition(suggestions, bslGlobals.types, monaco.languages.CompletionItemKind.Enum);
|
||||
if (!this.isItStringLiteral()) {
|
||||
suggestions = getCodeCompletition();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user