@@ -259,50 +259,51 @@ export namespace Tools {
259
259
}
260
260
}
261
261
}
262
- }
263
-
264
- /**
265
- * We do this to find previously opened files with the same path, but different case OR readonly flags.
266
- * Without this, it's possible for the same document to be opened twice simply due to the readonly flag.
267
- */
268
- export function findExistingDocumentUri ( uri : vscode . Uri ) {
269
- const bathUriString = uriStringWithoutFragment ( uri ) ;
270
- const possibleDoc = vscode . workspace . textDocuments . find ( document => uriStringWithoutFragment ( document . uri ) === bathUriString ) ;
271
- if ( possibleDoc ) {
272
- return possibleDoc . uri ;
273
- }
274
262
275
- return uri ;
276
- }
277
-
278
- /**
279
- * We convert member to lowercase as members are case insensitive.
280
- */
281
- function uriStringWithoutFragment ( uri : vscode . Uri ) {
282
- // To lowercase because the URI path is case-insensitive
283
- const baseUri = uri . scheme + `:` + uri . path ;
284
- const isCaseSensitive = ( uri . scheme === `streamfile` && uri . path . startsWith ( `/QOpenSys/` ) ) ;
285
- return ( isCaseSensitive ? baseUri : baseUri . toLowerCase ( ) ) ;
286
- }
287
-
288
- /**
289
- * Fixes an SQL statement to make it compatible with db2 CLI program QZDFMDB2.
290
- * - Changes `@clCommand` statements into Call `QSYS2.QCMDEX('clCommand')` procedure calls
291
- * - Makes sure each comment (`--`) starts on a new line
292
- * @param statement the statement to fix
293
- * @returns statement compatible with QZDFMDB2
294
- */
295
- export function fixSQL ( statement : string ) {
296
- return statement . split ( "\n" ) . map ( line => {
297
- if ( line . startsWith ( '@' ) ) {
298
- //- Escape all '
299
- //- Remove any trailing ;
300
- //- Put the command in a Call QSYS2.QCMDEXC statement
301
- line = `Call QSYS2.QCMDEXC('${ line . substring ( 1 , line . endsWith ( ";" ) ? line . length - 1 : undefined ) . replaceAll ( "'" , "''" ) } ');` ;
263
+
264
+ /**
265
+ * We do this to find previously opened files with the same path, but different case OR readonly flags.
266
+ * Without this, it's possible for the same document to be opened twice simply due to the readonly flag.
267
+ */
268
+ export function findExistingDocumentUri ( uri : vscode . Uri ) {
269
+ const bathUriString = uriStringWithoutFragment ( uri ) ;
270
+ const possibleDoc = vscode . workspace . textDocuments . find ( document => uriStringWithoutFragment ( document . uri ) === bathUriString ) ;
271
+ if ( possibleDoc ) {
272
+ return possibleDoc . uri ;
302
273
}
303
274
304
- //Make each comment start on a new line
305
- return line . replaceAll ( "--" , "\n--" ) ;
275
+ return uri ;
276
+ }
277
+
278
+ /**
279
+ * We convert member to lowercase as members are case insensitive.
280
+ */
281
+ function uriStringWithoutFragment ( uri : vscode . Uri ) {
282
+ // To lowercase because the URI path is case-insensitive
283
+ const baseUri = uri . scheme + `:` + uri . path ;
284
+ const isCaseSensitive = ( uri . scheme === `streamfile` && uri . path . startsWith ( `/QOpenSys/` ) ) ;
285
+ return ( isCaseSensitive ? baseUri : baseUri . toLowerCase ( ) ) ;
286
+ }
287
+
288
+ /**
289
+ * Fixes an SQL statement to make it compatible with db2 CLI program QZDFMDB2.
290
+ * - Changes `@clCommand` statements into Call `QSYS2.QCMDEX('clCommand')` procedure calls
291
+ * - Makes sure each comment (`--`) starts on a new line
292
+ * @param statement the statement to fix
293
+ * @returns statement compatible with QZDFMDB2
294
+ */
295
+ export function fixSQL ( statement : string ) {
296
+ return statement . split ( "\n" ) . map ( line => {
297
+ if ( line . startsWith ( '@' ) ) {
298
+ //- Escape all '
299
+ //- Remove any trailing ;
300
+ //- Put the command in a Call QSYS2.QCMDEXC statement
301
+ line = `Call QSYS2.QCMDEXC('${ line . substring ( 1 , line . endsWith ( ";" ) ? line . length - 1 : undefined ) . replaceAll ( "'" , "''" ) } ');` ;
302
+ }
303
+
304
+ //Make each comment start on a new line
305
+ return line . replaceAll ( "--" , "\n--" ) ;
306
+ }
307
+ ) . join ( "\n" ) ;
306
308
}
307
- ) . join ( "\n" ) ;
308
309
}
0 commit comments