mirror of
https://github.com/MaskRay/ccls.git
synced 2025-06-14 12:12:20 +00:00
Merge be9be38551
into 4c499c93e2
This commit is contained in:
commit
9b2ced23bb
@ -40,7 +40,7 @@ namespace {
|
|||||||
std::string StripFileType(const std::string &path) {
|
std::string StripFileType(const std::string &path) {
|
||||||
SmallString<128> Ret;
|
SmallString<128> Ret;
|
||||||
sys::path::append(Ret, sys::path::parent_path(path), sys::path::stem(path));
|
sys::path::append(Ret, sys::path::parent_path(path), sys::path::stem(path));
|
||||||
return Ret.str();
|
return sys::path::convert_to_slash(Ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocationInRange(SourceLocation L, CharSourceRange R,
|
bool LocationInRange(SourceLocation L, CharSourceRange R,
|
||||||
|
@ -34,7 +34,7 @@ std::string FileName(const FileEntry &file) {
|
|||||||
if (!StartsWith(ret, g_config->projectRoot)) {
|
if (!StartsWith(ret, g_config->projectRoot)) {
|
||||||
SmallString<256> dest;
|
SmallString<256> dest;
|
||||||
sys::fs::real_path(ret, dest);
|
sys::fs::real_path(ret, dest);
|
||||||
ret = dest.str();
|
ret = sys::path::convert_to_slash(dest.str());
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ void GetFilesInFolder(std::string folder, bool recursive, bool dir_prefix,
|
|||||||
if (sys::fs::is_regular_file(Status)) {
|
if (sys::fs::is_regular_file(Status)) {
|
||||||
if (!dir_prefix)
|
if (!dir_prefix)
|
||||||
path = path.substr(folder.size());
|
path = path.substr(folder.size());
|
||||||
handler(path);
|
handler(sys::path::convert_to_slash(path));
|
||||||
} else if (recursive && sys::fs::is_directory(Status) &&
|
} else if (recursive && sys::fs::is_directory(Status) &&
|
||||||
!seen.count(ID = Status.getUniqueID())) {
|
!seen.count(ID = Status.getUniqueID())) {
|
||||||
curr.push_back(path);
|
curr.push_back(path);
|
||||||
|
@ -567,7 +567,7 @@ public:
|
|||||||
if (!llvm::sys::path::is_absolute(Path) &&
|
if (!llvm::sys::path::is_absolute(Path) &&
|
||||||
!SM.getFileManager().makeAbsolutePath(Path))
|
!SM.getFileManager().makeAbsolutePath(Path))
|
||||||
return -1;
|
return -1;
|
||||||
it->second.second = Path.str();
|
it->second.second = llvm::sys::path::convert_to_slash(Path.str());
|
||||||
}
|
}
|
||||||
return it->second.first;
|
return it->second.first;
|
||||||
}
|
}
|
||||||
|
15
src/lsp.cc
15
src/lsp.cc
@ -220,10 +220,15 @@ void lsDocumentUri::SetPath(const std::string &path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string lsDocumentUri::GetPath() const {
|
std::string lsDocumentUri::GetPath() const {
|
||||||
if (raw_uri.compare(0, 8, "file:///"))
|
if (raw_uri.compare(0, 7, "file://")) {
|
||||||
|
LOG_S(WARNING)
|
||||||
|
<< "Received potentially bad URI (not starting with file://): "
|
||||||
|
<< raw_uri;
|
||||||
return raw_uri;
|
return raw_uri;
|
||||||
|
}
|
||||||
std::string ret;
|
std::string ret;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
// Skipping the initial "/" on Windows
|
||||||
size_t i = 8;
|
size_t i = 8;
|
||||||
#else
|
#else
|
||||||
size_t i = 7;
|
size_t i = 7;
|
||||||
@ -236,8 +241,14 @@ std::string lsDocumentUri::GetPath() const {
|
|||||||
ret.push_back(from_hex(raw_uri[i + 1]) * 16 + from_hex(raw_uri[i + 2]));
|
ret.push_back(from_hex(raw_uri[i + 1]) * 16 + from_hex(raw_uri[i + 2]));
|
||||||
i += 2;
|
i += 2;
|
||||||
} else
|
} else
|
||||||
ret.push_back(raw_uri[i] == '\\' ? '/' : raw_uri[i]);
|
ret.push_back(raw_uri[i]);
|
||||||
}
|
}
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::replace(ret.begin(), ret.end(), '\\', '/');
|
||||||
|
if (ret.size() > 1 && ret[0] >= 'a' && ret[0] <= 'z' && ret[1] == ':') {
|
||||||
|
ret[0] = toupper(ret[0]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,14 +35,20 @@ std::string NormalizePath(const std::string &path) {
|
|||||||
TCHAR buffer[MAX_PATH] = TEXT("");
|
TCHAR buffer[MAX_PATH] = TEXT("");
|
||||||
TCHAR **lpp_part = {NULL};
|
TCHAR **lpp_part = {NULL};
|
||||||
|
|
||||||
|
std::string result;
|
||||||
retval = GetFullPathName(path.c_str(), MAX_PATH, buffer, lpp_part);
|
retval = GetFullPathName(path.c_str(), MAX_PATH, buffer, lpp_part);
|
||||||
// fail, return original
|
// fail, return original
|
||||||
if (retval == 0)
|
if (retval == 0)
|
||||||
return path;
|
result = path;
|
||||||
|
else
|
||||||
|
result = buffer;
|
||||||
|
|
||||||
std::string result = buffer;
|
|
||||||
std::replace(result.begin(), result.end(), '\\', '/');
|
std::replace(result.begin(), result.end(), '\\', '/');
|
||||||
// std::transform(result.begin(), result.end(), result.begin(), ::tolower);
|
// Normalize drive letter.
|
||||||
|
if (result.size() > 1 && result[0] >= 'a' && result[0] <= 'z' &&
|
||||||
|
result[1] == ':') {
|
||||||
|
result[0] = toupper(result[0]);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +172,8 @@ struct ProjectProcessor {
|
|||||||
|
|
||||||
HeaderSearchOptions &HeaderOpts = CI->getHeaderSearchOpts();
|
HeaderSearchOptions &HeaderOpts = CI->getHeaderSearchOpts();
|
||||||
for (auto &E : HeaderOpts.UserEntries) {
|
for (auto &E : HeaderOpts.UserEntries) {
|
||||||
std::string path = ResolveIfRelative(entry.directory, E.Path);
|
std::string path =
|
||||||
|
NormalizePath(ResolveIfRelative(entry.directory, E.Path));
|
||||||
switch (E.Group) {
|
switch (E.Group) {
|
||||||
default:
|
default:
|
||||||
config->angle_dirs.insert(path);
|
config->angle_dirs.insert(path);
|
||||||
@ -327,8 +328,9 @@ LoadEntriesFromDirectory(ProjectConfig *project,
|
|||||||
ProjectProcessor proc(project);
|
ProjectProcessor proc(project);
|
||||||
for (tooling::CompileCommand &Cmd : CDB->getAllCompileCommands()) {
|
for (tooling::CompileCommand &Cmd : CDB->getAllCompileCommands()) {
|
||||||
Project::Entry entry;
|
Project::Entry entry;
|
||||||
entry.directory = std::move(Cmd.Directory);
|
entry.directory = NormalizePath(Cmd.Directory);
|
||||||
entry.filename = ResolveIfRelative(entry.directory, Cmd.Filename);
|
entry.filename =
|
||||||
|
NormalizePath(ResolveIfRelative(entry.directory, Cmd.Filename));
|
||||||
entry.args = std::move(Cmd.CommandLine);
|
entry.args = std::move(Cmd.CommandLine);
|
||||||
proc.Process(entry);
|
proc.Process(entry);
|
||||||
if (Seen.insert(entry.filename).second)
|
if (Seen.insert(entry.filename).second)
|
||||||
@ -378,6 +380,7 @@ void Project::Load(const std::string &root_directory) {
|
|||||||
LOG_S(INFO) << "angle_include_dir: " << path;
|
LOG_S(INFO) << "angle_include_dir: " << path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
// Setup project entries.
|
// Setup project entries.
|
||||||
std::lock_guard lock(mutex_);
|
std::lock_guard lock(mutex_);
|
||||||
path_to_entry_index.reserve(entries.size());
|
path_to_entry_index.reserve(entries.size());
|
||||||
@ -385,6 +388,7 @@ void Project::Load(const std::string &root_directory) {
|
|||||||
entries[i].id = i;
|
entries[i].id = i;
|
||||||
path_to_entry_index[entries[i].filename] = i;
|
path_to_entry_index[entries[i].filename] = i;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::SetFlagsForFile(const std::vector<std::string> &flags,
|
void Project::SetFlagsForFile(const std::vector<std::string> &flags,
|
||||||
|
Loading…
Reference in New Issue
Block a user