Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -84,7 +84,8 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration methodDecl
JavaType.Method myAddSuppressed = mt.withName("myAddSuppressed");
return md.withName(md.getName().withSimpleName("myAddSuppressed").withType(myAddSuppressed))
.withMethodType(myAddSuppressed);
} else if (METHOD_GETSUPPRESSED.matches(md, classDeclaration)) {
}
if (METHOD_GETSUPPRESSED.matches(md, classDeclaration)) {
JavaType.Method myGetSuppressed = mt.withName("myGetSuppressed");
return md.withName(md.getName().withSimpleName("myGetSuppressed").withType(myGetSuppressed))
.withMethodType(myGetSuppressed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,14 @@ private void getDataCacheProps(Xml.Tag puNode, SharedDataHolder sdh) {
if (propVal != null) {
if ("false".equalsIgnoreCase(propVal)) {
return "NONE";
} else if ("true".equalsIgnoreCase(propVal)) {
}
if ("true".equalsIgnoreCase(propVal)) {
return "ALL";
} else if (propVal.matches("(?i:true)\\(ExcludedTypes=.*")) {
}
if (propVal.matches("(?i:true)\\(ExcludedTypes=.*")) {
return "DISABLE_SELECTIVE";
} else if (propVal.matches("(?i:true)\\(Types=.*")) {
}
if (propVal.matches("(?i:true)\\(Types=.*")) {
return "ENABLE_SELECTIVE";
}
}
Expand All @@ -305,7 +308,8 @@ private void getDataCacheProps(Xml.Tag puNode, SharedDataHolder sdh) {
private @Nullable String convertScmValue(String scmValue) {
if ("NONE".equals(scmValue)) {
return "false";
} else if ("ALL".equals(scmValue)) {
}
if ("ALL".equals(scmValue)) {
return "true";
}
// otherwise, don't process it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ public J visitNewClass(J.NewClass newClass, ExecutionContext ctx) {
.build()
.apply(updateCursor(c), c.getCoordinates().replace());

} else if (newBase64Decoder.matches(c)) {
}
if (newBase64Decoder.matches(c)) {
return JavaTemplate.builder(useMimeCoder ? "Base64.getMimeDecoder()" : "Base64.getDecoder()")
.contextSensitive()
.imports("java.util.Base64")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx)
maybeRemoveImport("com.google.common.collect.Lists");
maybeAddImport("java.util.ArrayList");
return newArrayList.apply(getCursor(), method.getCoordinates().replace());
} else if (NEW_ARRAY_LIST_ITERABLE.matches(method) && method.getArguments().size() == 1 &&
}
if (NEW_ARRAY_LIST_ITERABLE.matches(method) && method.getArguments().size() == 1 &&
TypeUtils.isAssignableTo("java.util.Collection", method.getArguments().get(0).getType())) {
maybeRemoveImport("com.google.common.collect.Lists");
maybeAddImport("java.util.ArrayList");
return newArrayListCollection.apply(getCursor(), method.getCoordinates().replace(),
method.getArguments().get(0));
} else if (NEW_ARRAY_LIST_CAPACITY.matches(method)) {
}
if (NEW_ARRAY_LIST_CAPACITY.matches(method)) {
maybeRemoveImport("com.google.common.collect.Lists");
maybeAddImport("java.util.ArrayList");
return newArrayListCapacity.apply(getCursor(), method.getCoordinates().replace(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx)
.imports("java.util.concurrent.CopyOnWriteArrayList")
.build()
.apply(getCursor(), method.getCoordinates().replace());
} else if (NEW_ARRAY_LIST_ITERABLE.matches(method) && method.getArguments().size() == 1 &&
TypeUtils.isAssignableTo("java.util.Collection", method.getArguments().get(0).getType())) {
}
if (NEW_ARRAY_LIST_ITERABLE.matches(method) && method.getArguments().size() == 1 &&
TypeUtils.isAssignableTo("java.util.Collection", method.getArguments().get(0).getType())) {
maybeRemoveImport("com.google.common.collect.Lists");
maybeAddImport("java.util.concurrent.CopyOnWriteArrayList");
return JavaTemplate.builder("new CopyOnWriteArrayList<>(#{any(java.util.Collection)})")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx)
.imports("java.util.LinkedList")
.build()
.apply(getCursor(), method.getCoordinates().replace());
} else if (NEW_LINKED_LIST_ITERABLE.matches(method) && method.getArguments().size() == 1 &&
TypeUtils.isAssignableTo("java.util.Collection", method.getArguments().get(0).getType())) {
}
if (NEW_LINKED_LIST_ITERABLE.matches(method) && method.getArguments().size() == 1 &&
TypeUtils.isAssignableTo("java.util.Collection", method.getArguments().get(0).getType())) {
maybeRemoveImport("com.google.common.collect.Lists");
maybeAddImport("java.util.LinkedList");
return JavaTemplate.builder("new LinkedList<>(#{any(java.util.Collection)})")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx)
.imports("java.util.HashMap")
.build()
.apply(getCursor(), method.getCoordinates().replace());
} else if (NEW_HASH_MAP_WITH_MAP.matches(method)) {
}
if (NEW_HASH_MAP_WITH_MAP.matches(method)) {
maybeRemoveImport("com.google.common.collect.Maps");
maybeAddImport("java.util.HashMap");
return JavaTemplate.builder("new HashMap<>(#{any(java.util.Map)})")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx)
.imports("java.util.LinkedHashMap")
.build()
.apply(getCursor(), method.getCoordinates().replace());
} else if (NEW_LINKED_HASH_MAP_WITH_MAP.matches(method)) {
}
if (NEW_LINKED_HASH_MAP_WITH_MAP.matches(method)) {
maybeRemoveImport("com.google.common.collect.Maps");
maybeAddImport("java.util.LinkedHashMap");
return JavaTemplate.builder("new LinkedHashMap<>(#{any(java.util.Map)})")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,17 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx)
.imports("java.util.TreeMap")
.build()
.apply(getCursor(), method.getCoordinates().replace());
} else if (NEW_TREE_MAP_WITH_COMPARATOR.matches(method)) {
}
if (NEW_TREE_MAP_WITH_COMPARATOR.matches(method)) {
maybeRemoveImport("com.google.common.collect.Maps");
maybeAddImport("java.util.TreeMap");
return JavaTemplate.builder("new TreeMap<>(#{any(java.util.Comparator)})")
.contextSensitive()
.imports("java.util.TreeMap")
.build()
.apply(getCursor(), method.getCoordinates().replace(), method.getArguments().get(0));
} else if (NEW_TREE_MAP_WITH_MAP.matches(method)) {
}
if (NEW_TREE_MAP_WITH_MAP.matches(method)) {
maybeRemoveImport("com.google.common.collect.Maps");
maybeAddImport("java.util.TreeMap");
return JavaTemplate.builder("new TreeMap<>(#{any(java.util.Map)})")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx)
.imports("java.util.HashSet")
.build()
.apply(getCursor(), method.getCoordinates().replace());
} else if (method.getArguments().size() == 1 && TypeUtils.isAssignableTo("java.util.Collection", method.getArguments().get(0).getType())) {
}
if (method.getArguments().size() == 1 && TypeUtils.isAssignableTo("java.util.Collection", method.getArguments().get(0).getType())) {
return JavaTemplate.builder("new HashSet<>(#{any(java.util.Collection)})")
.contextSensitive()
.imports("java.util.HashSet")
.build()
.apply(getCursor(), method.getCoordinates().replace(), method.getArguments().get(0));
} else {
maybeAddImport("java.util.Arrays");
JavaTemplate newHashSetVarargs = JavaTemplate.builder("new HashSet<>(Arrays.asList(" + method.getArguments().stream().map(a -> "#{any()}").collect(Collectors.joining(",")) + "))")
.contextSensitive()
.imports("java.util.Arrays")
.imports("java.util.HashSet")
.build();
return newHashSetVarargs.apply(getCursor(), method.getCoordinates().replace(),
method.getArguments().toArray());
}
maybeAddImport("java.util.Arrays");
JavaTemplate newHashSetVarargs = JavaTemplate.builder("new HashSet<>(Arrays.asList(" + method.getArguments().stream().map(a -> "#{any()}").collect(Collectors.joining(",")) + "))")
.contextSensitive()
.imports("java.util.Arrays")
.imports("java.util.HashSet")
.build();
return newHashSetVarargs.apply(getCursor(), method.getCoordinates().replace(),
method.getArguments().toArray());
}
return super.visitMethodInvocation(method, ctx);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,18 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx)
.imports("java.util.LinkedHashSet")
.build()
.apply(getCursor(), method.getCoordinates().replace());
} else if (NEW_LINKED_HASH_SET_ITERABLE.matches(method) && method.getArguments().size() == 1 &&
TypeUtils.isAssignableTo("java.util.Collection", method.getArguments().get(0).getType())) {
}
if (NEW_LINKED_HASH_SET_ITERABLE.matches(method) && method.getArguments().size() == 1 &&
TypeUtils.isAssignableTo("java.util.Collection", method.getArguments().get(0).getType())) {
maybeRemoveImport("com.google.common.collect.Sets");
maybeAddImport("java.util.LinkedHashSet");
return JavaTemplate.builder("new LinkedHashSet<>(#{any(java.util.Collection)})")
.contextSensitive()
.imports("java.util.LinkedHashSet")
.build()
.apply(getCursor(), method.getCoordinates().replace(), method.getArguments().get(0));
} else if (NEW_LINKED_HASH_SET_CAPACITY.matches(method)) {
}
if (NEW_LINKED_HASH_SET_CAPACITY.matches(method)) {
maybeRemoveImport("com.google.common.collect.Sets");
maybeAddImport("java.util.LinkedHashSet");
return JavaTemplate.builder("new LinkedHashSet<>(#{any(int)})")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,26 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx)
.imports("java.util.HashMap")
.build()
.apply(getCursor(), coordinates, j.getArguments().toArray());
} else if (NEW_LINKED_HASHMAP.matches(j)) {
}
if (NEW_LINKED_HASHMAP.matches(j)) {
maybeRemoveImport("com.google.common.collect.Maps");
maybeAddImport("java.util.LinkedHashMap");
JavaCoordinates coordinates = j.getCoordinates().replace();
return JavaTemplate.builder("new LinkedHashMap<>(#{any()})")
.imports("java.util.LinkedHashMap")
.build()
.apply(getCursor(), coordinates, j.getArguments().toArray());
} else if (NEW_HASHSET.matches(j)) {
}
if (NEW_HASHSET.matches(j)) {
maybeRemoveImport("com.google.common.collect.Sets");
maybeAddImport("java.util.HashSet");
JavaCoordinates coordinates = j.getCoordinates().replace();
return JavaTemplate.builder("new HashSet<>(#{any()})")
.imports("java.util.HashSet")
.build()
.apply(getCursor(), coordinates, j.getArguments().toArray());
} else if (NEW_LINKED_HASHSET.matches(j)) {
}
if (NEW_LINKED_HASHSET.matches(j)) {
maybeRemoveImport("com.google.common.collect.Sets");
maybeAddImport("java.util.LinkedHashSet");
JavaCoordinates coordinates = j.getCoordinates().replace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
if (fireEventMatcher.matches(method) && mi.getSelect() != null) {
if (arguments.size() <= 1) {
return JavaTemplate.builder("#{any(jakarta.enterprise.inject.spi.BeanManager)}.getEvent()" +
".fire(#{any(jakarta.enterprise.inject.spi.BeforeBeanDiscovery)})")
".fire(#{any(jakarta.enterprise.inject.spi.BeforeBeanDiscovery)})")
.javaParser(JavaParser.fromJavaVersion().classpathFromResources(ctx, "jakarta.enterprise.cdi-api-3.0.0-M4"))
.build()
.apply(updateCursor(mi), mi.getCoordinates().replace(), mi.getSelect(), arguments.get(0));
Expand All @@ -66,13 +66,14 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
args[arguments.size()] = arguments.get(0);

String template = "#{any(jakarta.enterprise.inject.spi.BeanManager)}.getEvent()" +
".select(" + String.join(", ", Collections.nCopies(arguments.size() - 1, "#{any(java.lang.annotation.Annotation)}")) + ')' +
".fire(#{any(jakarta.enterprise.inject.spi.BeforeBeanDiscovery)})";
".select(" + String.join(", ", Collections.nCopies(arguments.size() - 1, "#{any(java.lang.annotation.Annotation)}")) + ')' +
".fire(#{any(jakarta.enterprise.inject.spi.BeforeBeanDiscovery)})";
return JavaTemplate.builder(template)
.javaParser(JavaParser.fromJavaVersion().classpathFromResources(ctx, "jakarta.enterprise.cdi-api-3.0.0-M4"))
.build()
.apply(updateCursor(mi), mi.getCoordinates().replace(), args);
} else if (createInjectionTargetMatcher.matches(method) && mi.getSelect() != null) {
}
if (createInjectionTargetMatcher.matches(method) && mi.getSelect() != null) {
return JavaTemplate.builder("#{any(jakarta.enterprise.inject.spi.BeanManager)}.getInjectionTargetFactory(#{any(jakarta.enterprise.inject.spi.AnnotatedType)}).createInjectionTarget(null)")
.javaParser(JavaParser.fromJavaVersion().classpathFromResources(ctx, "jakarta.enterprise.cdi-api-3.0.0-M4"))
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public static Matcher nullCheck() {
if (binary.getOperator() == Equal) {
if (J.Literal.isLiteralValue(binary.getLeft(), null)) {
return new NullCheck(cursor, binary.getRight());
} else if (J.Literal.isLiteralValue(binary.getRight(), null)) {
}
if (J.Literal.isLiteralValue(binary.getRight(), null)) {
return new NullCheck(cursor, binary.getLeft());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ public J.Case visitCase(J.Case case_, ExecutionContext ctx) {
}
if ((select instanceof J.FieldAccess || select instanceof J.Identifier) && equalTo instanceof J.Identifier && label.getName().getSimpleName().equals(((J.Identifier) equalTo).getSimpleName())) {
return select;
} else if ((equalTo instanceof J.FieldAccess || equalTo instanceof J.Identifier) && select instanceof J.Identifier && label.getName().getSimpleName().equals(((J.Identifier) select).getSimpleName())) {
}
if ((equalTo instanceof J.FieldAccess || equalTo instanceof J.Identifier) && select instanceof J.Identifier && label.getName().getSimpleName().equals(((J.Identifier) select).getSimpleName())) {
return equalTo;
}
return null;
Expand Down
Loading