Skip to content
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

ref: handle definition request #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Vavarine
Copy link
Collaborator

PR Description: Improve Block Definition Navigation with JSONC Parser

Overview

This PR enhances the "Go to Definition" functionality for VTEX IO blocks by refactoring the handleDefinitionRequest function to use the JSONC parser. The implementation now properly identifies block references in JSON/JSONC files and provides accurate navigation to their definitions.

Key Improvements

  • Replaced manual string parsing with proper JSONC token scanning
  • Added helper functions for better code organization and readability
  • Improved error handling with early returns and better error logging
  • Fixed issues with string token detection and position calculation
  • Removed debug console logs that were cluttering the output

Technical Details

The implementation now:

  1. Properly identifies string tokens in JSON/JSONC files
  2. Distinguishes between property names and values
  3. Accurately calculates positions for highlighting
  4. Provides better error handling and logging

Testing

The changes have been tested with various JSON files containing block references, including:

  • Block references in property values
  • Block references in arrays
  • Nested block structures
  • Files with JSONC comments

All tests confirm that the "Go to Definition" functionality works correctly, taking users to the appropriate block definition when clicking on a block reference.

Related Issues

Fixes the issue where hovering over a block reference would not highlight the entire block ID.

Comment on lines +26 to +27
console.log('blockId', blockId);
console.log('range', range);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log('blockId', blockId);
console.log('range', range);

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.

2 participants