Add C++ Template Support with Instantiation Tracking #368
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes Made
1. C++ Parser (
languages/cpp.py)template_declarationnodes_find_templates(): Extracts template definitions (name, location, source code)_extract_template_name(): Extracts names from function/class/struct templatesparse(): Returns templates under"templates"key_find_template_instantiations(): Captures template usage with arguments and locations2. Graph Builder (
tools/graph_builder.py)Schema & Core Integration
:Templateuniqueness constraint increate_schema()item_mappings: Added(file_data.get('templates', []), 'Template')Template Instantiation Tracking
Implemented
_create_template_instantiations(): CreatesUSES_TEMPLATErelationships between code elements and templatesImplemented
_find_containing_context(): Determines which Function or Class contains a template instantiation by line numberImplemented
_create_all_template_instantiations(): Batch processes all template instantiations after file parsingFeatures
Template definition detection
Template instantiation tracking
USES_TEMPLATErelationships with contextTemplate argument capture
Import resolution for external templates
Testing
Test with C++ code containing:
template<typename T> class Vector {};Vector<int> v;max<double>(1.0, 2.0);#359