rokucommunity / brighterscript

A superset of Roku's BrightScript language
MIT License
152 stars 47 forks source link

Diagnostics show up and disappear in LSP mode depending on which file was edited last #1209

Closed TwitchBronBron closed 1 month ago

TwitchBronBron commented 1 month ago

Found an issue with diagnostics going missing when editing a file.

it.only('lsp bug', () => {
    program.options.autoImportComponentScript = true;
    program.setFile('components/playerInterfaces.bs', `
        interface MediaObject
            optional url as string
        end interface
    `);
    program.setFile('components/player.xml', `
        <component name="Player" extends="Group">
        </component>
    `);
    program.setFile('components/player.bs', `
        import "playerInterfaces.bs"
        import "playerUtils.bs"
        sub test()
            media = {} as MediaObject
            print media.missingBool1
        end sub
    `);
    program.setFile('components/playerUtils.bs', `
        import "playerInterfaces.bs"
        function test1(media as MediaObject) as boolean
            print media.missingBool2
        end function
    `);
    program.validate();
    //we have both diagnostics
    expectDiagnostics(program, [
        DiagnosticMessages.cannotFindName('missingBool1', undefined, 'MediaObject').message,
        DiagnosticMessages.cannotFindName('missingBool2', undefined, 'MediaObject').message
    ]);

    //add the last file again thus "opening" it.
    program.setFile('components/playerUtils.bs', `
        import "playerInterfaces.bs"
        function test2(media as MediaObject) as boolean
            print media.missingBool2
        end function
    `);
    program.validate();
    //we STILL have both diagnostics
    expectDiagnostics(program, [
        DiagnosticMessages.cannotFindName('missingBool1', undefined, 'MediaObject').message,
        DiagnosticMessages.cannotFindName('missingBool2', undefined, 'MediaObject').message
    ]);
});