mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 01:21:57 +00:00
Move cleanup_maybe_relative_path to top of func in project.cc
This commit is contained in:
parent
fa240e3132
commit
b727e36afc
@ -86,6 +86,15 @@ bool IsCFile(const std::string& path) {
|
||||
Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
||||
ProjectConfig* config,
|
||||
const CompileCommandsEntry& entry) {
|
||||
auto cleanup_maybe_relative_path = [&](const std::string& path) {
|
||||
// TODO/FIXME: Normalization will fail for paths that do not exist. Should
|
||||
// it return an optional<std::string>?
|
||||
assert(!path.empty());
|
||||
if (path[0] == '/' || entry.directory.empty())
|
||||
return NormalizePathWithTestOptOut(path);
|
||||
return NormalizePathWithTestOptOut(entry.directory + "/" + path);
|
||||
};
|
||||
|
||||
Project::Entry result;
|
||||
result.filename = NormalizePathWithTestOptOut(entry.file);
|
||||
|
||||
@ -108,15 +117,6 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
||||
for (; i < entry.args.size(); ++i) {
|
||||
std::string arg = entry.args[i];
|
||||
|
||||
auto cleanup_maybe_relative_path = [&](const std::string& path) {
|
||||
// TODO/FIXME: Normalization will fail for paths that do not exist. Should
|
||||
// it return an optional<std::string>?
|
||||
assert(!path.empty());
|
||||
if (path[0] == '/' || entry.directory.empty())
|
||||
return NormalizePathWithTestOptOut(path);
|
||||
return NormalizePathWithTestOptOut(entry.directory + "/" + path);
|
||||
};
|
||||
|
||||
// Do not include path.
|
||||
if (result.filename == cleanup_maybe_relative_path(arg))
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user