generateCodeFrame() — vue Function Reference
Architecture documentation for the generateCodeFrame() function in codeframe.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD eb367a79_758d_d887_b761_550177f27249["generateCodeFrame()"] 16b5f9ed_1e09_eff8_5797_7cb90fc86d37["compileScript()"] 16b5f9ed_1e09_eff8_5797_7cb90fc86d37 -->|calls| eb367a79_758d_d887_b761_550177f27249 c16a3cd4_68e6_1d49_ea28_e5acec70d6e2["createCompileToFunctionFn()"] c16a3cd4_68e6_1d49_ea28_e5acec70d6e2 -->|calls| eb367a79_758d_d887_b761_550177f27249 6212b3cc_9023_ea82_5ae6_bad4340a5b91["repeat()"] eb367a79_758d_d887_b761_550177f27249 -->|calls| 6212b3cc_9023_ea82_5ae6_bad4340a5b91 style eb367a79_758d_d887_b761_550177f27249 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/compiler/codeframe.ts lines 3–37
export function generateCodeFrame(
source: string,
start: number = 0,
end: number = source.length
): string {
const lines = source.split(/\r?\n/)
let count = 0
const res: string[] = []
for (let i = 0; i < lines.length; i++) {
count += lines[i].length + 1
if (count >= start) {
for (let j = i - range; j <= i + range || end > count; j++) {
if (j < 0 || j >= lines.length) continue
res.push(
`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`
)
const lineLength = lines[j].length
if (j === i) {
// push underline
const pad = start - (count - lineLength) + 1
const length = end > count ? lineLength - pad : end - start
res.push(` | ` + repeat(` `, pad) + repeat(`^`, length))
} else if (j > i) {
if (end > count) {
const length = Math.min(end - count, lineLength)
res.push(` | ` + repeat(`^`, length))
}
count += lineLength + 1
}
}
break
}
}
return res.join('\n')
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does generateCodeFrame() do?
generateCodeFrame() is a function in the vue codebase.
What does generateCodeFrame() call?
generateCodeFrame() calls 1 function(s): repeat.
What calls generateCodeFrame()?
generateCodeFrame() is called by 2 function(s): compileScript, createCompileToFunctionFn.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free