-
Notifications
You must be signed in to change notification settings - Fork 18
Add classpath_depth to allow controlling transitive dependency depth #503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1beb5db
Add import_depth to allow controlling transative dependency depth
brian-mcnamara b2a04ce
Some refactoring
brian-mcnamara 7e4701e
Store unloaded dependencies for use in runtime
brian-mcnamara 7eb1b4e
Refactor
brian-mcnamara 5e55f34
Ensure loaded and unloaded are correct
brian-mcnamara 95d88a8
Allow import depth of 0
brian-mcnamara bbd6c32
Refactor importDepth to runtimeImportDepth
brian-mcnamara d2f127c
Rename import depth flag
brian-mcnamara 4426bfd
Don't maintain order and move flag inside settings
brian-mcnamara e32a36f
Apply suggestions from code review
brian-mcnamara a9c87e6
Review comments
brian-mcnamara 0e36caa
Merge remote-tracking branch 'origin/main' into perf
brian-mcnamara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
72 changes: 72 additions & 0 deletions
72
...e.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/classpath/ClasspathHolder.java
This file contains hidden or 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,72 @@ | ||
/*- | ||
* Copyright (c) 2024 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.util.Collection; | ||
import java.util.Collections; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
import org.eclipse.core.runtime.IPath; | ||
|
||
import com.salesforce.bazel.eclipse.core.model.discovery.classpath.ClasspathEntry; | ||
|
||
/** | ||
* Represents a targets classpath as two parts, loaded being the classpath entries that are loaded into the project | ||
* model, and unloaded being classpaths that are part of the target, but are not to be loaded in the project model. | ||
* | ||
* Note: Unloaded contains null values to keep the order between loaded and unloaded | ||
*/ | ||
public record ClasspathHolder(Collection<ClasspathEntry> loaded, Collection<ClasspathEntry> unloaded) { | ||
brian-mcnamara marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public static class ClasspathHolderBuilder { | ||
// Preserve classpath order. Add leaf level dependencies first and work the way up. This | ||
// prevents conflicts when a JAR repackages it's dependencies. In such a case we prefer to | ||
// resolve symbols from the original JAR rather than the repackaged version. | ||
// Using accessOrdered LinkedHashMap because jars that are present in `workspaceBuilder.jdeps` | ||
// and in `workspaceBuilder.directDeps`, we want to treat it as a directDep | ||
private final Map<IPath, ClasspathEntry> loadedEntries = | ||
new LinkedHashMap<>(/* initialCapacity= */ 32, /* loadFactor= */ 0.75f, /* accessOrder= */ true); | ||
private final Map<IPath, ClasspathEntry> unloadedEntries = | ||
new LinkedHashMap<>(/* initialCapacity= */ 32, /* loadFactor= */ 0.75f, /* accessOrder= */ true); | ||
private boolean hasUnloadedEntries = false; | ||
|
||
private final boolean partialClasspathEnabled; | ||
|
||
public ClasspathHolderBuilder(boolean partialClasspathEnabled) { | ||
this.partialClasspathEnabled = partialClasspathEnabled; | ||
} | ||
|
||
public ClasspathHolder build() { | ||
return new ClasspathHolder( | ||
loadedEntries.values(), | ||
hasUnloadedEntries ? unloadedEntries.values() : Collections.emptyList()); | ||
} | ||
|
||
public void put(IPath path, ClasspathEntry entry) { | ||
loadedEntries.put(path, entry); | ||
} | ||
|
||
public void putIfAbsent(IPath path, ClasspathEntry entry) { | ||
loadedEntries.putIfAbsent(path, entry); | ||
} | ||
|
||
public void putUnloadedIfAbsent(IPath path, ClasspathEntry entry) { | ||
if (!loadedEntries.containsKey(path)) { | ||
unloadedEntries.putIfAbsent(path, entry); | ||
hasUnloadedEntries = true; | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.