mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-19 03:55:49 +00:00
small fixes
This commit is contained in:
parent
9ac960109f
commit
cf1012b98c
@ -41,8 +41,7 @@ std::vector<CompilationEntry> LoadFromDirectoryListing(const std::string& projec
|
||||
EndsWith(file, ".hpp")) {
|
||||
|
||||
CompilationEntry entry;
|
||||
entry.directory = project_directory;
|
||||
entry.filename = file;
|
||||
entry.filename = NormalizePath(file);
|
||||
entry.args = args;
|
||||
result.push_back(entry);
|
||||
}
|
||||
@ -145,11 +144,10 @@ std::vector<CompilationEntry> LoadCompilationEntriesFromDirectory(const std::str
|
||||
CompilationEntry entry;
|
||||
|
||||
// TODO: remove ComplationEntry::directory
|
||||
entry.directory = clang::ToString(clang_CompileCommand_getDirectory(cx_command));
|
||||
entry.filename = clang::ToString(clang_CompileCommand_getFilename(cx_command));
|
||||
|
||||
std::string normalized = entry.directory + "/" + entry.filename;
|
||||
entry.filename = NormalizePath(normalized);
|
||||
std::string directory = clang::ToString(clang_CompileCommand_getDirectory(cx_command));
|
||||
std::string relative_filename = clang::ToString(clang_CompileCommand_getFilename(cx_command));
|
||||
std::string absolute_filename = directory + "/" + relative_filename;
|
||||
entry.filename = NormalizePath(absolute_filename);
|
||||
|
||||
unsigned int num_args = clang_CompileCommand_getNumArgs(cx_command);
|
||||
entry.args.reserve(num_args);
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <vector>
|
||||
|
||||
struct CompilationEntry {
|
||||
std::string directory;
|
||||
std::string filename;
|
||||
std::vector<std::string> args;
|
||||
};
|
||||
|
@ -1208,13 +1208,10 @@ IndexedFile Parse(std::string filename,
|
||||
//clang_enableStackTraces();
|
||||
//clang_toggleCrashRecovery(1);
|
||||
|
||||
args.push_back("-std=c++11");
|
||||
#if defined(_WIN32)
|
||||
args.push_back("-fms-compatibility");
|
||||
args.push_back("-fdelayed-template-parsing");
|
||||
// args.push_back("-isystem
|
||||
// C:\\Users\\jacob\\Desktop\\superindex\\indexer\\libcxx-3.9.1\\include");
|
||||
// args.push_back("--sysroot
|
||||
// C:\\Users\\jacob\\Desktop\\superindex\\indexer\\libcxx-3.9.1");
|
||||
#endif
|
||||
|
||||
clang::Index index(0 /*excludeDeclarationsFromPCH*/,
|
||||
0 /*displayDiagnostics*/);
|
||||
|
@ -126,7 +126,12 @@ void lsDocumentUri::SetPath(const std::string& path) {
|
||||
raw_uri.replace(raw_uri.begin() + index, raw_uri.begin() + index + 1, "%3A");
|
||||
}
|
||||
|
||||
// TODO: proper fix
|
||||
#if defined(_WIN32)
|
||||
raw_uri = "file:///" + raw_uri;
|
||||
#else
|
||||
raw_uri = "file://" + raw_uri;
|
||||
#endif
|
||||
//std::cerr << "Set uri to " << raw_uri << " from " << path;
|
||||
}
|
||||
|
||||
@ -141,7 +146,12 @@ std::string lsDocumentUri::GetPath() const {
|
||||
|
||||
index = result.find("file://");
|
||||
if (index != -1) {
|
||||
// TODO: proper fix
|
||||
#if defined(_WIN32)
|
||||
result.replace(result.begin() + index, result.begin() + index + 8, "");
|
||||
#else
|
||||
result.replace(result.begin() + index, result.begin() + index + 7, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
std::replace(result.begin(), result.end(), '\\', '/');
|
||||
|
@ -125,4 +125,19 @@ std::string GetWorkingDirectory() {
|
||||
char result[MAX_PATH];
|
||||
return std::string(result, GetModuleFileName(NULL, result, MAX_PATH));
|
||||
}
|
||||
|
||||
std::string NormalizePath(const std::string& path) {
|
||||
DWORD retval = 0;
|
||||
BOOL success = false;
|
||||
TCHAR buffer[MAX_PATH] = TEXT("");
|
||||
TCHAR buf[MAX_PATH] = TEXT("");
|
||||
TCHAR** lpp_part = { NULL };
|
||||
|
||||
retval = GetFullPathName(path.c_str(), MAX_PATH, buffer, lpp_part);
|
||||
// fail, return original
|
||||
if (retval == 0)
|
||||
return path;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user