Skip to content

Commit

Permalink
"Escape javadoc special characters" V2 (#1356)
Browse files Browse the repository at this point in the history
Reverts #1345

Fixes #1271
  • Loading branch information
iwahbe committed May 3, 2024
1 parent bc9c1ae commit c8db4b9
Show file tree
Hide file tree
Showing 7 changed files with 5,835 additions and 28 deletions.
26 changes: 13 additions & 13 deletions pkg/codegen/java/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,15 +414,15 @@ func genPropJavadoc(ctx *classFileContext, prop *schema.Property, options propJa
}

if prop.Comment != "" {
fprintf(w, "%s\n", formatBlockComment(preamble+prop.Comment, options.indent))
fprintf(w, "%s\n", formatForeignBlockCommentFrom(preamble+prop.Comment, len(preamble), options.indent))
}
if options.isBuilder {
fprintf(w, "%s\n", formatBlockComment("@return builder", options.indent))
}

if prop.DeprecationMessage != "" {
fprintf(w, "%s * @deprecated\n", options.indent)
fprintf(w, "%s\n", formatBlockComment(prop.DeprecationMessage, options.indent))
fprintf(w, "%s\n", formatForeignBlockComment(prop.DeprecationMessage, options.indent))
}
fprintf(w, "%s */\n", options.indent)
printObsoleteAttribute(ctx, prop.DeprecationMessage, options.indent)
Expand Down Expand Up @@ -523,7 +523,7 @@ func (pt *plainType) genInputType(ctx *classFileContext) error {
// Open the class.
if pt.comment != "" {
fprintf(w, "/**\n")
fprintf(w, "%s\n", formatBlockComment(pt.comment, ""))
fprintf(w, "%s\n", formatForeignBlockComment(pt.comment, ""))
fprintf(w, " */\n")
}

Expand Down Expand Up @@ -931,12 +931,12 @@ func (mod *modContext) genResource(ctx *classFileContext, r *schema.Resource, ar
if r.Comment != "" || r.DeprecationMessage != "" {
fprintf(w, "/**\n")
if r.Comment != "" {
fprintf(w, "%s\n", formatBlockComment(r.Comment, ""))
fprintf(w, "%s\n", formatForeignBlockComment(r.Comment, ""))
}

if r.DeprecationMessage != "" {
fprintf(w, " * @deprecated\n")
fprintf(w, "%s\n", formatBlockComment(r.DeprecationMessage, ""))
fprintf(w, "%s\n", formatForeignBlockComment(r.DeprecationMessage, ""))

}
fprintf(w, " */\n")
Expand Down Expand Up @@ -986,12 +986,12 @@ func (mod *modContext) genResource(ctx *classFileContext, r *schema.Resource, ar
if prop.Comment != "" || prop.DeprecationMessage != "" {
fprintf(w, " /**\n")
if prop.Comment != "" {
fprintf(w, "%s\n", formatBlockComment(prop.Comment, " "))
fprintf(w, "%s\n", formatForeignBlockComment(prop.Comment, " "))
}

if prop.DeprecationMessage != "" {
fprintf(w, " * @deprecated\n")
fprintf(w, "%s\n", formatBlockComment(prop.DeprecationMessage, " "))
fprintf(w, "%s\n", formatForeignBlockComment(prop.DeprecationMessage, " "))

}
fprintf(w, " */\n")
Expand All @@ -1009,7 +1009,7 @@ func (mod *modContext) genResource(ctx *classFileContext, r *schema.Resource, ar

if prop.Comment != "" {
fprintf(w, " /**\n")
fprintf(w, "%s\n", formatBlockComment("@return "+prop.Comment, " "))
fprintf(w, "%s\n", formatForeignBlockCommentFrom("@return "+prop.Comment, 2, " "))
fprintf(w, " */\n")
}

Expand Down Expand Up @@ -1220,10 +1220,10 @@ func printCommentFunction(ctx *classFileContext, fun *schema.Function, indent st
w := ctx.writer
if fun.Comment != "" || fun.DeprecationMessage != "" {
fprintf(w, " /**\n")
fprintf(w, "%s\n", formatBlockComment(fun.Comment, indent))
fprintf(w, "%s\n", formatForeignBlockComment(fun.Comment, indent))
if fun.DeprecationMessage != "" {
fprintf(w, " * @deprecated\n")
fprintf(w, "%s\n", formatBlockComment(fun.DeprecationMessage, indent))
fprintf(w, "%s\n", formatForeignBlockComment(fun.DeprecationMessage, indent))
}
fprintf(w, " */\n")
}
Expand Down Expand Up @@ -1469,7 +1469,7 @@ func (mod *modContext) genEnum(ctx *classFileContext, enum *schema.EnumType) err

if enum.Comment != "" {
fprintf(w, "%s/**\n", indent)
fprintf(w, "%s\n", formatBlockComment(enum.Comment, indent))
fprintf(w, "%s\n", formatForeignBlockComment(enum.Comment, indent))
fprintf(w, "%s */\n", indent)
}

Expand All @@ -1494,7 +1494,7 @@ func (mod *modContext) genEnum(ctx *classFileContext, enum *schema.EnumType) err
if e.Comment != "" || e.DeprecationMessage != "" {
fprintf(w, "%s/**\n", indent)
if e.Comment != "" {
fprintf(w, "%s\n", formatBlockComment(e.Comment, indent))
fprintf(w, "%s\n", formatForeignBlockComment(e.Comment, indent))
}

if e.DeprecationMessage != "" {
Expand Down Expand Up @@ -1685,7 +1685,7 @@ func (mod *modContext) genConfig(ctx *classFileContext, variables []*schema.Prop

if p.Comment != "" {
fprintf(w, "/**\n")
fprintf(w, "%s\n", formatBlockComment(p.Comment, ""))
fprintf(w, "%s\n", formatForeignBlockComment(p.Comment, ""))
fprintf(w, " */\n")
}
if err := getterTemplate.Execute(w, getterTemplateContext{
Expand Down

0 comments on commit c8db4b9

Please sign in to comment.