@@ -155,7 +155,12 @@ export default class Parser {
155155 if ( withBlocks ) {
156156 tokens = createBlocks ( tokens ) ;
157157 }
158-
158+
159+ // Remove newlines
160+ if ( tokens . some ( t => t . type === `newline` ) ) {
161+ tokens = tokens . filter ( t => t . type !== `newline` ) ;
162+ }
163+
159164 return tokens ;
160165 }
161166
@@ -388,7 +393,6 @@ export default class Parser {
388393 //Now the real work
389394 const parseContent = async ( fileUri : string , allContent : string ) => {
390395 const EOL = allContent . includes ( `\r\n` ) ? `\r\n` : `\n` ;
391- const LINEEND = `` . padEnd ( EOL . length ) ;
392396 let lines = allContent . split ( EOL ) ;
393397
394398 let postProcessingStatements : { [ procedure : string ] : Token [ ] [ ] } = { 'GLOBAL' : [ ] } ;
@@ -664,7 +668,7 @@ export default class Parser {
664668 if ( [ spec , comment ] . includes ( `*` ) ) {
665669 if ( currentStmtStart && currentStmtStart . content ) {
666670 // Since we're in an extended statement (usually fixed exec), we still need to collect the lengths for the tokeniser
667- currentStmtStart . content += `` . padEnd ( baseLine . length ) + LINEEND ;
671+ currentStmtStart . content += `` . padEnd ( baseLine . length ) + EOL ;
668672 }
669673
670674 continue ;
@@ -677,7 +681,7 @@ export default class Parser {
677681 } else if ( comment === `+` && fixedExec && currentStmtStart . content ) {
678682 // Fixed format EXEC SQL
679683 baseLine = `` . padEnd ( 7 ) + baseLine . substring ( 7 ) ;
680- currentStmtStart . content += baseLine + LINEEND ;
684+ currentStmtStart . content += baseLine + EOL ;
681685 continue ;
682686 } else {
683687 if ( spec === ` ` ) {
@@ -714,7 +718,7 @@ export default class Parser {
714718 // if part of a continued statement to ensure positions are correct.
715719 // See issue_358_no_reference_2
716720 if ( currentStmtStart && currentStmtStart . content ) {
717- currentStmtStart . content += `` . padEnd ( baseLine . length ) + LINEEND ;
721+ currentStmtStart . content += `` . padEnd ( baseLine . length ) + EOL ;
718722 }
719723 continue ;
720724 } ;
@@ -736,7 +740,7 @@ export default class Parser {
736740 currentStmtStart = {
737741 line : lineNumber ,
738742 index : lineIndex ,
739- content : baseLine + LINEEND
743+ content : baseLine + EOL
740744 }
741745 continue ;
742746 case '/END' :
@@ -747,15 +751,15 @@ export default class Parser {
747751 case '/' :
748752 // Comments in SQL, usually free-format
749753 if ( parts [ 1 ] === `*` && currentStmtStart ) {
750- currentStmtStart . content += `` . padEnd ( baseLine . length ) + LINEEND ;
754+ currentStmtStart . content += `` . padEnd ( baseLine . length ) + EOL ;
751755 continue ;
752756 }
753757 break ;
754758 default :
755759 // Maybe we're in a fixed exec statement, but a directive is being used.
756760 // See test case references_21_fixed_exec1
757761 if ( fixedExec && currentStmtStart && currentStmtStart . content ) {
758- currentStmtStart . content += `` . padEnd ( baseLine . length ) + LINEEND ;
762+ currentStmtStart . content += `` . padEnd ( baseLine . length ) + EOL ;
759763 continue ;
760764 }
761765 break ;
@@ -853,7 +857,7 @@ export default class Parser {
853857 // This happens when we put a comment on a line which is part of one long statement.
854858 // See references_24_comment_in_statement
855859 if ( currentStmtStart . content ) {
856- currentStmtStart . content += `` . padEnd ( baseLine . length ) + LINEEND ;
860+ currentStmtStart . content += `` . padEnd ( baseLine . length ) + EOL ;
857861 }
858862 } else {
859863 if ( stripComment ( line ) . endsWith ( `;` ) ) {
@@ -875,7 +879,7 @@ export default class Parser {
875879 if ( currentStmtStart . content . endsWith ( `-` ) )
876880 currentStmtStart . content = currentStmtStart . content . substring ( 0 , currentStmtStart . content . length - 1 ) + ` ` ;
877881
878- currentStmtStart . content += LINEEND ;
882+ currentStmtStart . content += EOL ;
879883
880884 continue ;
881885 }
@@ -1025,7 +1029,7 @@ export default class Parser {
10251029 lastItem . subItems . push ( currentItem ) ;
10261030 } else {
10271031 // Otherwise, we push as a new item
1028- currentItem . range . end = currentStmtStart . line ;
1032+ currentItem . range . end = tokens [ tokens . length - 1 ] . range . line ;
10291033 scope . addSymbol ( currentItem ) ;
10301034 }
10311035 } else {
0 commit comments