• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rokucommunity / brighterscript / #15701

29 Apr 2026 03:03PM UTC coverage: 88.947% (-0.2%) from 89.135%
#15701

push

web-flow
added source fix all code action support (#1659)

Co-authored-by: Bronley Plumb <bronley@gmail.com>

8399 of 9942 branches covered (84.48%)

Branch coverage included in aggregate %.

32 of 63 new or added lines in 9 files covered. (50.79%)

1 existing line in 1 file now uncovered.

10673 of 11500 relevant lines covered (92.81%)

2034.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

12.9
/src/bscPlugin/codeActions/FixAllCodeActionsProcessor.ts
1
import type { BsDiagnostic } from '../../interfaces';
2
import { DiagnosticCodeMap } from '../../DiagnosticMessages';
1✔
3
import type { DiagnosticMessageType } from '../../DiagnosticMessages';
4
import type { XmlFile } from '../../files/XmlFile';
5
import type { OnGetSourceFixAllCodeActionsEvent } from '../../interfaces';
6
import { isXmlFile } from '../../astUtils/reflection';
1✔
7
import { getMissingExtendsInsertPosition, getRemoveReturnValueChange } from './codeActionHelpers';
1✔
8

9
export class FixAllCodeActionsProcessor {
1✔
10
    public constructor(
NEW
11
        public event: OnGetSourceFixAllCodeActionsEvent
×
12
    ) { }
13

14
    public process() {
NEW
15
        const byCode = new Map<number | string, BsDiagnostic[]>();
×
NEW
16
        for (const diagnostic of this.event.diagnostics) {
×
NEW
17
            const key = diagnostic.code;
×
NEW
18
            if (!byCode.has(key)) {
×
NEW
19
                byCode.set(key, []);
×
20
            }
NEW
21
            byCode.get(key).push(diagnostic);
×
22
        }
23

NEW
24
        const missingExtends = byCode.get(DiagnosticCodeMap.xmlComponentMissingExtendsAttribute);
×
NEW
25
        if (missingExtends) {
×
NEW
26
            this.processMissingExtends(missingExtends as DiagnosticMessageType<'xmlComponentMissingExtendsAttribute'>[]);
×
27
        }
28

NEW
29
        const voidFunctionReturns = byCode.get(DiagnosticCodeMap.voidFunctionMayNotReturnValue);
×
NEW
30
        if (voidFunctionReturns) {
×
NEW
31
            this.processVoidFunctionReturnActions(voidFunctionReturns);
×
32
        }
33
    }
34

35
    /**
36
     * For every `voidFunctionMayNotReturnValue` diagnostic in this file,
37
     * remove the return value expression, leaving the bare `return` keyword.
38
     */
39
    private processVoidFunctionReturnActions(diagnostics: BsDiagnostic[]) {
NEW
40
        const changes = diagnostics.map(diagnostic => getRemoveReturnValueChange(diagnostic, this.event.file.srcPath));
×
NEW
41
        this.event.actions.push({
×
42
            title: 'Remove all void return values',
43
            kind: 'source.fixAll.brighterscript',
44
            isPreferred: true,
45
            changes: changes
46
        });
47
    }
48

49
    /**
50
     * For every `xmlComponentMissingExtendsAttribute` diagnostic in this file,
51
     * insert `extends="Group"` — the same choice marked `isPreferred` in the
52
     * per-diagnostic quick-fix.
53
     */
54
    private processMissingExtends(diagnostics: DiagnosticMessageType<'xmlComponentMissingExtendsAttribute'>[]) {
NEW
55
        if (!isXmlFile(this.event.file)) {
×
NEW
56
            return;
×
57
        }
58

NEW
59
        const changes = diagnostics.map(() => ({
×
60
            type: 'insert' as const,
61
            filePath: this.event.file.srcPath,
62
            position: getMissingExtendsInsertPosition(this.event.file as XmlFile),
63
            newText: ' extends="Group"'
64
        }));
65

NEW
66
        this.event.actions.push({
×
67
            title: 'Add missing extends attributes',
68
            kind: 'source.fixAll.brighterscript',
69
            isPreferred: true,
70
            changes: changes
71
        });
72
    }
73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc