BalticAmadeus / AblFormatter

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

variable of two keywords got splited during parsing #113

Open eglekaz opened 2 months ago

eglekaz commented 2 months ago

Variable outputStream in VAR statement was recognized as identifier, but later parsed as two separate keywords, which brings up error and rest of the file is not being formatted.

Example:

method public void WriteJson(filePath as char, inputJson as Object):
    var JsonSerializer jsonSerializer = new JsonSerializer(true).
    var FileOutputStream outputStream = new FileOutputStream(filePath).

    jsonSerializer:Serialize(inputJson, outputStream).
    outputStream:Close().
end method.

image image image image

eglekaz commented 2 months ago

Same happened with inputTable. And then after this it even thought that "def" in word "default" is DEFINE. Example: This:

if inputTable:default-buffer-handle:available = false then
      undo, throw new AppException(ErrorCode:RECORD_NOT_FOUND, inputTable:name).

Became this: if inputTable:defineault-buffer-handle:available = false then undo, throw new AppException(ErrorCode:RECORD_NOT_FOUND, inputTable:name).

eglekaz commented 2 months ago

Adding description from other issue as well (Cannot name variables that start with "for" or "define"): For example,

case dateFormat:
    when "YYYYYMMDD"
    then
        formattedDate = STRING(day, "99").
    otherwise
        message "HEEOLOO".
end.

turns into:

case dateFormat:
    when "YYYYYMMDD"
    then for
        mattedDate = STRING(day, "99").
    otherwise
        message "HEEOLOO".
end.

Similarly, if you use "define," it can result in:

case dateFormat:
    when "YYYYYMMDD"
    then define
        mattedDate = STRING(day, "99").
    otherwise
        message "HEEOLOO".
end.

image

eglekaz commented 2 months ago

Registered: https://github.com/usagi-coffee/tree-sitter-abl/issues/53