Bazel Language Server : Depend on the Bazel Starlark source code

154 views
Skip to first unread message

Josiah Saunders

unread,
Dec 2, 2020, 7:41:49 PM12/2/20
to bazel-dev

Hello!

A few of my friends and I are working on developing a language server for bazel, built in java, for our university capstone project. We would like to use the java implementation of the starlark parser provided in the bazelbuild/bazel at the following location:

src/main/java/net/starlark/java/**/*.java

Our project is built using bazel, however we are unable to import these source files because many of them are marked as private. My question is, how would we best go about depending on these source files? Is this possible?

Thanks in advance for any help,

Josiah

Josiah Saunders

unread,
Dec 14, 2020, 3:55:51 PM12/14/20
to bazel-dev
I was able to resolve this based on Cristian's suggestion: https://github.com/bazelbuild/bazel/issues/12608

laurentlb

unread,
Dec 15, 2020, 1:42:28 PM12/15/20
to Josiah Saunders, bazel-dev
Hi,

Where can we learn more about your project? I'd be interested in reading a design document about the project.

I know lots of people would be interested in a language server (judging by the number of personal emails I received about it), thanks for working on it!

-- 
Laurent

--
You received this message because you are subscribed to the Google Groups "bazel-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-dev/6b854ce7-9f1e-458a-b92d-7770e4d797d8n%40googlegroups.com.

Josiah Saunders

unread,
Dec 29, 2020, 11:47:14 AM12/29/20
to bazel-dev
Hey Laurent,

Sorry for the delay, I didn't see this notification. Thanks for your interest in the project! We've switched the design of our project a little since we first started because of some incorrect assumptions we made. I just created an updated design document, which I'll attach below. Please feel free to comment on any imperfections you see in the design!

We're happy to hear that this project will help a lot of people. Did anyone you heard from have suggestions about the implementation of the language server?

I'll be sure to keep tabs on this thread.

Thanks,

Josiah

Bazel Design Document.pdf

Josiah Saunders

unread,
Jan 22, 2021, 9:57:04 AM1/22/21
to bazel-dev
For an update on this, our repo is available here. Our server is written in java. We have imported the buildifier to provide file formatting as well as created a way to autocomplete bazel paths. We are now moving onto parsing starlark files to provide semantic highlighting from our server (e.g. underlining syntax errors in an IDE, etc).

We previously discussed ways to depend on a starlark language parser. We were going to use the starlark-go repo for parsing starlark and communicate with it through protobufs. We found this to be a really slow approach development-wise. I left a comment on this issue with more information about the issue we're running to. Does anyone have any further suggestions to depend on a starlark language parser?

Thanks,

Josiah

Josiah Saunders

unread,
Jan 24, 2021, 10:06:15 PM1/24/21
to bazel-dev

Update:

I've figured out a decent route to go. I was able to create a wrapper around the starlark-go repo in golang. I then compiled that into a shared library, or dll, using Cgo. With this, I was able to successfully use JNA to link up our java language server with the starlark-go parser!😄 This should fix the dependency concerns with depending on Bazel's builtin java parser

Reply all
Reply to author
Forward
0 new messages