mirror of
https://github.com/MaskRay/ccls.git
synced 2025-02-21 07:59:27 +00:00
wip
This commit is contained in:
parent
cf1012b98c
commit
a19d4f732f
@ -1,14 +1,30 @@
|
|||||||
|
# Language
|
||||||
-xc++
|
-xc++
|
||||||
-std=c++11
|
-std=c++11
|
||||||
|
|
||||||
|
# Includes
|
||||||
-IC:/Users/jacob/Desktop/superindex/indexer/third_party
|
-IC:/Users/jacob/Desktop/superindex/indexer/third_party
|
||||||
-IC:/Users/jacob/Desktop/superindex/indexer/third_party/doctest/doctest
|
-IC:/Users/jacob/Desktop/superindex/indexer/third_party/doctest/doctest
|
||||||
-IC:/Users/jacob/Desktop/superindex/indexer/third_party/rapidjson/include
|
-IC:/Users/jacob/Desktop/superindex/indexer/third_party/rapidjson/include
|
||||||
-IC:/Program Files/LLVM/include
|
-IC:/Program Files/LLVM/include
|
||||||
-I/usr/local/Cellar/llvm/3.9.1/include
|
|
||||||
|
# Use libcxx (platform args)
|
||||||
|
#-stdlib=libc++
|
||||||
|
#-nostdinc++
|
||||||
|
#-IC:/Users/jacob/Desktop/superindex/indexer/libcxx/include
|
||||||
|
#-fms-compatibility
|
||||||
|
#-fdelayed-template-parsing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#--sysrootC:/Users/jacob/Desktop/superindex/indexer/libcxx
|
#--sysrootC:/Users/jacob/Desktop/superindex/indexer/libcxx
|
||||||
#-IC:/Users/jacob/Desktop/superindex/indexer/libcxx/include
|
#-IC:/Users/jacob/Desktop/superindex/indexer/libcxx/include
|
||||||
#-FC:/Users/jacob/Desktop/superindex/indexer/libcxx/include
|
#-FC:/Users/jacob/Desktop/superindex/indexer/libcxx/include
|
||||||
|
|
||||||
-fms-compatibility
|
#-L<libcxx-install-prefix>/lib \
|
||||||
-fdelayed-template-parsing
|
#-Wl,-rpath,<libcxx-install-prefix>/lib \
|
||||||
|
#-I<libcxx-install-prefix>/include/c++/v1 \
|
@ -1,13 +1,30 @@
|
|||||||
|
# Language
|
||||||
-xc++
|
-xc++
|
||||||
-std=c++11
|
-std=c++11
|
||||||
|
|
||||||
|
# Includes
|
||||||
-IC:/Users/jacob/Desktop/superindex/indexer/third_party
|
-IC:/Users/jacob/Desktop/superindex/indexer/third_party
|
||||||
-IC:/Users/jacob/Desktop/superindex/indexer/third_party/doctest/doctest
|
-IC:/Users/jacob/Desktop/superindex/indexer/third_party/doctest/doctest
|
||||||
-IC:/Users/jacob/Desktop/superindex/indexer/third_party/rapidjson/include
|
-IC:/Users/jacob/Desktop/superindex/indexer/third_party/rapidjson/include
|
||||||
-IC:/Program Files/LLVM/include
|
-IC:/Program Files/LLVM/include
|
||||||
|
|
||||||
|
# Use libcxx
|
||||||
|
-stdlib=libc++
|
||||||
|
-nostdinc++
|
||||||
|
-IC:/Users/jacob/Desktop/superindex/indexer/libcxx/include
|
||||||
|
#-fms-compatibility
|
||||||
|
#-fdelayed-template-parsing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#--sysrootC:/Users/jacob/Desktop/superindex/indexer/libcxx
|
#--sysrootC:/Users/jacob/Desktop/superindex/indexer/libcxx
|
||||||
#-IC:/Users/jacob/Desktop/superindex/indexer/libcxx/include
|
#-IC:/Users/jacob/Desktop/superindex/indexer/libcxx/include
|
||||||
#-FC:/Users/jacob/Desktop/superindex/indexer/libcxx/include
|
#-FC:/Users/jacob/Desktop/superindex/indexer/libcxx/include
|
||||||
|
|
||||||
-fms-compatibility
|
#-L<libcxx-install-prefix>/lib \
|
||||||
-fdelayed-template-parsing
|
#-Wl,-rpath,<libcxx-install-prefix>/lib \
|
||||||
|
#-I<libcxx-install-prefix>/include/c++/v1 \
|
@ -311,8 +311,7 @@ void QueryDbMainLoop(
|
|||||||
|
|
||||||
std::vector<std::unique_ptr<BaseIpcMessage>> messages = language_client->GetMessages(&language_client->for_server);
|
std::vector<std::unique_ptr<BaseIpcMessage>> messages = language_client->GetMessages(&language_client->for_server);
|
||||||
for (auto& message : messages) {
|
for (auto& message : messages) {
|
||||||
// std::cerr << "Processing message " << static_cast<int>(message->ipc_id)
|
std::cerr << "[querydb] Processing message " << static_cast<int>(message->method_id) << std::endl;
|
||||||
// << std::endl;
|
|
||||||
|
|
||||||
switch (message->method_id) {
|
switch (message->method_id) {
|
||||||
case IpcId::Quit: {
|
case IpcId::Quit: {
|
||||||
@ -392,7 +391,12 @@ void QueryDbMainLoop(
|
|||||||
response.id = msg->id;
|
response.id = msg->id;
|
||||||
|
|
||||||
QueryableFile* file = FindFile(db, msg->params.textDocument.uri.GetPath());
|
QueryableFile* file = FindFile(db, msg->params.textDocument.uri.GetPath());
|
||||||
if (file) {
|
if (!file) {
|
||||||
|
std::cerr << "Unable to find file " << msg->params.textDocument.uri.GetPath() << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cerr << "File outline size is " << file->outline.size() << std::endl;
|
||||||
for (UsrRef ref : file->outline) {
|
for (UsrRef ref : file->outline) {
|
||||||
SymbolIdx symbol = db->usr_to_symbol[ref.usr];
|
SymbolIdx symbol = db->usr_to_symbol[ref.usr];
|
||||||
|
|
||||||
@ -444,7 +448,6 @@ void QueryDbMainLoop(
|
|||||||
|
|
||||||
response.result.push_back(info);
|
response.result.push_back(info);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SendOutMessageToClient(language_client, response);
|
SendOutMessageToClient(language_client, response);
|
||||||
break;
|
break;
|
||||||
@ -459,7 +462,11 @@ void QueryDbMainLoop(
|
|||||||
lsDocumentUri file_as_uri = msg->params.textDocument.uri;
|
lsDocumentUri file_as_uri = msg->params.textDocument.uri;
|
||||||
|
|
||||||
QueryableFile* file = FindFile(db, file_as_uri.GetPath());
|
QueryableFile* file = FindFile(db, file_as_uri.GetPath());
|
||||||
if (file) {
|
if (!file) {
|
||||||
|
std::cerr << "Unable to find file " << msg->params.textDocument.uri.GetPath() << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
for (UsrRef ref : file->outline) {
|
for (UsrRef ref : file->outline) {
|
||||||
SymbolIdx symbol = db->usr_to_symbol[ref.usr];
|
SymbolIdx symbol = db->usr_to_symbol[ref.usr];
|
||||||
switch (symbol.kind) {
|
switch (symbol.kind) {
|
||||||
@ -499,7 +506,6 @@ void QueryDbMainLoop(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SendOutMessageToClient(language_client, response);
|
SendOutMessageToClient(language_client, response);
|
||||||
break;
|
break;
|
||||||
@ -693,7 +699,7 @@ void LanguageServerStdinLoop(IpcMessageQueue* ipc) {
|
|||||||
|
|
||||||
response.result.capabilities.completionProvider = lsCompletionOptions();
|
response.result.capabilities.completionProvider = lsCompletionOptions();
|
||||||
response.result.capabilities.completionProvider->resolveProvider = false;
|
response.result.capabilities.completionProvider->resolveProvider = false;
|
||||||
response.result.capabilities.completionProvider->triggerCharacters = { ".", "::", "->", ":", ">" };
|
response.result.capabilities.completionProvider->triggerCharacters = { ".", "::", "->" };
|
||||||
|
|
||||||
response.result.capabilities.codeLensProvider = lsCodeLensOptions();
|
response.result.capabilities.codeLensProvider = lsCodeLensOptions();
|
||||||
response.result.capabilities.codeLensProvider->resolveProvider = false;
|
response.result.capabilities.codeLensProvider->resolveProvider = false;
|
||||||
@ -724,6 +730,7 @@ void LanguageServerStdinLoop(IpcMessageQueue* ipc) {
|
|||||||
case IpcId::TextDocumentDocumentSymbol:
|
case IpcId::TextDocumentDocumentSymbol:
|
||||||
case IpcId::TextDocumentCodeLens:
|
case IpcId::TextDocumentCodeLens:
|
||||||
case IpcId::WorkspaceSymbol:
|
case IpcId::WorkspaceSymbol:
|
||||||
|
std::cerr << "Spending message " << (int)message->method_id << std::endl;
|
||||||
ipc->SendMessage(&ipc->for_server, message->method_id, *message.get());
|
ipc->SendMessage(&ipc->for_server, message->method_id, *message.get());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -666,9 +666,8 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
|||||||
IndexedFile* db = param->db;
|
IndexedFile* db = param->db;
|
||||||
NamespaceHelper* ns = param->ns;
|
NamespaceHelper* ns = param->ns;
|
||||||
|
|
||||||
// std::cerr << "DECL kind=" << decl->entityInfo->kind << " at " <<
|
|
||||||
// db->id_cache.Resolve(decl->cursor, false).ToPrettyString(&db->id_cache) <<
|
//std::cerr << "DECL kind=" << decl->entityInfo->kind << " at " << db->id_cache.Resolve(decl->cursor, false).ToPrettyString(&db->id_cache) << std::endl;
|
||||||
// std::endl;
|
|
||||||
|
|
||||||
switch (decl->entityInfo->kind) {
|
switch (decl->entityInfo->kind) {
|
||||||
case CXIdxEntity_CXXNamespace: {
|
case CXIdxEntity_CXXNamespace: {
|
||||||
@ -1197,21 +1196,11 @@ void indexEntityReference(CXClientData client_data,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void emptyIndexDeclaration(CXClientData client_data,
|
|
||||||
const CXIdxDeclInfo* decl) {}
|
|
||||||
void emptyIndexEntityReference(CXClientData client_data,
|
|
||||||
const CXIdxEntityRefInfo* ref) {}
|
|
||||||
|
|
||||||
IndexedFile Parse(std::string filename,
|
IndexedFile Parse(std::string filename,
|
||||||
std::vector<std::string> args,
|
std::vector<std::string> args,
|
||||||
bool dump_ast) {
|
bool dump_ast) {
|
||||||
//clang_enableStackTraces();
|
clang_enableStackTraces();
|
||||||
//clang_toggleCrashRecovery(1);
|
clang_toggleCrashRecovery(1);
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
args.push_back("-fms-compatibility");
|
|
||||||
args.push_back("-fdelayed-template-parsing");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
clang::Index index(0 /*excludeDeclarationsFromPCH*/,
|
clang::Index index(0 /*excludeDeclarationsFromPCH*/,
|
||||||
0 /*displayDiagnostics*/);
|
0 /*displayDiagnostics*/);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "TranslationUnit.h"
|
#include "TranslationUnit.h"
|
||||||
#include "Tokens.h"
|
#include "Tokens.h"
|
||||||
#include "Utility.h"
|
#include "Utility.h"
|
||||||
|
#include "../platform.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
@ -16,9 +17,12 @@ TranslationUnit::TranslationUnit(
|
|||||||
unsigned flags) {
|
unsigned flags) {
|
||||||
|
|
||||||
std::vector<const char*> args;
|
std::vector<const char*> args;
|
||||||
for (const std::string& a : arguments) {
|
for (const std::string& a : arguments)
|
||||||
args.push_back(a.c_str());
|
args.push_back(a.c_str());
|
||||||
}
|
|
||||||
|
std::vector<std::string> platform_args = GetPlatformClangArguments();
|
||||||
|
for (const auto& arg : platform_args)
|
||||||
|
args.push_back(arg.c_str());
|
||||||
|
|
||||||
CXErrorCode error_code = clang_parseTranslationUnit2(
|
CXErrorCode error_code = clang_parseTranslationUnit2(
|
||||||
index.cx_index,
|
index.cx_index,
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
struct PlatformMutex {
|
struct PlatformMutex {
|
||||||
virtual ~PlatformMutex();
|
virtual ~PlatformMutex();
|
||||||
@ -26,3 +27,6 @@ std::unique_ptr<PlatformSharedMemory> CreatePlatformSharedMemory(
|
|||||||
void PlatformInit();
|
void PlatformInit();
|
||||||
std::string GetWorkingDirectory();
|
std::string GetWorkingDirectory();
|
||||||
std::string NormalizePath(const std::string& path);
|
std::string NormalizePath(const std::string& path);
|
||||||
|
|
||||||
|
// Returns any clang arguments that are specific to the current platform.
|
||||||
|
std::vector<std::string> GetPlatformClangArguments();
|
@ -137,6 +137,14 @@ std::string NormalizePath(const std::string& path) {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> GetPlatformClangArguments() {
|
||||||
|
// TODO: use install config variable for path?
|
||||||
|
return {
|
||||||
|
"-stdlib=libc++",
|
||||||
|
"-nostdinc++",
|
||||||
|
"-I/usr/local/Cellar/llvm/3.9.1/include"
|
||||||
|
};
|
||||||
|
}
|
||||||
#undef CHECKED
|
#undef CHECKED
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -42,7 +43,7 @@ struct PlatformMutexWin : public PlatformMutex {
|
|||||||
PlatformMutexWin(const std::string& name) {
|
PlatformMutexWin(const std::string& name) {
|
||||||
std::cerr << "[win] Creating mutex with name " << name << std::endl;
|
std::cerr << "[win] Creating mutex with name " << name << std::endl;
|
||||||
raw_mutex = CreateMutex(nullptr, false /*initial_owner*/, name.c_str());
|
raw_mutex = CreateMutex(nullptr, false /*initial_owner*/, name.c_str());
|
||||||
CheckForError({ERROR_ALREADY_EXISTS});
|
CheckForError({ ERROR_ALREADY_EXISTS });
|
||||||
}
|
}
|
||||||
|
|
||||||
~PlatformMutexWin() override {
|
~PlatformMutexWin() override {
|
||||||
@ -77,10 +78,10 @@ struct PlatformSharedMemoryWin : public PlatformSharedMemory {
|
|||||||
|
|
||||||
shmem_ = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0,
|
shmem_ = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0,
|
||||||
capacity, name.c_str());
|
capacity, name.c_str());
|
||||||
CheckForError({ERROR_ALREADY_EXISTS} /*allow*/);
|
CheckForError({ ERROR_ALREADY_EXISTS } /*allow*/);
|
||||||
|
|
||||||
data = MapViewOfFile(shmem_, FILE_MAP_ALL_ACCESS, 0, 0, capacity);
|
data = MapViewOfFile(shmem_, FILE_MAP_ALL_ACCESS, 0, 0, capacity);
|
||||||
CheckForError({ERROR_ALREADY_EXISTS} /*allow*/);
|
CheckForError({ ERROR_ALREADY_EXISTS } /*allow*/);
|
||||||
|
|
||||||
this->capacity = capacity;
|
this->capacity = capacity;
|
||||||
}
|
}
|
||||||
@ -138,6 +139,15 @@ std::string NormalizePath(const std::string& path) {
|
|||||||
if (retval == 0)
|
if (retval == 0)
|
||||||
return path;
|
return path;
|
||||||
|
|
||||||
return buffer;
|
std::string result = buffer;
|
||||||
|
std::replace(result.begin(), result.end(), '\\', '/');
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> GetPlatformClangArguments() {
|
||||||
|
return {
|
||||||
|
"-fms-compatibility",
|
||||||
|
"-fdelayed-template-parsing"
|
||||||
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user