in source/Highlights.cpp [451:497]
Bounds Highlights::get_callee_highlight_bounds(
const DexMethod* callee,
const FileLines& lines,
int callee_line_number,
const AccessPath& callee_port) {
if (!lines.has_line_number(callee_line_number)) {
WARNING(
3,
"Trying to access line {} of a file with {} lines",
callee_line_number,
lines.size());
return {callee_line_number, 0, 0};
}
auto line = lines.line(callee_line_number);
auto callee_name = callee->get_name()->str();
if (method::is_init(callee)) {
auto class_name = get_class_name(callee);
if (!class_name) {
return {callee_line_number, 0, 0};
}
callee_name = "new " + *class_name;
}
auto callee_start = line.find(callee_name + "(");
if (callee_start == std::string::npos) {
return {callee_line_number, 0, 0};
}
std::size_t callee_end =
std::min(callee_start + callee_name.length() - 1, line.length() - 1);
Bounds callee_name_bounds = {
callee_line_number,
static_cast<int>(callee_start),
static_cast<int>(callee_end)};
if (!callee_port.root().is_argument() ||
(method::is_init(callee) &&
callee_port.root().parameter_position() == 0)) {
return callee_name_bounds;
}
bool is_static = ::is_static(callee);
if (callee_port.root().parameter_position() == 0 && !is_static) {
return get_callee_this_parameter_bounds(line, callee_name_bounds);
}
return get_argument_bounds(
callee_port.root().parameter_position(),
is_static ? 0 : 1,
lines,
callee_name_bounds);
}