@@ -41,15 +41,15 @@ export const handleHover = (
4141} ;
4242
4343const 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