Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDScript parser reports named enum as having the line number after the closing brace #35975

Closed
Tracked by #40488
Razoric480 opened this issue Feb 7, 2020 · 1 comment

Comments

@Razoric480
Copy link
Contributor

Razoric480 commented Feb 7, 2020

Godot version:
195655a
OS/device including version:
Windows 10
Issue description:
The ConstantNode is created at the very end, once the tokenizer has moved on past the closing brace, so the line number reported is the line after the enum.

This causes documentation generated by the language server to only report a single line of a docstring if it was after the enum, and nothing else - which goes against how everything else is documented.
Steps to reproduce:

# TestFile.gd
extends Reference

# SLIDE = 0
#    Uses `move_and_slide`
# COLLIDE = 1
#    Uses `move_and_collide`
# POSITION = 2
#    Changes global_position directly
enum MovementType { SLIDE, COLLIDE, POSITION }
# Demonstration of the issue

tool
extends EditorScript

func _run() -> void:
	print_json()

func print_json() -> void:
	var workspace = Engine.get_singleton('GDScriptLanguageProtocol').get_workspace()
	var symbols: Dictionary = workspace.generate_script_api("res://TestFile.gd")
	print(JSON.print(symbols, "  "))

Result:

{
  "name": "",
  "path": "res://TestFile.gd",
  "extends_class": [
    "Reference"
  ],
  "extends_file": "",
  "icon": "",
  "signature": "class TestFile.gd",
  "description": " TestFile.gd\n",
  "sub_classes": [

  ],
  "constants": [
    {
      "name": "MovementType",
      "value": {
        "SLIDE": 0,
        "COLLIDE": 1,
        "POSITION": 2
      },
      "data_type": "Dictionary",
      "signature": "const MovementType: Dictionary = {\"COLLIDE\":1,\"POSITION\":2,\"SLIDE\":0}",
      "description": " Demonstration of the issue\n"
    }
  ],
  "members": [

  ],
  "signals": [

  ],
  "methods": [

  ],
  "static_functions": [

  ]
}
@Razoric480 Razoric480 changed the title GDScript parser reports enum as having the line number after the closing brace GDScript parser reports named enum as having the line number after the closing brace Feb 7, 2020
@akien-mga akien-mga added this to the 4.0 milestone Feb 7, 2020
@akien-mga
Copy link
Member

Fixed in 3.2.3 by #41126. Should be fixed in master already according to @vnen (likely in the GDScript "2.0" rewrite).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants