File tree Expand file tree Collapse file tree 3 files changed +15
-27
lines changed
main/kotlin/cc/unitmesh/kotlin/context
test/kotlin/cc/unitmesh/kotlin/context Expand file tree Collapse file tree 3 files changed +15
-27
lines changed Original file line number Diff line number Diff line change 94
94
name : tests-result
95
95
path : ${{ github.workspace }}/build/reports/tests
96
96
97
+ # Run tests
98
+ - name : Build Plugin
99
+ run : ./gradlew :plugin:buildPlugin
100
+
97
101
# Upload Kover report to CodeCov
98
102
- name : Upload Code Coverage Report
99
103
uses : codecov/codecov-action@v3
@@ -103,15 +107,6 @@ jobs:
103
107
with :
104
108
files : ${{ github.workspace }}/build/reports/kover/xml/report.xml
105
109
106
- - name : Upload coverage reports to Codecov
107
- uses : codecov/codecov-action@v3
108
- env :
109
- CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
110
-
111
- # Run tests
112
- - name : Build Plugin
113
- run : ./gradlew :plugin:buildPlugin
114
-
115
110
# Prepare plugin archive content for creating artifact
116
111
- name : Prepare Plugin Artifact
117
112
id : artifact
Original file line number Diff line number Diff line change @@ -42,26 +42,19 @@ class KotlinMethodContextBuilder : MethodContextBuilder {
42
42
}
43
43
44
44
object Util {
45
- fun getSignatureString (ktNamedFunction : KtNamedFunction ): String {
46
- val bodyBlockExpression = ktNamedFunction.bodyBlockExpression
45
+
46
+ fun getSignatureString (signatureString : KtNamedFunction ): String {
47
+ val bodyBlockExpression = signatureString.bodyBlockExpression
47
48
val startOffsetInParent = if (bodyBlockExpression != null ) {
48
49
bodyBlockExpression.startOffsetInParent
49
50
} else {
50
- val bodyExpression = ktNamedFunction.bodyExpression
51
- bodyExpression?.startOffsetInParent ? : ktNamedFunction.textLength
52
- }
53
-
54
- val docEnd = ktNamedFunction.docComment?.endOffset ? : 0
55
-
56
- val text = ktNamedFunction.text
57
-
58
- val result = if (docEnd < startOffsetInParent) {
59
- text.substring(docEnd, startOffsetInParent)
60
- } else {
61
- text.substring(ktNamedFunction.startOffsetInParent, startOffsetInParent)
51
+ val bodyExpression = signatureString.bodyExpression
52
+ bodyExpression?.startOffsetInParent ? : signatureString.textLength
62
53
}
63
54
64
- return result.replace(" \n " , " " ).trim()
55
+ val text = signatureString.text
56
+ val substring = text.substring(0 , startOffsetInParent)
57
+ return substring.replace(' \n ' , ' ' ).trim()
65
58
}
66
59
}
67
60
}
Original file line number Diff line number Diff line change @@ -25,10 +25,10 @@ class KotlinMethodContextBuilderTest : LightPlatformTestCase() {
25
25
val clz = PsiTreeUtil .findChildOfType(createFile, KtNamedFunction ::class .java)!!
26
26
27
27
val signatureString = KotlinMethodContextBuilder .Util .getSignatureString(clz)
28
- TestCase .assertEquals(signatureString, " fun main()" )
28
+ TestCase .assertEquals(signatureString, " /** * It's a hello, world. */ fun main()" )
29
29
}
30
30
31
- fun shouldIgnoreClassFunctionComment () {
31
+ fun testShouldIgnoreClassFunctionComment () {
32
32
// given
33
33
val code = """
34
34
class UserController {
@@ -45,7 +45,7 @@ class KotlinMethodContextBuilderTest : LightPlatformTestCase() {
45
45
val clz = PsiTreeUtil .findChildOfType(createFile, KtNamedFunction ::class .java)!!
46
46
47
47
val signatureString = KotlinMethodContextBuilder .Util .getSignatureString(clz)
48
- TestCase .assertEquals(signatureString, " fun main()" )
48
+ TestCase .assertEquals(signatureString, " /** * It's a hello, world. */ fun main()" )
49
49
}
50
50
51
51
fun testShouldHandleNormalClassFunctionComment () {
You can’t perform that action at this time.
0 commit comments