Fix dcl-ds with likeds/likerec bracket matching and folding#530
Open
richardm90 wants to merge 3 commits into
Open
Fix dcl-ds with likeds/likerec bracket matching and folding#530richardm90 wants to merge 3 commits into
richardm90 wants to merge 3 commits into
Conversation
dcl-ds declarations using likeds() or likerec() don't require end-ds, but were incorrectly treated as block openers causing mismatched bracket highlighting on subsequent end-proc statements.
Fixed bracketMatcher.ts to not treat dcl-ds with likeds/likerec as block openers. Added documentation tests.
Comments now stripped before checking if dcl-ds has likeds/likerec, preventing false positives. Added helper functions and test coverage.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Changes
Problem
The extension incorrectly treated
dcl-dsdeclarations withlikedsorlikerecas block openers requiringend-ds. This caused multiple issues:end-procwas highlighted in red as mismatched when preceded bydcl-ds likeds(...)dcl-ds likeds(...)would incorrectly match with the nextend-dsdcl-ds x; // likeds(fake)was treated as single-line when it should be a blockBefore the changes in this PR:
Comment out the data structure declaration:
Root Cause
In RPGLE,
dcl-dshas dual behavior:dcl-ds myStruct;...end-ds;(requires end-ds)dcl-ds myData likeds(SomeType);(no end-ds needed)Both folding range provider and bracket matcher were treating all
dcl-dsas block openers without checking forlikeds()/likerec().Solution
Updated stack-based block matching logic in both server and client to skip
dcl-dswhen it containslikeds()orlikerec()on the same line (excluding comments).Changes
Server-Side (Folding Ranges)
Client-Side (Bracket Highlighting)
stripComments()helper to remove//commentsisDclDsWithLikedsOrLikerec()helper for consistent checkingfindMatchingOpenForClosing(),findMatchingOpenForAnyClosing(),findBlockIndices(),findMatchingClose(),findMatchingOpen()textparameter and use helper to check for single-line declarationsTests
Technical Notes
dcl-dsonly - it's the only RPGLE declaration I could think of with this dual behaviourdcl-proc,if,dow, etc.) are unaffected/likeds\s*\(/handles optional white-space and is case-insensitiveChecklist
console.logs I added