| 1767 | */ |
| 1768 | const ACCESS_MACRO_LINE = /^([ \t]*)([A-Z][A-Z0-9]*_[A-Z0-9_]*)([ \t]*):(?!:)(?=[ \t]*(?:\/\/[^\n]*)?\r?$)/gm; |
| 1769 | export function rewriteCppAccessMacros(source: string): string { |
| 1770 | if (!/_[A-Z0-9_]*[ \t]*:(?!:)/.test(source)) return source; |
| 1771 | return source.replace(ACCESS_MACRO_LINE, (m, indent: string, name: string, gap: string) => { |
| 1772 | const keyword = /PRIVATE/.test(name) ? 'private' : /PROTECTED/.test(name) ? 'protected' |
| 1773 | : /PUBLIC|^Q_SIGNALS$|^Q_SLOTS$/.test(name) ? 'public' : null; |
| 1774 | if (!keyword || keyword.length > name.length + gap.length) return m; |
| 1775 | return `${indent}${keyword}${' '.repeat(name.length + gap.length - keyword.length)}:`; |
| 1776 | }); |
| 1777 | } |
| 1778 | |
| 1779 | /** |
| 1780 | * A preprocessor conditional in the middle of a declaration or expression — |