10void SimilarFunctionFinder::find_path_that_meets_pattern() {
13 for (
const auto& _path : paths) {
14 auto function = loader.
load(_path);
16 if (function.contains_given_pattern(function_pattern))
21void SimilarFunctionFinder::print_empty_path_message()
const {
27Function SimilarFunctionFinder::get_reference_function(
const Path& path)
const {
29 return loader.
load(path);
32void SimilarFunctionFinder::print_reference_path() {
34 auto function = get_reference_function(path);
38void SimilarFunctionFinder::print_similar_functions(
const std::vector<Path>& similar_paths) {
43 for (
const auto& similar_path : similar_paths) {
44 auto function = get_reference_function(similar_path);
52void SimilarFunctionFinder::print_similar_functions() {
56 print_reference_path();
60 fs::path full_path = params.path / fs::path{path.
relative_path()};
61 fs::path dir_path = full_path.parent_path();
65 print_similar_functions(similar_paths);
68void SimilarFunctionFinder::handle_show_mode() {
69 Function ref = get_reference_function(path);
76 similarity_table = _similarity_table;
77 function_pattern =
"";
81 open_folder =
options.has(
"open");
82 show_mode =
options.has(
"show");
83 no_numbers =
options.has(
"no-numbers");
86 throw CLIError(
"Similar Function Finder Command expect one parameter, but none was given");
92 function_pattern =
options.extra_args[0];
94 find_path_that_meets_pattern();
97 print_empty_path_message();
106 print_similar_functions();
Base class for CLI-related errors.
const CliOption * options() const final
Function load(const Path &path)
Loads a function from a path.
static void print_basic_info(const Function &function)
Prints formatted function information to console.
static void print_code(const Function &function, bool no_numbers=false)
Prints the function source code.
Represents a function extracted from a codebase.
Represents a logical path to a function in the codebase.
fs::path relative_path() const
Gets the directory portion of the path.
bool empty() const
Checks if path is empty.
static PreprocessRunParams 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.
Provides functionality to load Function objects from external sources.
Provides utilities for printing function information and source code.
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.