Skip to content

feat: #line-based navigation between source and generated files #27

@theodevelop

Description

@theodevelop

What problem does this solve?

When working with Bison/Flex grammars, the generated C files (.tab.c, lex.yy.c) are the actual files processed by clangd for go-to-definition, find references, etc. Navigating between the source .y/.l and the generated C requires manually searching for the matching #line directive — there is no direct jump.

Proposed solution

Add two editor context menu commands:
Show in Source (generated → .y/.l): available inside generated files only (detected by their header). Reads the nearest #line N "file.y" above the cursor and jumps to that file at the correct line. No configuration required.
Show in Generated File (.y/.l → generated): available inside .y/.l files. Locates the generated file via CMake detection (already in place), then Makefile, then fallback to $filename.tab.c / lex.yy.c, then workspace-wide search. Navigates to the matching line using #line directives. Shows a clear error if the file hasn't been generated yet.

Notes

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions