You've already forked bsl_console
mirror of
https://github.com/salexdv/bsl_console.git
synced 2025-09-16 09:06:17 +02:00
Вывод определения в EVENT_BEFORE_HOVER
This commit is contained in:
@@ -18,12 +18,22 @@ setOption('generateBeforeHoverEvent', false);
|
||||
```json
|
||||
{
|
||||
"word": {
|
||||
"word": "Документы",
|
||||
"startColumn": 8,
|
||||
"endColumn": 17
|
||||
"word": "Документ",
|
||||
"startColumn": 2,
|
||||
"endColumn": 10
|
||||
},
|
||||
"token": "identifierbsl",
|
||||
"line": 4,
|
||||
"column": 12
|
||||
"line": 11,
|
||||
"column": 6,
|
||||
"definition": {
|
||||
"code": "Для Каждого Документ Из МассивДокументов Цикл",
|
||||
"iterator": "МассивДокументов",
|
||||
"range": {
|
||||
"endColumn": 46,
|
||||
"endLineNumber": 1,
|
||||
"startColumn": 1,
|
||||
"startLineNumber": 10
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
@@ -7755,7 +7755,8 @@ class bslHelper {
|
||||
column: this.column,
|
||||
altKey: window.altPressed,
|
||||
ctrlKey: window.ctrlPressed,
|
||||
shiftKey: window.shiftPressed
|
||||
shiftKey: window.shiftPressed,
|
||||
definition: this.getDefinition()
|
||||
}
|
||||
window.sendEvent('EVENT_BEFORE_HOVER', params);
|
||||
}
|
||||
@@ -8008,13 +8009,13 @@ class bslHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the definition of the symbol at the given position of code
|
||||
* Returns current word definition
|
||||
*
|
||||
* @returns {array} Location[]
|
||||
* @returns {object} definition
|
||||
*/
|
||||
provideDefinition() {
|
||||
getDefinition() {
|
||||
|
||||
let location = null;
|
||||
let definition = null;
|
||||
|
||||
if (this.word) {
|
||||
|
||||
@@ -8032,13 +8033,53 @@ class bslHelper {
|
||||
let match = Finder.findPreviousMatch(this.model, pattern, position, false);
|
||||
|
||||
if (match && (is_function || match.range.startLineNumber < this.lineNumber)) {
|
||||
location = [{
|
||||
uri: this.model.uri,
|
||||
range: match.range
|
||||
}];
|
||||
definition = {
|
||||
range: match.range,
|
||||
code: match.matches[0],
|
||||
iterator: null
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (!definition) {
|
||||
|
||||
pattern = '(?:для каждого|for each)\\s*' + this.word + '\\s*(?:из|in)\\s*(.*)\\s*(?:цикл|do)';
|
||||
position = new monaco.Position(this.lineNumber, 999);
|
||||
match = Finder.findPreviousMatch(this.model, pattern, position, false);
|
||||
|
||||
if (match && match.range.startLineNumber <= this.lineNumber) {
|
||||
definition = {
|
||||
range: match.range,
|
||||
code: match.matches[0],
|
||||
iterator: match.matches[1].trim()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return definition;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the definition of the symbol at the given position of code
|
||||
*
|
||||
* @returns {array} Location[]
|
||||
*/
|
||||
provideDefinition() {
|
||||
|
||||
let location = null;
|
||||
let definition = this.getDefinition();
|
||||
|
||||
if (definition) {
|
||||
|
||||
location = [{
|
||||
uri: this.model.uri,
|
||||
range: definition.range
|
||||
}];
|
||||
|
||||
this.generateDefinitionEvent();
|
||||
|
||||
|
Reference in New Issue
Block a user