BalticAmadeus / AblFormatter

Code formatter for Progress OpenEdge (ABL)
Apache License 2.0
6 stars 0 forks source link

INCLUDES and COMMENTS are not formatted #108

Closed eglekaz closed 1 month ago

eglekaz commented 2 months ago

Tree-sitter does not correctly recognize that classBody and body can start and end with an INCLUDE or COMMENT. Instead, it only considers include statements/comments as part of the body after the define statement.

SSaulenas commented 2 months ago

Tree-sitter does not correctly recognize that classBody and body can start and end with an include. Instead, it only considers include statements as part of the body after the define statement. For example:

class Class final:
    {include/ttSomething.i}
    define public property prop as decimal initial 3.0 no-undo
        get.
        private set.

    {include/ttSomething.i}

    constructor private Class( ):
        m_NumCusts = 0.
    end.

    {include/ttSomething.i}
end class.

First include: Image

Second include:

Image

Last include:

Image

eglekaz commented 2 months ago

Adding description from #122: Tree-sitter does not correctly recognize that classBody and body can start and end with a comment. Instead, it only considers comment statements as part of the body after the define statement. For example:

class Class final:
    ///Comment
    define public property prop as decimal initial 3.0 no-undo
        get.
        private set.

    ///Comment

    constructor private Class( ):
        m_NumCusts = 0.
    end.

    ///Comment
end class.

First comment:

Image

Second comment:

Image

Last comment:

Image

PauliusKu commented 2 months ago

Link: https://github.com/usagi-coffee/tree-sitter-abl/issues/57

PauliusKu commented 2 months ago

I see it's fixed, so moving to to test

eglekaz commented 2 months ago

TESTING This:

class myUtility:
// some comment
method public static int toInt(pcValue as char):
// some comment
DEFINE var iNumber as int no-undo initial ?.
// some comment
iNumber = int(pcValue) no-error.
// some comment
return iNumber.
// some comment
end.
// some comment
end class.

Becomes this:

class myUtility:
  // some comment
  method public static int toInt(pcValue as char):
  // some comment
     DEFINE var iNumber as int no-undo initial ?.
     // some comment
     iNumber = int(pcValue) no-error.
     // some comment
     return iNumber.
     // some comment
  end.
  // some comment
end class.

First comment inside of the METHOD is not fully formatted, but seems to be recognized by tree-sitter. INCLUDES were formatted correctly with similar example.

PauliusKu commented 2 months ago

I think @gustason can check this issue further and create a solution. I will assign lower priority as I see that the issue appear only with some comments.

gustason commented 2 months ago

This issue has been fixed after the recent tree-sitter update.

PauliusKu commented 1 month ago

Closing the ticket