Skip to content

Commit

Permalink
Merge branch 'main' into allow_pom_download_failures
Browse files Browse the repository at this point in the history
  • Loading branch information
stefdev49 committed Dec 3, 2024
2 parents 42daecb + f0b1d51 commit 5fbe47e
Show file tree
Hide file tree
Showing 90 changed files with 4,032 additions and 608 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/receive-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ jobs:
annotationPattern: '@org.jetbrains.annotations.NotNull'
- org.openrewrite.java.RemoveAnnotation:
annotationPattern: '@jakarta.annotation.Nonnull'
- org.openrewrite.java.jspecify.MigrateToJspecify
#- org.openrewrite.java.jspecify.MigrateToJspecify
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=57dafb5c2622c6cc08b993c85b7c06956a2f53536432a30ead46166dbca0f1e9
distributionSha256Sum=f397b287023acdba1e9f6fc5ea72d22dd63669d59ed4a289a29b1a76eee151c6
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openrewrite.java.internal.JavaTypeCache;
import org.openrewrite.java.internal.AdaptiveRadixJavaTypeCache;
import org.openrewrite.java.internal.JavaTypeCache;

import java.net.URISyntaxException;
import java.util.Map;
Expand Down
2 changes: 1 addition & 1 deletion rewrite-core/src/main/java/org/openrewrite/Cursor.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Cursor getRoot() {
/**
* @return true if this cursor is the root of the tree, false otherwise
*/
final boolean isRoot() {
final public boolean isRoot() {
return ROOT_VALUE.equals(value);
}

Expand Down
2 changes: 1 addition & 1 deletion rewrite-core/src/main/java/org/openrewrite/GitRemote.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ private String repositoryPath(RemoteServerMatch match, URI normalizedUri) {
.replaceFirst("^/", "");
}

private static final Pattern PORT_PATTERN = Pattern.compile(":\\d+");
private static final Pattern PORT_PATTERN = Pattern.compile(":\\d+(/.+)(/.+)+");

static URI normalize(String url) {
try {
Expand Down
12 changes: 12 additions & 0 deletions rewrite-core/src/main/java/org/openrewrite/ScanningRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;

/**
Expand Down Expand Up @@ -126,4 +127,15 @@ public boolean isAcceptable(SourceFile sourceFile, ExecutionContext ctx) {
}
};
}

// For now, ScanningRecipes do not support `*RecipeList`, as the accumulator is not evaluated for these methods
@Override
public final List<Recipe> getRecipeList() {
return super.getRecipeList();
}

@Override
public final void buildRecipeList(RecipeList list) {
super.buildRecipeList(list);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,6 @@ public TreeVisitor<?, ExecutionContext> getVisitor(T acc) {
return Preconditions.check(bellwether.isPreconditionApplicable(), delegate.getVisitor(acc));
}

@Override
public List<Recipe> getRecipeList() {
return decorateWithPreconditionBellwether(bellwether, delegate.getRecipeList());
}

@Override
public boolean causesAnotherCycle() {
return delegate.causesAnotherCycle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected boolean matchesPartialKey(byte[] key, int depth) {
}

// Helper method to find common prefix length
protected static int findCommonPrefixLength(byte[] key1, int start1, byte[] key2, int start2) {
protected static int findCommonPrefixLength(byte[] key1, int start1, byte[] key2) {
int maxLength = Math.min(key1.length - start1, key2.length);
int i = 0;
while (i < maxLength && key1[start1 + i] == key2[i]) {
Expand Down Expand Up @@ -118,7 +118,7 @@ Node<V> insert(byte[] key, int depth, V value) {
return new LeafNode<>(partialKey, value);
}

int commonPrefix = findCommonPrefixLength(key, depth, partialKey, 0);
int commonPrefix = findCommonPrefixLength(key, depth, partialKey);
byte[] commonKey = Arrays.copyOfRange(key, depth, depth + commonPrefix);
Node4<V> newNode = new Node4<>(commonKey);

Expand Down Expand Up @@ -194,7 +194,7 @@ V search(byte[] key, int depth) {
@Override
Node<V> insert(byte[] key, int depth, V value) {
if (!matchesPartialKey(key, depth)) {
int commonPrefix = findCommonPrefixLength(key, depth, partialKey, 0);
int commonPrefix = findCommonPrefixLength(key, depth, partialKey);

byte[] commonKey = Arrays.copyOfRange(key, depth, depth + commonPrefix);
Node4<V> newNode = new Node4<>(commonKey);
Expand Down Expand Up @@ -272,7 +272,7 @@ Node<V> insert(byte[] key, int depth, V value) {
private static class Node4<V> extends InternalNode<V> {
// Keys and children inline to avoid array overhead
private byte k0, k1, k2, k3;
private Node<V> c0, c1, c2, c3;
private @Nullable Node<V> c0, c1, c2, c3;
private byte size;

Node4(byte[] partialKey) {
Expand All @@ -290,6 +290,7 @@ private static class Node4<V> extends InternalNode<V> {
return null;
}

@SuppressWarnings("DataFlowIssue")
@Override
@Nullable InternalNode<V> addChild(byte key, Node<V> child) {
// Check if we're replacing an existing child
Expand Down Expand Up @@ -390,6 +391,7 @@ InternalNode<V> cloneWithNewKey(byte[] newKey) {
return clone;
}

@SuppressWarnings("DataFlowIssue")
@Override
Node<V> copy() {
Node4<V> clone = new Node4<>(Arrays.copyOf(partialKey, partialKey.length));
Expand All @@ -410,7 +412,7 @@ Node<V> copy() {
private static class Node16<V> extends InternalNode<V> {
private static final int LINEAR_SEARCH_THRESHOLD = 8;
private byte[] keys;
private Node<V>[] children;
private @Nullable Node<V>[] children;
private int size;

@SuppressWarnings("unchecked")
Expand All @@ -432,13 +434,13 @@ Node<V> getChild(byte key) {
return null;
}

int idx = unsignedBinarySearch(keys, 0, size, key & 0xFF);
int idx = unsignedBinarySearch(keys, size, key & 0xFF);
return idx >= 0 ? children[idx] : null;
}

// Custom binary search for unsigned bytes
private int unsignedBinarySearch(byte[] array, int fromIndex, int toIndex, int key) {
int low = fromIndex;
private int unsignedBinarySearch(byte[] array, int toIndex, int key) {
int low = 0;
int high = toIndex - 1;

while (low <= high) {
Expand Down Expand Up @@ -471,6 +473,7 @@ InternalNode<V> addChild(byte key, Node<V> child) {
Node48<V> node = new Node48<>(partialKey);
node.value = this.value;
for (int i = 0; i < size; i++) {
//noinspection DataFlowIssue
node.addChild(keys[i], children[i]);
}
node.addChild(key, child);
Expand Down Expand Up @@ -511,6 +514,7 @@ Node<V> copy() {
clone.children = Arrays.copyOf(this.children, this.children.length);
// Deep copy children
for (int i = 0; i < size; i++) {
//noinspection DataFlowIssue
clone.children[i] = children[i].copy();
}
return clone;
Expand All @@ -519,7 +523,7 @@ Node<V> copy() {

private static class Node48<V> extends InternalNode<V> {
private byte[] index;
private Node<V>[] children;
private @Nullable Node<V>[] children;
private int size;

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -552,6 +556,7 @@ InternalNode<V> addChild(byte key, Node<V> child) {
node.value = this.value;
for (int i = 0; i < 256; i++) {
if (index[i] >= 0) {
//noinspection DataFlowIssue
node.addChild((byte) i, children[index[i]]);
}
}
Expand Down Expand Up @@ -584,14 +589,15 @@ Node<V> copy() {
clone.children = Arrays.copyOf(this.children, this.children.length);
// Deep copy children
for (int i = 0; i < size; i++) {
//noinspection DataFlowIssue
clone.children[i] = children[i].copy();
}
return clone;
}
}

private static class Node256<V> extends InternalNode<V> {
private final @Nullable Node<V>[] children;
private final @Nullable Node<V> [] children;

@SuppressWarnings("unchecked")
Node256(byte[] partialKey) {
Expand Down Expand Up @@ -628,8 +634,9 @@ Node<V> copy() {
System.arraycopy(this.children, 0, clone.children, 0, this.children.length);
// Deep copy children
for (int i = 0; i < 256; i++) {
if (children[i] != null) {
clone.children[i] = children[i].copy();
Node<V> child = children[i];
if (child != null) {
clone.children[i] = child.copy();
}
}
return clone;
Expand Down
Loading

0 comments on commit 5fbe47e

Please sign in to comment.