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

Commit e178ba8

Browse files
authored
Merge pull request #118 from ncordon/fix.readme.example
Fixes README examples
2 parents 5ab254d + 28ad95e commit e178ba8

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ target
44
*~
55
.idea
66
src/libuast-native
7+
src/main/proto
8+
!src/main/proto/github.com/gogo/protobuf/gogoproto/gogo.proto
9+
src/main/resources
710
.history
811
Libuast.so
912
build/*

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ guide to learn more about how to use and deploy a bblfsh server, install languag
8080
API
8181
```scala
8282
import scala.io.Source
83-
import org.bblfsh.client.BblfshClient
83+
import org.bblfsh.client.v2.BblfshClient, BblfshClient._
8484
import gopkg.in.bblfsh.sdk.v2.protocol.driver.Mode
8585

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

9595
// Filtered response
96-
println(client.filter(resp.get, "//uast:Import"))
96+
println(client.filter(resp.get, "//uast:Identifier"))
9797
```
9898

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

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

111111
Please read the [Babelfish clients](https://doc.bblf.sh/user/language-clients.html)

src/main/scala/org/bblfsh/client/v2/BblfshClient.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ object BblfshClient {
161161
}
162162
}
163163

164+
/** Enables API: client.filter and client.iterator for client an instance of BblfshClient */
165+
implicit class BblfshClientMethods(val client: BblfshClient) {
166+
def filter(node: NodeExt, query: String) = BblfshClient.filter(node, query)
167+
def filter(node: JNode, query: String) = BblfshClient.filter(node, query)
168+
def iterator(node: NodeExt, treeOrder: Int) = BblfshClient.iterator(node, treeOrder)
169+
def iterator(node: JNode, treeOrder: Int) = BblfshClient.iterator(node, treeOrder)
170+
}
171+
164172
/** Factory method for iterator over an external/native node */
165173
def iterator(node: NodeExt, treeOrder: Int): Libuast.UastIterExt = {
166174
Libuast.UastIterExt(node, treeOrder)

0 commit comments

Comments
 (0)