Skip to content

Publish Diagnistics Improvement - #166

Open
oisanjaya wants to merge 15 commits into
genericptr:trunkfrom
oisanjaya:diag_overhaul
Open

oisanjaya wants to merge 15 commits into
genericptr:trunkfrom
oisanjaya:diag_overhaul

Conversation

@oisanjaya

Copy link
Copy Markdown
Contributor

To be effective, this PR should compiled using FPC main branch (as time of writing, i use 6460b5bae7) with Lazarus also on main branch. Compile using stable FPC and Lazarus give no notable differences to our current Publish Diagnostic handling state.

That is because fcl-passrc still being actively developed and "multi error" handling eventhough has been merged to main branch, it still not merged to any "stable" branch. I think even FPC's latest release_3_2_4_rc2 tag doesn't have theese commits merged. @mvancanneyt maybe able to confirm this.

Now let's go into what this PR do.

As I mentioned in #163 there are two paths that triggers textDocument/publishDiagnostic that is via CodeToolBoss, used by serverprotocol/PasLS.*.pas and via TSourceParser which is used by PasLS.Synchronization.pas.

The issue with current implementation is, TPublishDiagnostics are created on the fly before sending Publish Diagnostic notification. This would make previous errors, for example that has been sent by StrictSyntaxCheck() cleared when new error from Goto Definition command issued. Any new notification also clear errors from another open files.

I propose to use persistent TPublishDiagnostics which owned and managed by TDiagnosticHandler. This object instance have 3 field: fUserMessages, fCodeToolErrors, and fParserErrors. fCodeToolErrors, and fParserErrors are mapped to a URI, so every file can have their own TDiagnosticItems. Corresponding fields are cleared then re-populated each CheckSyntax() call

I also modify CodeToolsCheckSyntax() to gather all identifier in file then check if that identifier is defined. This will trigger CodeToolBoss' errors and add those errors into TDiagnosticItems mapped to current file. Unfortunately CodeToolBoss still report many Pascal keyword like public, private, protected as "identifier not found". I feel that's downside compile against "non-stable" branch of compiler. But I think it still valuable progress toward publishDiagnostic handling correctness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant