10void SimilarFunctionFinder::find_path_that_meets_pattern() {
12 for (
const auto& _path : paths) {
13 if (_path.contains_given_pattern(function_pattern)) {
19void SimilarFunctionFinder::print_empty_path_message()
const {
25Function SimilarFunctionFinder::get_reference_function(
const Path& path)
const {
31void SimilarFunctionFinder::print_reference_path() {
33 auto function = get_reference_function(path);
34 function.print_basic_info();
37void SimilarFunctionFinder::print_similar_functions(
const std::vector<Path>& similar_paths) {
42 for (
const auto& similar_path : similar_paths) {
43 auto function = get_reference_function(similar_path);
45 function.print_basic_info();
51void SimilarFunctionFinder::print_similar_functions() {
55 print_reference_path();
60 fs::path dir_path = full_path.parent_path();
64 print_similar_functions(similar_paths);
67void SimilarFunctionFinder::handle_show_mode() {
68 Function ref = get_reference_function(path);
75 similarity_table = _similarity_table;
76 function_pattern =
"";
80 open_folder =
options.args.count(
"open") > 0;
81 show_mode =
options.args.count(
"show") > 0;
82 no_numbers =
options.args.count(
"no-numbers") > 0;
84 if (
options.args.count(
"help") > 0) {
88 if (
options.extra_args.empty()) {
89 throw CLIError(
"Similar Function Finder Command expect one parameter, but none was given");
97 function_pattern =
options.extra_args[0];
99 find_path_that_meets_pattern();
102 print_empty_path_message();
111 print_similar_functions();
Base class for CLI-related errors.
const CliOption * options() const final
Represents a code function with its content and metadata.
void print_code(bool no_numbers=false)
void print_basic_info()
Prints formatted function information to console.
Path manipulation class for tool-specific directory structure.
std::string build_relative_path() const
Builds relative path portion.
bool is_empty() const
Checks if path is empty.
static std::vector< std::string > read_current_run_params()
read preprocessing parameters runs
SimilarFunctionFinder(Similarity_Table *_similarity_table)
Constructs finder and initiates search.
bool validate(const ParsedOptions &options) override
Validate the arguments already analyzed.
bool run(const ParsedOptions &options) override
Handles similar function finding command.
Represents a similarity graph between functions (paths).
const std::vector< Path > & get_path_list() const
Gets list of all known paths.
std::vector< Path > get_similar_path_to_the_reference(const Path &reference)
Gets paths similar to reference path.
void open_folder(const std::string &path)
const std::string LIMITER_PRINT
Constant string used as a visual delimiter/separator in prints.
Similar function locator interface.