MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / getCoveredRanges

Method getCoveredRanges

src/extraction/astro-extractor.ts:247–266  ·  view source on GitHub ↗

* Line ranges (0-indexed, inclusive) the template scans must skip: * the frontmatter block and / blocks.

(
    frontmatter: { startLine: number; endLine: number } | null
  )

Source from the content-addressed store, hash-verified

245 * the frontmatter block and <script>/<style> blocks.
246 */
247 private getCoveredRanges(
248 frontmatter: { startLine: number; endLine: number } | null
249 ): Array<[number, number]> {
250 const coveredRanges: Array<[number, number]> = [];
251
252 if (frontmatter) {
253 // Cover from the opening fence line through the closing fence line
254 coveredRanges.push([frontmatter.startLine - 1, frontmatter.endLine]);
255 }
256
257 const tagRegex = /<(script|style)(\s[^>]*)?>[\s\S]*?<\/\1>/g;
258 let tagMatch;
259 while ((tagMatch = tagRegex.exec(this.source)) !== null) {
260 const startLine = (this.source.substring(0, tagMatch.index).match(/\n/g) || []).length;
261 const endLine = startLine + (tagMatch[0].match(/\n/g) || []).length;
262 coveredRanges.push([startLine, endLine]);
263 }
264
265 return coveredRanges;
266 }
267
268 /**
269 * Extract function calls from Astro template expressions.

Callers 1

extractMethod · 0.95

Calls 1

execMethod · 0.65

Tested by

no test coverage detected