Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.intellij.diff.DiffManager
import com.intellij.diff.DiffManagerEx
import com.intellij.diff.requests.SimpleDiffRequest
import com.intellij.ide.BrowserUtil
import com.intellij.notification.NotificationType
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.fileChooser.FileChooserFactory
import com.intellij.openapi.fileChooser.FileSaverDescriptor
Expand Down Expand Up @@ -48,6 +50,8 @@
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.credentials.SsoProfileData
import software.aws.toolkits.jetbrains.services.codewhisperer.customization.CodeWhispererModelConfigurator
import software.aws.toolkits.jetbrains.settings.CodeWhispererSettings
import software.aws.toolkits.jetbrains.utils.getCleanedContent
import software.aws.toolkits.jetbrains.utils.notify
import software.aws.toolkits.resources.message
import java.io.File
import java.nio.file.Files
Expand All @@ -70,19 +74,12 @@

override fun showMessage(messageParams: MessageParams) {
val type = when (messageParams.type) {
MessageType.Error -> Level.ERROR
MessageType.Warning -> Level.WARN
MessageType.Info, MessageType.Log -> Level.INFO
MessageType.Error -> NotificationType.ERROR
MessageType.Warning -> NotificationType.WARNING
MessageType.Info, MessageType.Log -> NotificationType.INFORMATION

Check warning on line 79 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt#L77-L79

Added lines #L77 - L79 were not covered by tests
}

if (type == Level.ERROR &&
messageParams.message.lineSequence().firstOrNull()?.contains("NOTE: The AWS SDK for JavaScript (v2) is in maintenance mode.") == true
) {
LOG.info { "Suppressed Flare AWS JS SDK v2 EoL error message" }
return
}

LOG.atLevel(type).log(messageParams.message)
notify(type, message("q.window.title"), getCleanedContent(messageParams.message, true), project, emptyList())

Check warning on line 82 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt#L82

Added line #L82 was not covered by tests
}

override fun showMessageRequest(requestParams: ShowMessageRequestParams): CompletableFuture<MessageActionItem?>? {
Expand All @@ -92,15 +89,33 @@
}

override fun logMessage(message: MessageParams) {
showMessage(message)
val type = when (message.type) {
MessageType.Error -> Level.ERROR
MessageType.Warning -> Level.WARN
MessageType.Info, MessageType.Log -> Level.INFO

Check warning on line 95 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt#L93-L95

Added lines #L93 - L95 were not covered by tests
}

if (type == Level.ERROR &&
message.message.lineSequence().firstOrNull()?.contains("NOTE: The AWS SDK for JavaScript (v2) is in maintenance mode.") == true
) {
LOG.info { "Suppressed Flare AWS JS SDK v2 EoL error message" }
return

Check warning on line 102 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt#L101-L102

Added lines #L101 - L102 were not covered by tests
}

LOG.atLevel(type).log(message.message)

Check warning on line 105 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt#L105

Added line #L105 was not covered by tests
}

override fun showDocument(params: ShowDocumentParams?): CompletableFuture<ShowDocumentResult> {
override fun showDocument(params: ShowDocumentParams): CompletableFuture<ShowDocumentResult> {
try {
if (params == null || params.uri.isNullOrEmpty()) {
if (params.uri.isNullOrEmpty()) {
return CompletableFuture.completedFuture(ShowDocumentResult(false))
}

if (params.external == true) {
BrowserUtil.open(params.uri)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be on edt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no but i dont want to rewrite this and it's not a slow operation

return CompletableFuture.completedFuture(ShowDocumentResult(true))

Check warning on line 116 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt#L115-L116

Added lines #L115 - L116 were not covered by tests
}

ApplicationManager.getApplication().invokeLater {
try {
val virtualFile = VirtualFileManager.getInstance().findFileByUrl(params.uri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
)
}

private fun notify(type: NotificationType, title: String, content: String = "", project: Project? = null, notificationActions: Collection<AnAction>) {
fun notify(type: NotificationType, title: String, content: String = "", project: Project? = null, notificationActions: Collection<AnAction>) {

Check warning on line 45 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/utils/NotificationUtils.kt

View check run for this annotation

Codecov / codecov/patch

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/utils/NotificationUtils.kt#L45

Added line #L45 was not covered by tests
val notification = Notification(GROUP_DISPLAY_ID, title, content, type)
notificationActions.forEach {
notification.addAction(if (it !is NotificationAction) createNotificationExpiringAction(it) else it)
Expand Down Expand Up @@ -182,4 +182,4 @@
}
}

private fun getCleanedContent(content: String, stripHtml: Boolean): String = if (stripHtml) StringUtil.stripHtml(content, true) else content
fun getCleanedContent(content: String, stripHtml: Boolean): String = if (stripHtml) StringUtil.stripHtml(content, true) else content
Loading