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

Migrate scala-client to SDK.v3 + libuast.v3 #83

Closed
17 tasks done
bzz opened this issue May 20, 2019 · 8 comments
Closed
17 tasks done

Migrate scala-client to SDK.v3 + libuast.v3 #83

bzz opened this issue May 20, 2019 · 8 comments
Assignees
Milestone

Comments

@bzz
Copy link
Contributor

bzz commented May 20, 2019

An umbrella issue for client migration to new SDK.

Takes similar approach to bblfsh/client-python. but aims to avoid having all the changes in a single PR, so will be broken down.

@bzz bzz self-assigned this May 20, 2019
@bzz
Copy link
Contributor Author

bzz commented May 20, 2019

New API example

Protocol.v2 response is protobuf-like encoded binary blob, so libuast now provides a method to decode() it on the Go side. Decoding will result only in in-memory UAST representation on the Go side, thus in order to be exposed to the host environment (JVM) as objects - the root node is also needs to load()ed.

Examples below use explicit type excessively in order to highlight the API internals, real applications \w same code will be more concise.

decode + load (Go->JVM)

import org.bblfsh.client.v2.*

// parse
//// read the binary UASTv2
val resp = client.parse(fileName, fileContent)

//// decode it, UAST is backed by Go
val ctx: Context = resp.uast.decode()
val rootNode: Node = ctx.root()

//// load the UAST from Go to JVM
val rootJvm: Map[String, _] = rootNode.load()

Iterate UAST (JVM)

// iterate the tree from root
def processRecursive(node: Any): Unit = node match {
  case m: Map[_, _] => {
    for ((k, v) <- m) {
      println(k)
      processRecursive(v)
    }
  }
  case s: Seq[_] => {
    for (e <- s) {
      processRecursive(e)
    }
  }
  case a: Any => println(a)
}

processRecursive(rootJvm)

Query (Go->JVM)

Print every node

val nodes: List[Node] = ctx.filter(rootNode, "//*")
nodes.foreach { n =>
    println(s"Node: $n")
}

@bzz bzz changed the title Migrate scala-client to SDK.v2 + libuast.v3 Migrate scala-client to SDK.v3 + libuast.v3 May 20, 2019
@dennwc
Copy link
Member

dennwc commented May 21, 2019

Maybe we can call NodeExt just Node (and same for Context)? Native nodes will be Map[string, _] (or whatever), so we won't need a native node type (opposed to NodeExt).

Also, the Context work is mentioned in the filter, but it is required to make decode work, so it probably belongs to that task group.

@bzz
Copy link
Contributor Author

bzz commented May 21, 2019

Thank you for the suggestion! I assumed that it will be simpler to make the decode part work first, with a global context.

@bzz
Copy link
Contributor Author

bzz commented May 23, 2019

#83 (comment) updated to include better type names and USAT iteration example.

bzz added a commit to bzz/client-scala that referenced this issue May 29, 2019
It also adds a temp job that will be kept updated and
is expected to pass for bblfsh#83
and track it's progress.

Signed-off-by: Alexander Bezzubov <bzz@apache.org>
bzz added a commit to bzz/client-scala that referenced this issue May 29, 2019
It also adds a temp job that will be kept updated and
is expected to pass for bblfsh#83
and track it's progress.

Signed-off-by: Alexander Bezzubov <bzz@apache.org>
@dennwc dennwc pinned this issue May 29, 2019
@bzz bzz unpinned this issue May 29, 2019
@bzz
Copy link
Contributor Author

bzz commented Jul 9, 2019

A pre-release RC1 was cut from the current state of v2 migration https://github.com/bblfsh/scala-client/releases/tag/v2.0-rc1

Update: RC1 is blocked by #98 and will be re-published once that is merged.

Update: RC1 has been published.

@bzz
Copy link
Contributor Author

bzz commented Aug 1, 2019

Update: RC3 has been published.

This was referenced Aug 6, 2019
@bzz bzz added this to the v2.0.0 milestone Aug 14, 2019
@bzz
Copy link
Contributor Author

bzz commented Aug 14, 2019

The only missing part before doing v2.0.0 release is a developer documentation!
Will submit a PR first thing tomorrow and start preparing a release notes.

@bzz bzz mentioned this issue Aug 16, 2019
5 tasks
@bzz
Copy link
Contributor Author

bzz commented Aug 16, 2019

Everything seems to be ready for initial release 🎉

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

No branches or pull requests

2 participants