godotengine / godotengine/godot
Abstract functions will have comments when they are completed during inheritance
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
v4.5.stable.official [876b29033]
### System information
Godot v4.5.stable - Windows 10 (build 19045) - Multi-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2060 with Max-Q Design (NVIDIA; 31.0.15.1700) - AMD Ryzen 7 4800H with Radeon Graphics (16 threads) - 23.37 GiB memory
### Issue description
I created a class using abstract class keywords and added some abstract functions, then wrote comments for the functions. When I implemented the inheritance class of this class, I found that when completing abstract methods, I would insert the comments of the next function as completion content into the code.
### Steps to reproduce
StateBase.gd
``` gdscript
## StateBase
@abstract
class_name StateBase
extends Node
var state_machine: StateMachine
## enter state
func enter() -> void:
pass
## exit state
@abstract func exit() -> void
@abstract func process_update(delta: float) -> void
## every physics process
@abstract func physical_process_update(delta: float) -> void
```
Another code file:
``` gdscript
extends StateBase
func pr
```
At this point, a completion prompt will appear with comments for the parent class declaration file.
If it is the `enter` method, it will not trigger the problem as it is not an abstract method.
If it is the `exit` method, the absence of comments in the next function `process_update` will not trigger an issue.
### Minimal reproduction project (MRP)
[godot-test-4.5.zip](https://github.com/user-attachments/files/22359960/godot-test-4.5.zip)
Contributor guide
Research direction
Start with the attached godot-test-4.5.zip reproduction, then compare StateBase.gd with the derived code file where `func pr` triggers completion. Reproduce the abstract-method suggestions for `exit`, `process_update`, and `physical_process_update`; done means completing an abstract method no longer inserts comments from the following parent function.
Written by the indexing model from the issue text.
Assessment
- Domain
- devtools, game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100