Skip to content

Commit 79544a9

Browse files
authored
Merge branch 'main' into dmsWork
2 parents 2858151 + 2c20422 commit 79544a9

File tree

16 files changed

+261
-32
lines changed

16 files changed

+261
-32
lines changed

.changes/3.40.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"date" : "2024-11-14",
3+
"version" : "3.40",
4+
"entries" : [ {
5+
"type" : "feature",
6+
"description" : "Amazon Q /dev: Add an action to accept individual files"
7+
}, {
8+
"type" : "bugfix",
9+
"description" : "Fix a bug when Amazon Q responds with still indexing message even when `@workspace` index is done"
10+
}, {
11+
"type" : "bugfix",
12+
"description" : "Fix issue where Amazon Q inline chat can be invoked from non-editor windows"
13+
} ]
14+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Amazon Q chat: `@workspace` command shown in all tab types"
4+
}

.changes/next-release/bugfix-418aac17-9702-451e-8880-9c41b3441574.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

.changes/next-release/bugfix-4a387896-7a93-4474-a86d-f6dc5d53ab57.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

.changes/next-release/feature-6403bbaf-0521-4d39-abbf-f9e25fe5a837.json

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "feature",
3+
"description" : "Code Transform: Enable support for Java 17 projects."
4+
}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# _3.40_ (2024-11-14)
2+
- **(Feature)** Amazon Q /dev: Add an action to accept individual files
3+
- **(Bug Fix)** Fix a bug when Amazon Q responds with still indexing message even when `@workspace` index is done
4+
- **(Bug Fix)** Fix issue where Amazon Q inline chat can be invoked from non-editor windows
5+
16
# _3.39_ (2024-11-12)
27
- **(Bug Fix)** Fix poor inline suggestions from Amazon Q caused by improperly formatted supplemental context
38

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
# Toolkit Version
5-
toolkitVersion=3.40-SNAPSHOT
5+
toolkitVersion=3.41-SNAPSHOT
66

77
# Publish Settings
88
publishToken=
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package software.aws.toolkits.jetbrains.services.amazonqFeatureDev.util
5+
6+
import com.intellij.diff.comparison.ComparisonManager
7+
import com.intellij.diff.comparison.ComparisonPolicy
8+
import com.intellij.diff.fragments.LineFragment
9+
import com.intellij.openapi.progress.EmptyProgressIndicator
10+
11+
data class DiffMetrics(
12+
val insertedLines: Int,
13+
val insertedCharacters: Int,
14+
)
15+
16+
fun lineEnding(content: String, curr: Int, end: Int): Int {
17+
require(curr <= end) { "curr must be within end of range" }
18+
require(end <= content.length) { "end must be within content" }
19+
20+
return if (curr == end) {
21+
-1
22+
} else if (content[curr] == '\r') {
23+
if ((curr + 1 < end) && (content[curr + 1] == '\n')) {
24+
2
25+
} else {
26+
1
27+
}
28+
} else if (content[curr] == '\n') {
29+
1
30+
} else {
31+
-1
32+
}
33+
}
34+
35+
fun getDiffMetrics(before: String, after: String): DiffMetrics {
36+
val comparisonManager = ComparisonManager.getInstance()
37+
val fragments = comparisonManager.compareLines(
38+
before,
39+
after,
40+
ComparisonPolicy.DEFAULT,
41+
EmptyProgressIndicator()
42+
)
43+
44+
var accLineCount = 0
45+
var accCharCount = 0
46+
47+
fragments.forEach { fragment: LineFragment ->
48+
var curr = fragment.startOffset2
49+
val end = fragment.endOffset2
50+
51+
while (curr < end) {
52+
accLineCount += 1
53+
54+
// Consume leading whitespace:
55+
while (curr < end && lineEnding(after, curr, end) == -1 && after[curr].isWhitespace()) curr++
56+
57+
// Consume through EOL:
58+
val lineContentStart = curr
59+
while (curr < end && lineEnding(after, curr, end) == -1) curr++
60+
var lineContentEnd = curr
61+
curr += maxOf(lineEnding(after, curr, end), 0)
62+
63+
// Walk back trailing whitespace and record character count before continuing to next line:
64+
while (lineContentEnd > lineContentStart && after[lineContentEnd - 1].isWhitespace()) lineContentEnd--
65+
accCharCount += lineContentEnd - lineContentStart
66+
}
67+
}
68+
69+
return DiffMetrics(
70+
insertedLines = accLineCount,
71+
insertedCharacters = accCharCount,
72+
)
73+
}

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/controller/ChatController.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class ChatController private constructor(
9494

9595
private val messagePublisher: MessagePublisher = context.messagesFromAppToUi
9696
private val telemetryHelper = TelemetryHelper(context.project, chatSessionStorage)
97+
9798
constructor(
9899
context: AmazonQAppInitContext,
99100
) : this(
@@ -144,7 +145,11 @@ class ChatController private constructor(
144145
} else {
145146
sendOpenSettingsMessage(message.tabId)
146147
}
147-
} else if (CodeWhispererSettings.getInstance().isProjectContextEnabled() && isInternalUser) {
148+
} else if (
149+
CodeWhispererSettings.getInstance().isProjectContextEnabled() &&
150+
isInternalUser &&
151+
ProjectContextController.getInstance(context.project).getProjectContextIndexComplete()
152+
) {
148153
// if user does not have @workspace in the prompt, but user is Amazon internal
149154
// add project context by default
150155
val projectContextController = ProjectContextController.getInstance(context.project)

0 commit comments

Comments
 (0)