Skip to content

[display] don't serialize the full declaring type into completion item origins - #12973

Merged
Simn merged 4 commits into
developmentfrom
fix/huge-completion-response
Jun 30, 2026
Merged

[display] don't serialize the full declaring type into completion item origins#12973
Simn merged 4 commits into
developmentfrom
fix/huge-completion-response

Conversation

@kLabz

@kLabz kLabz commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Each completion item carries an origin identifying where the field comes from (Self/StaticImport/Parent/StaticExtension). For a ClassField, the origin was serialized as the entire declaring module type with all fields fully expanded via generate_module_type. A field inherited from a big class dragged that whole class's field list into every item that came from it, so completion responses ballooned (one real project: ~27 MB for ~340 items, ~83 KB/item), which clients then spent seconds parsing.

Add a generate_minimal flag to the genjson context. When set, generate_class emits empty fields/statics/overrides and null constructor/init, and generate_enum emits empty constructors; the type's identifying data (pack/name/moduleName/pos/meta/params/kind, class kind+isInterface, typedef type) is kept. ClassFieldOrigin.to_json now serializes origins through such a context, so an origin only identifies its declaring type instead of inlining its members. Scoped to completion origins; the completionItem/resolve path and full type listings are unaffected.

Same project now returns ~0.73 MB (~2.1 KB/item).
Ran haxe LSP tests with this, no failure.

kLabz added 4 commits June 30, 2026 10:52
…m origins

Each completion item carries an `origin` identifying where the field comes
from (Self/StaticImport/Parent/StaticExtension). For a ClassField, the origin
was serialized as the entire declaring module type with all fields fully
expanded via generate_module_type. A field inherited from a big class dragged
that whole class's field list into every item that came from it, so completion
responses ballooned (one real project: ~27 MB for ~340 items, ~83 KB/item),
which clients then spent seconds parsing.

Add a `generate_minimal` flag to the genjson context. When set, generate_class
emits empty fields/statics/overrides and null constructor/init, and
generate_enum emits empty constructors; the type's identifying data
(pack/name/moduleName/pos/meta/params/kind, class kind+isInterface, typedef
type) is kept. ClassFieldOrigin.to_json now serializes origins through such a
context, so an origin only identifies its declaring type instead of inlining
its members. Scoped to completion origins; the completionItem/resolve path and
full type listings are unaffected.

Same project now returns ~0.73 MB (~2.1 KB/item).
Replace the generation_mode enum with explicit generate_* booleans on the
context, built via create_full_config / create_minimal_config presets:

- drop the unconstructable GMWithoutDoc variant
- generation_mode (GMFull/GMMinimum) -> generate_docs / generate_exprs /
  generate_origins
- generate_minimal -> generate_member_bodies
- remove the now-single-use create_json_context helper, inlining the
  resolve-aware choice at its one call site
@Simn
Simn merged commit 23f8f98 into development Jun 30, 2026
108 of 109 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants