mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 00:55:08 +00:00
cmake_minimum_required 3.8; clean up
This commit is contained in:
parent
20e0beb9f3
commit
e3133bea90
@ -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/)
|
||||
|
@ -438,8 +438,8 @@ void MessageHandler::textDocument_completion(CompletionParam ¶m,
|
||||
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 ¶m,
|
||||
// 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 ¶m,
|
||||
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);
|
||||
|
@ -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 =
|
||||
|
@ -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 *replace_end_pos) const {
|
||||
int start = GetOffsetForPosition(position, buffer_content);
|
||||
Position WorkingFile::GetCompletionPosition(Position pos, std::string *filter,
|
||||
Position *replace_end_pos) const {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -50,16 +50,10 @@ 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,
|
||||
Position *replace_end_pos) const;
|
||||
// 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:
|
||||
// Compute index_to_buffer and buffer_to_index.
|
||||
|
Loading…
Reference in New Issue
Block a user