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

Roles are sorted in encoding step but not in decoding one #431

Open
ncordon opened this issue Aug 30, 2019 · 0 comments
Open

Roles are sorted in encoding step but not in decoding one #431

ncordon opened this issue Aug 30, 2019 · 0 comments

Comments

@ncordon
Copy link
Member

ncordon commented Aug 30, 2019

A node with roles like:

Visibility, World, Declaration, Type

would be encoded as:

Declaration, Type, Visibility, World

due to this line which is code called by libuast. We should probably move the sorting to after the transformations step (as suggested by @creachadair and @dennwc) to avoid having decoding and encodings (when we parse a tree and we just decode it for example, then if we encode and decode back we end up with different orders).

Reproducible example, using scala-client:

import org.bblfsh.client.v2.BblfshClient, BblfshClient._

// This file is in scala-client repo
val fileName = "src/test/resources/Tiny.java"
val fileContent = Source.fromFile(fileName).getLines.mkString("\n")
val resp = client.parse(fileName, fileContent)
val ctx: ContextExt = resp.uast.decode()
val tree = ctx.root()
val bytes = ctx.encode(tree, fmt)
val decoded = BblfshClient.decode(bytes, fmt)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant