GithubHelp home page GithubHelp logo

bazel-ls-eclipse's Introduction

This code has been been merged back into bazel-eclipse. No further development activity will happen here.


B2Eclipse

This is the set of Eclipse plugins for developing Bazel projects in Eclipse. Currently supports running in a language server mode only (through the Eclipse JDT LS).

Repository structure

  • com.salesforce.b2eclipse.jdt.ls - the code which does all that Bazel-related stuff for building classpaths before they can be further processed by JDT.
  • com.salesforce.b2eclipse.repository - here you can find the outcome of the build (packaged plugins).
  • com.salesforce.b2eclipse.tests - integration tests for the jdt.ls plugin.
  • com.salesforce.b2eclipse.ui - a plugin for the client (the one which is connected to the language server for code interactions). It's rather a simple connection provider to a language server, not a full-fledged UI plugin.

Properties

The following properties are passed from the client to configure the plugin:

  • java.import.bazel.enabled - whether Bazel support should be enabled in JDT LS (disabled by default);
  • java.import.bazel.src.path - location of sources (relative to a package). Defaults to /src/main/java;
  • java.import.bazel.test.path - location of test sources (relative to a package). Defaults to /src/test/java.

Assumptions

  • Root package is not allowed (i.e. there should be no BUILD file beside the WORKSPACE);
  • A project has to be in a valid state (i.e. no unsatisfied dependencies are allowed);
  • Each package is to have sources;
  • Sources of a package are expected to be under the path specified through the following properties: java.import.bazel.src.path, java.import.bazel.test.path (details in the Properties section).
  • Sources of a package cannot reside in the root of it. They should be in a subdir;
  • Subpackages are not supported (i.e. package within package).

Future vision

Will be shipped separately as two independent features: standalone feature and as extension for Eclipse JDT LS.

Vision diagram

Building from the command line

The following command will install Apache Maven if necessary, then build the server into the /com.salesforce.b2eclipse.repository/target/repository folder:

    $ ./mvnw clean verify

Note: currently, the build can only run when launched with JDK 8.

Features

  • Code completion
  • Code navigation

License

This work is dual-licensed under EPL 2.0 and Apache License 2.0. See corresponding files: EPL2.0, Apache License 2.0.

bazel-ls-eclipse's People

Contributors

alexeishmidman avatar beginningineer avatar guw avatar igoryasko121 avatar kkazakevich avatar leonovecsergey avatar plaird avatar pmitrafanau avatar svc-scm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bazel-ls-eclipse's Issues

VSCode Extension publishing

  • GitHub Actions to build project and publish VSX package
  • Instruction how to publish extension into VSCode Matketplace (via Azure Pipelines)

Proper error handling

  • Incorrect src path produces NPE since no aspects are calculated
  • Dependencies on missing targets produce NPE
  • Specify restrictions in the readme (such as ignored root package - i.e. BUILD file alongside WORKSPACE, etc)

NPE when is called form VSCode

right after import is finished VSCode sends workspace/didChangeConfiguration command including java.home. during it processing I'm getting:

java.lang.NullPointerException
	at org.eclipse.jdt.ls.core.internal.JVMConfigurator.configureDefaultVM(JVMConfigurator.java:88)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.didChangeConfiguration(JDTLanguageServer.java:432)
	...

recently plugin was made as an extension for eclipse.jdt.ls so we moved to own *.target, *.launch files and sorrowfully missed something - org.eclipse.jdt.launching.macosx have to be added to launch configurations.

Race condition on "initialize" / "initialized"

“initialize” request, which is sent from the client, triggers build process against the current workspace asynchronously without waiting for the finishing of the build:

/* (non-Javadoc)
 * @see org.eclipse.lsp4j.services.LanguageServer#initialize(org.eclipse.lsp4j.InitializeParams)
 */
@Override
public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
	logInfo(">> initialize");
	InitHandler handler = new InitHandler(pm, preferenceManager, client, commandHandler);
	return CompletableFuture.completedFuture(handler.initialize(params));
}

After that the client sends “initialized” notification (see org.eclipse.lsp4j.services.LanguageServer#initialized for JavaDoc).
The handler of the “initialized” notification should wait for the build process to complete (see the code snippet below):


/*
 * (non-Javadoc)
 * @see org.eclipse.lsp4j.services.LanguageServer#initialized(org.eclipse.lsp4j.InitializedParams)
 */
@Override
public void initialized(InitializedParams params) {
	logInfo(">> initialized");
	try {
		Job.getJobManager().join(InitHandler.JAVA_LS_INITIALIZATION_JOBS, null);
	} catch (OperationCanceledException | InterruptedException e) {
		logException(e.getMessage(), e);
	}
...
}

The problem of the synchronization occurs in the case when build jobs are not started yet on the server-side, but the notification is received and the server tries to wait for the initialization jobs to be completed. In this situation, the “join” method returns immediately and lets the execution runs further with wrong results.

for the complete code see org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer

Fix missing bazelWorkspaceRootDirectory at project reimport

Currently we getting next exception on file close/open cycle:
java.lang.IllegalStateException: Attempt to retrieve the classpath of a Bazel Java project prior to setting up the Bazel workspace.
at com.salesforce.b2eclipse.classpath.BazelClasspathContainer.getClasspathEntries(BazelClasspathContainer.java:120)

Java sources path configuration

source/test path locations should be overridable via params of initialize request (LSP).
also Bazel support feature of eclipse.jdt.ls should be configurable in the same way.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.