Skip to content

gdradon cc reports incorrect line numbers #421

Description

@stuartwakefield

The gdradon cc command appears to be reporting the line numbers of the converted code rather than the original source GDScript line number.

Minimal reproduction

Given the file example.gd:

extends Node3D

@export var name = "World"

func _ready():
        print("Hello, %s!" % name)

When running the following command:

gdradon cc example.gd

Outputs the following:

example.gd
    F 3:0 _ready - A (1)

Expected the following:

example.gd
    F 5:0 _ready - A (1)

Relevant code

The code is converted from GDScript to Python here:
https://github.com/Scony/godot-gdscript-toolkit/blob/master/gdtoolkit/gdradon/__main__.py#L45

Code complexity is calculated in this call using the converted Python code python_code:
https://github.com/Scony/godot-gdscript-toolkit/blob/master/gdtoolkit/gdradon/__main__.py#L46

Line number is extracted from result:
https://github.com/Scony/godot-gdscript-toolkit/blob/master/gdtoolkit/gdradon/__main__.py#L59

Lark parser is configured to propagate_positions:
https://github.com/Scony/godot-gdscript-toolkit/blob/master/gdtoolkit/parser/parser.py#L88

Therefore, statement: Tree should have a property statement.meta.line:
https://github.com/Scony/godot-gdscript-toolkit/blob/master/gdtoolkit/gd2py/__init__.py#L35

This information could potentially be used to map converted code line numbers to source code line numbers. It might also be necessary to correctly map column numbers also.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions