[display] don't serialize the full declaring type into completion item origins - #12973
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each completion item carries an
originidentifying 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_minimalflag 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.