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

Commit

Permalink
Merge pull request #118 from ncordon/fix.readme.example
Browse files Browse the repository at this point in the history
Fixes README examples
  • Loading branch information
ncordon authored Aug 22, 2019
2 parents 5ab254d + 28ad95e commit e178ba8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ target
*~
.idea
src/libuast-native
src/main/proto
!src/main/proto/github.com/gogo/protobuf/gogoproto/gogo.proto
src/main/resources
.history
Libuast.so
build/*
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ guide to learn more about how to use and deploy a bblfsh server, install languag
API
```scala
import scala.io.Source
import org.bblfsh.client.BblfshClient
import org.bblfsh.client.v2.BblfshClient, BblfshClient._
import gopkg.in.bblfsh.sdk.v2.protocol.driver.Mode

val client = BblfshClient("localhost", 9432)
Expand All @@ -93,7 +93,7 @@ val resp = client.parse(filename, fileContent, Mode.SEMANTIC)
println(resp.get)

// Filtered response
println(client.filter(resp.get, "//uast:Import"))
println(client.filter(resp.get, "//uast:Identifier"))
```

Command line:
Expand All @@ -105,7 +105,7 @@ java -jar build/bblfsh-client-assembly-*.jar -f <file.py>
or if you want to use a XPath query:

```
java -jar build/bblfsh-client-assembly-*.jar -f <file.py> -q "//uast:Import"
java -jar build/bblfsh-client-assembly-*.jar -f <file.py> -q "//uast:Identifier"
```

Please read the [Babelfish clients](https://doc.bblf.sh/user/language-clients.html)
Expand Down
8 changes: 8 additions & 0 deletions src/main/scala/org/bblfsh/client/v2/BblfshClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ object BblfshClient {
}
}

/** Enables API: client.filter and client.iterator for client an instance of BblfshClient */
implicit class BblfshClientMethods(val client: BblfshClient) {
def filter(node: NodeExt, query: String) = BblfshClient.filter(node, query)
def filter(node: JNode, query: String) = BblfshClient.filter(node, query)
def iterator(node: NodeExt, treeOrder: Int) = BblfshClient.iterator(node, treeOrder)
def iterator(node: JNode, treeOrder: Int) = BblfshClient.iterator(node, treeOrder)
}

/** Factory method for iterator over an external/native node */
def iterator(node: NodeExt, treeOrder: Int): Libuast.UastIterExt = {
Libuast.UastIterExt(node, treeOrder)
Expand Down

0 comments on commit e178ba8

Please sign in to comment.