| 903 | } |
| 904 | |
| 905 | appendVariable(name: string, defaultValue?: string | ((snippet: SnippetString) => any)): SnippetString { |
| 906 | if (typeof defaultValue === 'function') { |
| 907 | const nested = new SnippetString(); |
| 908 | nested._tabstop = this._tabstop; |
| 909 | defaultValue(nested); |
| 910 | this._tabstop = nested._tabstop; |
| 911 | defaultValue = nested.value; |
| 912 | } else if (typeof defaultValue === 'string') { |
| 913 | defaultValue = defaultValue.replace(/\$|}/g, '\\$&'); // CodeQL [SM02383] This code is not used in production, only used for mocks in testing. |
| 914 | } |
| 915 | |
| 916 | this.value += '${'; |
| 917 | this.value += name; |
| 918 | if (defaultValue) { |
| 919 | this.value += ':'; |
| 920 | this.value += defaultValue; |
| 921 | } |
| 922 | this.value += '}'; |
| 923 | |
| 924 | return this; |
| 925 | } |
| 926 | } |
| 927 | |
| 928 | export enum DiagnosticTag { |