Skip to content

Commit 256048b

Browse files
committed
fix: parse diagnostic path
1 parent 7bd5874 commit 256048b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/extension.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,10 @@ async function refreshDiagnostics(result: ResultType) {
353353
globalDiagnostics
354354
)
355355

356-
for (const path in result.files) {
356+
// https://github.com/phpstan/phpstan-src/blob/6d228a53/src/Analyser/MutatingScope.php#L289
357+
const contextRegex = / \(in context of .+\)$/
358+
359+
for (let path in result.files) {
357360
const pathItem = result.files[path]
358361
const diagnostics: vscode.Diagnostic[] = []
359362
for (const messageItem of pathItem.messages) {
@@ -367,6 +370,11 @@ async function refreshDiagnostics(result: ResultType) {
367370

368371
diagnostics.push(diagnostic)
369372
}
373+
374+
const matches = contextRegex.exec(path)
375+
376+
if (matches) path = path.slice(0, matches.index)
377+
370378
$.diagnosticCollection.set(vscode.Uri.file(path), diagnostics)
371379
}
372380
}

0 commit comments

Comments
 (0)