Skip to content

Fix navigation bar wrong entries for local functions (#1932)#1936

Closed
Copilot wants to merge 1 commit into
mainfrom
copilot/investigate-issue-1932
Closed

Fix navigation bar wrong entries for local functions (#1932)#1936
Copilot wants to merge 1 commit into
mainfrom
copilot/investigate-issue-1932

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

Root cause

The commit that added LOCAL CLASS support (8cb728b7a1) introduced a CASE XSharpLexer.LOCAL branch in ParseVisibilityAndModifiers that consumes the LOCAL keyword when followed by any keyword not in IsValidLocalSuffix. Since FUNCTION and PROCEDURE were not in IsValidLocalSuffix, ParseVisibilityAndModifiers consumed LOCAL for local function and local procedure declarations.

This caused IsStartOfEntity to see FUNCTION/PROCEDURE (instead of LOCAL FUNCTION/LOCAL PROCEDURE) and classify local functions as global Kind.Function instead of Kind.LocalFunc. Consequently:

  1. The entity was added to _globalType.XMembers instead of being parented to the containing method
  2. The range-update logic in the new entity loop treated the last local function as non-local, incorrectly overwriting its Range.EndLine with the line of return nil (the tokenBefore of the next method)
  3. FindMemberAtRow returned the misclassified local function instead of the containing method when cursor was at return nil
  4. The navigation bar showed wrong type/member entries

Fix

Added FUNCTION and PROCEDURE to IsValidLocalSuffix so that ParseVisibilityAndModifiers does not consume LOCAL when followed by these keywords. IsStartOfEntity then correctly sees LOCAL FUNCTION/LOCAL PROCEDURE and creates Kind.LocalFunc/Kind.LocalProc entities, which ParseLocalFuncProc handles properly.

The LOCAL CLASS feature is unaffected since CLASS is not added to IsValidLocalSuffix.

Fixes #1932, related to #1935.

…CAL keyword being consumed in ParseVisibilityAndModifiers

Agent-Logs-Url: https://github.com/X-Sharp/XSharpPublic/sessions/f69f4cba-fc28-43fd-a578-b44a64177ee8

Co-authored-by: RobertvanderHulst <14240939+RobertvanderHulst@users.noreply.github.com>
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.

[X# 3] Wrong entries in navigation bar

2 participants