|
16 | 16 | */ |
17 | 17 | import { LineIssues } from './issues.js'; |
18 | 18 | import { Comment } from './comments.js'; |
19 | | -import { extractEffectiveLine, LINE_ADJUSTMENT } from './locations.js'; |
| 19 | +import { extractEffectiveLine } from './locations.js'; |
20 | 20 |
|
21 | 21 | const STARTS_WITH_QUICKFIX = /^ *(edit|del|add|fix)@/; |
22 | | -export const QUICKFIX_SEPARATOR = '[,\\s]+'; |
23 | | -export const QUICKFIX_ID = |
24 | | - '\\[\\[(?<quickfixes>\\w+(=\\d+)?!?(?:' + QUICKFIX_SEPARATOR + '(?:\\w+(=\\d+)?!?))*)\\]\\]'; |
| 22 | +export const QUICKFIX_SEPARATOR = String.raw`[,\s]+`; |
| 23 | +export const QUICKFIX_ID = String.raw`\[\[(?<quickfixes>\w+(=\d+)?!?(?:${QUICKFIX_SEPARATOR}(?:\w+(=\d+)?!?))*)\]\]`; |
| 24 | +const BRACED_TEXT_CONTENT = String.raw`(?:(?!\}\}(?!\})).)*`; |
| 25 | +// Legacy fixtures support line adjustments both as `@+1` and `+1`. |
| 26 | +const QUICKFIX_LINE_ADJUSTMENT = String.raw`(?:@?(?<lineAdjustment>(?<relativeAdjustment>[+-])?\d+))?`; |
25 | 27 | const QUICKFIX_DESCRIPTION_PATTERN = new RegExp( |
26 | | - ' *' + |
| 28 | + String.raw`^ *` + |
27 | 29 | // quickfix description, ex: fix@qf1 {{Replace with foo}} |
28 | | - 'fix@(?<quickfixId>\\w+)' + |
| 30 | + String.raw`fix@(?<quickfixId>\w+)` + |
29 | 31 | // message, ex: {{msg}} |
30 | | - ' *(?:\\{\\{(?<message>.*?)\\}\\}(?!\\}))? *' + |
31 | | - '(?:\\r(\\n?)|\\n)?', |
| 32 | + String.raw` *(?:\{\{(?<message>${BRACED_TEXT_CONTENT})\}\}(?!\}))? *` + |
| 33 | + String.raw`(?:\r?\n)?$`, |
32 | 34 | ); |
33 | 35 |
|
34 | 36 | const QUICKFIX_CHANGE_PATTERN = new RegExp( |
35 | | - ' *' + |
| 37 | + String.raw`^ *` + |
36 | 38 | // quickfix edit, ex: edit@qf1 |
37 | | - '(?<type>edit|add|del)@(?<quickfixId>\\w+)' + |
38 | | - LINE_ADJUSTMENT + |
| 39 | + String.raw`(?<type>edit|add|del)@(?<quickfixId>\w+)` + |
| 40 | + QUICKFIX_LINE_ADJUSTMENT + |
39 | 41 | // start and end columns, ex: [[sc=1;ec=5]] both are optional |
40 | | - ' *(?:\\[\\[' + |
41 | | - '(?<firstColumnType>sc|ec)=(?<firstColumnValue>\\d+)(?:;(?<secondColumnType>sc|ec)=(?<secondColumnValue>\\d+))?' + |
42 | | - '\\]\\])?' + |
| 42 | + String.raw` *(?:\[\[` + |
| 43 | + String.raw`(?<firstColumnType>sc|ec)=(?<firstColumnValue>\d+)(?:;(?<secondColumnType>sc|ec)=(?<secondColumnValue>\d+))?` + |
| 44 | + String.raw`\]\])?` + |
43 | 45 | // contents to be applied, ex: {{foo}} |
44 | | - ' *(?:\\{\\{(?<contents>.*?)\\}\\}(?!\\}))?' + |
45 | | - ' *(?:\\r(\\n?)|\\n)?', |
| 46 | + String.raw` *(?:\{\{(?<contents>${BRACED_TEXT_CONTENT})\}\}(?!\}))?` + |
| 47 | + String.raw` *(?:\r?\n)?$`, |
46 | 48 | ); |
47 | 49 |
|
48 | 50 | type ChangeType = 'add' | 'del' | 'edit'; |
|
0 commit comments