Skip to content

[#1175] Empty Entity Parsing#1176

Merged
parsonsmatt merged 6 commits into
masterfrom
matt/1175-empty-entity-parse
Dec 11, 2020
Merged

[#1175] Empty Entity Parsing#1176
parsonsmatt merged 6 commits into
masterfrom
matt/1175-empty-entity-parse

Conversation

@parsonsmatt

@parsonsmatt parsonsmatt commented Dec 11, 2020

Copy link
Copy Markdown
Collaborator

Before submitting your PR, check that you've:

After submitting your PR:

  • Update the Changelog.md file with a link to your PR
  • Bumped the version number if there isn't an (unreleased) on the Changelog
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

Fixes #1175


Currently just a failing test. I should really get this fixed soon.

@parsonsmatt

Copy link
Copy Markdown
Collaborator Author

Test failure message:

  test/main.hs:316:13:
  1) #1175 empty entity associateLines works
       Actual list is not a permutation of expected list!
         expected list contains:   [LinesWithComments {lwcLines = Line {lineIndent = 0, tokens = "Foo" :|
 []} :| [Line {lineIndent = 4, tokens = "name" :| ["String"]},Line {lineIndent = 4, tokens = "age" :| ["I
nt"]}], lwcComments = []}, LinesWithComments {lwcLines = Line {lineIndent = 0, tokens = "EmptyEntity" :|
[]} :| [], lwcComments = []}, LinesWithComments {lwcLines = Line {lineIndent = 0, tokens = "Bar" :| []} :
| [Line {lineIndent = 4, tokens = "name" :| ["String"]}], lwcComments = []}, LinesWithComments {lwcLines
= Line {lineIndent = 0, tokens = "Baz" :| []} :| [Line {lineIndent = 4, tokens = "a" :| ["Int"]},Line {li
neIndent = 4, tokens = "b" :| ["String"]},Line {lineIndent = 4, tokens = "c" :| ["FooId"]}], lwcComments
= []}]
         actual list contains:     [LinesWithComments {lwcLines = Line {lineIndent = 0, tokens = "Foo" :|
 []} :| [Line {lineIndent = 4, tokens = "name" :| ["String"]},Line {lineIndent = 4, tokens = "age" :| ["I
nt"]}], lwcComments = []}, LinesWithComments {lwcLines = Line {lineIndent = 0, tokens = "EmptyEntity" :|
[]} :| [Line {lineIndent = 0, tokens = "Bar" :| []},Line {lineIndent = 4, tokens = "name" :| ["String"]}]
, lwcComments = []}, LinesWithComments {lwcLines = Line {lineIndent = 0, tokens = "Baz" :| []} :| [Line {
lineIndent = 4, tokens = "a" :| ["Int"]},Line {lineIndent = 4, tokens = "b" :| ["String"]},Line {lineInde
nt = 4, tokens = "c" :| ["FooId"]}], lwcComments = []}]
         the missing elements are: [LinesWithComments {lwcLines = Line {lineIndent = 0, tokens = "EmptyEn
tity" :| []} :| [], lwcComments = []}, LinesWithComments {lwcLines = Line {lineIndent = 0, tokens = "Bar"
 :| []} :| [Line {lineIndent = 4, tokens = "name" :| ["String"]}], lwcComments = []}]
         the extra elements are:   [LinesWithComments {lwcLines = Line {lineIndent = 0, tokens = "EmptyEn
tity" :| []} :| [Line {lineIndent = 0, tokens = "Bar" :| []},Line {lineIndent = 4, tokens = "name" :| ["S
tring"]}], lwcComments = []}]

Or, with formatting,

expected =
    [ LinesWithComments
        {lwcLines = Line {lineIndent = 0, tokens = "Foo" :|
     []} :| [Line {lineIndent = 4, tokens = "name" :| ["String"]},Line {lineIndent = 4, tokens = "age" :| ["I
    nt"]}], lwcComments = []}, LinesWithComments {lwcLines = Line {lineIndent = 0, tokens = "EmptyEntity" :|
    []} :| [], lwcComments = []}
    , LinesWithComments
        {lwcLines = Line {lineIndent = 0, tokens = "Bar" :| []} : | [Line {lineIndent = 4, tokens = "name" :| ["String"]}], lwcComments = []}
    , LinesWithComments
        { lwcLines =
            Line {lineIndent = 0, tokens = "Baz" :| []} :|
                [ Line
                    { lineIndent = 4
                    , tokens = "a" :| ["Int"]
                    }
                , Line
                    { lineIndent = 4
                    , tokens = "b" :| ["String"]
                    }
                , Line {lineIndent = 4, tokens = "c" :| ["FooId"]}]
        , lwcComments = []
        }
]

actual =
    [ LinesWithComments
        { lwcLines =
            Line { lineIndent = 0 , tokens = "Foo" :| [] } :|
                [ Line { lineIndent = 4, tokens = "name" :| ["String"]}
                , Line { lineIndent = 4, tokens = "age" :| ["Int"]}
                ]
        , lwcComments = []
        }
    , LinesWithComments
        { lwcLines =
            Line {lineIndent = 0, tokens = "EmptyEntity" :| []} :|
                [ Line {lineIndent = 0, tokens = "Bar" :| []}
                , Line {lineIndent = 4, tokens = "name" :| ["String"]}
                ]
        , lwcComments = []
        }
    , LinesWithComments
        { lwcLines = Line {lineIndent = 0, tokens = "Baz" :| []} :|
            [ Line { lineIndent = 4, tokens = "a" :| ["Int"]}
            , Line {lineIndent = 4, tokens = "b" :| ["String"]}
            , Line {lineIndent = 4, tokens = "c" :| ["FooId"]}
            ]
        , lwcComments = []
        }
    ]

missing =
        [ LinesWithComments
            { lwcLines = Line {lineIndent = 0, tokens = "EmptyEntity" :| []} :| []
            , lwcComments = []
            }
        , LinesWithComments
            { lwcLines = Line {lineIndent = 0, tokens = "Bar":| []} :| [Line {lineIndent = 4, tokens = "name" :| ["String"]}]
            , lwcComments = []
            }
        ]

extra =
    [ LinesWithComments
        { lwcLines = Line {lineIndent = 0, tokens = "EmptyEntity" :| []} :|
            [ Line {lineIndent = 0, tokens = "Bar" :| []}
            , Line {lineIndent = 4, tokens = "name" :| ["String"]}
            ]
        , lwcComments = []
        }
    ]

So, what's happening is that the parser is recognizing the syntax and combining EmptyEntity and Bar into a single LinesWIthComments record, when in reality, they should be split.

@parsonsmatt

Copy link
Copy Markdown
Collaborator Author

By using Debug.traceShowId, I'm able to determine the exact cause of the problem in associateLines:

associateLines :: [Line' NonEmpty] -> [LinesWithComments]
associateLines lines =
    foldr combine [] $
    Debug.traceShowId $
    foldr toLinesWithComments [] lines
  where

So the problem occurs in toLinesWIthComments.

@parsonsmatt parsonsmatt merged commit 8e92f11 into master Dec 11, 2020
@parsonsmatt parsonsmatt deleted the matt/1175-empty-entity-parse branch April 1, 2021 16:55
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

Successfully merging this pull request may close these issues.

Migration doesn't migrate all tables if a atable with no fields exists in models

1 participant