1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
// Copyright (C) 2011-2018 ycmd contributors
//
// This file is part of ycmd.
//
// ycmd is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ycmd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ycmd. If not, see <http://www.gnu.org/licenses/>.
#ifndef COMPLETIONDATA_H_2JCTF1NU
#define COMPLETIONDATA_H_2JCTF1NU
#include "FixIt.h"
namespace YouCompleteMe {
enum class CompletionKind {
STRUCT = 0,
CLASS,
ENUM,
TYPE,
MEMBER,
FUNCTION,
VARIABLE,
MACRO,
PARAMETER,
NAMESPACE,
UNKNOWN
};
// This class holds pieces of information about a single completion coming from
// clang. These pieces are shown in Vim's UI in different ways.
//
// Normally, the completion menu looks like this (without square brackets):
//
// [main completion text] [kind] [extra menu info]
// [main completion text] [kind] [extra menu info]
// [main completion text] [kind] [extra menu info]
// ... (etc.) ...
//
// The user can also enable a "preview" window that will show extra information
// about a completion at the top of the buffer.
struct CompletionData {
CompletionData() = default;
CompletionData( CXCompletionString completion_string,
CXCursorKind kind,
CXCodeCompleteResults *results,
size_t index );
// What should actually be inserted into the buffer. For a function like
// "int foo(int x)", this is just "foo". Same for a data member like "foo_":
// we insert just "foo_".
std::string TextToInsertInBuffer() const {
return original_string_;
}
// Currently, here we show the full function signature (without the return
// type) if the current completion is a function or just the raw TypedText if
// the completion is, say, a data member. So for a function like "int foo(int
// x)", this would be "foo(int x)". For a data member like "count_", it would
// be just "count_".
std::string MainCompletionText() const {
return everything_except_return_type_;
}
// This is extra info shown in the pop-up completion menu, after the
// completion text and the kind. Currently we put the return type of the
// function here, if any.
std::string ExtraMenuInfo() const {
return return_type_;
}
// This is used to show extra information in vim's preview window. This is the
// window that vim usually shows at the top of the buffer. This should be used
// for extra information about the completion.
std::string DetailedInfoForPreviewWindow() const {
return detailed_info_;
}
std::string DocString() const {
return doc_string_;
}
std::string detailed_info_;
std::string return_type_;
CompletionKind kind_;
// The original, raw completion string. For a function like "int foo(int x)",
// the original string is "foo". For a member data variable like "foo_", this
// is just "foo_". This corresponds to clang's TypedText chunk of the
// completion string.
std::string original_string_;
std::string everything_except_return_type_;
std::string doc_string_;
FixIt fixit_;
private:
void ExtractDataFromChunk( CXCompletionString completion_string,
size_t chunk_num,
bool &saw_left_paren,
bool &saw_function_params,
bool &saw_placeholder );
void BuildCompletionFixIt( CXCodeCompleteResults *results, size_t index );
};
} // namespace YouCompleteMe
#endif /* end of include guard: COMPLETIONDATA_H_2JCTF1NU */
|