8000 Feat/struct size info on hover by giuinktse7 · Pull Request #1 · giuinktse7/ols · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
57d1abd
WIP struct size info on hover
xdk78 Jul 28, 2025
c57c77c
Merge branch 'master' of https://github.com/DanielGavin/ols
xdk78 Jul 30, 2025
7d4e615
Merge branch 'master' of https://github.com/DanielGavin/ols
xdk78 Oct 25, 2025
b12039e
Merge branch 'master' into feat/struct-size-info-on-hover
giuinktse7 Sep 3, 2026
c334876
fix: update call-sites to use config
giuinktse7 Sep 3, 2026
e139beb
fix: prevent recursive pointer loops in struct size calculation
giuinktse7 Sep 3, 2026
8c5a5e2
fix: avoid reporting incomplete struct layouts on hover
giuinktse7 Sep 3, 2026
5f0e062
fix: use target-native widths for struct hover layouts
giuinktse7 Sep 3, 2026
09bc8b0
fix: account for struct layout directives in hover info
giuinktse7 Sep 3, 2026
0f488b5
fix: avoid double-counting promoted using fields in struct layouts
giuinktse7 Sep 3, 2026
c0b83b4
feat: support slices, dynamic arrays, maps, and enums in struct hover…
giuinktse7 Sep 3, 2026
cd82003
feat: support matrices in struct hover layouts
giuinktse7 Sep 3, 2026
dcff962
feat(server): add reusable integer constant evaluator
giuinktse7 Sep 3, 2026
b4a1f54
fix: use resolve_integer_constant in get_fixed_array_length
giuinktse7 Sep 3, 2026
384ff5f
feat(server): support bit set layouts in struct hovers
giuinktse7 Sep 3, 2026
456496d
feat(server): support fixed-capacity dynamic array layouts
giuinktse7 Sep 3, 2026
02ed320
Merge remote-tracking branch 'origin/master' into feat/struct-size-in…
giuinktse7 Sep 3, 2026
a3cc915
fix: prevent recursive struct layout crashes
giuinktse7 Sep 3, 2026
db66b83
fix: suppress incorrect SOA and SIMD layouts
giuinktse7 Sep 3, 2026
7929365
feat: support SIMD and SOA pointer layouts
giuinktse7 Sep 3, 2026
0227f0e
fix: restrict struct layout info to hover
giuinktse7 Sep 3, 2026
13c9200
fix: separate struct layout from hover documentation
giuinktse7 Sep 3, 2026
26890e3
feat: support remaining built-in type layouts
giuinktse7 Sep 3, 2026
99fa317
feat: evaluate extended integer constants in type layouts
giuinktse7 Sep 3, 2026
4a39663
fix: reject ambiguous typed complements in layout constants
giuinktse7 Sep 3, 2026
0720d29
feat: support bit fields and enumerated array layouts
giuinktse7 Sep 3, 2026
f53acf9
feat: show padding in struct layout hovers
giuinktse7 Sep 3, 2026
d05159c
fix: normalize package aliases in imported layouts
giuinktse7 Sep 3, 2026
fdc0cdf
fix: resolve layouts for empty enumerated arrays
giuinktse7 Sep 3, 2026
1b7907a
feat: add struct hover info support for union
giuinktse7 Sep 3, 2026
16320f4
feat: support #no_nil and #shared_nil union layouts
giuinktse7 Sep 3, 2026
7bba8b9
feat: support oversized union layouts
giuinktse7 Sep 3, 2026
8306e88
feat: support custom-aligned union layouts
giuinktse7 Sep 3, 2026
b70749d
feat: resolve specialized polymorphic union layouts
giuinktse7 Sep 3, 2026
46d673c
fix: suppress overflowing struct layouts
giuinktse7 Sep 3, 2026
92da45c
chore: formatting
giuinktse7 Sep 3, 2026
3c9fa69
fix: suppress typed arithmetic in layout constants
giuinktse7 Sep 3, 2026
4a6fdf4
fix: suppress hover layouts for explicit checker targets
giuinktse7 Sep 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions misc/ols.schema.json
8000
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
"type": "boolean",
"description": "Enables hover feature"
},
"enable_hover_struct_size_info": {
"type": "boolean",
"description": "Enables struct size and alignment information in hover.",
"default": false
},
"enable_procedure_context": { "type": "boolean" },
"enable_snippets": {
"type": "boolean",
Expand Down
1 change: 1 addition & 0 deletions src/common/config.odin
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Config :: struct {
verbose: bool,
enable_format: bool,
enable_hover: bool,
enable_hover_struct_size_info: bool,
enable_document_symbols: bool,
enable_semantic_tokens: bool,
enable_unused_imports_reporting: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/server/analysis.odin
Original file line number Diff line number Diff line change
Expand Up @@ -3067,7 +3067,7 @@ resolve_symbol_return :: proc(ast_context: ^AstContext, symbol: Symbol, ok := tr
append(&b.types, clone_expr(type, ast_context.allocator, nil))
}
b.poly = cast(^ast.Field_List)clone_type(v.poly, ast_context.allocator, nil)
resolve_poly_struct(ast_context, &b, v.poly)
apply_poly_arguments(ast_context, &b.types, &b.args, &b.poly_names, v.poly)
}

//expand the types and names from the using - can't be done while indexing without complicating everything(this also saves memory)
Expand Down
32 changes: 28 additions & 4 deletions src/server/collector.odin
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,11 @@ collect_bit_field_fields :: proc(
}
}

