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