@@ -41,15 +41,15 @@ export const handleHover = (
41
41
} ;
42
42
43
43
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 ) {
53
53
if ( match . includes ( '.' ) ) {
54
54
const separateMatches = match . split ( '.' ) ;
55
55
let i = 1 ;
@@ -65,10 +65,8 @@ const findWord = (document: TextDocument, position: Position): string => {
65
65
//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
66
66
//because in the symbolTable it is stored as a method call, for example this.accountRepo.getById()
67
67
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 ++ ) {
72
70
let myLength = allMatches [ i ] . length ;
73
71
if ( allMatches [ i ] . includes ( '.' ) ) {
74
72
myLength -= allMatches [ i - 1 ] . length ;
@@ -81,7 +79,7 @@ const findWord = (document: TextDocument, position: Position): string => {
81
79
} else {
82
80
currentPosition += myLength + 1 ;
83
81
}
84
- } catch ( e ) { }
85
- }
82
+ }
83
+ } catch ( e ) { }
86
84
return undefined ;
87
85
} ;
0 commit comments