backing_type := clone_type(bit_field_type.backing_type, collection.allocator, &collection.unique_strings)
replace_package_alias(backing_type, package_map, collection)

value := SymbolBitFieldValue {
backing_type = clone_type(bit_field_type.backing_type, collection.allocator, &collection.unique_strings),
backing_type = backing_type,
names = names[:],
types = types[:],
ranges = ranges[:],
Expand All @@ -249,18 +252,24 @@ collect_enum_fields :: proc(
name, range, value := get_enum_field_name_range_value(n, file.src)
append(&names, strings.clone(name, collection.allocator))
append(&ranges, range)
append(&values, clone_type(value, collection.allocator, &collection.unique_strings))

cloned := clone_type(value, collection.allocator, &collection.unique_strings)
replace_package_alias(cloned, package_map, collection)
append(&values, cloned)
}

temp_docs, temp_comments := get_field_docs_and_comments(file, enum_type.fields, context.temp_allocator)
docs := clone_dynamic_array(temp_docs, collection.allocator, &collection.unique_strings)
comments := clone_dynamic_array(temp_comments, collection.allocator, &collection.unique_strings)

base_type := clone_type(enum_type.base_type, collection.allocator, &collection.unique_strings)
replace_package_alias(base_type, package_map, collection)

value := SymbolEnumValue {
names = names[:],
ranges = ranges[:],
values = values[:],
base_type = clone_type(enum_type.base_type, collection.allocator, &collection.unique_strings),
base_type = base_type,
comments = comments[:],
docs = docs[:],
}
Expand All @@ -285,14 +294,17 @@ collect_union_fields :: proc(
temp_docs, temp_comments := get_field_docs_and_comments(file, union_type.variants, context.temp_allocator)
docs := clone_dynamic_array(temp_docs, collection.allocator, &collection.unique_strings)
comments := clone_dynamic_array(temp_comments, collection.allocator, &collection.unique_strings)

align := clone_type(union_type.align, collection.allocator, &collection.unique_strings)
replace_package_alias(align, package_map, collection)

value := SymbolUnionValue {
types = types[:],
poly = cast(^ast.Field_List)clone_type(union_type.poly_params, collection.allocator, &collection.unique_strings),
comments = comments[:],
docs = docs[:],
kind = union_type.kind,
align = clone_type(union_type.align, collection.allocator, &collection.unique_strings),
align = align,
where_clauses = clone_array(union_type.where_clauses, collection.allocator, &collection.unique_strings),
}

Expand Down Expand Up @@ -894,14 +906,26 @@ collect_symbols :: proc(collection: ^SymbolCollection, file: ast.File, uri: stri
} else {
symbol.value = collect_array(collection, v^, package_map)
}
if array_is_soa(v^) {
symbol.flags |= {.Soa}
}
if array_is_simd(v^) {
symbol.flags |= {.Simd}
}
case ^ast.Dynamic_Array_Type:
token = v^
token_type = .Type
symbol.value = collect_dynamic_array(collection, v^, package_map)
if dynamic_array_is_soa(v^) {
symbol.flags |= {.Soa}
}
case ^ast.Fixed_Capacity_Dynamic_Array_Type:
token = v^
token_type = .Type
symbol.value = collect_fixed_cap_dynamic_array(collection, v^, package_map)
if fixed_cap_dynamic_array_is_soa(v^) {
symbol.flags |= {.Soa}
}
case ^ast.Multi_Pointer_Type:
token = v^
token_type = .Type
Expand Down
2 changes: 1 addition & 1 deletion src/server/completion.odin
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ convert_completion_results :: proc(
build_documentation(ast_context, &result.symbol, true)
item := CompletionItem {
label = result.symbol.name,
documentation = write_hover_content(ast_context, result.symbol),
documentation = write_symbol_content(ast_context, result.symbol),
sortText = fmt.tprintf("%05d", i),
}

Expand Down
Loading
Loading
0