Arkanjo 0.2
A tool for find code duplicated functions in codebases
Loading...
Searching...
No Matches
function_breaker_java.hpp
Go to the documentation of this file.
1
11#pragma once
12
15#include <array>
16#include <set>
17#include <string>
18#include <utility>
19#include <vector>
20#include <filesystem>
21namespace fs = std::filesystem;
22
31 const int NUMBER_OF_LINES_BEFORE_FOR_FUNCTION_NAME = 7;
32 const int JAVA_RELEVANT_DEPTH = 1;
33 const bool IGNORE_EMPTY_FUNCTIONS = true;
34 const bool ALLOW_STRUCTS = false;
35
41 set<array<int, 3>> find_start_end_and_depth_of_brackets(const vector<string>& brackets_content);
42
49 set<pair<int, int>> find_start_end_of_brackets_of_given_depth(vector<string> brackets_content, int depth);
50
56 // TODO: Refactor, refactor this
57 int find_position_first_open_bracket(const string& s);
58
64 string extract_last_token_of_string(const string& s);
65
72 Line_content build_line_code(int line_number, const string& content);
73
81 vector<Line_content> get_lines_before_body_function(const vector<string>& file_content, int line_start_body_function, int pos_bracket);
82
88 vector<Line_content> remove_parenteses_at_the_end_of_the_scope(vector<Line_content> code);
89
95 vector<Line_content> remove_content_until_find_parenteses_at_the_end(vector<Line_content> code);
96
102 vector<Line_content> remove_parameters_of_declaration_c(vector<Line_content> code);
103
109 vector<Line_content> remove_parameters_of_declaration_java(vector<Line_content> code);
110
117 vector<Line_content> remove_parameters_of_declaration(vector<Line_content> code, PROGRAMMING_LANGUAGE programming_language);
118
126 pair<string, int> extract_function_name_and_line_from_declaration(const vector<string>& file_content, int line_start_body_function, PROGRAMMING_LANGUAGE programming_language);
127
135 vector<string> build_function_content(int start_number_line, int end_number_line, const vector<string>& file_content);
136
146 vector<string> build_header_content(int start_number_line, int line_declaration, const fs::path& relative_path, const string& function_name, const vector<string>& file_content);
147
155 bool is_body_function_empty(int start_number_line, int end_number_line, const vector<string>& file_content);
156
165 void process_function(int start_number_line, int end_number_line, const fs::path& relative_path, const vector<string>& file_content, PROGRAMMING_LANGUAGE programming_language);
166
173 fs::path file_path_from_folder_path(const fs::path& file_path, const fs::path& folder_path);
174
180 void file_breaker_java(const fs::path& file_path, const fs::path& folder_path);
181
182 public:
188 FunctionBreakerJava(const fs::path& file_path, const fs::path& folder_path);
189};
Java function parser and extractor.
FunctionBreakerJava(const fs::path &file_path, const fs::path &folder_path)
Constructs Java function breaker and processes file.
Function breaker utilities and constants.
PROGRAMMING_LANGUAGE
Enumeration of supported programming languages.
Structure representing a line of source code.
Defines utility functions used across all files.