Skip to content

Conversation

ishaksebsib
Copy link
Contributor

@ishaksebsib ishaksebsib commented Sep 8, 2025

Description

Problem

Diagnostics displayed incorrect line content because the diagnostic renderer used combined source content instead of the specific file content where the error occurred.

Before (incorrect):

error[E204]: field `Label` is a reserved field name
   ┌─ /home/pro/test/helix/second/queries.hx:3:6
   │
 3 │      RETURN friends  ← Wrong content from query.hx file instead of the schema.hx 
   │     ^^^^^^^^^^^^^

Solution

  • Added filepath parameter to schema parsing methods (parse_field_def, parse_node_body, parse_properties)

  • Updated diagnostic rendering in helix-cli/src/utils.rs to find the correct file content by matching the diagnostic's filepath:

// Find the correct file content for this diagnostic
let file_content = content.files.iter()
    .find(|f| f.name == filepath)
    .map(|f| &f.content)
    .unwrap_or(&analyzed_source.src);

After (correct):

error[E204]: field `Label` is a reserved field name
   ┌─ /home/pro/test/helix/second/schema.hx:3:63Label: String,Correct content from schema file
   │     ^^^^^^^^^^^^^

summary

• Added filepath parameter to schema parsing methods (parse_field_def, parse_node_body, parse_properties)
• Updated location creation to use loc_with_filepath(filepath) instead of loc()
• Fixed diagnostic rendering to use individual file content matching the diagnostic's filepath
• Updated CLI integration to pass Content structure for proper file access

Related Issues

None

Checklist when merging to main

  • No compiler warnings (if applicable)
  • Code is formatted with rustfmt
  • No useless or dead code (if applicable)
  • Code is easy to understand
  • Doc comments are used for all functions, enums, structs, and fields (where appropriate)
  • All tests pass
  • Performance has not regressed (assuming change was not to fix a bug)
  • Version number has been updated in helix-cli/Cargo.toml and helixdb/Cargo.toml

Additional Notes

None

@ishaksebsib ishaksebsib changed the title fix: Correct diagnostic file content rendering and add filepath to schema parsing methods fix(hql): Correct diagnostic file content rendering and add filepath to schema parsing methods Sep 8, 2025
@xav-db xav-db merged commit 7a6279e into HelixDB:dev Sep 9, 2025
13 checks passed
@ishaksebsib ishaksebsib deleted the fix/schema-diagnostic-filepaths branch September 9, 2025 10:20
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