forked from eclipse-jdtls/eclipse.jdt.ls
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add experimental support for Bazel (eclipse#543)
Signed-off-by: Pavel Mitrafanau <[email protected]>
- Loading branch information
1 parent
99a643b
commit 01bc27b
Showing
5 changed files
with
147 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...lipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/BazelProjectImporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package org.eclipse.jdt.ls.core.internal.managers; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.IProgressMonitor; | ||
import org.eclipse.core.runtime.OperationCanceledException; | ||
import org.eclipse.jdt.ls.core.internal.AbstractProjectImporter; | ||
import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin; | ||
import org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager; | ||
|
||
import com.salesforce.b2eclipse.abstractions.WorkProgressMonitor; | ||
import com.salesforce.b2eclipse.config.BazelEclipseProjectFactory; | ||
import com.salesforce.b2eclipse.importer.BazelProjectImportScanner; | ||
import com.salesforce.b2eclipse.model.BazelPackageInfo; | ||
import com.salesforce.b2eclipse.runtime.impl.EclipseWorkProgressMonitor; | ||
|
||
public final class BazelProjectImporter extends AbstractProjectImporter { | ||
|
||
private static final String WORKSPACE_FILE_NAME = "WORKSPACE"; | ||
|
||
@Override | ||
public boolean applies(IProgressMonitor monitor) throws OperationCanceledException, CoreException { | ||
PreferenceManager preferencesManager = JavaLanguageServerPlugin.getPreferencesManager(); | ||
if (preferencesManager != null && !preferencesManager.getPreferences().isImportBazelEnabled()) { | ||
return false; | ||
} | ||
if (!rootFolder.exists() || !rootFolder.isDirectory()) { | ||
return false; | ||
} | ||
File workspaceFile = new File(rootFolder, WORKSPACE_FILE_NAME); | ||
if (!workspaceFile.exists()) { | ||
return false; | ||
} | ||
return true; | ||
|
||
} | ||
|
||
@Override | ||
public void importToWorkspace(IProgressMonitor monitor) throws OperationCanceledException, CoreException { | ||
BazelProjectImportScanner scanner = new BazelProjectImportScanner(); | ||
|
||
BazelPackageInfo workspaceRootPackage = scanner.getProjects(rootFolder); | ||
|
||
if (workspaceRootPackage == null) { | ||
throw new IllegalArgumentException(); | ||
} | ||
List<BazelPackageInfo> 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() { | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters