Skip to content

Commit

Permalink
Showing 4 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
*/
package org.openrewrite;

import lombok.Getter;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.marker.SearchResult;

@@ -136,13 +137,15 @@ public RecipeCheck(Recipe check, TreeVisitor<?, ExecutionContext> v) {
this.check = check;
}

public Recipe getCheck() {
public Recipe getRecipe() {
return check;
}
}

public static class Check extends TreeVisitor<Tree, ExecutionContext> {
@Getter
private final TreeVisitor<?, ExecutionContext> check;

private final TreeVisitor<?, ExecutionContext> v;

public Check(TreeVisitor<?, ExecutionContext> check, TreeVisitor<?, ExecutionContext> v) {
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
package org.openrewrite.java.search;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Value;
import lombok.With;
import org.openrewrite.Tree;
@@ -34,6 +35,8 @@

public class UsesMethod<P> extends JavaIsoVisitor<P> {
private final String methodPattern;

@Getter
private final MethodMatcher methodMatcher;

public UsesMethod(String methodPattern) {
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
*/
package org.openrewrite.java.search;

import lombok.Getter;
import org.openrewrite.Tree;
import org.openrewrite.internal.StringUtils;
import org.openrewrite.internal.lang.Nullable;
@@ -33,8 +34,11 @@
public class UsesType<P> extends JavaIsoVisitor<P> {

@Nullable
@Getter
private final String fullyQualifiedType;

@Nullable
@Getter
private final Predicate<JavaType> typePattern;

@Nullable
23 changes: 14 additions & 9 deletions rewrite-java/src/main/java/org/openrewrite/java/tree/JavaType.java
Original file line number Diff line number Diff line change
@@ -657,7 +657,7 @@ public Parameterized(@Nullable Integer managedReference, @Nullable FullyQualifie
}

Parameterized(@Nullable Integer managedReference, @Nullable FullyQualified type,
@Nullable JavaType[] typeParameters) {
@Nullable JavaType[] typeParameters) {
this.managedReference = managedReference;
this.type = unknownIfNull(type);
this.typeParameters = nullIfEmpty(typeParameters);
@@ -1148,9 +1148,9 @@ public Method(@Nullable Integer managedReference, long flagsBitMap, @Nullable Fu
}

public Method(@Nullable Integer managedReference, long flagsBitMap, @Nullable FullyQualified declaringType, String name,
@Nullable JavaType returnType, @Nullable String[] parameterNames,
@Nullable JavaType[] parameterTypes, @Nullable FullyQualified[] thrownExceptions,
@Nullable FullyQualified[] annotations, @Nullable List<String> defaultValue) {
@Nullable JavaType returnType, @Nullable String[] parameterNames,
@Nullable JavaType[] parameterTypes, @Nullable FullyQualified[] thrownExceptions,
@Nullable FullyQualified[] annotations, @Nullable List<String> defaultValue) {
this.managedReference = managedReference;
this.flagsBitMap = flagsBitMap & Flag.VALID_FLAGS;
this.declaringType = unknownIfNull(declaringType);
@@ -1207,9 +1207,10 @@ public FullyQualified getDeclaringType() {
return declaringType;
}

public boolean isOverride() {
@Nullable
public JavaType.Method getOverride() {
if (declaringType instanceof JavaType.Unknown) {
return false;
return null;
}

Stack<FullyQualified> interfaces = new Stack<>();
@@ -1231,11 +1232,15 @@ public boolean isOverride() {
continue nextMethod;
}
}
return true;
return method;
}
}
}
return false;
return null;
}

public boolean isOverride() {
return getOverride() != null;
}

public boolean isInheritedFrom(String fullyQualifiedTypeName) {
@@ -1397,7 +1402,7 @@ public Variable(@Nullable Integer managedReference, long flagsBitMap, String nam
}

Variable(@Nullable Integer managedReference, long flagsBitMap, String name, @Nullable JavaType owner,
@Nullable JavaType type, @Nullable FullyQualified[] annotations) {
@Nullable JavaType type, @Nullable FullyQualified[] annotations) {
this.managedReference = managedReference;
this.flagsBitMap = flagsBitMap & Flag.VALID_FLAGS;
this.name = name;

0 comments on commit 9472d87

Please sign in to comment.