Arkanjo 0.1
A tool for find code duplicated functions in codebases
Loading...
Searching...
No Matches
similar_function_finder.cpp
Go to the documentation of this file.
2
3void Similar_Function_Finder::find_path_that_meets_pattern(){
4 vector<Path> paths = similarity_table->get_path_list();
5 for(auto _path : paths){
6 if(_path.contains_given_pattern(function_pattern)){
7 path = _path;
8 }
9 }
10}
11
12void Similar_Function_Finder::print_empty_path_message(){
13 string line1 = EMPTY_PATH_MESSAGE_1 + function_pattern;
14 string line2 = EMPTY_PATH_MESSAGE_2;
15 cout << line1 << '\n';
16 cout << line2 << '\n';
17}
18
19void Similar_Function_Finder::print_function(Path path){
20 Function function(path);
21 function.print_basic_info();
22}
23
24void Similar_Function_Finder::print_reference_path(){
25 string line1 = REFERENCE_PATH_MESSAGE;
26 cout << line1 << '\n';
27 print_function(path);
28}
29
30void Similar_Function_Finder::print_similar_functions(vector<Path> similar_paths){
31 string line1 = COUNT_MESSAGE_1 + to_string(similar_paths.size()) + COUNT_MESSAGE_2;
32 cout << line1 << '\n';
33 for(auto similar_path : similar_paths){
34 print_function(similar_path);
35 }
36}
37
38void Similar_Function_Finder::print_similar_functions(){
39 if(path.is_empty()){
40 print_empty_path_message();
41 return;
42 }
43 vector<Path> similar_paths = similarity_table->get_similar_path_to_the_reference(path);
44
45 cout << Utils::LIMITER_PRINT << '\n';
46 print_reference_path();
47 print_similar_functions(similar_paths);
48}
49
50Similar_Function_Finder::Similar_Function_Finder(string _function_pattern, Similarity_Table *_similarity_table){
51 similarity_table = _similarity_table;
52 function_pattern = _function_pattern;
53
54 find_path_that_meets_pattern();
55 print_similar_functions();
56}
Represents a code function with its content and metadata.
Definition function.hpp:33
Path manipulation class for tool-specific directory structure.
Definition path.hpp:27
bool is_empty()
Checks if path is empty.
Definition path.cpp:33
Similar_Function_Finder(string _function_pattern, Similarity_Table *_similarity_table)
Constructs finder and initiates search.
Manages and analyzes function similarity relationships.
vector< Path > get_path_list()
Gets list of all known paths.
vector< Path > get_similar_path_to_the_reference(Path reference)
Gets paths similar to reference path.
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition json.hpp:25317
const string LIMITER_PRINT
Constant string used as a visual delimiter/separator in prints.
Definition utils.hpp:33
Similar function locator interface.