`@code { … }` / `@functions { … }` (Blazor) and `@{ … }` (Razor) C# blocks.
()
| 232 | |
| 233 | /** `@code { … }` / `@functions { … }` (Blazor) and `@{ … }` (Razor) C# blocks. */ |
| 234 | private extractCodeBlocks(): Array<{ content: string; lineOffset: number }> { |
| 235 | const blocks: Array<{ content: string; lineOffset: number }> = []; |
| 236 | const re = /@(?:code|functions)\b\s*\{|@\{/g; |
| 237 | let m: RegExpExecArray | null; |
| 238 | while ((m = re.exec(this.source)) !== null) { |
| 239 | const openIdx = this.source.indexOf('{', m.index); |
| 240 | if (openIdx < 0) continue; |
| 241 | const close = this.matchBrace(this.source, openIdx); |
| 242 | if (close < 0) continue; |
| 243 | const content = this.source.slice(openIdx + 1, close); |
| 244 | // newlines before the content's first char → 0-indexed line of content start |
| 245 | const lineOffset = (this.source.slice(0, openIdx + 1).match(/\n/g) || []).length; |
| 246 | blocks.push({ content, lineOffset }); |
| 247 | re.lastIndex = close; |
| 248 | } |
| 249 | return blocks; |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * Delegate each `@code`/`@functions`/`@{` block's C# to the tree-sitter C# |
no test coverage detected