Skip to content

Missing last leading comments with namespace #593

@abdul-alhasany

Description

@abdul-alhasany

Hi,
I am trying to parse a file with a file level comment. This parse works fine when not using a namespace. However, with namespace the leadingComments node is missing the last one. The comment exists in the comments node.

When I try the code on ASTexplore everything is fine. The problem only occurs when using node.

This is what I have at top level:

/**
 * File leve comment
 *
 * @package testing
 */

/**
 * namespace comment
 *
 * Another top level comment
 */

// Testing another comment

/*
One more comment
*/

and this is the json produced:

[{
    "kind": "commentblock",
    "loc": {
        "source": null,
        "start": {
            "line": 2,
            "column": 0,
            "offset": 6
        },
        "end": {
            "line": 6,
            "column": 3,
            "offset": 57
        }
    },
    "value": "/**\n * File leve comment\n *\n * @package testing\n */",
    "offset": 6
}, {
    "kind": "commentblock",
    "loc": {
        "source": null,
        "start": {
            "line": 8,
            "column": 0,
            "offset": 59
        },
        "end": {
            "line": 12,
            "column": 3,
            "offset": 119
        }
    },
    "value": "/**\n * namespace comment\n *\n * Another top level comment\n */",
    "offset": 59
}, {
    "kind": "commentline",
    "loc": {
        "source": null,
        "start": {
            "line": 14,
            "column": 0,
            "offset": 121
        },
        "end": {
            "line": 15,
            "column": 0,
            "offset": 148
        }
    },
    "value": "// Testing another comment\n",
    "offset": 121
}]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions