mirror of
https://github.com/MaskRay/ccls.git
synced 2025-02-18 06:31:15 +00:00
Handle int8_t int16_t uint8_t uint16_t enum constants
Clean up clang_complete
This commit is contained in:
parent
8bb5d47377
commit
0d715e7bcf
@ -160,6 +160,11 @@ void BuildDetailString(CXCompletionString completion_string,
|
|||||||
std::vector<std::string>* parameters,
|
std::vector<std::string>* parameters,
|
||||||
bool include_snippets) {
|
bool include_snippets) {
|
||||||
int num_chunks = clang_getNumCompletionChunks(completion_string);
|
int num_chunks = clang_getNumCompletionChunks(completion_string);
|
||||||
|
auto append = [&](const char* text) {
|
||||||
|
detail += text;
|
||||||
|
if (do_insert)
|
||||||
|
insert += text;
|
||||||
|
};
|
||||||
for (int i = 0; i < num_chunks; ++i) {
|
for (int i = 0; i < num_chunks; ++i) {
|
||||||
CXCompletionChunkKind kind =
|
CXCompletionChunkKind kind =
|
||||||
clang_getCompletionChunkKind(completion_string, i);
|
clang_getCompletionChunkKind(completion_string, i);
|
||||||
@ -224,71 +229,23 @@ void BuildDetailString(CXCompletionString completion_string,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case CXCompletionChunk_LeftParen:
|
// clang-format off
|
||||||
detail += "(";
|
case CXCompletionChunk_LeftParen: append("("); break;
|
||||||
if (do_insert)
|
case CXCompletionChunk_RightParen: append(")"); break;
|
||||||
insert += "(";
|
case CXCompletionChunk_LeftBracket: append("["); break;
|
||||||
break;
|
case CXCompletionChunk_RightBracket: append("]"); break;
|
||||||
case CXCompletionChunk_RightParen:
|
case CXCompletionChunk_LeftBrace: append("{"); break;
|
||||||
detail += ")";
|
case CXCompletionChunk_RightBrace: append("}"); break;
|
||||||
if (do_insert)
|
case CXCompletionChunk_LeftAngle: append("<"); break;
|
||||||
insert += ")";
|
case CXCompletionChunk_RightAngle: append(">"); break;
|
||||||
break;
|
case CXCompletionChunk_Comma: append(", "); break;
|
||||||
case CXCompletionChunk_LeftBracket:
|
case CXCompletionChunk_Colon: append(":"); break;
|
||||||
detail += "[";
|
case CXCompletionChunk_SemiColon: append(";"); break;
|
||||||
if (do_insert)
|
case CXCompletionChunk_Equal: append("="); break;
|
||||||
insert += "[";
|
// clang-format on
|
||||||
break;
|
|
||||||
case CXCompletionChunk_RightBracket:
|
|
||||||
detail += "]";
|
|
||||||
if (do_insert)
|
|
||||||
insert += "]";
|
|
||||||
break;
|
|
||||||
case CXCompletionChunk_LeftBrace:
|
|
||||||
detail += "{";
|
|
||||||
if (do_insert)
|
|
||||||
insert += "{";
|
|
||||||
break;
|
|
||||||
case CXCompletionChunk_RightBrace:
|
|
||||||
detail += "}";
|
|
||||||
if (do_insert)
|
|
||||||
insert += "}";
|
|
||||||
break;
|
|
||||||
case CXCompletionChunk_LeftAngle:
|
|
||||||
detail += "<";
|
|
||||||
if (do_insert)
|
|
||||||
insert += "<";
|
|
||||||
break;
|
|
||||||
case CXCompletionChunk_RightAngle:
|
|
||||||
detail += ">";
|
|
||||||
if (do_insert)
|
|
||||||
insert += ">";
|
|
||||||
break;
|
|
||||||
case CXCompletionChunk_Comma:
|
|
||||||
detail += ", ";
|
|
||||||
if (do_insert)
|
|
||||||
insert += ", ";
|
|
||||||
break;
|
|
||||||
case CXCompletionChunk_Colon:
|
|
||||||
detail += ":";
|
|
||||||
if (do_insert)
|
|
||||||
insert += ":";
|
|
||||||
break;
|
|
||||||
case CXCompletionChunk_SemiColon:
|
|
||||||
detail += ";";
|
|
||||||
if (do_insert)
|
|
||||||
insert += ";";
|
|
||||||
break;
|
|
||||||
case CXCompletionChunk_Equal:
|
|
||||||
detail += "=";
|
|
||||||
if (do_insert)
|
|
||||||
insert += "=";
|
|
||||||
break;
|
|
||||||
case CXCompletionChunk_HorizontalSpace:
|
case CXCompletionChunk_HorizontalSpace:
|
||||||
case CXCompletionChunk_VerticalSpace:
|
case CXCompletionChunk_VerticalSpace:
|
||||||
detail += " ";
|
append(" ");
|
||||||
if (do_insert)
|
|
||||||
insert += " ";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -490,13 +490,12 @@ void SetVarDetail(IndexVar* var,
|
|||||||
CXType enum_type = clang_getCanonicalType(
|
CXType enum_type = clang_getCanonicalType(
|
||||||
clang_getEnumDeclIntegerType(semanticContainer->cursor));
|
clang_getEnumDeclIntegerType(semanticContainer->cursor));
|
||||||
std::string hover = qualified_name + " = ";
|
std::string hover = qualified_name + " = ";
|
||||||
if (enum_type.kind == CXType_Int || enum_type.kind == CXType_Long ||
|
if (enum_type.kind == CXType_UInt || enum_type.kind == CXType_ULong ||
|
||||||
enum_type.kind == CXType_LongLong)
|
enum_type.kind == CXType_ULongLong)
|
||||||
hover += std::to_string(clang_getEnumConstantDeclValue(cursor.cx_cursor));
|
|
||||||
else if (enum_type.kind == CXType_UInt || enum_type.kind == CXType_ULong ||
|
|
||||||
enum_type.kind == CXType_ULongLong)
|
|
||||||
hover += std::to_string(
|
hover += std::to_string(
|
||||||
clang_getEnumConstantDeclUnsignedValue(cursor.cx_cursor));
|
clang_getEnumConstantDeclUnsignedValue(cursor.cx_cursor));
|
||||||
|
else
|
||||||
|
hover += std::to_string(clang_getEnumConstantDeclValue(cursor.cx_cursor));
|
||||||
def.detailed_name = std::move(qualified_name);
|
def.detailed_name = std::move(qualified_name);
|
||||||
def.hover = hover;
|
def.hover = hover;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user