-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support source code lookup for classes not on the project classpath
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 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
45 changes: 45 additions & 0 deletions
45
...se.core/src/com/salesforce/bazel/eclipse/core/classpath/BazelSourceContainerResolver.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,45 @@ | ||
/*- | ||
* Copyright (c) 2023 Salesforce and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Salesforce - adapted from M2E, JDT or other Eclipse project | ||
*/ | ||
package com.salesforce.bazel.eclipse.core.classpath; | ||
|
||
import java.io.File; | ||
import java.util.Collection; | ||
import java.util.Set; | ||
|
||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.IProgressMonitor; | ||
import org.eclipse.debug.core.sourcelookup.ISourceContainer; | ||
import org.eclipse.debug.core.sourcelookup.containers.ExternalArchiveSourceContainer; | ||
import org.eclipse.jdt.launching.sourcelookup.advanced.ISourceContainerResolver; | ||
|
||
import com.salesforce.bazel.eclipse.core.util.jar.SourceJarFinder; | ||
|
||
/** | ||
* A resolver to find source code for Bazel classpath container entries | ||
*/ | ||
public class BazelSourceContainerResolver implements ISourceContainerResolver { | ||
|
||
@Override | ||
public Collection<ISourceContainer> resolveSourceContainers(File classesLocation, IProgressMonitor monitor) | ||
throws CoreException { | ||
|
||
var sourceJar = SourceJarFinder.findSourceJar(classesLocation.toPath()); | ||
if (sourceJar != null) { | ||
return Set.of(new ExternalArchiveSourceContainer(sourceJar.toOSString(), true)); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
} |