mirror of
https://github.com/safishamsi/graphify.git
synced 2026-07-13 10:57:13 +00:00
21bcb436b5
The C++ base_class_clause handler's `template_type` branch read the base
name (`sub.child_by_field_name("name")`) and emitted the `inherits` edge,
but never descended into the base's `template_argument_list`. As a result
`class Car : public Base<Dep>` emitted `Car -> Base` (inherits) yet dropped
the `Car -> Dep` generic_arg reference entirely.
The Java handler `_emit_java_parent_type` already emits these generic_arg
references for base-class type arguments; C++ was the asymmetric gap.
Fix: after emitting the `inherits` edge, grab the base's `arguments` field
(the `template_argument_list`) and run `_cpp_collect_type_refs` over each
named argument with the generic flag set, emitting a `references` edge
(context "generic_arg") per collected type, guarding target != class node.
`_cpp_collect_type_refs` already handles nested/qualified args, so
`Base<std::vector<Dep>>` is covered too.
Adds a templated base (`Connection<T>`) + derived class
(`PooledClient : public Connection<HttpClient>`) to tests/fixtures/sample.cpp
and a test mirroring the Java generic-parents test.
56 lines
1.2 KiB
C++
56 lines
1.2 KiB
C++
#include <iostream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
class HttpClient {
|
|
public:
|
|
HttpClient(const std::string& baseUrl) : baseUrl_(baseUrl) {}
|
|
|
|
std::string get(const std::string& path) {
|
|
return buildRequest("GET", path);
|
|
}
|
|
|
|
std::string post(const std::string& path, const std::string& body) {
|
|
return buildRequest("POST", path);
|
|
}
|
|
|
|
private:
|
|
std::string baseUrl_;
|
|
std::vector<std::string> tags_;
|
|
|
|
std::string buildRequest(const std::string& method, const std::string& path) {
|
|
return method + " " + baseUrl_ + path;
|
|
}
|
|
};
|
|
|
|
class AuthedHttpClient : public HttpClient {
|
|
public:
|
|
AuthedHttpClient(const std::string& baseUrl, const std::string& token)
|
|
: HttpClient(baseUrl), token_(token) {}
|
|
|
|
private:
|
|
std::string token_;
|
|
};
|
|
|
|
struct RetryingHttpClient : HttpClient {
|
|
int maxRetries;
|
|
};
|
|
|
|
template <typename T>
|
|
class Connection {
|
|
public:
|
|
T resource;
|
|
};
|
|
|
|
class PooledClient : public Connection<HttpClient> {
|
|
public:
|
|
int poolSize;
|
|
};
|
|
|
|
int main() {
|
|
HttpClient client("https://api.example.com");
|
|
std::string response = client.get("/users");
|
|
std::cout << response << std::endl;
|
|
return 0;
|
|
}
|