cmake_minimum_required 3.8; clean up

This commit is contained in:
Fangrui Song 2018-12-13 20:58:13 -08:00
parent 7b6768fd1c
commit 926ea421e6
5 changed files with 23 additions and 28 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.8)
project(ccls LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/)

View File

@ -438,8 +438,8 @@ void MessageHandler::textDocument_completion(CompletionParam &param,
ReplyOnce &reply) {
static CompleteConsumerCache<std::vector<CompletionItem>> cache;
std::string path = param.textDocument.uri.GetPath();
WorkingFile *file = wfiles->GetFile(path);
if (!file) {
WorkingFile *wf = wfiles->GetFile(path);
if (!wf) {
reply.NotReady(true);
return;
}
@ -449,9 +449,8 @@ void MessageHandler::textDocument_completion(CompletionParam &param,
// It shouldn't be possible, but sometimes vscode will send queries out
// of order, ie, we get completion request before buffer content update.
std::string buffer_line;
if (param.position.line >= 0 &&
param.position.line < file->buffer_lines.size())
buffer_line = file->buffer_lines[param.position.line];
if (param.position.line >= 0 && param.position.line < wf->buffer_lines.size())
buffer_line = wf->buffer_lines[param.position.line];
clang::CodeCompleteOptions CCOpts;
CCOpts.IncludeBriefComments = true;
@ -487,7 +486,7 @@ void MessageHandler::textDocument_completion(CompletionParam &param,
std::string filter;
Position end_pos = param.position;
Position begin_pos =
file->FindStableCompletionSource(param.position, &filter, &end_pos);
wf->GetCompletionPosition(param.position, &filter, &end_pos);
#if LLVM_VERSION_MAJOR < 8
ParseIncludeLineResult preprocess = ParseIncludeLine(buffer_line);

View File

@ -143,11 +143,15 @@ void MessageHandler::textDocument_signatureHelp(
std::string path = param.textDocument.uri.GetPath();
Position begin_pos = param.position;
if (WorkingFile *file = wfiles->GetFile(path)) {
std::string completion_text;
WorkingFile *wf = wfiles->GetFile(path);
if (!wf) {
reply.NotReady(true);
return;
}
{
std::string filter;
Position end_pos = param.position;
begin_pos = file->FindStableCompletionSource(param.position,
&completion_text, &end_pos);
begin_pos = wf->GetCompletionPosition(param.position, &filter, &end_pos);
}
SemaManager::OnComplete callback =

View File

@ -336,21 +336,19 @@ std::optional<int> WorkingFile::GetIndexPosFromBufferPos(int line, int *column,
index_lines, is_end);
}
Position
WorkingFile::FindStableCompletionSource(Position position,
std::string *existing_completion,
Position WorkingFile::GetCompletionPosition(Position pos, std::string *filter,
Position *replace_end_pos) const {
int start = GetOffsetForPosition(position, buffer_content);
int start = GetOffsetForPosition(pos, buffer_content);
int i = start;
while (i > 0 && isIdentifierBody(buffer_content[i - 1]))
--i;
*replace_end_pos = position;
*replace_end_pos = pos;
for (int i = start;
i < buffer_content.size() && isIdentifierBody(buffer_content[i]); i++)
replace_end_pos->character++;
*existing_completion = buffer_content.substr(i, start - i);
*filter = buffer_content.substr(i, start - i);
return GetPositionForOffset(buffer_content, i);
}

View File

@ -50,15 +50,9 @@ struct WorkingFile {
// Also resolves |column| if not NULL.
std::optional<int> GetIndexPosFromBufferPos(int line, int *column,
bool is_end);
// Returns a relatively stable completion position (it jumps back until there
// is a non-alphanumeric character).
//
// 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,
// Returns the stable completion position (it jumps back until there is a
// non-alphanumeric character).
Position GetCompletionPosition(Position pos, std::string *filter,
Position *replace_end_pos) const;
private: