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

Missing last leading comments with namespace #593

Open
abdul-alhasany opened this issue Aug 15, 2020 · 0 comments
Open

Missing last leading comments with namespace #593

abdul-alhasany opened this issue Aug 15, 2020 · 0 comments

Comments

@abdul-alhasany
Copy link

abdul-alhasany commented Aug 15, 2020

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
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant