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

ChildrenOrder unexpected behaviour #421

Closed
ncordon opened this issue Aug 6, 2019 · 2 comments
Closed

ChildrenOrder unexpected behaviour #421

ncordon opened this issue Aug 6, 2019 · 2 comments
Assignees
Labels

Comments

@ncordon
Copy link
Member

ncordon commented Aug 6, 2019

Using the python-client

from bblfsh import *

def set_position(node: dict, start_offset: int, start_line: int, start_col: int,
                 end_offset: int, end_line: int, end_col: int) -> None:
            node["@pos"] = {
                "@type": "uast:Positions",
                "start": {
                    "@type": "uast:Position",
                    "offset": start_offset,
                    "line": start_line,
                    "col": start_col
                },
                "end": {
                    "@type": "uast:Position",
                    "offset": end_offset,
                    "line": end_line,
                    "col": end_col
                }
            }

root = {"@type": "root"}
set_position(root, 0,1,1, 1,1,2)

son1 = {"@type": "son1"}
set_position(son1, 2,2,2, 3,2,3)

son1_1 = {"@type": "son1_1"}
set_position(son1_1, 10,10,1, 12,2,2)

son1_2 = {"@type": "son1_2"}
set_position(son1_2, 10,10,1, 12,2,2)

son1["children"] = [son1_1, son1_2]

son2 = {"@type": "son2"}
set_position(son2, 100,100,1,  101,100,2)

son2_1 = {"@type": "son2_1"}
set_position(son2_1, 5,5,1, 6,5,2)

son2_2 = {"@type": "son2_2"}
set_position(son2_2, 15,15,1, 16,15,2)

son2["children"] = [son2_1, son2_2]
root["children"] = [son1, son2]


it = iterator(root, TreeOrder.CHILDREN_ORDER)
next(it)
#[{'@type': 'son1', '@pos': {'@type': 'uast:Positions', 'start': {'@type': 'uast:Position', 'offset': 2, 'line': 2, 'col': 2}, 'end': {'@type': 'uast:Position', 'offset': 3, 'line': 2, 'col': 3}}, 'children': [{'@type': 'son1_1', '@pos': {'@type': 'uast:Positions', 'start': {'@type': 'uast:Position', 'offset': 10, 'line': 10, 'col': 1}, 'end': {'@type': 'uast:Position', 'offset': 12, 'line': 2, 'col': 2}}}, {'@type': 'son1_2', '@pos': {'@type': 'uast:Positions', 'start': {'@type': 'uast:Position', 'offset': 10, 'line': 10, 'col': 1}, 'end': {'@type': 'uast:Position', 'offset': 12, 'line': 2, 'col': 2}}}]}, {'@type': 'son2', '@pos': {'@type': 'uast:Positions', 'start': {'@type': 'uast:Position', 'offset': 100, 'line': 100, 'col': 1}, 'end': {'@type': 'uast:Position', 'offset': 101, 'line': 100, 'col': 2}}, 'children': [{'@type': 'son2_1', '@pos': {'@type': 'uast:Positions', 'start': {'@type': 'uast:Position', 'offset': 5, 'line': 5, 'col': 1}, 'end': {'@type': 'uast:Position', 'offset': 6, 'line': 5, 'col': 2}}}, {'@type': 'son2_2', '@pos': {'@type': 'uast:Positions', 'start': {'@type': 'uast:Position', 'offset': 15, 'line': 15, 'col': 1}, 'end': {'@type': 'uast:Position', 'offset': 16, 'line': 15, 'col': 2}}}]}]

We get an array [son1, son2] rather than son1 then son2 next time we call the iterator

@ncordon ncordon self-assigned this Aug 6, 2019
@ncordon ncordon added the bug label Aug 6, 2019
@ncordon ncordon mentioned this issue Aug 6, 2019
2 tasks
@creachadair
Copy link
Contributor

It looks like #422 didn't auto-close this (maybe that doesn't work in the title?)

@ncordon
Copy link
Member Author

ncordon commented Aug 8, 2019

I forgot to reference the number of the issue in the title. Normally I put Closes #zzz but this time I forgot 🙈

@ncordon ncordon closed this as completed Aug 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants