-
Notifications
You must be signed in to change notification settings - Fork 274
telemetry(amazonq): Adding cwsprChatProgrammingLanguage parameter to insertAtCursor and CopyAtClipboard events #4959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 17 commits
fa8c411
89ae57f
d0b4b50
4fb43b7
fefcb99
a883685
3aacba4
f4ae707
7a6e925
7b6fbd1
d9a0fbf
fc6a8a1
da650e8
29d8df3
20237b1
1e18908
ee23f93
b3a7e35
d1e87d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,25 @@ | |
| return htmlRenderer.render(document) | ||
| } | ||
|
|
||
| fun extractCodeBlockLanguage(message: String): String { | ||
| // This fulfills both the cases of unit test generation(java, python) and general use case(Non java and Non python) languages. | ||
| val defaultTestGenResponseLanguage: String = "plaintext" | ||
| val indexStart: Int = 3 | ||
|
||
| val codeBlockStart = message.indexOf("```") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are there any other edge cases with this we need to worry about?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if (codeBlockStart == -1) { | ||
| return defaultTestGenResponseLanguage | ||
| } | ||
|
|
||
| val languageStart = codeBlockStart + indexStart | ||
| val languageEnd = message.indexOf('\n', languageStart) | ||
|
|
||
| if (languageEnd == -1) { | ||
| return defaultTestGenResponseLanguage | ||
| } | ||
|
|
||
| return message.substring(languageStart, languageEnd).trim().ifEmpty { defaultTestGenResponseLanguage } | ||
| } | ||
|
|
||
| class CodeBlockRenderer(private val html: HtmlWriter) : NodeRenderer { | ||
| override fun getNodeTypes(): Set<Class<out Node>> = setOf(FencedCodeBlock::class.java) | ||
| override fun render(node: Node?) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.