(serializedValue: string, strict: boolean)
| 202 | } |
| 203 | |
| 204 | private static _deserializeRegexValue(serializedValue: string, strict: boolean): RegExp | null { |
| 205 | |
| 206 | if (isFalsyOrWhitespace(serializedValue)) { |
| 207 | if (strict) { |
| 208 | throw new Error('missing regexp-value for =~-expression'); |
| 209 | } else { |
| 210 | console.warn('missing regexp-value for =~-expression'); |
| 211 | } |
| 212 | return null; |
| 213 | } |
| 214 | |
| 215 | let start = serializedValue.indexOf('/'); |
| 216 | let end = serializedValue.lastIndexOf('/'); |
| 217 | if (start === end || start < 0 /* || to < 0 */) { |
| 218 | if (strict) { |
| 219 | throw new Error(`bad regexp-value '${serializedValue}', missing /-enclosure`); |
| 220 | } else { |
| 221 | console.warn(`bad regexp-value '${serializedValue}', missing /-enclosure`); |
| 222 | } |
| 223 | return null; |
| 224 | } |
| 225 | |
| 226 | let value = serializedValue.slice(start + 1, end); |
| 227 | let caseIgnoreFlag = serializedValue[end + 1] === 'i' ? 'i' : ''; |
| 228 | try { |
| 229 | return new RegExp(value, caseIgnoreFlag); |
| 230 | } catch (e) { |
| 231 | if (strict) { |
| 232 | throw new Error(`bad regexp-value '${serializedValue}', parse error: ${e}`); |
| 233 | } else { |
| 234 | console.warn(`bad regexp-value '${serializedValue}', parse error: ${e}`); |
| 235 | } |
| 236 | return null; |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | function cmp(a: ContextKeyExpression, b: ContextKeyExpression): number { |
nothing calls this directly
no test coverage detected