get_code_frame() — svelte Function Reference
Architecture documentation for the get_code_frame() function in compile_diagnostic.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD f609be53_8034_fe8d_2190_bf30d43e4262["get_code_frame()"] 266f0f82_b1c9_08bb_80b9_55a66e7d3dba["compile_diagnostic.js"] f609be53_8034_fe8d_2190_bf30d43e4262 -->|defined in| 266f0f82_b1c9_08bb_80b9_55a66e7d3dba 1ebd1167_7ae9_a3fc_392d_71c76041a208["constructor()"] 1ebd1167_7ae9_a3fc_392d_71c76041a208 -->|calls| f609be53_8034_fe8d_2190_bf30d43e4262 184a741b_e6eb_ec65_2aed_bbd8c93cecbc["tabs_to_spaces()"] f609be53_8034_fe8d_2190_bf30d43e4262 -->|calls| 184a741b_e6eb_ec65_2aed_bbd8c93cecbc style f609be53_8034_fe8d_2190_bf30d43e4262 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/compiler/utils/compile_diagnostic.js lines 18–36
function get_code_frame(source, line, column) {
const lines = source.split('\n');
const frame_start = Math.max(0, line - 2);
const frame_end = Math.min(line + 3, lines.length);
const digits = String(frame_end + 1).length;
return lines
.slice(frame_start, frame_end)
.map((str, i) => {
const is_error_line = frame_start + i === line;
const line_num = String(i + frame_start + 1).padStart(digits, ' ');
if (is_error_line) {
const indicator =
' '.repeat(digits + 2 + tabs_to_spaces(str.slice(0, column)).length) + '^';
return `${line_num}: ${tabs_to_spaces(str)}\n${indicator}`;
}
return `${line_num}: ${tabs_to_spaces(str)}`;
})
.join('\n');
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does get_code_frame() do?
get_code_frame() is a function in the svelte codebase, defined in packages/svelte/src/compiler/utils/compile_diagnostic.js.
Where is get_code_frame() defined?
get_code_frame() is defined in packages/svelte/src/compiler/utils/compile_diagnostic.js at line 18.
What does get_code_frame() call?
get_code_frame() calls 1 function(s): tabs_to_spaces.
What calls get_code_frame()?
get_code_frame() is called by 1 function(s): constructor.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free