Skip to content

Commit

Permalink
Merge pull request #664 from mP1/feature/mP1-walkingkooka-pull-2773-S…
Browse files Browse the repository at this point in the history
…ortedSets-N-ImmutableSortedSet

mP1/walkingkooka#2773 SortedSets & ImmutableS…
  • Loading branch information
mP1 authored Sep 5, 2024
2 parents 6410af0 + e57e0d4 commit 5f390fb
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 22 deletions.
5 changes: 3 additions & 2 deletions src/main/java/walkingkooka/j2cl/maven/J2clArtifact.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import walkingkooka.collect.list.Lists;
import walkingkooka.collect.map.Maps;
import walkingkooka.collect.set.Sets;
import walkingkooka.collect.set.SortedSets;
import walkingkooka.j2cl.maven.log.TreeLogger;
import walkingkooka.predicate.Predicates;
import walkingkooka.reflect.PackageName;
Expand Down Expand Up @@ -566,7 +567,7 @@ private void verify(final TreeLogger logger) {
this.context.verifyClasspathRequiredJavascriptSourceRequiredIgnoredDependencies(
all.stream()
.map(J2clArtifact::coords)
.collect(Collectors.toCollection(Sets::sorted)),
.collect(Collectors.toCollection(SortedSets::tree)),
this,
logger
);
Expand Down Expand Up @@ -708,7 +709,7 @@ private void logDependencies(final String label,
this.dependencies().stream()
.filter(filter)
.map(J2clArtifact::toString)
.collect(Collectors.toCollection(Sets::sorted))
.collect(Collectors.toCollection(SortedSets::tree))
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/walkingkooka/j2cl/maven/J2clArtifactCoords.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.model.Dependency;
import walkingkooka.collect.set.Sets;
import walkingkooka.collect.set.SortedSets;
import walkingkooka.j2cl.maven.unpack.J2clTaskUnpack;
import walkingkooka.text.CharSequences;

Expand All @@ -40,7 +40,7 @@ final class J2clArtifactCoords implements Comparable<J2clArtifactCoords> {
* Creates a sorted {@link Set} to hold coords.
*/
static Set<J2clArtifactCoords> set() {
return Sets.sorted();
return SortedSets.tree();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/walkingkooka/j2cl/maven/J2clMavenContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import walkingkooka.Context;
import walkingkooka.collect.list.Lists;
import walkingkooka.collect.map.Maps;
import walkingkooka.collect.set.Sets;
import walkingkooka.collect.set.SortedSets;
import walkingkooka.j2cl.maven.closure.ClosureFormattingOption;
import walkingkooka.j2cl.maven.hash.HashBuilder;
import walkingkooka.j2cl.maven.log.MavenLogger;
Expand Down Expand Up @@ -307,7 +307,7 @@ private void prepareTasks(final J2clArtifact artifact) {
if (false == this.tasks.containsKey(artifact)) {

// keep transitive dependencies alphabetical sorted for better readability when trySubmitTasks pretty prints queue processing.
final Set<J2clArtifact> required = Sets.sorted();
final Set<J2clArtifact> required = SortedSets.tree();

this.tasks.put(artifact, required);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.RemoteRepository;
import walkingkooka.collect.set.Sets;
import walkingkooka.collect.set.SortedSets;
import walkingkooka.j2cl.maven.closure.ClosureFormattingOption;
import walkingkooka.j2cl.maven.log.TreeLogger;
import walkingkooka.text.CharSequences;
Expand Down Expand Up @@ -222,7 +222,7 @@ final Set<ClosureFormattingOption> formatting() {
final Set<String> javaCompilerArguments() {
return this.javaCompilerArguments.stream()
.map(String::trim)
.collect(Collectors.toCollection(Sets::sorted));
.collect(Collectors.toCollection(SortedSets::tree));
}

@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/walkingkooka/j2cl/maven/J2clMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import walkingkooka.collect.list.Lists;
import walkingkooka.collect.set.Sets;
import walkingkooka.collect.set.SortedSets;
import walkingkooka.j2cl.maven.log.BrowserLogLevel;
import walkingkooka.j2cl.maven.log.MavenLogger;
import walkingkooka.j2cl.maven.log.TreeLogger;
Expand Down Expand Up @@ -147,7 +147,7 @@ private List<String> findTestClassNames(final TreeLogger logger) throws IOExcept
logger.line(testSourceRootPath.toAbsolutePath().toString());
logger.indent();
{
final Set<String> tests = Sets.sorted();
final Set<String> tests = SortedSets.tree();
final List<PathMatcher> pathMatchers = this.tests(testSourceRootPath);

Files.walkFileTree(testSourceRootPath, new SimpleFileVisitor<>() {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/walkingkooka/j2cl/maven/J2clPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import walkingkooka.collect.list.Lists;
import walkingkooka.collect.map.Maps;
import walkingkooka.collect.set.Sets;
import walkingkooka.collect.set.SortedSets;
import walkingkooka.file.Files2;
import walkingkooka.j2cl.maven.log.TreeFormat;
import walkingkooka.j2cl.maven.log.TreeLogger;
Expand Down Expand Up @@ -273,7 +274,7 @@ public Set<J2clPath> gatherFiles(final Predicate<Path> filter) throws IOExceptio
return Files.find(this.path(), Integer.MAX_VALUE, (p, a) -> filter.test(p))
.map(J2clPath::with)
.sorted()
.collect(Collectors.toCollection(Sets::sorted));
.collect(Collectors.toCollection(SortedSets::tree));
}

public boolean isFile() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import walkingkooka.collect.list.Lists;
import walkingkooka.collect.map.Maps;
import walkingkooka.collect.set.Sets;
import walkingkooka.collect.set.SortedSets;
import walkingkooka.j2cl.maven.J2clArtifact;
import walkingkooka.j2cl.maven.J2clMavenContext;
import walkingkooka.j2cl.maven.J2clPath;
Expand Down Expand Up @@ -163,7 +164,9 @@ private static boolean compile0(final J2clArtifact artifact,
defines,
entryPoints,
externs,
formatting.stream().map(ClosureFormattingOption::name).collect(Collectors.toCollection(Sets::sorted)),
formatting.stream()
.map(ClosureFormattingOption::name)
.collect(Collectors.toCollection(SortedSets::tree)),
languageOut,
sourceMaps,
unitedSourceRoot,
Expand Down Expand Up @@ -250,7 +253,7 @@ private static Map<String, Collection<String>> prepareArguments(final Compilatio

arguments.put("--compilation_level", Sets.of(compilationLevel.name()));
{
final Set<String> definesSet = Sets.sorted();
final Set<String> definesSet = SortedSets.tree();
if (compilationLevel == CompilationLevel.BUNDLE) {
definesSet.add("goog.ENABLE_DEBUG_LOADER=false");
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/walkingkooka/j2cl/maven/hash/J2clTaskHash.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package walkingkooka.j2cl.maven.hash;

import com.google.common.collect.Lists;
import walkingkooka.collect.set.Sets;
import walkingkooka.collect.set.SortedSets;
import walkingkooka.j2cl.maven.J2clArtifact;
import walkingkooka.j2cl.maven.J2clMavenContext;
import walkingkooka.j2cl.maven.J2clPath;
Expand Down Expand Up @@ -69,7 +69,7 @@ public J2clTaskResult execute(final J2clArtifact artifact,
final J2clTaskKind kind,
final C context,
final TreeLogger logger) throws Exception {
final Set<String> hashItemNames = Sets.sorted();
final Set<String> hashItemNames = SortedSets.tree();
final HashBuilder hash = HashBuilder.empty();
context.computeHash(
artifact,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package walkingkooka.j2cl.maven.output;

import walkingkooka.collect.set.Sets;
import walkingkooka.collect.set.SortedSets;
import walkingkooka.j2cl.maven.J2clArtifact;
import walkingkooka.j2cl.maven.J2clMavenContext;
import walkingkooka.j2cl.maven.J2clPath;
Expand Down Expand Up @@ -121,7 +122,7 @@ public J2clTaskResult executeWithDirectory(final J2clArtifact artifact,
}
logger.outdent();

final Set<J2clPath> destinationFiles = Sets.sorted();
final Set<J2clPath> destinationFiles = SortedSets.tree();
destinationFiles.addAll(closureCompileDestinationFiles);
destinationFiles.addAll(unpackPublicDestinationFiles);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package walkingkooka.j2cl.maven.shade;

import walkingkooka.collect.set.Sets;
import walkingkooka.collect.set.SortedSets;
import walkingkooka.j2cl.maven.J2clArtifact;
import walkingkooka.j2cl.maven.J2clMavenContext;
import walkingkooka.j2cl.maven.J2clPath;
Expand Down Expand Up @@ -117,10 +117,10 @@ private void copyAndShade(final J2clArtifact artifact,

final Set<J2clPath> files = root.gatherFiles(J2clPath.ALL_FILES.and(filter));

final Set<J2clPath> possibleFiles = Sets.sorted();
final Set<J2clPath> possibleFiles = SortedSets.tree();
possibleFiles.addAll(files);

final Set<J2clPath> nonShadedFiles = Sets.sorted();
final Set<J2clPath> nonShadedFiles = SortedSets.tree();
nonShadedFiles.addAll(files);

for (final Entry<PackageName, PackageName> mapping : shade.entrySet()) {
Expand All @@ -131,7 +131,7 @@ private void copyAndShade(final J2clArtifact artifact,
output :
output.append(replace.replace('.', File.separatorChar));

final Set<J2clPath> shadedFiles = Sets.sorted();
final Set<J2clPath> shadedFiles = SortedSets.tree();
final J2clPath shadedRoot = root.append(find.replace('.', File.separatorChar));

// filter only files belonging to and under shade source root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.j2cl.tools.gwtincompatible.GwtIncompatibleStripper;
import walkingkooka.collect.list.Lists;
import walkingkooka.collect.set.Sets;
import walkingkooka.collect.set.SortedSets;
import walkingkooka.j2cl.maven.J2clPath;
import walkingkooka.j2cl.maven.J2clTaskResult;
import walkingkooka.j2cl.maven.log.TreeFormat;
Expand Down Expand Up @@ -215,7 +216,7 @@ private static Set<J2clPath> gatherFiles(final J2clPath root,

private static Set<J2clPath> gatherFiles0(final J2clPath root,
final Predicate<Path> include) throws IOException {
final SortedSet<J2clPath> files = Sets.sorted();
final SortedSet<J2clPath> files = SortedSets.tree();

Files.walkFileTree(
root.path(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.junit.jupiter.api.Test;
import walkingkooka.collect.map.Maps;
import walkingkooka.collect.set.Sets;
import walkingkooka.collect.set.SortedSets;
import walkingkooka.reflect.ClassTesting2;
import walkingkooka.reflect.JavaVisibility;

Expand Down Expand Up @@ -170,7 +171,7 @@ private Map<J2clArtifactCoords, Set<J2clArtifactCoords>> transform(final Map<Str
private Set<J2clArtifactCoords> transformCsv(final String csv) {
return Arrays.stream(csv.isEmpty() ? new String[0] : csv.split(","))
.map(J2clArtifactCoords::parse)
.collect(Collectors.toCollection(Sets::sorted));
.collect(Collectors.toCollection(SortedSets::tree));
}

private void runAndCheck0(final Map<J2clArtifactCoords, Set<J2clArtifactCoords>> flat,
Expand Down

0 comments on commit 5f390fb

Please sign in to comment.