From 395b0a6467dab73a206391a977976dd3a705c49d Mon Sep 17 00:00:00 2001 From: Chao Shen Date: Mon, 14 May 2018 10:16:30 +0800 Subject: [PATCH] Bring back old completion features. --- src/clang_complete.cc | 2 +- src/clang_complete.h | 4 ---- src/include_complete.cc | 5 +++++ src/messages/text_document_completion.cc | 2 +- src/standard_headers.inc | 1 + 5 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 src/standard_headers.inc diff --git a/src/clang_complete.cc b/src/clang_complete.cc index 6d23be43..ee499ad7 100644 --- a/src/clang_complete.cc +++ b/src/clang_complete.cc @@ -776,7 +776,7 @@ std::shared_ptr ClangCompleteManager::TryGetSession( // If this request is for a completion, we should move it to // |completion_sessions|. if (mark_as_completion) { - assert(!completion_sessions_.TryGet(filename)); + // assert(!completion_sessions_.TryGet(filename)); preloaded_sessions_.TryTake(filename); completion_sessions_.Insert(filename, preloaded_session); } diff --git a/src/clang_complete.h b/src/clang_complete.h index ee0cd6a7..aa471c8e 100644 --- a/src/clang_complete.h +++ b/src/clang_complete.h @@ -44,10 +44,6 @@ struct ClangCompleteManager { using OnDiagnostic = std::function diagnostics)>; - using OnIndex = std::function& unsaved, - const std::string& path, - const std::vector& args)>; using OnComplete = std::function& results, bool is_cached_result)>; diff --git a/src/include_complete.cc b/src/include_complete.cc index ea33fa33..e9b3722d 100644 --- a/src/include_complete.cc +++ b/src/include_complete.cc @@ -8,6 +8,8 @@ #include +#include "standard_headers.inc" + namespace { struct CompletionCandidate { @@ -96,6 +98,9 @@ void IncludeComplete::Rescan() { absolute_path_to_completion_item.clear(); inserted_paths.clear(); + for (auto& header : kStandardHeaders) + completion_items.push_back(BuildCompletionItem(header, true, true)); + if (!match_ && (g_config->completion.includeWhitelist.size() || g_config->completion.includeBlacklist.size())) match_ = std::make_unique(g_config->completion.includeWhitelist, diff --git a/src/messages/text_document_completion.cc b/src/messages/text_document_completion.cc index a0820549..17534491 100644 --- a/src/messages/text_document_completion.cc +++ b/src/messages/text_document_completion.cc @@ -365,7 +365,7 @@ struct Handler_TextDocumentCompletion : MessageHandler { lock.lock(); std::string quote = result.match[5]; for (auto& item : include_complete->completion_items) - if (quote.empty() || quote == (item.use_angle_brackets_ ? "<" : "\"")) + // if (quote.empty() || quote == (item.use_angle_brackets_ ? "<" : "\"")) out.result.items.push_back(item); } FilterAndSortCompletionResponse(&out, result.pattern, has_open_paren); diff --git a/src/standard_headers.inc b/src/standard_headers.inc new file mode 100644 index 00000000..ee069976 --- /dev/null +++ b/src/standard_headers.inc @@ -0,0 +1 @@ +static const std::vector kStandardHeaders = { "algorithm", "any", "array", "atomic", "bitset", "cassert", "ccomplex", "cctype", "cerrno", "cfenv", "cfloat", "chrono", "cinttypes", "ciso646", "climits", "clocale", "cmath", "codecvt", "complex", "complex.h", "condition_variable", "coroutine", "csetjmp", "csignal", "cstdarg", "cstdbool", "cstddef", "cstdint", "cstdio", "cstdlib", "cstring", "ctgmath", "ctime", "ctype.h", "cwchar", "cwctype", "cxxabi.h", "deque", "dynarray", "errno.h", "exception", "experimental", "ext", "filesystem", "float.h", "forward_list", "fstream", "functional", "future", "initializer_list", "inttypes.h", "iomanip", "ios", "iosfwd", "iostream", "istream", "iterator", "limits", "limits.h", "list", "locale", "locale.h", "map", "math.h", "memory", "memory_resource", "module.modulemap", "mutex", "new", "numeric", "optional", "ostream", "propagate_const", "queue", "random", "ratio", "regex", "scoped_allocator", "set", "setjmp.h", "shared_mutex", "sstream", "stack", "stdbool.h", "stddef.h", "stdexcept", "stdint.h", "stdio.h", "stdlib.h", "streambuf", "string", "string.h", "string_view", "strstream", "support", "system_error", "tgmath.h", "thread", "tuple", "typeindex", "typeinfo", "type_traits", "unordered_map", "unordered_set", "utility", "valarray", "variant", "vector", "wchar.h", "wctype.h" };