Skip to content

Conversation

liumofei-amazon
Copy link
Contributor

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

Checklist

  • My code follows the code style of this project
  • I have added tests to cover my changes
  • A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

@liumofei-amazon liumofei-amazon requested review from a team as code owners June 27, 2025 21:16
@liumofei-amazon liumofei-amazon force-pushed the diagnostics branch 2 times, most recently from 759b773 to 7f25c1c Compare July 2, 2025 23:42
if (isInternalUser(getStartUrl(project))) {
val oldDiagnostics = sessionContext.diagnostics.orEmpty()
// wait for the IDE itself to update its diagnostics for current file
delay(500)
Copy link
Contributor

Choose a reason for hiding this comment

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

this will reflect in metrics

Copy link
Contributor

Choose a reason for hiding this comment

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

what if diagnostics run takes longer than 500ms?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was based on @leigaol 's PR earlier 2720828 to let the LSP have time to have new diagnostics

This should only be reflected in this telemetry path right?

Copy link
Contributor

Choose a reason for hiding this comment

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

There is no callback provided by JetBrains for "diagnostic updated complete" once the acceptance is done. Meanwhile, user can also do quick keyboard input immediately after acceptance.

We ack two issues with the implementation:

  1. If IDE itself does not provide diagnostics (like VSC), we will return [] in diagnostics.
  2. If IDE cannot finish within 500ms, we will return [] in diagnostics.

There is no workaround for #1 because we cannot force user to install the LSP for that language.
For #2, 500ms is a best middle ground between "too fast to see any diagnostic showing up" and "too slow to be interrupted by next user input".

severity == HighlightSeverity.WARNING ||
severity == HighlightSeverity.WEAK_WARNING -> "WARNING"
severity == HighlightSeverity.INFORMATION -> "INFORMATION"
severity.toString().contains("TEXT", ignoreCase = true) -> "HINT"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
severity.toString().contains("TEXT", ignoreCase = true) -> "HINT"
severity.name == "TEXT" -> "HINT"

?

Copy link
Contributor Author

@liumofei-amazon liumofei-amazon Jul 4, 2025

Choose a reason for hiding this comment

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

I think this changed the original logic right? It was trying to look contains not exact match

Copy link
Contributor

Choose a reason for hiding this comment

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

my question is if we can do equality or does it need to be a contains check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2025-07-07 at 2 30 33 PM I've run a local test to check what's the actual type, yes I can use the equality here

?.key ?: "OTHER"
}

fun convertSeverity(severity: HighlightSeverity): String = when {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fun convertSeverity(severity: HighlightSeverity): String = when {
fun convertSeverity(severity: HighlightSeverity): DiagnosticSeverity = when {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix

Comment on lines 361 to 367
val diagnosticPatterns = mapOf(
"TYPE_ERROR" to listOf("type", "cast"),
"SYNTAX_ERROR" to listOf("expected", "indent", "syntax"),
"REFERENCE_ERROR" to listOf("undefined", "not defined", "undeclared", "reference", "symbol"),
"BEST_PRACTICE" to listOf("deprecated", "unused", "uninitialized", "not initialized"),
"SECURITY" to listOf("security", "vulnerability")
)
Copy link
Contributor

Choose a reason for hiding this comment

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

extract so we are not constantly rebuilding nested data structures

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix

@rli rli merged commit 858aacc into aws:main Jul 8, 2025
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants