|
|
|
@ -1012,18 +1012,7 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
get_declaration_location=[this](){ |
|
|
|
auto get_header_location=[this]() { |
|
|
|
if(!parsed) { |
|
|
|
|
|
|
|
Info::get().print("Buffer is parsing"); |
|
|
|
|
|
|
|
return Offset(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
auto identifier=get_identifier(); |
|
|
|
|
|
|
|
if(identifier) { |
|
|
|
|
|
|
|
auto source_location=identifier.cursor.get_canonical().get_source_location(); |
|
|
|
|
|
|
|
auto offset=source_location.get_offset(); |
|
|
|
|
|
|
|
return Offset(offset.line-1, offset.index-1, source_location.get_path()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
// If cursor is at an include line, return offset to included file
|
|
|
|
// If cursor is at an include line, return offset to included file
|
|
|
|
const static std::regex include_regex("^[ \t]*#[ \t]*include[ \t]*[<\"](.+)[>\"][ \t]*$"); |
|
|
|
const static std::regex include_regex("^[ \t]*#[ \t]*include[ \t]*[<\"](.+)[>\"][ \t]*$"); |
|
|
|
std::smatch sm; |
|
|
|
std::smatch sm; |
|
|
|
@ -1073,12 +1062,30 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file |
|
|
|
if(!client_data.found_include.empty()) |
|
|
|
if(!client_data.found_include.empty()) |
|
|
|
return Offset(0, 0, client_data.found_include); |
|
|
|
return Offset(0, 0, client_data.found_include); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return Offset(); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get_declaration_location=[this, get_header_location](){ |
|
|
|
|
|
|
|
if(!parsed) { |
|
|
|
|
|
|
|
Info::get().print("Buffer is parsing"); |
|
|
|
|
|
|
|
return Offset(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
auto identifier=get_identifier(); |
|
|
|
|
|
|
|
if(identifier) { |
|
|
|
|
|
|
|
auto source_location=identifier.cursor.get_canonical().get_source_location(); |
|
|
|
|
|
|
|
auto offset=source_location.get_offset(); |
|
|
|
|
|
|
|
return Offset(offset.line-1, offset.index-1, source_location.get_path()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
auto location=get_header_location(); |
|
|
|
|
|
|
|
if(location) |
|
|
|
|
|
|
|
return location; |
|
|
|
} |
|
|
|
} |
|
|
|
Info::get().print("No declaration found"); |
|
|
|
Info::get().print("No declaration found"); |
|
|
|
return Offset(); |
|
|
|
return Offset(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
is_implementation=[this]() { |
|
|
|
is_implementation_location=[this]() { |
|
|
|
if(!parsed) |
|
|
|
if(!parsed) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
auto iter=get_buffer()->get_insert()->get_iter(); |
|
|
|
auto iter=get_buffer()->get_insert()->get_iter(); |
|
|
|
@ -1093,7 +1100,7 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
get_implementation_locations=[this](const std::vector<Source::View*> &views){ |
|
|
|
get_implementation_locations=[this, get_header_location](const std::vector<Source::View*> &views){ |
|
|
|
std::vector<Offset> locations; |
|
|
|
std::vector<Offset> locations; |
|
|
|
if(!parsed) { |
|
|
|
if(!parsed) { |
|
|
|
Info::get().print("Buffer is parsing"); |
|
|
|
Info::get().print("Buffer is parsing"); |
|
|
|
@ -1163,6 +1170,13 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file |
|
|
|
return locations; |
|
|
|
return locations; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
auto location=get_header_location(); |
|
|
|
|
|
|
|
if(location) { |
|
|
|
|
|
|
|
locations.emplace_back(location); |
|
|
|
|
|
|
|
return locations; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
Info::get().print("No implementation found"); |
|
|
|
Info::get().print("No implementation found"); |
|
|
|
return locations; |
|
|
|
return locations; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|