Skip to content

Commit ced1b87

Browse files
committed
address comments
1 parent 3cfb3c8 commit ced1b87

File tree

3 files changed

+47
-45
lines changed

3 files changed

+47
-45
lines changed

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererAutoTriggerService.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class CodeWhispererAutoTriggerService : CodeWhispererAutoTriggerHandler, Disposa
4343
private var lastInvocationTime: Instant? = null
4444
private var lastInvocationLineNum: Int? = null
4545
var timeAtLastCharTyped: Instant = Instant.now()
46+
private set
4647

4748
init {
4849
scheduleReset()

plugins/amazonq/codewhisperer/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererCodeCoverageTrackerTest.kt

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ import software.aws.toolkits.jetbrains.services.codewhisperer.telemetry.CodeCove
6464
import software.aws.toolkits.jetbrains.services.codewhisperer.telemetry.CodeWhispererCodeCoverageTracker
6565
import software.aws.toolkits.jetbrains.services.codewhisperer.toolwindow.CodeWhispererCodeReferenceManager
6666
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants.TOTAL_SECONDS_IN_MINUTE
67-
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererUtil.getUnmodifiedAcceptedCharsCount
6867
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CrossFileStrategy
6968
import software.aws.toolkits.jetbrains.services.telemetry.NoOpPublisher
7069
import software.aws.toolkits.jetbrains.services.telemetry.TelemetryService
@@ -441,50 +440,6 @@ internal class CodeWhispererCodeCoverageTrackerTestPython : CodeWhispererCodeCov
441440
verify(sut, Times(0)).emitCodeWhispererCodeContribution()
442441
}
443442

