@@ -9,7 +9,7 @@ import showOutput from "./showOutput";
99import stopAnalyse from "./stopAnalyse" ;
1010import { spawn } from "child_process" ;
1111import { Diagnostic , DiagnosticSeverity , Range , Uri } from "vscode" ;
12- import { getFileLine } from "../utils/fs" ;
12+ import { getFileLines } from "../utils/fs" ;
1313
1414function setStatusBarProgress ( ext : Ext , progress ?: number ) {
1515 let text = "$(sync~spin) PHPStan analysing..." ;
@@ -56,7 +56,7 @@ async function refreshDiagnostics(ext: Ext, result: PHPStanAnalyseResult) {
5656 }
5757 } ) ;
5858
59- ext . log ( 'Using paths mappings: ' + JSON . stringify ( pathMaps ) ) ;
59+ ext . log ( 'Using path mappings: ' + JSON . stringify ( pathMaps ) ) ;
6060
6161 for ( const path in result . files ) {
6262 let realPath = path ;
@@ -74,19 +74,17 @@ async function refreshDiagnostics(ext: Ext, result: PHPStanAnalyseResult) {
7474 }
7575 }
7676
77+ const fileLines : string [ ] = await getFileLines ( resolve ( realPath ) ) ;
78+
7779 const pathItem = result . files [ path ] ;
7880 const diagnostics : Diagnostic [ ] = [ ] ;
7981 for ( const messageItem of pathItem . messages ) {
8082 const line = messageItem . line ? messageItem . line - 1 : 0 ;
83+ const lineText = messageItem . line ? ( fileLines [ line ] ?? '' ) : '' ;
8184
82- const lineText = await getFileLine ( resolve ( realPath ) , messageItem . line ?? 0 ) ;
8385 const startCol = Math . max ( 0 , lineText . search ( / [ ^ \s ] / g) ) ;
8486 const endCol = Math . max ( 0 , lineText . search ( / \s * $ / g) ) ;
8587
86- ext . log ( JSON . stringify ( {
87- line, startCol, endCol
88- } ) ) ;
89-
9088 const range = new Range ( line , startCol , line , endCol ) ;
9189 const diagnostic = new Diagnostic (
9290 range ,
0 commit comments