@@ -63,6 +63,7 @@ import { getVersionData } from '../../../codewhisperer/service/transformByQ/tran
6363import AdmZip from 'adm-zip'
6464import { AuthError } from '../../../auth/sso/server'
6565import { isSQLTransformReady } from '../../../dev/config'
66+ import { spawnSync } from 'child_process'
6667
6768// These events can be interactions within the chat,
6869// or elsewhere in the IDE
@@ -189,10 +190,35 @@ export class GumbyController {
189190 this . messenger . sendCommandMessage ( data )
190191 }
191192
193+ // silently check if user has open Java projects using embedded SQL
194+ private async anyProjectContainsEmbeddedOracleSQL ( ) {
195+ try {
196+ // gets just open Java projects
197+ const projects = await getValidSQLConversionCandidateProjects ( )
198+ for ( const project of projects ) {
199+ // case-insensitive, recursive search, display only count of matching lines
200+ const args = [ '-i' , '-r' , '-c' , 'oracle.jdbc.OracleDriver' ]
201+ // TO-DO: handle Windows
202+ const spawnResult = spawnSync ( 'grep' , args , {
203+ cwd : project . path ,
204+ shell : true ,
205+ encoding : 'utf-8' ,
206+ } )
207+ if ( spawnResult . status !== 0 ) {
208+ return false
209+ }
210+ // TO-DO: parse stdout for the count of matching lines
211+ }
212+ } catch ( err ) {
213+ return false
214+ }
215+ return true
216+ }
217+
192218 private async transformInitiated ( message : any ) {
193219 // feature flag for SQL transformations
194- if ( ! isSQLTransformReady ) {
195- // TODO: if (!projectContainsEmbeddedSQLUsingOracle)
220+ const containsOracleSQL = await this . anyProjectContainsEmbeddedOracleSQL ( )
221+ if ( ! isSQLTransformReady && ! containsOracleSQL ) {
196222 await this . handleLanguageUpgrade ( message )
197223 return
198224 }
0 commit comments