Skip to content

Fix plain JavaDocs formatting #1436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2022
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 @@ -7,7 +7,6 @@ import org.utbot.framework.codegen.renderer.CgRendererContext
import org.utbot.framework.codegen.renderer.CgVisitor
import org.utbot.framework.codegen.renderer.auxiliaryClassTextById
import org.utbot.framework.codegen.renderer.utilMethodTextById
import org.utbot.framework.codegen.reports.TestsGenerationReport
import org.utbot.framework.plugin.api.BuiltinClassId
import org.utbot.framework.plugin.api.ClassId
import org.utbot.framework.plugin.api.ConstructorId
Expand Down Expand Up @@ -60,6 +59,7 @@ interface CgElement {
is CgCustomTagStatement -> visit(element)
is CgDocCodeStmt -> visit(element)
is CgDocRegularStmt -> visit(element)
is CgDocRegularLineStmt -> visit(element)
is CgDocClassLinkStmt -> visit(element)
is CgDocMethodLinkStmt -> visit(element)
is CgAnonymousFunction -> visit(element)
Expand Down Expand Up @@ -423,7 +423,19 @@ class CgDocRegularStmt(val stmt: String) : CgDocStatement() {
override fun isEmpty(): Boolean = stmt.isEmpty()

override fun equals(other: Any?): Boolean =
if (other is CgDocCodeStmt) this.hashCode() == other.hashCode() else false
if (other is CgDocRegularStmt) this.hashCode() == other.hashCode() else false

override fun hashCode(): Int = stmt.hashCode()
}

/**
* Represents an element of a whole line of a multiline comment.
*/
class CgDocRegularLineStmt(val stmt: String) : CgDocStatement() {
override fun isEmpty(): Boolean = stmt.isEmpty()

override fun equals(other: Any?): Boolean =
if (other is CgDocRegularLineStmt) this.hashCode() == other.hashCode() else false

override fun hashCode(): Int = stmt.hashCode()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.utbot.framework.codegen.domain.models.CgDocClassLinkStmt
import org.utbot.framework.codegen.domain.models.CgDocCodeStmt
import org.utbot.framework.codegen.domain.models.CgDocMethodLinkStmt
import org.utbot.framework.codegen.domain.models.CgDocPreTagStatement
import org.utbot.framework.codegen.domain.models.CgDocRegularLineStmt
import org.utbot.framework.codegen.domain.models.CgDocRegularStmt
import org.utbot.framework.codegen.domain.models.CgDocumentationComment
import org.utbot.framework.codegen.domain.models.CgElement
Expand Down Expand Up @@ -360,7 +361,12 @@ abstract class CgAbstractRenderer(
override fun visit(element: CgDocRegularStmt){
if (element.isEmpty()) return

print(" * " + element.stmt)
print(element.stmt.replace("\n", "\n * "))
}
override fun visit(element: CgDocRegularLineStmt){
if (element.isEmpty()) return

print(" * " + element.stmt + "\n")
}
override fun visit(element: CgDocClassLinkStmt) {
if (element.isEmpty()) return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import org.utbot.framework.codegen.domain.models.CgSwitchCase
import org.utbot.framework.codegen.domain.models.CgSwitchCaseLabel
import org.utbot.framework.codegen.domain.models.CgClass
import org.utbot.framework.codegen.domain.models.CgClassBody
import org.utbot.framework.codegen.domain.models.CgDocRegularLineStmt
import org.utbot.framework.codegen.domain.models.CgNestedClassesRegion
import org.utbot.framework.codegen.domain.models.CgTestMethod
import org.utbot.framework.codegen.domain.models.CgTestMethodCluster
Expand Down Expand Up @@ -132,6 +133,7 @@ interface CgVisitor<R> {
fun visit(element: CgCustomTagStatement): R
fun visit(element: CgDocCodeStmt): R
fun visit(element: CgDocRegularStmt): R
fun visit(element: CgDocRegularLineStmt): R
fun visit(element: CgDocClassLinkStmt): R
fun visit(element: CgDocMethodLinkStmt): R

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.utbot.framework.codegen.tree.ututils

import org.utbot.framework.codegen.domain.builtin.UtilClassFileMethodProvider
import org.utbot.framework.codegen.domain.context.CgContext
import org.utbot.framework.codegen.domain.models.CgDocRegularStmt
import org.utbot.framework.codegen.domain.models.CgDocRegularLineStmt
import org.utbot.framework.codegen.domain.models.CgDocumentationComment
import org.utbot.framework.codegen.renderer.CgAbstractRenderer
import org.utbot.framework.plugin.api.CodegenLanguage
Expand Down Expand Up @@ -35,8 +35,8 @@ sealed class UtilClassKind(
fun utilClassDocumentation(codegenLanguage: CodegenLanguage): CgDocumentationComment
= CgDocumentationComment(
listOf(
CgDocRegularStmt("$utilClassKindCommentText \n"),
CgDocRegularStmt("$UTIL_CLASS_VERSION_COMMENT_PREFIX${utilClassVersion(codegenLanguage)} \n"),
CgDocRegularLineStmt(utilClassKindCommentText),
CgDocRegularLineStmt("$UTIL_CLASS_VERSION_COMMENT_PREFIX${utilClassVersion(codegenLanguage)}"),
)
)

Expand Down