File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -111,13 +111,12 @@ object CodeWhispererEditorUtil {
111111 /* *
112112 * Checks if the language is json and checks if left context contains keywords
113113 */
114- fun isSupportedJsonFormat (fileName : String , leftContext : String , language : CodeWhispererProgrammingLanguage ): Boolean =
115- (language is CodeWhispererJson ) &&
116- (
117- JsonConfigFileNamingConvention .contains(fileName.lowercase()) ||
118- AWSTemplateKeyWordsRegex .containsMatchIn(leftContext) ||
119- AWSTemplateCaseInsensitiveKeyWordsRegex .containsMatchIn(leftContext.lowercase(Locale .getDefault()))
120- )
114+ fun isSupportedJsonFormat (fileName : String , leftContext : String , language : CodeWhispererProgrammingLanguage ): Boolean {
115+ assert (language is CodeWhispererJson )
116+ return JsonConfigFileNamingConvention .contains(fileName.lowercase()) ||
117+ AWSTemplateKeyWordsRegex .containsMatchIn(leftContext) ||
118+ AWSTemplateCaseInsensitiveKeyWordsRegex .containsMatchIn(leftContext.lowercase(Locale .getDefault()))
119+ }
121120
122121 /* *
123122 * Checks if the [otherRange] overlaps this TextRange. Note that the comparison is `<` because the endOffset of TextRange is exclusive.
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ import software.aws.toolkits.jetbrains.services.codewhisperer.editor.CodeWhisper
5959import software.aws.toolkits.jetbrains.services.codewhisperer.editor.CodeWhispererEditorUtil.isSupportedJsonFormat
6060import software.aws.toolkits.jetbrains.services.codewhisperer.explorer.CodeWhispererExplorerActionManager
6161import software.aws.toolkits.jetbrains.services.codewhisperer.explorer.isCodeWhispererEnabled
62+ import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages.CodeWhispererJson
6263import software.aws.toolkits.jetbrains.services.codewhisperer.model.CaretPosition
6364import software.aws.toolkits.jetbrains.services.codewhisperer.model.DetailContext
6465import software.aws.toolkits.jetbrains.services.codewhisperer.model.FileContextInfo
@@ -171,7 +172,12 @@ class CodeWhispererService(private val cs: CoroutineScope) : Disposable {
171172
172173 val language = requestContext.fileContextInfo.programmingLanguage
173174 val leftContext = requestContext.fileContextInfo.caretContext.leftFileContext
174- if (! language.isCodeCompletionSupported() || ! isSupportedJsonFormat(requestContext.fileContextInfo.filename, leftContext, language)) {
175+ if (! language.isCodeCompletionSupported() || (language is CodeWhispererJson && ! isSupportedJsonFormat(
176+ requestContext.fileContextInfo.filename,
177+ leftContext,
178+ language
179+ ))
180+ ) {
175181 LOG .debug { " Programming language $language is not supported by CodeWhisperer" }
176182 if (triggerTypeInfo.triggerType == CodewhispererTriggerType .OnDemand ) {
177183 showCodeWhispererInfoHint(
You can’t perform that action at this time.
0 commit comments