1
0
mirror of https://github.com/salexdv/bsl_console.git synced 2024-11-24 08:33:29 +02:00

Рефакторинг provideQueryDefinition

This commit is contained in:
salexdv 2023-04-10 14:09:04 +03:00
parent e4ee921f18
commit 702ab1c092

View File

@ -7911,32 +7911,46 @@ class bslHelper {
}
/**
* Provide the definition of the symbol at the given position of query
* Provide the definition for query field
*
* @returns {array} Location[]
*/
provideQueryDefinition() {
getQueryFieldDefinition() {
let location = null;
if (this.word) {
if (this.wordHasCharsBefore('.')) {
let pattern = '(as|как)\\s*' + this.word;
let position = new monaco.Position(this.lineNumber, 1);
let match = Finder.findPreviousMatch(this.model, pattern, position, false);
if (match && match.range.startLineNumber < this.lineNumber) {
let match_position = new monaco.Position(match.range.startLineNumber, match.range.startColumn);
let match_comma = Finder.findPreviousMatch(this.model, ',', match_position, false);
if (match_comma) {
match.range.startLineNumber = match_comma.range.startLineNumber + 1;
match.range.startColumn;
}
location = [{
uri: this.model.uri,
range: match.range
}];
}
}
else if (this.wordHasCharsAfter('.')) {
return location;
}
/**
* Provide the definition for query source
*
* @returns {array} Location[]
*/
getQuerySourceDefinition() {
let location = null;
let pattern = '(as|как)\\s*' + this.word;
let position = new monaco.Position(this.lineNumber, this.model.getLineMaxColumn(this.lineNumber));
let match = Finder.findNextMatch(this.model, pattern, position, false);
@ -7948,9 +7962,18 @@ class bslHelper {
}];
}
}
else {
return location;
}
/**
* Provide the definition for temp table
*
* @returns {array} Location[]
*/
getQueryTempTableDefinition() {
let location = null;
let pattern = '(поместить|into)[\\s\\n\\t]*' + this.word;
let position = new monaco.Position(this.lineNumber, 1);
let match = Finder.findPreviousMatch(this.model, pattern, position, false);
@ -7962,8 +7985,28 @@ class bslHelper {
}];
}
return location;
}
/**
* Provide the definition of the symbol at the given position of query
*
* @returns {array} Location[]
*/
provideQueryDefinition() {
let location = null;
if (this.word) {
if (this.wordHasCharsBefore('.'))
location = this.getQueryFieldDefinition()
else if (this.wordHasCharsAfter('.'))
location = this.getQuerySourceDefinition();
else
location = this.getQueryTempTableDefinition();
}
return location;