Skip to content
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

Eclipse 4.8.0 (JDT) #262

Merged
merged 6 commits into from
Jul 19, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Properties;

import com.diffplug.common.base.Errors;
Expand Down Expand Up @@ -151,6 +152,12 @@ public Properties getPreferences() {
return preferences.getProperties();
}

/** Returns first coordinate from sorted set that starts with a given prefix.*/
public Optional<String> getMavenCoordinate(String prefix) {
return jarState.getMavenCoordinates().stream()
.filter(coordinate -> coordinate.startsWith(prefix)).findFirst();
}

/** Load class based on the given configuration of JAR provider and Maven coordinates. */
public Class<?> loadClass(String name) {
try {
Expand Down
8 changes: 6 additions & 2 deletions lib/src/main/java/com/diffplug/spotless/JarState.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
public final class JarState implements Serializable {
private static final long serialVersionUID = 1L;

@SuppressWarnings("unused")
private final Set<String> mavenCoordinates;
private final TreeSet<String> mavenCoordinates;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I almost missed this one. There are corner-cases where classpath order matters. Unless we have a really compelling reason, I think we should keep this as Set and not TreeSet

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to emphasize that I expect a deterministic result for getMavenCoordinates for the same input. I do not insist. What's your final decision?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then feel free to press the merge button, and I'll test the master integration build on some of my projects

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, THX.

@SuppressWarnings("unused")
private final FileSignature fileSignature;

Expand Down Expand Up @@ -92,4 +91,9 @@ URL[] jarUrls() {
public ClassLoader getClassLoader() {
return SpotlessCache.instance().classloader(this);
}

/** Returns unmodifiable view on sorted Maven coordinates */
public Set<String> getMavenCoordinates() {
return Collections.unmodifiableSet(mavenCoordinates);
}
}