Skip to content

Commit 17072a0

Browse files
authored
fixed hover error for multiple lines object (#32)
1 parent 98209c7 commit 17072a0

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to the "bitloops-language" extension will be documented in t
44

55
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
66

7+
### 0.4.7
8+
9+
Fixed hover error.
10+
711
### 0.4.6
812

913
Updated version of bitloops-transpiler, added Iterator loop.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ No known issues.
3333

3434
## What's New
3535

36-
### 0.4.6
36+
### 0.4.7
3737

38-
Updated version of bitloops-transpiler, added Iterator for-of loop.
38+
Fixed hover error.
3939

4040
---
4141

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"icon": "assets/images/bitloops-language-logo-256x256.png",
1111
"license": "MIT",
12-
"version": "0.4.6",
12+
"version": "0.4.7",
1313
"scripts": {
1414
"vs:package": "vsce package",
1515
"vs:publish": "vsce publish",

server/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "bitloops-lsp-server",
33
"description": "BitLoops Language Server",
4-
"version": "0.4.6",
4+
"version": "0.4.7",
55
"publisher": "Bitloops",
66
"license": "MIT",
77
"engines": {

server/src/lsp/handlers/hover-handler/hover.ts

+13-15
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ export const handleHover = (
4141
};
4242

4343
const findWord = (document: TextDocument, position: Position): string => {
44-
const line = document.getText().split('\n')[position.line]; //get the current line
45-
let currentPosition = line.indexOf(line.trimStart()[0]); //get the position of the first non-whitespace character
46-
const wordRegExp = /\b[\w.]+\b\(?/g; //find all words, including those which contain dots or opening parentheses
47-
const matches = line.match(wordRegExp) || [];
48-
const allMatches = []; //this array will contain all the matches, including the words which contain dots incrementally
49-
//for example: if the word is this.accountRepo.getById(accountId).ifError(), the array will contain the following elements:
50-
//[this, this.accountRepo, this.accountRepo.getById(), accountId, this.accountRepo.getById().ifError()] in this order
51-
for (const match of matches) {
52-
try {
44+
try {
45+
const line = document.getText().split('\n')[position.line]; //get the current line
46+
let currentPosition = line.indexOf(line.trimStart()[0]); //get the position of the first non-whitespace character
47+
const wordRegExp = /\b[\w.]+\b\(?/g; //find all words, including those which contain dots or opening parentheses
48+
const matches = line.match(wordRegExp) || [];
49+
const allMatches = []; //this array will contain all the matches, including the words which contain dots incrementally
50+
//for example: if the word is this.accountRepo.getById(accountId).ifError(), the array will contain the following elements:
51+
//[this, this.accountRepo, this.accountRepo.getById(), accountId, this.accountRepo.getById().ifError()] in this order
52+
for (const match of matches) {
5353
if (match.includes('.')) {
5454
const separateMatches = match.split('.');
5555
let i = 1;
@@ -65,10 +65,8 @@ const findWord = (document: TextDocument, position: Position): string => {
6565
//for methods: we keep the opening parenthesis in the matched word so we can separate the method from the variable and then we add the closing parenthesis
6666
//because in the symbolTable it is stored as a method call, for example this.accountRepo.getById()
6767
else allMatches.push(match);
68-
} catch (e) {}
69-
}
70-
for (let i = 0; i < allMatches.length; i++) {
71-
try {
68+
}
69+
for (let i = 0; i < allMatches.length; i++) {
7270
let myLength = allMatches[i].length;
7371
if (allMatches[i].includes('.')) {
7472
myLength -= allMatches[i - 1].length;
@@ -81,7 +79,7 @@ const findWord = (document: TextDocument, position: Position): string => {
8179
} else {
8280
currentPosition += myLength + 1;
8381
}
84-
} catch (e) {}
85-
}
82+
}
83+
} catch (e) {}
8684
return undefined;
8785
};

0 commit comments

Comments
 (0)