small fixes

This commit is contained in:
Jacob Dufault 2017-03-27 22:27:06 -07:00
parent 9ac960109f
commit cf1012b98c
5 changed files with 32 additions and 13 deletions

View File

@ -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);

View File

@ -4,7 +4,6 @@
#include <vector>
struct CompilationEntry {
std::string directory;
std::string filename;
std::vector<std::string> args;
};

View File

@ -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*/);

View File

@ -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(), '\\', '/');

View File

@ -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