Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
bce32bb
Add mapping for migration for joda LocalDate
Feb 17, 2025
0ed4bf2
Fix safe migration issue.
Feb 18, 2025
fa80bf7
Merge branch 'main' into add-localdate-mapping-to-joda-recipe
timtebeek Feb 18, 2025
4d2d32f
Add LocalDateTime mapping
Feb 18, 2025
d058821
Add LocalTime mapping
Feb 19, 2025
d5f61bc
Add Seconds mapping
Feb 19, 2025
e16c12d
Add Days mapping
Feb 20, 2025
ccbc050
Add tests
Feb 20, 2025
37eb88c
Disable safe check in Visitor
Feb 21, 2025
53f40df
add additional mappings
Mar 4, 2025
86e5b1d
add additional mappings
Mar 6, 2025
8b466aa
add additional mappings
Mar 19, 2025
3fc49b1
Update .gitlab-ci.yml file
Mar 24, 2025
6a6008b
fix assignment to primitive
Mar 26, 2025
60c7759
add mappings
Mar 28, 2025
015df71
Fix mappings
Mar 29, 2025
6036bb2
Add mappings
Apr 2, 2025
214b137
Merge remote-tracking branch 'refs/remotes/origin/add-localdate-mappi…
Apr 2, 2025
c8b70f8
Merge branch 'refs/heads/main' into add-localdate-mapping-to-joda-recipe
Apr 7, 2025
bf618b5
Add mappings
Apr 7, 2025
dc0f687
Merge branch 'openrewrite:main' into add-localdate-mapping-to-joda-re…
YarochkinMichael Apr 10, 2025
26b04fe
Merge pull request #1 from YarochkinMichael/main
YarochkinMichael Apr 22, 2025
272cab9
Merge branch 'main' into add-localdate-mapping-to-joda-recipe
timtebeek May 6, 2025
a0dedc0
Apply suggestions from code review
timtebeek May 6, 2025
3774163
Update build.gradle.kts
timtebeek May 6, 2025
a08d224
Merge branch 'openrewrite:main' into add-localdate-mapping-to-joda-re…
YarochkinMichael Jun 10, 2025
890ff0f
Merge branch 'openrewrite:main' into add-localdate-mapping-to-joda-re…
YarochkinMichael Jun 14, 2025
d757bf8
Add mappings
Jun 16, 2025
f2bdd45
Fix tests
Aug 1, 2025
27c79d7
Merge branch 'refs/heads/main' into add-localdate-mapping-to-joda-recipe
Aug 1, 2025
f841f60
Merge branch 'main' into add-localdate-mapping-to-joda-recipe
Aug 6, 2025
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
31 changes: 31 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
before_script:
- function setEnv(){
$env:JAVA_HOME="C:\Runners\OpenRewrite\CO_JDK";
$env:PATH+= ";$env:JAVA_HOME\bin";
dir env:;
}
- setEnv

stages:
- build
- test
- deploy

build:
stage: build
script:
- ./gradlew clean assemble --no-daemon

test:
stage: test
script:
- ./gradlew check --no-daemon
rules:
- when: never # Never run the test job

deploy:
stage: deploy
only:
- add-localdate-mapping-to-joda-recipe
script:
- ./gradlew publishNebulaPublicationToPrimionNexusRepository --no-daemon
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.openrewrite.java.JavadocVisitor;
import org.openrewrite.java.tree.*;
import org.openrewrite.java.tree.J.VariableDeclarations.NamedVariable;
import org.openrewrite.marker.SearchResult;

import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -95,14 +96,19 @@ public J visitCompilationUnit(J.CompilationUnit cu, ExecutionContext ctx) {

@Override
public J visitVariable(NamedVariable variable, ExecutionContext ctx) {
if (variable.getType() == null || !variable.getType().isAssignableFrom(JODA_CLASS_PATTERN)) {
if (variable.getType() == null){
return SearchResult.found(variable, "Variable with no type is found. Please check your code."); // unhandled case
}
if (!variable.getType().isAssignableFrom(JODA_CLASS_PATTERN)) {
return super.visitVariable(variable, ctx);
}
// TODO: handle class variables
// working fine with disabling for safe check in JodaTimeVisitor
if (isClassVar(variable)) {
acc.getUnsafeVars().add(variable);
return variable;
}

variable = (NamedVariable) super.visitVariable(variable, ctx);

if (!variable.getType().isAssignableFrom(JODA_CLASS_PATTERN)) {
Expand Down Expand Up @@ -199,13 +205,26 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx)
if (argPos == -1) {
return method;
}
String paramName = parentMethod.getMethodType().getParameterNames().get(argPos);
NamedVariable var = acc.getVarTable().getVarByName(parentMethod.getMethodType(), paramName);

JavaType.Method parentMethodType = parentMethod.getMethodType();
List<JavaType> parameterTypes = parentMethodType.getParameterTypes();
int parameterTypesSize = parameterTypes.size();
//try to process method with variable arguments
if(argPos > parameterTypesSize)
{
//todo find better way to detect (...) in method arguments
if (parameterTypes.get(parameterTypesSize - 1).toString().endsWith("[]")){
return method;
}
}

String paramName = parentMethodType.getParameterNames().get(argPos);
NamedVariable var = acc.getVarTable().getVarByName(parentMethodType, paramName);
if (var != null) {
methodReferencedVars.computeIfAbsent(method.getMethodType(), k -> new HashSet<>()).add(var);
} else {
methodUnresolvedReferencedVars.computeIfAbsent(method.getMethodType(), k -> new HashSet<>())
.add(new UnresolvedVar(parentMethod.getMethodType(), paramName));
.add(new UnresolvedVar(parentMethodType, paramName));
}
}
return method;
Expand Down
Loading