444-
@Test
445-
fun `test getUnmodifiedAcceptedCharsCount()`() {
446-
var originalRecommendation = "foo"
447-
var modifiedRecommendation = "fou"
448-
var unmodifiedCharsCount = getUnmodifiedAcceptedCharsCount(originalRecommendation, modifiedRecommendation)
449-
assertThat(unmodifiedCharsCount).isEqualTo(2)
450-
451-
originalRecommendation = "foo"
452-
modifiedRecommendation = "f11111oo"
453-
unmodifiedCharsCount = getUnmodifiedAcceptedCharsCount(originalRecommendation, modifiedRecommendation)
454-
assertThat(unmodifiedCharsCount).isEqualTo(3)
455-
456-
originalRecommendation = "foo"
457-
modifiedRecommendation = "fo"
458-
unmodifiedCharsCount = getUnmodifiedAcceptedCharsCount(originalRecommendation, modifiedRecommendation)
459-
assertThat(unmodifiedCharsCount).isEqualTo(2)
460-
461-
originalRecommendation = "helloworld"
462-
modifiedRecommendation = "HelloWorld"
463-
unmodifiedCharsCount = getUnmodifiedAcceptedCharsCount(originalRecommendation, modifiedRecommendation)
464-
assertThat(unmodifiedCharsCount).isEqualTo("helloworld".length - 2)
465-
466-
originalRecommendation = "helloworld"
467-
modifiedRecommendation = "World"
468-
unmodifiedCharsCount = getUnmodifiedAcceptedCharsCount(originalRecommendation, modifiedRecommendation)
469-
assertThat(unmodifiedCharsCount).isEqualTo("helloworld".length - "hello".length - 1)
470-
471-
originalRecommendation = "CodeWhisperer"
472-
modifiedRecommendation = "CODE"
473-
unmodifiedCharsCount = getUnmodifiedAcceptedCharsCount(originalRecommendation, modifiedRecommendation)
474-
assertThat(unmodifiedCharsCount).isEqualTo(1)
475-
476-
originalRecommendation = "CodeWhisperer"
477-
modifiedRecommendation = "codewhispererISBEST"
478-
unmodifiedCharsCount = getUnmodifiedAcceptedCharsCount(originalRecommendation, modifiedRecommendation)
479-
assertThat(unmodifiedCharsCount).isEqualTo("CodeWhisperer".length - 2)
480-
481-
val pythonCommentAddedByUser = "\"\"\"we don't count this comment as generated by CodeWhisperer\"\"\"\n"
482-
originalRecommendation = "x, y):\n\treturn x + y"
483-
modifiedRecommendation = "x, y):\n$pythonCommentAddedByUser\treturn x + y"
484-
unmodifiedCharsCount = getUnmodifiedAcceptedCharsCount(originalRecommendation, modifiedRecommendation)
485-
assertThat(unmodifiedCharsCount).isEqualTo(originalRecommendation.length)
486-
}
487-
488443
@Test
489444
fun `test flush() won't emit telemetry when users are not editing the document (totalTokens == 0)`() {
490445
sut = TestCodePercentageTracker(project, TOTAL_SECONDS_IN_MINUTE, CodeWhispererPython.INSTANCE)

plugins/amazonq/codewhisperer/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererUtilTest.kt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import software.aws.toolkits.jetbrains.core.credentials.sono.SONO_URL
2323
import software.aws.toolkits.jetbrains.core.region.MockRegionProviderRule
2424
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererUtil.getCompletionType
2525
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererUtil.getTelemetryOptOutPreference
26+
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererUtil.getUnmodifiedAcceptedCharsCount
2627
import software.aws.toolkits.jetbrains.services.codewhisperer.util.runIfIdcConnectionOrTelemetryEnabled
2728
import software.aws.toolkits.jetbrains.services.codewhisperer.util.toCodeChunk
2829
import software.aws.toolkits.jetbrains.settings.AwsSettings
@@ -192,4 +193,49 @@ class CodeWhispererUtilTest {
192193
assertThat(AwsSettings.getInstance().isTelemetryEnabled).isFalse
193194
assertThat(getTelemetryOptOutPreference()).isEqualTo(OptOutPreference.OPTOUT)
194195
}
196+
197+
@Test
198+
fun `test getUnmodifiedAcceptedCharsCount()`() {
199+
var originalRecommendation = "foo"
200+
var modifiedRecommendation = "fou"
201+
var unmodifiedCharsCount = getUnmodifiedAcceptedCharsCount(originalRecommendation, modifiedRecommendation)
202+
assertThat(unmodifiedCharsCount).isEqualTo(2)
203+
204+
originalRecommendation = "foo"
205+
modifiedRecommendation = "f11111oo"
206+
unmodifiedCharsCount = getUnmodifiedAcceptedCharsCount(originalRecommendation, modifiedRecommendation)
207+
assertThat(unmodifiedCharsCount).isEqualTo(3)
208+
209+
originalRecommendation = "foo"
210+
modifiedRecommendation = "fo"
211+
unmodifiedCharsCount = getUnmodifiedAcceptedCharsCount(originalRecommendation, modifiedRecommendation)
212+
assertThat(unmodifiedCharsCount).isEqualTo(2)
213+
214+
originalRecommendation = "helloworld"
215+
modifiedRecommendation = "HelloWorld"
216+
unmodifiedCharsCount = getUnmodifiedAcceptedCharsCount(originalRecommendation, modifiedRecommendation)
217+
assertThat(unmodifiedCharsCount).isEqualTo("helloworld".length - 2)
218+
219+
originalRecommendation = "helloworld"
220+
modifiedRecommendation = "World"
221+
unmodifiedCharsCount = getUnmodifiedAcceptedCharsCount(originalRecommendation, modifiedRecommendation)
222+
assertThat(unmodifiedCharsCount).isEqualTo("helloworld".length - "hello".length - 1)
223+
224+
originalRecommendation = "CodeWhisperer"
225+
modifiedRecommendation = "CODE"
226+
unmodifiedCharsCount = getUnmodifiedAcceptedCharsCount(originalRecommendation, modifiedRecommendation)
227+
assertThat(unmodifiedCharsCount).isEqualTo(1)
228+
229+
originalRecommendation = "CodeWhisperer"
230+
modifiedRecommendation = "codewhispererISBEST"
231+
unmodifiedCharsCount = getUnmodifiedAcceptedCharsCount(originalRecommendation, modifiedRecommendation)
232+
assertThat(unmodifiedCharsCount).isEqualTo("CodeWhisperer".length - 2)
233+
234+
val pythonCommentAddedByUser = "\"\"\"we don't count this comment as generated by CodeWhisperer\"\"\"\n"
235+
originalRecommendation = "x, y):\n\treturn x + y"
236+
modifiedRecommendation = "x, y):\n$pythonCommentAddedByUser\treturn x + y"
237+
unmodifiedCharsCount = getUnmodifiedAcceptedCharsCount(originalRecommendation, modifiedRecommendation)
238+
assertThat(unmodifiedCharsCount).isEqualTo(originalRecommendation.length)
239+
}
240+
195241
}

0 commit comments

Comments
 (0)