From b9af199053f9dbbb2944cfa85abd7765dcebf695 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Thu, 4 Jan 2024 21:05:36 +0800 Subject: [PATCH] fix(java): add simple fix for Java stratLine issue --- .../src/main/kotlin/cc/unitmesh/pick/ext/CodeDataStructUtil.kt | 2 ++ .../pick/builder/unittest/java/JavaTestCodeServiceE2ETest.kt | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/unit-picker/src/main/kotlin/cc/unitmesh/pick/ext/CodeDataStructUtil.kt b/unit-picker/src/main/kotlin/cc/unitmesh/pick/ext/CodeDataStructUtil.kt index aed2ef5..8043ca1 100644 --- a/unit-picker/src/main/kotlin/cc/unitmesh/pick/ext/CodeDataStructUtil.kt +++ b/unit-picker/src/main/kotlin/cc/unitmesh/pick/ext/CodeDataStructUtil.kt @@ -17,6 +17,8 @@ fun CodeContainer.buildSourceCode(codeLines: List) { if (annotationPos.StartLine != 0) { position.StartLine = annotationPos.StartLine position.StartLinePosition = annotationPos.StartLinePosition + } else { + position.StartLine -= 2 } } diff --git a/unit-picker/src/test/kotlin/cc/unitmesh/pick/builder/unittest/java/JavaTestCodeServiceE2ETest.kt b/unit-picker/src/test/kotlin/cc/unitmesh/pick/builder/unittest/java/JavaTestCodeServiceE2ETest.kt index 660678c..6c5dabe 100644 --- a/unit-picker/src/test/kotlin/cc/unitmesh/pick/builder/unittest/java/JavaTestCodeServiceE2ETest.kt +++ b/unit-picker/src/test/kotlin/cc/unitmesh/pick/builder/unittest/java/JavaTestCodeServiceE2ETest.kt @@ -145,7 +145,6 @@ public class CompanyService { } """ - val underTestContainer = JavaAnalyser().analysis(underTestCode, "CompanyService.java") underTestContainer.buildSourceCode(underTestCode.lines())