bazelPackagesToImport = workspaceRootPackage.getChildPackageInfos().stream()
+ .collect(Collectors.toList());
+
+ WorkProgressMonitor progressMonitor = new EclipseWorkProgressMonitor(null);
+
+ BazelEclipseProjectFactory.setImportBazelSRCPath(
+ JavaLanguageServerPlugin.getPreferencesManager().getPreferences().getImportBazelSrcPath());
+ BazelEclipseProjectFactory.setImportBazelTestPath(
+ JavaLanguageServerPlugin.getPreferencesManager().getPreferences().getImportBazelTestPath());
+
+ BazelEclipseProjectFactory.importWorkspace(workspaceRootPackage, bazelPackagesToImport, progressMonitor,
+ monitor);
+ }
+
+ @Override
+ public void reset() {
+
+ }
+
+}
diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/Preferences.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/Preferences.java
index 6bac113b92..5862f0f583 100644
--- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/Preferences.java
+++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/Preferences.java
@@ -208,6 +208,31 @@ public class Preferences {
*/
public static final String SELECTIONRANGE_ENABLED_KEY = "java.selectionRange.enabled";
+ /**
+ * Preference key to enable/disable bazel importer.
+ */
+ public static final String IMPORT_BAZEL_ENABLED = "java.import.bazel.enabled";
+
+ /**
+ * Preference key to change java classes src path for bazel importer.
+ */
+ public static final String BAZEL_SRC_PATH = "java.import.bazel.src.path";
+
+ /**
+ * Preference key to change java classes test path for bazel importer.
+ */
+ public static final String BAZEL_TEST_PATH = "java.import.bazel.test.path";
+
+ /**
+ * Default java class src path for bazel importer.
+ */
+ public static final String BAZEL_DEFAULT_SRC_PATH = "/src/main/java";
+
+ /**
+ * Default java class test path for bazel importer.
+ */
+ public static final String BAZEL_DEFAULT_TEST_PATH = "/src/test/java";
+
/**
* A named preference that holds the favorite static members.
*
@@ -383,6 +408,9 @@ public class Preferences {
private boolean generateToStringListArrayContents;
private int generateToStringLimitElements;
private List preferredContentProviderIds;
+ private boolean importBazelEnabled;
+ private String importBazelSrcPath;
+ private String importBazelTestPath;
private String mavenUserSettings;
@@ -566,6 +594,10 @@ public Preferences() {
parallelBuildsCount = PreferenceInitializer.PREF_MAX_CONCURRENT_BUILDS_DEFAULT;
maxCompletionResults = JAVA_COMPLETION_MAX_RESULTS_DEFAULT;
referencedLibraries = JAVA_PROJECT_REFERENCED_LIBRARIES_DEFAULT;
+ importBazelEnabled = false;
+ importBazelSrcPath = BAZEL_DEFAULT_SRC_PATH;
+ importBazelTestPath = BAZEL_DEFAULT_TEST_PATH;
+
}
/**
@@ -613,6 +645,13 @@ public static Preferences createFrom(Map configuration) {
boolean implementationCodeLensEnabled = getBoolean(configuration, IMPLEMENTATIONS_CODE_LENS_ENABLED_KEY, false);
prefs.setImplementationCodelensEnabled(implementationCodeLensEnabled);
+ boolean importBazelEnabled = getBoolean(configuration, IMPORT_BAZEL_ENABLED, false);
+ prefs.setImportBazelEnabled(importBazelEnabled);
+ String importBazelSrcPath = getString(configuration, BAZEL_SRC_PATH, BAZEL_DEFAULT_SRC_PATH);
+ prefs.setImportBazelSrcPath(importBazelSrcPath);
+ String importBazelTestPath = getString(configuration, BAZEL_TEST_PATH, BAZEL_DEFAULT_TEST_PATH);
+ prefs.setImportBazelTestPath(importBazelTestPath);
+
boolean javaFormatEnabled = getBoolean(configuration, JAVA_FORMAT_ENABLED_KEY, true);
prefs.setJavaFormatEnabled(javaFormatEnabled);
@@ -896,6 +935,11 @@ public Preferences setImportMavenEnabled(boolean enabled) {
return this;
}
+ public Preferences setImportBazelEnabled(boolean enabled) {
+ this.importBazelEnabled = enabled;
+ return this;
+ }
+
public Preferences setMavenDownloadSources(boolean enabled) {
this.mavenDownloadSources = enabled;
return this;
@@ -1041,6 +1085,24 @@ public Preferences setMaxBuildCount(int maxConcurrentBuilds) {
return this;
}
+ public Preferences setImportBazelSrcPath(String importBazelSrcPath) {
+ this.importBazelSrcPath = importBazelSrcPath;
+ return this;
+ }
+
+ public Preferences setImportBazelTestPath(String importBazelTestPath) {
+ this.importBazelTestPath = importBazelTestPath;
+ return this;
+ }
+
+ public String getImportBazelSrcPath() {
+ return importBazelSrcPath;
+ }
+
+ public String getImportBazelTestPath() {
+ return importBazelTestPath;
+ }
+
public Severity getIncompleteClasspathSeverity() {
return incompleteClasspathSeverity;
}
@@ -1113,6 +1175,10 @@ public boolean isImportMavenEnabled() {
return importMavenEnabled;
}
+ public boolean isImportBazelEnabled() {
+ return importBazelEnabled;
+ }
+
public boolean isMavenDownloadSources() {
return mavenDownloadSources;
}
diff --git a/org.eclipse.jdt.ls.target/org.eclipse.jdt.ls.tp.target b/org.eclipse.jdt.ls.target/org.eclipse.jdt.ls.tp.target
index fad13d0dc6..e28f92a941 100644
--- a/org.eclipse.jdt.ls.target/org.eclipse.jdt.ls.tp.target
+++ b/org.eclipse.jdt.ls.target/org.eclipse.jdt.ls.tp.target
@@ -45,10 +45,14 @@
+
+
+
+
-
\ No newline at end of file
+