Skip to content

Conversation

@san-rizz-777
Copy link

Changes Made

1. C++ Parser (languages/cpp.py)

  • Added Tree-sitter query for template_declaration nodes
  • Implemented _find_templates(): Extracts template definitions (name, location, source code)
  • Implemented _extract_template_name(): Extracts names from function/class/struct templates
  • Updated parse(): Returns templates under "templates" key
  • Added Tree-sitter query for template instantiations (if applicable)
  • Implemented _find_template_instantiations(): Captures template usage with arguments and locations

2. Graph Builder (tools/graph_builder.py)

Schema & Core Integration

  • Added :Template uniqueness constraint in create_schema()
  • Updated item_mappings: Added (file_data.get('templates', []), 'Template')
  • Templates now automatically graphed when files are processed

Template Instantiation Tracking

  • Implemented _create_template_instantiations(): Creates USES_TEMPLATE relationships between code elements and templates

    • Resolves template locations (local vs. imported)
    • Links instantiations to containing functions/classes
    • Falls back to File→Template relationship if no context found
    • Stores line numbers and template arguments
  • Implemented _find_containing_context(): Determines which Function or Class contains a template instantiation by line number

  • Implemented _create_all_template_instantiations(): Batch processes all template instantiations after file parsing

Features

Template definition detection
Template instantiation tracking
USES_TEMPLATE relationships with context
Template argument capture
Import resolution for external templates

Testing

Test with C++ code containing:

  • Template definitions: template<typename T> class Vector {};
  • Template instantiations: Vector<int> v;
  • Template function calls: max<double>(1.0, 2.0);

#359

@vercel
Copy link

vercel bot commented Oct 10, 2025

@san-rizz-777 is attempting to deploy a commit to the shashankss1205's projects Team on Vercel.

A member of the Team first needs to authorize it.

@san-rizz-777
Copy link
Author

@Shashankss1205 Please review pr!😁😁

@Shashankss1205
Copy link
Owner

@san-rizz-777 There's a bug because of which the end2end tests are failing, Please check that and make corrections on the PR.

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