Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

semantic: Discrepancy in parsing of header comments  #56

@r0mainK

Description

@r0mainK

Basically, if we have:

// comment 1
// comment 2
package foo
// comment 3
// comment 4
import "bar"

Then:

  • comment 1, comment 2, comment 3 and comment 4 go in the Comments attribute of the root node
  • comment 1 and comment 2 go in the Doc attribute of the root node
  • comment 3 and comment 4 go in the Doc attribute of the GenDecl node in the root node's Decl attribute

However, if we have:

// comment 1

// comment 2
package foo
// comment 3

// comment 4
import "bar"

Then:

  • comment 1, comment 2, comment 3 and comment 4 still go in the Comments attribute of the root node
  • only comment 2 goes in the Doc attribute of the root node
  • only comment 4 goes in the Doc attribute of the GenDecl node in the root node's Decl attribute

Basically, any comments placed before a newline before the package/import keywords get removed from the Doc attributes of the respective nodes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions