(source: string)
| 845 | const CPP_POINTER_ANNOTATION_RE = |
| 846 | /([*&])\s*((?:[A-Z][A-Z0-9]*_[A-Z0-9_]*(?:\s+|(?=\*)))+)(?=\*|::|(?!(?:and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|xor|xor_eq)\b)[A-Za-z_~])/g; |
| 847 | export function blankCppPointerAnnotationMacros(source: string): string { |
| 848 | if (!/[*&]\s*[A-Z][A-Z0-9]*_/.test(source)) return source; |
| 849 | const code = maskCppCode(source); |
| 850 | const spans: Array<[number, number]> = []; |
| 851 | const re = new RegExp(CPP_POINTER_ANNOTATION_RE.source, 'g'); |
| 852 | let m: RegExpExecArray | null; |
| 853 | while ((m = re.exec(code)) !== null) { |
| 854 | const run = m[2] as string; |
| 855 | const start = m.index + m[0].length - run.length; |
| 856 | // After `&`, only a name: `flags & FOO_BIT\n && ok` is an expression. |
| 857 | if (m[1] === '&' && code[start + run.length] === '*') continue; |
| 858 | // A `*` after a closing bracket or a number multiplies: `sizeof(int) * CHAR_BIT * 3`. |
| 859 | if (/(?:[)\]]|\b\d[\w.]*)\s*$/.test(code.slice(Math.max(0, m.index - 40), m.index))) continue; |
| 860 | pushCppRunTokens(spans, run, start); |
| 861 | } |
| 862 | return blankCppSpans(source, spans, code); |
| 863 | } |
| 864 | |
| 865 | // Keywords that take a parenthesized operand: a `)` closing one of these is |
| 866 | // not a parameter list, so a token after it is not a trailing attribute. |
no test coverage detected