-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract code comment to quality to analysis
- Loading branch information
Showing
10 changed files
with
48 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...c/unitmesh/core/comment/DocInstruction.kt → ...esh/core/comment/DocCommentInstruction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
unit-picker/src/main/kotlin/cc/unitmesh/pick/builder/comment/CommentsExtractor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package cc.unitmesh.pick.builder.comment | ||
|
||
import cc.unitmesh.core.SupportedLang | ||
import cc.unitmesh.quality.documentation.CodeComment | ||
|
||
/** | ||
* Extracts the documentation comments (KDoc) from the given code. | ||
* | ||
* @param code the Kotlin code from which to extract the KDoc comments | ||
* @return a list of pairs, where each pair contains the line number and the extracted KDoc comment | ||
*/ | ||
fun extractComments(code: String, language: SupportedLang): List<CodeComment> { | ||
return when (language) { | ||
SupportedLang.KOTLIN -> CodeComment.extractKotlinComment(code) | ||
SupportedLang.JAVA -> CodeComment.extractKotlinComment(code) | ||
else -> { | ||
println("Unsupported language: $language") | ||
emptyList() | ||
} | ||
} | ||
} |
13 changes: 6 additions & 7 deletions
13
unit-picker/src/main/kotlin/cc/unitmesh/pick/builder/comment/DocumentationTypedInsBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,26 @@ | ||
package cc.unitmesh.pick.builder.comment | ||
|
||
import cc.unitmesh.core.SupportedLang | ||
import cc.unitmesh.core.SupportedLang.* | ||
import cc.unitmesh.core.comment.DocInstruction | ||
import cc.unitmesh.core.comment.DocCommentInstruction | ||
import cc.unitmesh.core.completion.TypedIns | ||
import cc.unitmesh.core.completion.TypedInsBuilder | ||
import cc.unitmesh.pick.worker.job.JobContext | ||
import chapi.domain.core.CodeContainer | ||
|
||
class DocumentationTypedInsBuilder(val context: JobContext) : TypedInsBuilder { | ||
private val kotlinCommentBuilder = JvmCommentBuilder(SupportedLang.KOTLIN) | ||
private val javaCommentBuilder = JvmCommentBuilder(SupportedLang.JAVA, DocInstruction.JAVA) | ||
private val javaCommentBuilder = JvmCommentBuilder(SupportedLang.JAVA, DocCommentInstruction.JAVA) | ||
|
||
override fun build(container: CodeContainer): List<TypedIns> { | ||
val language = context.project.language | ||
return when (language) { | ||
JAVA -> javaCommentBuilder.build(context.job.code, container) | ||
KOTLIN -> { | ||
SupportedLang.JAVA -> javaCommentBuilder.build(context.job.code, container) | ||
SupportedLang.KOTLIN -> { | ||
kotlinCommentBuilder.build(context.job.code, container) | ||
} | ||
|
||
TYPESCRIPT -> TODO() | ||
RUST -> TODO() | ||
SupportedLang.TYPESCRIPT -> TODO() | ||
SupportedLang.RUST -> TODO() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
unit-picker/src/main/kotlin/cc/unitmesh/pick/builder/comment/ins/ClassCommentIns.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters