mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-27 01:51:57 +00:00
cmake_minimum_required 3.8; clean up
This commit is contained in:
parent
7b6768fd1c
commit
926ea421e6
@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.1)
|
cmake_minimum_required(VERSION 3.8)
|
||||||
project(ccls LANGUAGES CXX)
|
project(ccls LANGUAGES CXX)
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/)
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/)
|
||||||
|
@ -438,8 +438,8 @@ void MessageHandler::textDocument_completion(CompletionParam ¶m,
|
|||||||
ReplyOnce &reply) {
|
ReplyOnce &reply) {
|
||||||
static CompleteConsumerCache<std::vector<CompletionItem>> cache;
|
static CompleteConsumerCache<std::vector<CompletionItem>> cache;
|
||||||
std::string path = param.textDocument.uri.GetPath();
|
std::string path = param.textDocument.uri.GetPath();
|
||||||
WorkingFile *file = wfiles->GetFile(path);
|
WorkingFile *wf = wfiles->GetFile(path);
|
||||||
if (!file) {
|
if (!wf) {
|
||||||
reply.NotReady(true);
|
reply.NotReady(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -449,9 +449,8 @@ void MessageHandler::textDocument_completion(CompletionParam ¶m,
|
|||||||
// It shouldn't be possible, but sometimes vscode will send queries out
|
// It shouldn't be possible, but sometimes vscode will send queries out
|
||||||
// of order, ie, we get completion request before buffer content update.
|
// of order, ie, we get completion request before buffer content update.
|
||||||
std::string buffer_line;
|
std::string buffer_line;
|
||||||
if (param.position.line >= 0 &&
|
if (param.position.line >= 0 && param.position.line < wf->buffer_lines.size())
|
||||||
param.position.line < file->buffer_lines.size())
|
buffer_line = wf->buffer_lines[param.position.line];
|
||||||
buffer_line = file->buffer_lines[param.position.line];
|
|
||||||
|
|
||||||
clang::CodeCompleteOptions CCOpts;
|
clang::CodeCompleteOptions CCOpts;
|
||||||
CCOpts.IncludeBriefComments = true;
|
CCOpts.IncludeBriefComments = true;
|
||||||
@ -487,7 +486,7 @@ void MessageHandler::textDocument_completion(CompletionParam ¶m,
|
|||||||
std::string filter;
|
std::string filter;
|
||||||
Position end_pos = param.position;
|
Position end_pos = param.position;
|
||||||
Position begin_pos =
|
Position begin_pos =
|
||||||
file->FindStableCompletionSource(param.position, &filter, &end_pos);
|
wf->GetCompletionPosition(param.position, &filter, &end_pos);
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 8
|
#if LLVM_VERSION_MAJOR < 8
|
||||||
ParseIncludeLineResult preprocess = ParseIncludeLine(buffer_line);
|
ParseIncludeLineResult preprocess = ParseIncludeLine(buffer_line);
|
||||||
|
@ -143,11 +143,15 @@ void MessageHandler::textDocument_signatureHelp(
|
|||||||
|
|
||||||
std::string path = param.textDocument.uri.GetPath();
|
std::string path = param.textDocument.uri.GetPath();
|
||||||
Position begin_pos = param.position;
|
Position begin_pos = param.position;
|
||||||
if (WorkingFile *file = wfiles->GetFile(path)) {
|
WorkingFile *wf = wfiles->GetFile(path);
|
||||||
std::string completion_text;
|
if (!wf) {
|
||||||
|
reply.NotReady(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::string filter;
|
||||||
Position end_pos = param.position;
|
Position end_pos = param.position;
|
||||||
begin_pos = file->FindStableCompletionSource(param.position,
|
begin_pos = wf->GetCompletionPosition(param.position, &filter, &end_pos);
|
||||||
&completion_text, &end_pos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SemaManager::OnComplete callback =
|
SemaManager::OnComplete callback =
|
||||||
|
@ -336,21 +336,19 @@ std::optional<int> WorkingFile::GetIndexPosFromBufferPos(int line, int *column,
|
|||||||
index_lines, is_end);
|
index_lines, is_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
Position
|
Position WorkingFile::GetCompletionPosition(Position pos, std::string *filter,
|
||||||
WorkingFile::FindStableCompletionSource(Position position,
|
|
||||||
std::string *existing_completion,
|
|
||||||
Position *replace_end_pos) const {
|
Position *replace_end_pos) const {
|
||||||
int start = GetOffsetForPosition(position, buffer_content);
|
int start = GetOffsetForPosition(pos, buffer_content);
|
||||||
int i = start;
|
int i = start;
|
||||||
while (i > 0 && isIdentifierBody(buffer_content[i - 1]))
|
while (i > 0 && isIdentifierBody(buffer_content[i - 1]))
|
||||||
--i;
|
--i;
|
||||||
|
|
||||||
*replace_end_pos = position;
|
*replace_end_pos = pos;
|
||||||
for (int i = start;
|
for (int i = start;
|
||||||
i < buffer_content.size() && isIdentifierBody(buffer_content[i]); i++)
|
i < buffer_content.size() && isIdentifierBody(buffer_content[i]); i++)
|
||||||
replace_end_pos->character++;
|
replace_end_pos->character++;
|
||||||
|
|
||||||
*existing_completion = buffer_content.substr(i, start - i);
|
*filter = buffer_content.substr(i, start - i);
|
||||||
return GetPositionForOffset(buffer_content, i);
|
return GetPositionForOffset(buffer_content, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,15 +50,9 @@ struct WorkingFile {
|
|||||||
// Also resolves |column| if not NULL.
|
// Also resolves |column| if not NULL.
|
||||||
std::optional<int> GetIndexPosFromBufferPos(int line, int *column,
|
std::optional<int> GetIndexPosFromBufferPos(int line, int *column,
|
||||||
bool is_end);
|
bool is_end);
|
||||||
// Returns a relatively stable completion position (it jumps back until there
|
// Returns the stable completion position (it jumps back until there is a
|
||||||
// is a non-alphanumeric character).
|
// non-alphanumeric character).
|
||||||
//
|
Position GetCompletionPosition(Position pos, std::string *filter,
|
||||||
// The out param |is_global_completion| is set to true if this looks like a
|
|
||||||
// global completion.
|
|
||||||
// The out param |existing_completion| is set to any existing completion
|
|
||||||
// content the user has entered.
|
|
||||||
Position FindStableCompletionSource(Position position,
|
|
||||||
std::string *existing_completion,
|
|
||||||
Position *replace_end_pos) const;
|
Position *replace_end_pos) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user