@@ -25,9 +25,17 @@ import org.mockito.kotlin.mock
25
25
import org.mockito.kotlin.spy
26
26
import org.mockito.kotlin.times
27
27
import org.mockito.kotlin.verify
28
+ import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages.CodeWhispererCpp
28
29
import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages.CodeWhispererCsharp
30
+ import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages.CodeWhispererGo
29
31
import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages.CodeWhispererJava
32
+ import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages.CodeWhispererJavaScript
33
+ import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages.CodeWhispererJsx
30
34
import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages.CodeWhispererKotlin
35
+ import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages.CodeWhispererPython
36
+ import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages.CodeWhispererRuby
37
+ import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages.CodeWhispererTsx
38
+ import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages.CodeWhispererTypeScript
31
39
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererUserGroup
32
40
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererUserGroupSettings
33
41
import software.aws.toolkits.jetbrains.services.codewhisperer.util.DefaultCodeWhispererFileContextProvider
@@ -59,6 +67,107 @@ class CodeWhispererFileContextProviderTest {
59
67
sut = FileContextProvider .getInstance(project) as DefaultCodeWhispererFileContextProvider
60
68
}
61
69
70
+ @Test
71
+ fun `shouldFetchUtgContext - fully support` () {
72
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererJava .INSTANCE , CodeWhispererUserGroup .CrossFile )).isTrue
73
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererJava .INSTANCE , CodeWhispererUserGroup .Control )).isTrue
74
+ }
75
+
76
+ @Test
77
+ fun `shouldFetchUtgContext - partially support` () {
78
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererPython .INSTANCE , CodeWhispererUserGroup .CrossFile )).isTrue
79
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererPython .INSTANCE , CodeWhispererUserGroup .Control )).isFalse
80
+ }
81
+
82
+ @Test
83
+ fun `shouldFetchUtgContext - no support` () {
84
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererJavaScript .INSTANCE , CodeWhispererUserGroup .Control )).isNull()
85
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererJavaScript .INSTANCE , CodeWhispererUserGroup .CrossFile )).isNull()
86
+
87
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererJsx .INSTANCE , CodeWhispererUserGroup .Control )).isNull()
88
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererJsx .INSTANCE , CodeWhispererUserGroup .CrossFile )).isNull()
89
+
90
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererTypeScript .INSTANCE , CodeWhispererUserGroup .Control )).isNull()
91
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererTypeScript .INSTANCE , CodeWhispererUserGroup .CrossFile )).isNull()
92
+
93
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererTsx .INSTANCE , CodeWhispererUserGroup .Control )).isNull()
94
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererTsx .INSTANCE , CodeWhispererUserGroup .CrossFile )).isNull()
95
+
96
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererCsharp .INSTANCE , CodeWhispererUserGroup .Control )).isNull()
97
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererCsharp .INSTANCE , CodeWhispererUserGroup .CrossFile )).isNull()
98
+
99
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererKotlin .INSTANCE , CodeWhispererUserGroup .Control )).isNull()
100
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererKotlin .INSTANCE , CodeWhispererUserGroup .CrossFile )).isNull()
101
+
102
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererGo .INSTANCE , CodeWhispererUserGroup .Control )).isNull()
103
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererGo .INSTANCE , CodeWhispererUserGroup .CrossFile )).isNull()
104
+
105
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererTsx .INSTANCE , CodeWhispererUserGroup .Control )).isNull()
106
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchUtgContext(CodeWhispererTsx .INSTANCE , CodeWhispererUserGroup .CrossFile )).isNull()
107
+ }
108
+
109
+ @Test
110
+ fun `shouldFetchCrossfileContext - fully support` () {
111
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererJava .INSTANCE , CodeWhispererUserGroup .CrossFile )).isTrue
112
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererJava .INSTANCE , CodeWhispererUserGroup .Control )).isTrue
113
+ }
114
+
115
+ @Test
116
+ fun `shouldFetchCrossfileContext - partially support` () {
117
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererPython .INSTANCE , CodeWhispererUserGroup .Control )).isFalse
118
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererPython .INSTANCE , CodeWhispererUserGroup .CrossFile )).isTrue
119
+
120
+ assertThat(
121
+ DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(
122
+ CodeWhispererJavaScript .INSTANCE ,
123
+ CodeWhispererUserGroup .Control
124
+ )
125
+ ).isFalse
126
+ assertThat(
127
+ DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(
128
+ CodeWhispererJavaScript .INSTANCE ,
129
+ CodeWhispererUserGroup .CrossFile
130
+ )
131
+ ).isTrue
132
+
133
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererJsx .INSTANCE , CodeWhispererUserGroup .Control )).isFalse
134
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererJsx .INSTANCE , CodeWhispererUserGroup .CrossFile )).isTrue
135
+
136
+ assertThat(
137
+ DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(
138
+ CodeWhispererTypeScript .INSTANCE ,
139
+ CodeWhispererUserGroup .Control
140
+ )
141
+ ).isFalse
142
+ assertThat(
143
+ DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(
144
+ CodeWhispererTypeScript .INSTANCE ,
145
+ CodeWhispererUserGroup .CrossFile
146
+ )
147
+ ).isTrue
148
+
149
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererTsx .INSTANCE , CodeWhispererUserGroup .Control )).isFalse
150
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererTsx .INSTANCE , CodeWhispererUserGroup .CrossFile )).isTrue
151
+ }
152
+
153
+ @Test
154
+ fun `shouldFetchCrossfileContext - no support` () {
155
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererCsharp .INSTANCE , CodeWhispererUserGroup .Control )).isNull()
156
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererCsharp .INSTANCE , CodeWhispererUserGroup .CrossFile )).isNull()
157
+
158
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererKotlin .INSTANCE , CodeWhispererUserGroup .Control )).isNull()
159
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererKotlin .INSTANCE , CodeWhispererUserGroup .CrossFile )).isNull()
160
+
161
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererGo .INSTANCE , CodeWhispererUserGroup .Control )).isNull()
162
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererGo .INSTANCE , CodeWhispererUserGroup .CrossFile )).isNull()
163
+
164
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererCpp .INSTANCE , CodeWhispererUserGroup .Control )).isNull()
165
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererCpp .INSTANCE , CodeWhispererUserGroup .CrossFile )).isNull()
166
+
167
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererRuby .INSTANCE , CodeWhispererUserGroup .Control )).isNull()
168
+ assertThat(DefaultCodeWhispererFileContextProvider .shouldFetchCrossfileContext(CodeWhispererRuby .INSTANCE , CodeWhispererUserGroup .CrossFile )).isNull()
169
+ }
170
+
62
171
@Test
63
172
fun `languages not supporting supplemental context will return empty` () {
64
173
val psiFiles = setupFixture(fixture)
0 commit comments