mirror of
https://github.com/MaskRay/ccls.git
synced 2025-02-18 06:31:15 +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(
|
Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
||||||
ProjectConfig* config,
|
ProjectConfig* config,
|
||||||
const CompileCommandsEntry& entry) {
|
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;
|
Project::Entry result;
|
||||||
result.filename = NormalizePathWithTestOptOut(entry.file);
|
result.filename = NormalizePathWithTestOptOut(entry.file);
|
||||||
|
|
||||||
@ -108,15 +117,6 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
|||||||
for (; i < entry.args.size(); ++i) {
|
for (; i < entry.args.size(); ++i) {
|
||||||
std::string arg = entry.args[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.
|
// Do not include path.
|
||||||
if (result.filename == cleanup_maybe_relative_path(arg))
|
if (result.filename == cleanup_maybe_relative_path(arg))
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user