Skip to content

Fix code completion support for local structs in GDScript - #1448

Merged
Arctis-Fireblight merged 1 commit into
Redot-Engine:masterfrom
Arctis-Fireblight:fix-gh1434
Sep 27, 2026
Merged

Arctis-Fireblight merged 1 commit into
Redot-Engine:masterfrom
Arctis-Fireblight:fix-gh1434

Conversation

@Arctis-Fireblight

@Arctis-Fireblight Arctis-Fireblight commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor
  • Extend GDScript editor to handle code completion for locally defined structs.
  • Add tests for local member and parameter struct type completions.
  • Update configuration files to include new struct-based test cases.

Fixes #1434

Summary by CodeRabbit

  • New Features
    • GDScript code completion now suggests nested structs from the current class and its outer classes when entering a type annotation.
    • Nested structs are not suggested when completion is limited to inheritable types.

- Extend GDScript editor to handle code completion for locally defined structs.
- Add tests for local member and parameter struct type completions.
- Update configuration files to include new struct-based test cases.
@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: Redot-Engine/redot-engine/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: fa1000eb-92f9-42ee-bcfd-972dd4b7e307

📥 Commits

Reviewing files that changed from the base of the PR and between 39c6dda and d7011b0.

📒 Files selected for processing (5)
  • modules/gdscript/gdscript_editor.cpp
  • modules/gdscript/tests/scripts/completion/struct/struct_local_member_type.cfg
  • modules/gdscript/tests/scripts/completion/struct/struct_local_member_type.gd
  • modules/gdscript/tests/scripts/completion/struct/struct_local_parameter_type.cfg
  • modules/gdscript/tests/scripts/completion/struct/struct_local_parameter_type.gd

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


Walkthrough

Code completion now offers nested structs from the current and outer classes when suggesting types for member and parameter annotations. It does not include nested structs when suggestions are restricted to inheritable types. New fixtures cover both annotation contexts.

Changes

Nested struct type completion

Layer / File(s) Summary
Nested struct type suggestions
modules/gdscript/gdscript_editor.cpp, modules/gdscript/tests/scripts/completion/struct/struct_local_member_type.*, modules/gdscript/tests/scripts/completion/struct/struct_local_parameter_type.*
_list_available_types adds nested structs from the current and outer classes to non-inheritance type suggestions. Fixtures cover member and parameter type annotations.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: mcdubhghlas, generalprotectionfault

Merge Risk: ⚪ Minimal · up to d7011

The change adds local struct suggestions for member and parameter annotations, with fixtures checking for both. No actionable merge-blocking risk is established.

Architecture Summary

Architecture risk: 🔵 Low · up to d7011

The change affects 1 system.

Changed systems: modules

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — modules (service) was modified; 5 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in modules/gdscript/gdscript_editor.cpp: _list_available_types now offers each current or outer class’s nested structs as class-type completion options, with local location ranking, when p_inherit_only is false. Structs are not added to inheritance-only suggestions.
  • observed — Modified behavior in modules/gdscript/tests/scripts/completion/struct/struct_local_member_type.cfg: Adds an output configuration that includes the LocalMemberType display.
  • observed — Modified behavior in modules/gdscript/tests/scripts/completion/struct/struct_local_member_type.gd: Adds the LocalMemberType struct with an integer value member and a top-level item declaration with an incomplete type annotation at the completion position.
  • observed — Modified behavior in modules/gdscript/tests/scripts/completion/struct/struct_local_parameter_type.cfg: Adds an output configuration including LocalParameterType.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (4 skipped: 4 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing GDScript code completion for locally defined structs.
Linked Issues check ✅ Passed Issue [#1434] requires completion for locally declared struct names in same-class variable types and function parameter types. The change adds GDScriptParser::ClassNode::Member::STRUCT handling in `…
Out of Scope Changes check ✅ Passed The pull request changes only GDScript completion logic and adds focused completion fixtures and expected-output configuration for the two cases in issue [#1434]. These changes directly support the is…
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (4 skipped: 4 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Arctis-Fireblight
Arctis-Fireblight merged commit 20c3300 into Redot-Engine:master Sep 27, 2026
19 checks passed
@Arctis-Fireblight
Arctis-Fireblight deleted the fix-gh1434 branch September 27, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

26.3.beta.1 – GDScript Structs – Inconsistent code completion behavior, especially when statically typing variables

1 participant