@@ -6,37 +6,44 @@ import { setupLanguageFeatures, LanguageIdEnum } from 'monaco-sql-languages/esm/
66import { completionService } from './helpers/completionService' ;
77
88/**
9- * replace dtstack custom params, eg: @@{componentParams}, ${taskCustomParams}
9+ * replace dtstack custom params, eg: @@{componentParams}, ${taskCustomParams}, #{taskCustomParams}
1010 * @param code editor value
1111 * @returns replaced string
1212 */
1313const preprocessCode = ( code : string ) : string => {
1414 const regex1 = / @ @ { [ A - Z a - z 0 - 9 . _ - ] * } / g;
1515 const regex2 = / \$ { [ A - Z a - z 0 - 9 . _ - ] * } / g;
16+ const regex3 = / # \{ [ A - Z a - z 0 - 9 . _ - ] * } / g;
1617 let result = code ;
1718
1819 if ( regex1 . test ( code ) ) {
1920 result = result . replace ( regex1 , ( str ) => {
2021 return str . replace ( / @ | { | } | \. | - / g, '_' ) ;
2122 } ) ;
2223 }
23- if ( regex2 . test ( code ) ) {
24+ if ( regex2 . test ( result ) ) {
2425 result = result . replace ( regex2 , ( str ) => {
2526 return str . replace ( / \$ | { | } | \. | - / g, '_' ) ;
2627 } ) ;
2728 }
29+ if ( regex3 . test ( result ) ) {
30+ result = result . replace ( regex3 , ( str ) => {
31+ return str . replace ( / # | { | } | \. | - / g, '_' ) ;
32+ } ) ;
33+ }
2834 return result ;
2935} ;
3036
3137/**
32- * replace dtstack custom grammar, eg: @@{componentParams}, ${taskCustomParams}
38+ * replace dtstack custom grammar, eg: @@{componentParams}, ${taskCustomParams}, #{taskCustomParams}
3339 * @param code editor value
3440 * @param mark some sql grammar need special mark to replace the beginning and the end
3541 * @returns replaced string
3642 */
3743const preprocessCodeHive = ( code : string , mark ?: string ) : string => {
3844 const regex1 = / @ @ { [ A - Z a - z 0 - 9 . _ - ] * } / g;
3945 const regex2 = / \$ { [ A - Z a - z 0 - 9 . _ - ] * } / g;
46+ const regex3 = / # \{ [ A - Z a - z 0 - 9 . _ - ] * } / g;
4047 let result = code ;
4148
4249 if ( regex1 . test ( code ) ) {
@@ -50,14 +57,22 @@ const preprocessCodeHive = (code: string, mark?: string): string => {
5057 return str . replace ( / @ | { | } | \. | - / g, '_' ) ;
5158 } ) ;
5259 }
53- if ( regex2 . test ( code ) ) {
60+ if ( regex2 . test ( result ) ) {
5461 result = result . replace ( regex2 , ( str ) => {
5562 if ( mark ) {
5663 return str . replace ( / \$ | } / g, mark ) . replace ( / { | \. | - / g, '_' ) ;
5764 }
5865 return str . replace ( / \$ | { | } | \. | - / g, '_' ) ;
5966 } ) ;
6067 }
68+ if ( regex3 . test ( result ) ) {
69+ result = result . replace ( regex3 , ( str ) => {
70+ if ( mark ) {
71+ return str . replace ( / # | } / g, mark ) . replace ( / { | \. | - / g, '_' ) ;
72+ }
73+ return str . replace ( / # | { | } | \. | - / g, '_' ) ;
74+ } ) ;
75+ }
6176 return result ;
6277} ;
6378
0 commit comments