From 329af67c2cedfa559868baed1c3fdafe413248d5 Mon Sep 17 00:00:00 2001 From: Matt Langford Date: Thu, 23 Apr 2026 12:19:14 -0400 Subject: [PATCH] feat: .hh extension support in parser --- code_review_graph/parser.py | 1 + tests/fixtures/sample.hh | 22 ++++++++++++++++++++++ tests/test_multilang.py | 24 ++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 tests/fixtures/sample.hh diff --git a/code_review_graph/parser.py b/code_review_graph/parser.py index f681263a..219d1de4 100644 --- a/code_review_graph/parser.py +++ b/code_review_graph/parser.py @@ -88,6 +88,7 @@ class EdgeInfo: ".c": "c", ".h": "c", ".hpp": "cpp", + ".hh": "cpp", ".kt": "kotlin", ".swift": "swift", ".php": "php", diff --git a/tests/fixtures/sample.hh b/tests/fixtures/sample.hh new file mode 100644 index 00000000..62170fc9 --- /dev/null +++ b/tests/fixtures/sample.hh @@ -0,0 +1,22 @@ +#pragma once +#include + +class Shape { +public: + std::string color; + + Shape(std::string c) : color(c) {} + virtual double area() const = 0; +}; + +class Circle : public Shape { +public: + double radius; + + Circle(std::string c, double r) : Shape(c), radius(r) {} + double area() const override { return 3.14159 * radius * radius; } +}; + +inline double perimeter(const Circle& circle) { + return 2.0 * 3.14159 * circle.radius; +} diff --git a/tests/test_multilang.py b/tests/test_multilang.py index 9d45f434..d08628e4 100644 --- a/tests/test_multilang.py +++ b/tests/test_multilang.py @@ -316,6 +316,30 @@ def test_finds_inheritance(self): assert len(inherits) >= 1 +class TestHhParsing: + def setup_method(self): + self.parser = CodeParser() + self.nodes, self.edges = self.parser.parse_file(FIXTURES / "sample.hh") + + def test_detects_language(self): + assert self.parser.detect_language(Path("types.hh")) == "cpp" + + def test_finds_classes(self): + classes = [n for n in self.nodes if n.kind == "Class"] + names = {c.name for c in classes} + assert "Shape" in names + assert "Circle" in names + + def test_finds_functions(self): + funcs = [n for n in self.nodes if n.kind == "Function"] + names = {f.name for f in funcs} + assert "perimeter" in names + + def test_finds_inheritance(self): + inherits = [e for e in self.edges if e.kind == "INHERITS"] + assert len(inherits) >= 1 + + def _has_csharp_parser(): try: import tree_sitter_language_pack as tslp