ArKanjo 0.2
A tool for find code duplicated functions in codebases
Loading...
Searching...
No Matches
feature_extractor.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5#include <unordered_set>
6
7#include <tree_sitter/api.h>
8
9struct Features {
10 std::vector<std::string> ast;
11};
12
14 static constexpr std::string_view FUNCTION_NODES[] = {
15 "function_definition",
16 "function_item",
17 "closure_expression",
18 "method_definition",
19 "method_declaration"
20 };
21
22 static constexpr std::string_view BLOCK_NODES[] = {
23 "block",
24 "block_expression",
25 "compound_statement"
26 };
27
28 static constexpr std::string_view NODES[] = {
29 "identifier",
30 "field_identifier",
31 "type_identifier",
32 "number_literal",
33 "string_literal"
34 };
35
36public:
37 static bool is_lexical_node(std::string_view type);
38 static bool is_block_node(std::string_view type);
39 static bool is_function_node(std::string_view type);
40
41 static std::string get_node_text(TSNode node, const std::string& source);
42};
static std::string get_node_text(TSNode node, const std::string &source)
static bool is_lexical_node(std::string_view type)
static bool is_block_node(std::string_view type)
static bool is_function_node(std::string_view type)
std::vector< std::string > ast