diff --git a/en/clice/features/hover.md b/en/clice/features/hover.md index db6b3de09..351c96720 100644 --- a/en/clice/features/hover.md +++ b/en/clice/features/hover.md @@ -766,14 +766,16 @@ tests/snap/hover/macro_hover/06_preamble_define_hover.cpp - + **Members on type hover** Hovering an enum or struct type lists its members -The card names the type (and a struct's layout), but the member list is -not expanded — the body renders as `{}`. +A class lists its data members and member types, an enum its +enumerators with their values; member functions are left out. The +`max_members` option caps the list, 20 entries by default, and `0` +turns it off. ```snap tests/snap/hover/special_hover_targets/01_type_members_on_hover.cpp diff --git a/en/clice/features/overview.md b/en/clice/features/overview.md index 633fd34e8..0bef348ca 100644 --- a/en/clice/features/overview.md +++ b/en/clice/features/overview.md @@ -16,7 +16,7 @@ Language Server Protocol features available when using clice as an editor backen | Feature | Status | | ----------------------------------------- | ------------------------------------------ | | [Code Completion](./completion.md) | 57 supported | -| [Hover](./hover.md) | 37 supported · 20 partial · 10 unsupported | +| [Hover](./hover.md) | 38 supported · 19 partial · 10 unsupported | | [Signature Help](./signature-help.md) | 14 supported | | [Code Navigation](./navigation.md) | 71 supported · 12 partial · 26 unsupported | | [Document Links](./document-links.md) | 7 supported · 1 partial · 1 unsupported | diff --git a/en/clice/guide/configuration.md b/en/clice/guide/configuration.md index bf0de5227..f7009d7ad 100644 --- a/en/clice/guide/configuration.md +++ b/en/clice/guide/configuration.md @@ -212,6 +212,16 @@ Show the desugared form of a type, e.g. `vector::size_type (aka unsigned lo +
+ +| Option | Type | Default | +| ------------- | -------- | ------- | +| `max_members` | `uint32` | `20` | + +Maximum number of members the definition of a hovered class or enum lists: data members and member types, or enumerators; member functions are left out. `0` shows the declaration alone. + +
+ ## `[inlay_hints]` diff --git a/public/clice-config.schema.json b/public/clice-config.schema.json index f28ee37cd..559655c94 100644 --- a/public/clice-config.schema.json +++ b/public/clice-config.schema.json @@ -40,7 +40,8 @@ "description": "The [hover] section: hover rendering options.", "default": { "parse_comment_as_markdown": true, - "show_aka": true + "show_aka": true, + "max_members": 20 } }, "inlay_hints": { @@ -184,6 +185,13 @@ "type": "boolean", "description": "Show the desugared form of a type, e.g. `vector::size_type (aka unsigned long)`.", "default": true + }, + "max_members": { + "type": "integer", + "minimum": 0, + "maximum": 4294967295, + "description": "Maximum number of members the definition of a hovered class or enum lists: data members and member types, or enumerators; member functions are left out. `0` shows the declaration alone.", + "default": 20 } }, "additionalProperties": false diff --git a/sources/clice/tests/snap/hover/c_records.cpp b/sources/clice/tests/snap/hover/c_records.cpp new file mode 100644 index 000000000..749fbd66b --- /dev/null +++ b/sources/clice/tests/snap/hover/c_records.cpp @@ -0,0 +1,35 @@ +// - flags: ["-x", "c", "-std=c11"] + +struct Point { + int x; + union { + int tag; + float weight; + }; + struct { + int width, height; + } size; + enum { Small, Large } scale; +}; + +struct §(c_struct)Point point; + +struct ops { + int (*open)(struct inode*, struct file*); + const struct item* first; + int count; +}; + +struct §(c_mentions)ops table; + +struct Packed { + char raw[sizeof(struct { int a; long b; })]; + __typeof__(struct { int t; }) typed; + void (*callback)(struct { int x; }* arg); + _Atomic struct { + int value; + } atomic; + int tail; +}; + +struct §(c_inner_tags)Packed packed; diff --git a/sources/clice/tests/snap/hover/c_records.snap.yml b/sources/clice/tests/snap/hover/c_records.snap.yml new file mode 100644 index 000000000..fd745e53a --- /dev/null +++ b/sources/clice/tests/snap/hover/c_records.snap.yml @@ -0,0 +1,51 @@ +--- +created_at: 2026-10-09 +input_file: c_records.cpp +--- +c_inner_tags: { range: "34:7-34:13" } +### struct `Packed` + +--- +```cpp +struct Packed { + char raw[16]; + typeof(struct(unnamed)) typed; + void (*callback)(struct(unnamed) *); + _Atomic(struct(unnamed)) atomic; + int tail; +} +``` + +c_mentions: { range: "22:7-22:10" } +### struct `ops` + +--- +```cpp +struct ops { + int (*open)(struct inode *, struct file *); + const struct item *first; + int count; +} +``` + +c_struct: { range: "14:7-14:12" } +### struct `Point` + +--- +\- flags: ["-x", "c", "-std=c11"] + +--- +```cpp +struct Point { + int x; + union { + int tag; + float weight; + }; + struct { + int width; + int height; + } size; + enum { Small = 0, Large = 1 } scale; +} +``` diff --git a/sources/clice/tests/snap/hover/enum_members.cpp b/sources/clice/tests/snap/hover/enum_members.cpp new file mode 100644 index 000000000..d89e88e62 --- /dev/null +++ b/sources/clice/tests/snap/hover/enum_members.cpp @@ -0,0 +1,34 @@ +// The enumerator summary of an enum: values as written, computed values for +// the rest. + +namespace implicit_values { +enum Level { Low, Medium = 10, High }; +§(implicit_values)Level level; +} + +namespace written_values { +enum Permission : unsigned { + Read = 1 << 0, + Write = 1 << 1, + Execute = 1 << 2, + All = Read | Write | Execute, +}; +§(written_values)Permission permission; +} + +namespace scoped { +enum class Ordering : signed char { Less = -1, Equal, Greater }; +§(scoped)Ordering ordering; +} + +namespace empty { +enum class Tag : int {}; +§(empty)Tag tag; +} + +namespace dependent { +template struct Holder { + enum Size { None, Bytes = sizeof(T), Twice }; + §(dependent)Size size; +}; +} diff --git a/sources/clice/tests/snap/hover/enum_members.snap.yml b/sources/clice/tests/snap/hover/enum_members.snap.yml new file mode 100644 index 000000000..9ec5d889b --- /dev/null +++ b/sources/clice/tests/snap/hover/enum_members.snap.yml @@ -0,0 +1,53 @@ +--- +created_at: 2026-10-09 +input_file: enum_members.cpp +--- +dependent: { range: "31:4-31:8" } +### enum `Size` + +--- +```cpp +// In Holder +public: enum Size { None, Bytes = sizeof(T), Twice } +``` + +empty: { range: "25:0-25:3" } +### enum `Tag` + +--- +```cpp +// In namespace empty +enum class Tag : int {} +``` + +implicit_values: { range: "5:0-5:5" } +### enum `Level` + +--- +```cpp +// In namespace implicit_values +enum Level { Low = 0, Medium = 10, High = 11 } +``` + +scoped: { range: "20:0-20:8" } +### enum `Ordering` + +--- +```cpp +// In namespace scoped +enum class Ordering : signed char { Less = -1, Equal = 0, Greater = 1 } +``` + +written_values: { range: "15:0-15:10" } +### enum `Permission` + +--- +```cpp +// In namespace written_values +enum Permission : unsigned int { + Read = 1 << 0, + Write = 1 << 1, + Execute = 1 << 2, + All = Read | Write | Execute +} +``` diff --git a/sources/clice/tests/snap/hover/hover_correctness/01_ms_inheritance.snap.yml b/sources/clice/tests/snap/hover/hover_correctness/01_ms_inheritance.snap.yml index 0a626b4f0..b668002b9 100644 --- a/sources/clice/tests/snap/hover/hover_correctness/01_ms_inheritance.snap.yml +++ b/sources/clice/tests/snap/hover/hover_correctness/01_ms_inheritance.snap.yml @@ -20,5 +20,7 @@ struct_hover: { range: "12:7-12:13" } --- ```cpp // In namespace ms -struct Widget {} +struct Widget { + int value; +} ``` diff --git a/sources/clice/tests/snap/hover/layout_information/02_type_layout.snap.yml b/sources/clice/tests/snap/hover/layout_information/02_type_layout.snap.yml index 5667122c5..360685953 100644 --- a/sources/clice/tests/snap/hover/layout_information/02_type_layout.snap.yml +++ b/sources/clice/tests/snap/hover/layout_information/02_type_layout.snap.yml @@ -11,5 +11,8 @@ Size: 16 bytes, alignment 8 bytes --- ```cpp // In namespace layout -struct Widget {} +struct Widget { + int id; + double value; +} ``` diff --git a/sources/clice/tests/snap/hover/member_truncation.cpp b/sources/clice/tests/snap/hover/member_truncation.cpp new file mode 100644 index 000000000..04b484907 --- /dev/null +++ b/sources/clice/tests/snap/hover/member_truncation.cpp @@ -0,0 +1,60 @@ +// Long member lists stop at the default limit of 20 entries, nested members +// included; huge initializers are left out of the summary. + +namespace long_record { +struct Registers { + int r00, r01, r02, r03, r04, r05, r06, r07, r08, r09; + int r10, r11, r12, r13, r14, r15, r16, r17, r18, r19; + int r20; +}; +§(long_record)Registers registers; +} + +namespace exact_record { +struct Registers { + int r00, r01, r02, r03, r04, r05, r06, r07, r08, r09; + int r10, r11, r12, r13, r14, r15, r16, r17, r18, r19; +}; +§(exact_record)Registers registers; +} + +namespace long_enum { +enum Opcode { + Op00, Op01, Op02, Op03, Op04, Op05, Op06, Op07, Op08, Op09, + Op10, Op11, Op12, Op13, Op14, Op15, Op16, Op17, Op18, Op19, + Op20, Op21, +}; +§(long_enum)Opcode opcode; +} + +namespace nested_cut { +struct Packet { + int r00, r01, r02, r03, r04, r05, r06, r07, r08, r09; + int r10, r11, r12, r13, r14, r15, r16, r17; + union { + int word; + short half; + char byte; + }; + int trailer; +}; +§(nested_cut)Packet packet; +} + +#define DUPLICATE_FOUR(x) x, x, x, x +#define DUPLICATE_256(x) DUPLICATE_FOUR(DUPLICATE_FOUR(DUPLICATE_FOUR(DUPLICATE_FOUR(x)))) +#define SUM_FOUR(x) x + x + x + x +#define SUM_256(x) SUM_FOUR(SUM_FOUR(SUM_FOUR(SUM_FOUR(x)))) + +namespace huge_initializers { +struct Tables { + int large_field[256] = {DUPLICATE_256(0)}; + inline static int large_static[256] = {DUPLICATE_256(0)}; + int small_field = 1; + inline static int small_static = 2; +}; +§(huge_record_initializers)Tables tables; + +enum Sum { Small = 1, Large = SUM_256(1) }; +§(huge_enumerator)Sum sum; +} diff --git a/sources/clice/tests/snap/hover/member_truncation.snap.yml b/sources/clice/tests/snap/hover/member_truncation.snap.yml new file mode 100644 index 000000000..476f4737e --- /dev/null +++ b/sources/clice/tests/snap/hover/member_truncation.snap.yml @@ -0,0 +1,151 @@ +--- +created_at: 2026-10-09 +input_file: member_truncation.cpp +--- +exact_record: { range: "17:0-17:9" } +### struct `Registers` + +--- +```cpp +// In namespace exact_record +struct Registers { + int r00; + int r01; + int r02; + int r03; + int r04; + int r05; + int r06; + int r07; + int r08; + int r09; + int r10; + int r11; + int r12; + int r13; + int r14; + int r15; + int r16; + int r17; + int r18; + int r19; +} +``` + +huge_enumerator: { range: "58:0-58:3" } +### enum `Sum` + +--- +```cpp +// In namespace huge_initializers +enum Sum { Small = 1, Large = 256 } +``` + +huge_record_initializers: { range: "55:0-55:6" } +### struct `Tables` + +--- +```cpp +// In namespace huge_initializers +struct Tables { + int large_field[256]; + static int large_static[256]; + int small_field = 1; + static int small_static = 2; +} +``` + +long_enum: { range: "26:0-26:6" } +### enum `Opcode` + +--- +```cpp +// In namespace long_enum +enum Opcode { + Op00 = 0, + Op01 = 1, + Op02 = 2, + Op03 = 3, + Op04 = 4, + Op05 = 5, + Op06 = 6, + Op07 = 7, + Op08 = 8, + Op09 = 9, + Op10 = 10, + Op11 = 11, + Op12 = 12, + Op13 = 13, + Op14 = 14, + Op15 = 15, + Op16 = 16, + Op17 = 17, + Op18 = 18, + Op19 = 19, + // ... +} +``` + +long_record: { range: "9:0-9:9" } +### struct `Registers` + +--- +```cpp +// In namespace long_record +struct Registers { + int r00; + int r01; + int r02; + int r03; + int r04; + int r05; + int r06; + int r07; + int r08; + int r09; + int r10; + int r11; + int r12; + int r13; + int r14; + int r15; + int r16; + int r17; + int r18; + int r19; + // ... +} +``` + +nested_cut: { range: "40:0-40:6" } +### struct `Packet` + +--- +```cpp +// In namespace nested_cut +struct Packet { + int r00; + int r01; + int r02; + int r03; + int r04; + int r05; + int r06; + int r07; + int r08; + int r09; + int r10; + int r11; + int r12; + int r13; + int r14; + int r15; + int r16; + int r17; + union { + int word; + // ... + }; + // ... +} +``` diff --git a/sources/clice/tests/snap/hover/module_related/03_export_status.snap.yml b/sources/clice/tests/snap/hover/module_related/03_export_status.snap.yml index f47e1b5f9..fa7afc920 100644 --- a/sources/clice/tests/snap/hover/module_related/03_export_status.snap.yml +++ b/sources/clice/tests/snap/hover/module_related/03_export_status.snap.yml @@ -23,7 +23,9 @@ Size: 4 bytes, alignment 4 bytes --- ```cpp -export struct Square {} +export struct Square { + int side; +} ``` internal_fn: { range: "22:4-22:13" } diff --git a/sources/clice/tests/snap/hover/record_members.cpp b/sources/clice/tests/snap/hover/record_members.cpp new file mode 100644 index 000000000..7838d0b37 --- /dev/null +++ b/sources/clice/tests/snap/hover/record_members.cpp @@ -0,0 +1,182 @@ +// The member summary of a class: which members it lists, access sections, +// nested and unnamed types, templates. + +namespace access_sections { +struct Base { + int base_field; +}; + +class Widget : public Base { + int id; + +public: + using Size = unsigned long; + template using Pointer = T*; + static constexpr int limit = 4; + enum class Kind { Small, Large }; + struct Node { + int hidden; + }; + struct Forward; + template struct Nested { + T hidden; + }; + + Widget(); + ~Widget(); + void reset(); + operator bool() const; + friend struct Base; + using Base::base_field; + static_assert(limit > 0); + +protected: + void helper(); + +private: + static int instances; + mutable int cache = 0; + unsigned flags : 3; +}; + +void use() { + §(class_sections)Widget widget; + Widget::§(nested_type)Node node; +} +} + +namespace functions_only { +struct Service { + Service(); + void start(); + void stop(); +}; +§(functions_only)Service service; +} + +namespace unnamed_members { +struct Value { + enum { inline_capacity = 16 }; + int kind; + union { + long integer; + double decimal; + }; + struct { + int x, y; + } position, *previous; + struct Named { + int z; + } named; + alignas(8) union { + int bits; + float real; + } aligned[2]; + typedef struct { + int first, second; + } Pair; + static struct { + int count; + } shared; +}; +§(unnamed_members)Value current; +} + +namespace templates { +template struct Box { + using value_type = T; + T value; + template static constexpr bool holds = false; + template static constexpr bool holds = true; + template struct Rebind {}; + template struct Rebind {}; + struct Inner { + T hidden; + }; + void clear(); +}; + +template struct Box { + T* pointer; +}; + +template <> struct Box { + unsigned char bits; +}; + +template struct §(primary_declaration)Box; +template void take(§(primary_use)Box box); +§(implicit_instantiation)Box integer; +§(partial_specialization)Box pointer; +§(explicit_specialization)Box flag; +} + +namespace instantiated_unnamed { +template struct Expected { + union { + T value; + int error; + }; + struct { + T low, high; + } range, *last; + enum { capacity = sizeof(T) }; + struct { + T* next; + } *lazy; + bool has_error : 1; +}; +§(instantiated_unnamed)Expected expected; +} + +namespace declarator_specifiers { +struct Device { + volatile struct { + unsigned control; + unsigned status; + } registers; + mutable struct { + int hits; + } cache; + const struct Limits { + int low, high; + } limits{0, 1}; + void attach(struct Driver* driver); + typedef struct Handle* HandlePtr; + struct { + int id; + } queue[sizeof(struct Request*)], *head; +}; +§(declarator_specifiers)Device device; +} + +namespace forward_declared { +struct Later; +§(before_definition)Later* later; +struct Later { + int value; +}; +} + +namespace redeclared_nested { +class Tree { + struct Node; + template struct Visitor; + Node* root; + struct Node { + int value; + }; + template struct Visitor {}; +}; +§(redeclared_nested)Tree tree; +} + +namespace derived_members { +struct Shape { + int sides; +}; +struct Square final : Shape { + int length; +}; +§(derived)Square square; +} diff --git a/sources/clice/tests/snap/hover/record_members.snap.yml b/sources/clice/tests/snap/hover/record_members.snap.yml new file mode 100644 index 000000000..734a718cb --- /dev/null +++ b/sources/clice/tests/snap/hover/record_members.snap.yml @@ -0,0 +1,225 @@ +--- +created_at: 2026-10-09 +input_file: record_members.cpp +--- +before_definition: { range: "154:0-154:5" } +### struct `Later` + +--- +```cpp +// In namespace forward_declared +struct Later { + int value; +} +``` + +class_sections: { range: "42:4-42:10" } +### class `Widget` + +--- +```cpp +// In namespace access_sections +class Widget : public Base { + int id; + +public: + using Size = unsigned long; + template using Pointer = T *; + static constexpr int limit = 4; + enum class Kind : int; + struct Node; + struct Forward; + template struct Nested; + +private: + static int instances; + mutable int cache = 0; + unsigned int flags : 3; +} +``` + +declarator_specifiers: { range: "149:0-149:6" } +### struct `Device` + +--- +```cpp +// In namespace declarator_specifiers +struct Device { + volatile struct { + unsigned int control; + unsigned int status; + } registers; + mutable struct { + int hits; + } cache; + const struct Limits limits{0, 1}; + typedef struct Handle *HandlePtr; + struct { + int id; + } queue[8], *head; +} +``` + +derived: { range: "180:0-180:6" } +### struct `Square` + +--- +```cpp +// In namespace derived_members +struct Square final : Shape { + int length; +} +``` + +explicit_specialization: { range: "110:0-110:3" } +### struct `Box` + +--- +```cpp +// In namespace templates +template <> struct Box { + unsigned char bits; +} +``` + +functions_only: { range: "53:0-53:7" } +### struct `Service` + +--- +```cpp +// In namespace functions_only +struct Service {} +``` + +implicit_instantiation: { range: "108:0-108:3" } +### struct `Box` + +--- +```cpp +// In namespace templates +template <> struct Box { + using value_type = int; + int value; + template static constexpr bool holds; + template struct Rebind; + struct Inner; +} +``` + +instantiated_unnamed: { range: "128:0-128:8" } +### struct `Expected` + +--- +```cpp +// In namespace instantiated_unnamed +template <> struct Expected { + union { + long value; + int error; + }; + struct { + long low; + long high; + } range, *last; + enum { capacity = sizeof(long) }; + struct { + // ... + } *lazy; + bool has_error : 1; +} +``` + +nested_type: { range: "43:12-43:16" } +### struct `Node` + +--- +```cpp +// In Widget +public: struct Node { + int hidden; +} +``` + +partial_specialization: { range: "109:0-109:3" } +### struct `Box` + +--- +```cpp +// In namespace templates +template <> struct Box { + int *pointer; +} +``` + +primary_declaration: { range: "106:29-106:32" } +### struct `Box` + +--- +```cpp +// In namespace templates +template struct Box { + using value_type = T; + T value; + template static constexpr bool holds = false; + template struct Rebind; + struct Inner; +} +``` + +primary_use: { range: "107:32-107:35" } +### struct `Box` + +--- +```cpp +// In namespace templates +template struct Box { + using value_type = T; + T value; + template static constexpr bool holds = false; + template struct Rebind; + struct Inner; +} +``` + +redeclared_nested: { range: "170:0-170:4" } +### class `Tree` + +--- +```cpp +// In namespace redeclared_nested +class Tree { + struct Node; + template struct Visitor; + Node *root; +} +``` + +unnamed_members: { range: "81:0-81:5" } +### struct `Value` + +--- +```cpp +// In namespace unnamed_members +struct Value { + enum { inline_capacity = 16 }; + int kind; + union { + long integer; + double decimal; + }; + struct { + int x; + int y; + } position, *previous; + struct Named named; + union { + int bits; + float real; + } aligned[2] alignas(8); + typedef struct { + int first; + int second; + } Pair; + static struct(unnamed) shared; +} +``` diff --git a/sources/clice/tests/snap/hover/special_hover_targets/01_type_members_on_hover.cpp b/sources/clice/tests/snap/hover/special_hover_targets/01_type_members_on_hover.cpp index 7a4261272..b8ddb4160 100644 --- a/sources/clice/tests/snap/hover/special_hover_targets/01_type_members_on_hover.cpp +++ b/sources/clice/tests/snap/hover/special_hover_targets/01_type_members_on_hover.cpp @@ -1,24 +1,29 @@ /// # Members on type hover /// -/// - status: partial +/// - status: supported /// - issues: clangd#959 +/// - config: {"max_members": 2} /// /// Hovering an enum or struct type lists its members /// -/// The card names the type (and a struct's layout), but the member list is -/// not expanded — the body renders as `{}`. +/// A class lists its data members and member types, an enum its +/// enumerators with their values; member functions are left out. The +/// `max_members` option caps the list, 20 entries by default, and `0` +/// turns it off. namespace members { enum Col§(enum_type)or { Red, - Green, + Green = 4, Blue, }; struct Poi§(struct_type)nt { - int x; - int y; + using Scalar = double; + Scalar x; + Scalar y; + Scalar length() const; }; } diff --git a/sources/clice/tests/snap/hover/special_hover_targets/01_type_members_on_hover.snap.yml b/sources/clice/tests/snap/hover/special_hover_targets/01_type_members_on_hover.snap.yml index 305a1494f..e4c6c443f 100644 --- a/sources/clice/tests/snap/hover/special_hover_targets/01_type_members_on_hover.snap.yml +++ b/sources/clice/tests/snap/hover/special_hover_targets/01_type_members_on_hover.snap.yml @@ -2,23 +2,58 @@ created_at: 2026-08-23 input_file: special_hover_targets/01_type_members_on_hover.cpp --- -enum_type: { range: "12:5-12:10" } -### enum `Color` +default: + enum_type: { range: "15:5-15:10" } + ### enum `Color` ---- -```cpp -// In namespace members -enum Color {} -``` + --- + ```cpp + // In namespace members + enum Color { Red = 0, Green = 4, Blue = 5 } + ``` -struct_type: { range: "18:7-18:12" } -### struct `Point` + struct_type: { range: "21:7-21:12" } + ### struct `Point` ---- -Size: 8 bytes, alignment 4 bytes + --- + Size: 16 bytes, alignment 8 bytes ---- -```cpp -// In namespace members -struct Point {} -``` + --- + ```cpp + // In namespace members + struct Point { + using Scalar = double; + Scalar x; + Scalar y; + } + ``` + +configured: + enum_type: { range: "15:5-15:10" } + ### enum `Color` + + --- + ```cpp + // In namespace members + enum Color { + Red = 0, + Green = 4, + // ... + } + ``` + + struct_type: { range: "21:7-21:12" } + ### struct `Point` + + --- + Size: 16 bytes, alignment 8 bytes + + --- + ```cpp + // In namespace members + struct Point { + using Scalar = double; + Scalar x; + // ... + } + ``` diff --git a/sources/clice/tests/snap/hover/symbol_information/02_symbol_kind.snap.yml b/sources/clice/tests/snap/hover/symbol_information/02_symbol_kind.snap.yml index d99d5f3bb..fd734de0f 100644 --- a/sources/clice/tests/snap/hover/symbol_information/02_symbol_kind.snap.yml +++ b/sources/clice/tests/snap/hover/symbol_information/02_symbol_kind.snap.yml @@ -8,7 +8,7 @@ enum: { range: "16:11-16:16" } --- ```cpp // In namespace kinds -enum class Color : int {} +enum class Color : int { Red = 0 } ``` enumerator: { range: "17:4-17:7" } @@ -69,7 +69,9 @@ Size: 4 bytes, alignment 4 bytes --- ```cpp // In namespace kinds -struct Point {} +struct Point { + int x; +} ``` typedef: { range: "20:6-20:11" } @@ -93,5 +95,7 @@ Size: 4 bytes, alignment 4 bytes --- ```cpp // In namespace kinds -union Packet {} +union Packet { + int raw; +} ``` diff --git a/sources/clice/tests/snap/hover/tag_decls.snap.yml b/sources/clice/tests/snap/hover/tag_decls.snap.yml index 7fe744d4e..926986ec8 100644 --- a/sources/clice/tests/snap/hover/tag_decls.snap.yml +++ b/sources/clice/tests/snap/hover/tag_decls.snap.yml @@ -26,7 +26,10 @@ class Controller {} --- ```cpp // In namespace union_use::model -union Storage {} +union Storage { + long integer; + double decimal; +} ``` 04_forward_class: { range: "27:0-27:7" } @@ -44,7 +47,7 @@ class Session {} --- ```cpp // In namespace enum_use -enum Direction {} +enum Direction { North = 0, East = 1, South = 2, West = 3 } ``` 06_enumerator: { range: "37:19-37:23" } diff --git a/sources/clice/tests/snap/hover/templates.snap.yml b/sources/clice/tests/snap/hover/templates.snap.yml index 791c4d06b..d2c565587 100644 --- a/sources/clice/tests/snap/hover/templates.snap.yml +++ b/sources/clice/tests/snap/hover/templates.snap.yml @@ -329,7 +329,9 @@ typename... Types --- ```cpp // In namespace injected_name -template struct Link {} +template struct Link { + Link *next; +} ``` 30_dependent_method: { range: "167:14-167:19" } @@ -451,7 +453,7 @@ struct Item {} --- ```cpp // In namespace explicit_instantiation -template <> struct Box +template <> struct Box {} ``` 41_function_directive: { range: "240:14-240:17" } diff --git a/sources/clice/tests/snap/hover/type_information/08_instantiation_args.snap.yml b/sources/clice/tests/snap/hover/type_information/08_instantiation_args.snap.yml index 61eb44f52..e770e983a 100644 --- a/sources/clice/tests/snap/hover/type_information/08_instantiation_args.snap.yml +++ b/sources/clice/tests/snap/hover/type_information/08_instantiation_args.snap.yml @@ -8,7 +8,9 @@ input_file: type_information/08_instantiation_args.cpp --- ```cpp // In namespace instantiation_args -template <> struct Wrapper {} +template <> struct Wrapper { + int value; +} ``` 02_call: { range: "23:10-23:18" } diff --git a/zh/clice/features/hover.md b/zh/clice/features/hover.md index a1ec18cb9..8252a4fa3 100644 --- a/zh/clice/features/hover.md +++ b/zh/clice/features/hover.md @@ -709,13 +709,13 @@ tests/snap/hover/macro_hover/06_preamble_define_hover.cpp - + **类型悬停中的成员** 悬停于枚举或结构体类型时,会列出其成员 -卡片显示类型名称(对于结构体,还会显示其布局),但不展开成员列表,类型体显示为 `{}`。 +类会列出其数据成员和成员类型,枚举会列出其枚举项及对应的值;成员函数不会列出。`max_members` 选项限制列表的条目数,默认为 20,设为 `0` 则关闭该列表。 ```snap tests/snap/hover/special_hover_targets/01_type_members_on_hover.cpp diff --git a/zh/clice/features/overview.md b/zh/clice/features/overview.md index 9453e9faa..a9f64e777 100644 --- a/zh/clice/features/overview.md +++ b/zh/clice/features/overview.md @@ -16,7 +16,7 @@ clice 提供一套基于 LLVM/Clang 构建的 C++ 开发工具。本节介绍已 | 功能 | 状态 | | ---------------------------------- | ------------------------------------------ | | [代码补全](./completion.md) | 支持 57 项 | -| [悬停](./hover.md) | 支持 37 项 · 部分支持 20 项 · 不支持 10 项 | +| [悬停](./hover.md) | 支持 38 项 · 部分支持 19 项 · 不支持 10 项 | | [签名帮助](./signature-help.md) | 支持 14 项 | | [代码导航](./navigation.md) | 支持 71 项 · 部分支持 12 项 · 不支持 26 项 | | [文档链接](./document-links.md) | 支持 7 项 · 部分支持 1 项 · 不支持 1 项 | diff --git a/zh/clice/guide/configuration.md b/zh/clice/guide/configuration.md index 0f82bbbf0..4295864cc 100644 --- a/zh/clice/guide/configuration.md +++ b/zh/clice/guide/configuration.md @@ -212,6 +212,16 @@ clice 会在后台查看磁盘上的文件,以发现编辑器之外发生的 +
+ +| 选项 | 类型 | 默认值 | +| ------------- | -------- | ------ | +| `max_members` | `uint32` | `20` | + +悬停类或枚举时,其定义中最多列出的成员数:类的数据成员和成员类型,或枚举的枚举项;成员函数不列出。`0` 表示只显示声明。 + +
+ ## `[inlay_hints]`