* Process a script block by delegating to TreeSitterExtractor
(
block: { content: string; startLine: number; isSetup: boolean; language: Language },
componentNodeId: string
)
| 243 | * Process a script block by delegating to TreeSitterExtractor |
| 244 | */ |
| 245 | private processScriptBlock( |
| 246 | block: { content: string; startLine: number; isSetup: boolean; language: Language }, |
| 247 | componentNodeId: string |
| 248 | ): void { |
| 249 | const scriptLanguage = block.language; |
| 250 | |
| 251 | // Check if the script language parser is available |
| 252 | if (!isLanguageSupported(scriptLanguage)) { |
| 253 | this.errors.push({ |
| 254 | message: `Parser for ${scriptLanguage} not available, cannot parse Vue script block`, |
| 255 | severity: 'warning', |
| 256 | }); |
| 257 | return; |
| 258 | } |
| 259 | |
| 260 | // Delegate to TreeSitterExtractor |
| 261 | const extractor = new TreeSitterExtractor(this.filePath, block.content, scriptLanguage); |
| 262 | const result = extractor.extract(); |
| 263 | |
| 264 | // An Options API component's functions — `methods`, `computed`, `watch`, |
| 265 | // lifecycle hooks — are object-literal members the TS extractor leaves as |
| 266 | // part of the file. Name each one, and hand it the calls written inside it. |
| 267 | if (!block.isSetup) this.addOptionsMembers(block, result, componentNodeId); |
| 268 | |
| 269 | foldScriptResult( |
| 270 | result, |
| 271 | { filePath: this.filePath, componentNodeId, lineOffset: block.startLine, language: 'vue', perInstance: block.isSetup }, |
| 272 | { nodes: this.nodes, edges: this.edges, unresolvedReferences: this.unresolvedReferences, errors: this.errors } |
| 273 | ); |
| 274 | } |
| 275 | |
| 276 | /** |
| 277 | * Extract component usages from the Vue `<template>`. |
no test coverage detected