forked from SSlinky/VBA-LanguageServer
-
Notifications
You must be signed in to change notification settings - Fork 0
Fix document symbol handling #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
62a5c42
fix: Better handle no documents symbols error
DecimalTurn 92c4336
Fix startup parse + symbol readiness lifecycle
DecimalTurn d627296
Simplify document symbol request wiring
DecimalTurn f9fa9b7
fix: use normalized URI to retrieve the latest document instance
DecimalTurn b0d67f9
fix: improve missing symbols logging and severity determination
DecimalTurn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| import 'reflect-metadata'; | ||
|
|
||
| import { describe, it } from 'mocha'; | ||
| import * as assert from 'assert'; | ||
| import dedent from 'dedent'; | ||
| import { SymbolKind } from 'vscode-languageserver'; | ||
|
|
||
| import { getMissingSymbolsLogSeverity, shouldHaveSymbols } from '../utils/helpers'; | ||
|
|
||
| describe('Helpers symbol classification', () => { | ||
| it('does not flag legitimate no-symbol module content', () => { | ||
| const moduleText = dedent` | ||
| Option Explicit | ||
| Attribute VB_Name = "Module1" | ||
| ' comment | ||
| Rem comment | ||
| #If VBA7 Then | ||
| #Else | ||
| #End If | ||
| `; | ||
|
|
||
| const result = shouldHaveSymbols(moduleText); | ||
|
|
||
| assert.strictEqual(result, false, 'Expected legitimate directive-only content to skip missing-symbol error logging'); | ||
| }); | ||
|
|
||
| it('flags substantive code with empty symbol list', () => { | ||
| const moduleText = dedent` | ||
| Option Explicit | ||
| Public Sub Test() | ||
| End Sub | ||
| `; | ||
|
|
||
| const result = shouldHaveSymbols(moduleText); | ||
|
|
||
| assert.strictEqual(result, true, 'Expected substantive code to be flagged when symbols are missing'); | ||
| }); | ||
|
|
||
| it('does not flag a procedure wrapped in conditional compilation', () => { | ||
| const moduleText = dedent` | ||
| Option Explicit | ||
| #If Win64 Then | ||
| Public Sub ConditionalProc() | ||
| End Sub | ||
| #End If | ||
| `; | ||
|
|
||
| const result = shouldHaveSymbols(moduleText); | ||
|
|
||
| assert.strictEqual(result, false, 'Expected conditional-compilation-only procedures to be treated as legitimate zero-symbol content'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Helpers missing-symbol log severity', () => { | ||
| it('returns error when no symbols are produced at all', () => { | ||
| const moduleText = dedent` | ||
| Option Explicit | ||
| Public Sub Test() | ||
| End Sub | ||
| `; | ||
|
|
||
| const severity = getMissingSymbolsLogSeverity( | ||
| moduleText, | ||
| [] | ||
| ); | ||
|
|
||
| assert.strictEqual(severity, 'error'); | ||
| }); | ||
|
|
||
| it('returns warn when only module symbol exists but member symbols are expected', () => { | ||
| const moduleText = dedent` | ||
| Option Explicit | ||
| Public Sub Test() | ||
| End Sub | ||
| `; | ||
|
|
||
| const severity = getMissingSymbolsLogSeverity( | ||
| moduleText, | ||
| [{ kind: SymbolKind.File }] | ||
| ); | ||
|
|
||
| assert.strictEqual(severity, 'warn'); | ||
| }); | ||
|
|
||
| it('returns none when only module symbol exists and content is legitimately non-symbolic', () => { | ||
| const moduleText = dedent` | ||
| Attribute VB_Name = "Module1" | ||
| Option Explicit | ||
| `; | ||
|
|
||
| const severity = getMissingSymbolsLogSeverity( | ||
| moduleText, | ||
| [{ kind: SymbolKind.File }] | ||
| ); | ||
|
|
||
| assert.strictEqual(severity, 'none'); | ||
| }); | ||
|
|
||
| it('returns none when only module symbol exists and procedures are in inactive compiler branch', () => { | ||
| const moduleText = dedent` | ||
| Option Explicit | ||
| #If Win64 Then | ||
| #Else | ||
| Public Sub ConditionalProc() | ||
| End Sub | ||
| #End If | ||
| `; | ||
|
|
||
| const severity = getMissingSymbolsLogSeverity( | ||
| moduleText, | ||
| [{ kind: SymbolKind.File }] | ||
| ); | ||
|
|
||
| assert.strictEqual(severity, 'none'); | ||
| }); | ||
|
|
||
| it('returns none when member symbols are present', () => { | ||
| const moduleText = dedent` | ||
| Option Explicit | ||
| Public Sub Test() | ||
| End Sub | ||
| `; | ||
|
|
||
| const severity = getMissingSymbolsLogSeverity( | ||
| moduleText, | ||
| [{ kind: SymbolKind.File }, { kind: SymbolKind.Method }] | ||
| ); | ||
|
|
||
| assert.strictEqual(severity, 'none'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.