Skip to content

Commit

Permalink
858 incorporate new parser into core (#868)
Browse files Browse the repository at this point in the history
* Fix parsing duplicate pom files

Added target to default ignorePatterns
Refactor method names for test
Fix dependency download
Fix test by ignoring poms when parsing resources
Add logging
Replace List with Set to avoid duplicates

* Refactoring

* Add test proving duplicate parsing of resources

* Fix path calculcation to other modules

* Back to use shrinkwrap in tests

* Replace single-line with multi-line String

* Bumped maven-resolver.version

* Fix test allow SbmCoreConfig construct ExecutionContext

* GH Action

* Assert correct classpath

* Fix testdata

* Cleanup

* Disabled test that must be reactivated later

* Move JavaSourceUtil to sbm-support-rewrite

* Move OpenRewriteTestSupport to test-helper

* Back to use shrinkwrap in tests

* Add missing test projects

* Back to use shrinkwrap in tests

* Revamp/move open rewrite test support to test helper (#939)

* Revamp/make other modules compile (#943)

* Update license header

* Add sbm-support-boot module

* Add sbm-support-boot module

* Module sbm-support-boot compiles

* Module sbm-support-jee compiles

* Module sbm-support-weblogic compiles

* WIP sbm-recipes-jee-to-boot

* Make SwapResponseWithResponseEntity compile

* Make SwapCacheControl compile

* Make SwapStatusForHttpStatus compile

* Make fieldsMapping a member

* Remove unused member

* Make ReplaceMediaType compile

Also removes unused member

* Make ReplaceResponseEntityBuilder compile

* Make sbm-recipes-jee-to-boot compile

* Make sbm-recipes-spring-cloud compile

* Delete unused classes

* Delete unused classes

* Make sbm-recipes-boot-upgrade compile

* Using shrinkwrap depchain dependency

* Replace single line with multi line string

* Cleanup properties order
  • Loading branch information
fabapp2 authored Sep 24, 2023
1 parent f48a9eb commit 79ee7f3
Show file tree
Hide file tree
Showing 70 changed files with 832 additions and 2,260 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public interface JavaSource extends ProjectResource {
* <p>
* Be careful if the given {@code Recipe} affects more than the wrapped compilation unit YOU MUST CALL {@link JavaSourceSet.apply(..)}
*/
void apply(Recipe recipe);
void apply(Recipe... recipe);

/**
* Retrieve the {@code Type} declared in this {@code JavaSource}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public interface Type {

Annotation getAnnotation(String fqName);

void apply(Recipe r);
void apply(Recipe... r);

boolean hasMethod(String methodPattern);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ public Annotation getAnnotation(String fqName) {
}

@Override
public void apply(Recipe r) {

public void apply(Recipe... r) {
throw new UnsupportedOperationException();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ public <T> void replaceLiteral(Class<T> klass, LiteralTransformer<T> t) {
refactoring.refactor(getResource(), new ReplaceLiteralVisitor<>(klass, t));
}


@Override
public String toString() {
return "OpenRewriteJavaSource(" + getAbsolutePath() + ")";
Expand All @@ -181,7 +180,7 @@ public String toString() {
* {@inheritDoc}
*/
@Override
public void apply(Recipe recipe) {
public void apply(Recipe... recipe) {
refactoring.refactor(getResource(), recipe);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public String toString() {
}

@Override
public void apply(Recipe r) {
public void apply(Recipe... r) {
refactoring.refactor(rewriteSourceFileHolder, r);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ public class RetrieveAnnotationTypeTest {
@Test
void retrieveAnnotation() {
String javaSource =
"import javax.ejb.Stateless;\n" +
"@Stateless\n" +
"public class MyClass {" +
"}";
"""
import javax.ejb.Stateless;
@Stateless
public class MyClass { }
""";

// String mavenRepo = System.getProperty("user.home") + "/.m2/repository";
// List<Path> paths = JavaParser.dependenciesFromClasspath("ejb-api");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,31 @@ public class GetImplementsTest {
@Test
void test() {
String businessInterface =
"package com.example.jee.app.ejb.local;\n" +
"\n" +
"import javax.ejb.Local;\n" +
"\n" +
"@Local\n" +
"public interface ABusinessInterface {\n" +
" String businessMethod();\n" +
"}";
"""
package com.example.jee.app.ejb.local;
import javax.ejb.Local;
@Local
public interface ABusinessInterface {
String businessMethod();
}
""";

String ejb =
"package com.example.jee.app.ejb.local;\n" +
"\n" +
"import javax.ejb.Stateless;\n" +
"\n" +
"@Stateless\n" +
"public class ABean implements ABusinessInterface {\n" +
"\n" +
" @Override\n" +
" public String businessMethod() {\n" +
" return \"A\";\n" +
" }\n" +
"}";
"""
package com.example.jee.app.ejb.local;
import javax.ejb.Stateless;
@Stateless
public class ABean implements ABusinessInterface {
@Override
public String businessMethod() {
return "A";
}
}
""";

List<J.CompilationUnit> compilationUnitsFromStrings = OpenRewriteTestSupport.createCompilationUnitsFromStrings(List.of("javax.ejb:javax.ejb-api:3.2"), businessInterface, ejb);

Expand Down
5 changes: 3 additions & 2 deletions components/sbm-recipes-boot-upgrade/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>

<dependencies>
Expand Down Expand Up @@ -73,6 +73,7 @@
<dependency>
<groupId>org.springframework.sbm</groupId>
<artifactId>recipe-test-support</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public String getDescription() {
}

@Override
protected TreeVisitor<?, ExecutionContext> getVisitor() {
public TreeVisitor<?, ExecutionContext> getVisitor() {

return new PropertiesVisitor<ExecutionContext>() {

Expand Down

This file was deleted.

Loading

0 comments on commit 79ee7f3

Please sign in to comment.