Skip to content

Commit

Permalink
fixed hover error for multiple lines object (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
Traigor authored Jul 6, 2023
1 parent 98209c7 commit 17072a0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to the "bitloops-language" extension will be documented in t

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

### 0.4.7

Fixed hover error.

### 0.4.6

Updated version of bitloops-transpiler, added Iterator loop.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ No known issues.

## What's New

### 0.4.6
### 0.4.7

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

---

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"icon": "assets/images/bitloops-language-logo-256x256.png",
"license": "MIT",
"version": "0.4.6",
"version": "0.4.7",
"scripts": {
"vs:package": "vsce package",
"vs:publish": "vsce publish",
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bitloops-lsp-server",
"description": "BitLoops Language Server",
"version": "0.4.6",
"version": "0.4.7",
"publisher": "Bitloops",
"license": "MIT",
"engines": {
Expand Down
28 changes: 13 additions & 15 deletions server/src/lsp/handlers/hover-handler/hover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ export const handleHover = (
};

const findWord = (document: TextDocument, position: Position): string => {
const line = document.getText().split('\n')[position.line]; //get the current line
let currentPosition = line.indexOf(line.trimStart()[0]); //get the position of the first non-whitespace character
const wordRegExp = /\b[\w.]+\b\(?/g; //find all words, including those which contain dots or opening parentheses
const matches = line.match(wordRegExp) || [];
const allMatches = []; //this array will contain all the matches, including the words which contain dots incrementally
//for example: if the word is this.accountRepo.getById(accountId).ifError(), the array will contain the following elements:
//[this, this.accountRepo, this.accountRepo.getById(), accountId, this.accountRepo.getById().ifError()] in this order
for (const match of matches) {
try {
try {
const line = document.getText().split('\n')[position.line]; //get the current line
let currentPosition = line.indexOf(line.trimStart()[0]); //get the position of the first non-whitespace character
const wordRegExp = /\b[\w.]+\b\(?/g; //find all words, including those which contain dots or opening parentheses
const matches = line.match(wordRegExp) || [];
const allMatches = []; //this array will contain all the matches, including the words which contain dots incrementally
//for example: if the word is this.accountRepo.getById(accountId).ifError(), the array will contain the following elements:
//[this, this.accountRepo, this.accountRepo.getById(), accountId, this.accountRepo.getById().ifError()] in this order
for (const match of matches) {
if (match.includes('.')) {
const separateMatches = match.split('.');
let i = 1;
Expand All @@ -65,10 +65,8 @@ const findWord = (document: TextDocument, position: Position): string => {
//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
//because in the symbolTable it is stored as a method call, for example this.accountRepo.getById()
else allMatches.push(match);
} catch (e) {}
}
for (let i = 0; i < allMatches.length; i++) {
try {
}
for (let i = 0; i < allMatches.length; i++) {
let myLength = allMatches[i].length;
if (allMatches[i].includes('.')) {
myLength -= allMatches[i - 1].length;
Expand All @@ -81,7 +79,7 @@ const findWord = (document: TextDocument, position: Position): string => {
} else {
currentPosition += myLength + 1;
}
} catch (e) {}
}
}
} catch (e) {}
return undefined;
};

0 comments on commit 17072a0

Please sign in to comment.