Skip to content

Commit

Permalink
Reduce warnings by generating JavaDoc (#45)
Browse files Browse the repository at this point in the history
* Reduce warnings by generating JavaDoc

* Package private visibility on templates to reduce warnings
  • Loading branch information
timtebeek authored Dec 17, 2023
1 parent 4aa4d3d commit bbf420f
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,15 @@ public void visitClassDef(JCTree.JCClassDecl classDecl) {
String after = descriptor.afterTemplate.getName().toString();

StringBuilder recipe = new StringBuilder();
String refasterRuleClassName = classDecl.sym.fullname.toString().substring(classDecl.sym.packge().fullname.length() + 1);
recipe.append("/**\n * OpenRewrite recipe created for Refaster template `").append(refasterRuleClassName).append("`.\n */\n");
String recipeName = templateFqn.substring(templateFqn.lastIndexOf('.') + 1);
recipe.append("@NonNullApi\n");
recipe.append(descriptor.classDecl.sym.outermostClass() == descriptor.classDecl.sym ?
"public class " : "public static class ").append(recipeName).append(" extends Recipe {\n");
recipe.append("\n");
recipe.append(recipeDescriptor(classDecl,
"Refaster template `" + classDecl.sym.fullname.toString().substring(classDecl.sym.packge().fullname.length() + 1) + '`',
"Refaster template `" + refasterRuleClassName + '`',
"Recipe created for the following Refaster template:\\n```java\\n" + escape(templateCode) + "\\n```\\n."
));
recipe.append(" @Override\n");
Expand Down Expand Up @@ -333,6 +335,7 @@ public void visitClassDef(JCTree.JCClassDecl classDecl) {
}

if (outerClassRequired) {
out.write("/**\n * OpenRewrite recipes created for Refaster template `" + inputOuterFQN + "`.\n */\n");
String outerClassName = className.substring(className.lastIndexOf('.') + 1);
out.write("public class " + outerClassName + " extends Recipe {\n");
out.write(recipeDescriptor(classDecl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ public void visitIdent(JCTree.JCIdent ident) {
}

out.write("\n");
out.write("public class " + templateFqn.substring(templateFqn.lastIndexOf('.') + 1) + " {\n");
out.write(" public static JavaTemplate.Builder getTemplate() {\n");
out.write("class " + templateFqn.substring(templateFqn.lastIndexOf('.') + 1) + " {\n");
out.write(" static JavaTemplate.Builder getTemplate() {\n");
out.write(" return JavaTemplate\n");
out.write(" .builder(\"" + templateSource + "\")");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package foo;
import org.openrewrite.java.*;

public class ParameterReuseRecipe$1_before {
public static JavaTemplate.Builder getTemplate() {
class ParameterReuseRecipe$1_before {
static JavaTemplate.Builder getTemplate() {
return JavaTemplate
.builder("#{s:any(java.lang.String)}.equals(#{s})");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package foo;
import org.openrewrite.java.*;

public class ShouldAddClasspathRecipes$FullyQualifiedRecipe$1_after {
public static JavaTemplate.Builder getTemplate() {
class ShouldAddClasspathRecipes$FullyQualifiedRecipe$1_after {
static JavaTemplate.Builder getTemplate() {
return JavaTemplate
.builder("org.slf4j.LoggerFactory.getLogger(#{message:any(java.lang.String)})")
.javaParser(JavaParser.fromJavaVersion().classpath("slf4j-api"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package foo;
import org.openrewrite.java.*;

public class ShouldAddClasspathRecipes$FullyQualifiedRecipe$1_before {
public static JavaTemplate.Builder getTemplate() {
class ShouldAddClasspathRecipes$FullyQualifiedRecipe$1_before {
static JavaTemplate.Builder getTemplate() {
return JavaTemplate
.builder("System.out.println(#{message:any(java.lang.String)})");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package foo;
import org.openrewrite.java.*;

public class ShouldAddClasspathRecipes$PrimitiveRecipe$1_after {
public static JavaTemplate.Builder getTemplate() {
class ShouldAddClasspathRecipes$PrimitiveRecipe$1_after {
static JavaTemplate.Builder getTemplate() {
return JavaTemplate
.builder("System.out.print(#{i:any(int)})");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package foo;
import org.openrewrite.java.*;

public class ShouldAddClasspathRecipes$PrimitiveRecipe$1_before {
public static JavaTemplate.Builder getTemplate() {
class ShouldAddClasspathRecipes$PrimitiveRecipe$1_before {
static JavaTemplate.Builder getTemplate() {
return JavaTemplate
.builder("System.out.println(#{i:any(int)})");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package foo;
import org.openrewrite.java.*;

public class ShouldAddClasspathRecipes$UnqualifiedRecipe$1_after {
public static JavaTemplate.Builder getTemplate() {
class ShouldAddClasspathRecipes$UnqualifiedRecipe$1_after {
static JavaTemplate.Builder getTemplate() {
return JavaTemplate
.builder("org.slf4j.LoggerFactory.getLogger(#{message:any(java.lang.String)})")
.javaParser(JavaParser.fromJavaVersion().classpath("slf4j-api"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package foo;
import org.openrewrite.java.*;

public class ShouldAddClasspathRecipes$UnqualifiedRecipe$1_before {
public static JavaTemplate.Builder getTemplate() {
class ShouldAddClasspathRecipes$UnqualifiedRecipe$1_before {
static JavaTemplate.Builder getTemplate() {
return JavaTemplate
.builder("System.out.println(#{message:any(java.lang.String)})");
}
Expand Down

0 comments on commit bbf420f

Please sign in to comment.