Home / Class/ CompileDiagnostic Class — svelte Architecture

CompileDiagnostic Class — svelte Architecture

Architecture documentation for the CompileDiagnostic class in compile_diagnostic.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  fca2e303_5d6d_304a_d0fc_14ab13a1ecb7["CompileDiagnostic"]
  266f0f82_b1c9_08bb_80b9_55a66e7d3dba["compile_diagnostic.js"]
  fca2e303_5d6d_304a_d0fc_14ab13a1ecb7 -->|defined in| 266f0f82_b1c9_08bb_80b9_55a66e7d3dba
  1ebd1167_7ae9_a3fc_392d_71c76041a208["constructor()"]
  fca2e303_5d6d_304a_d0fc_14ab13a1ecb7 -->|method| 1ebd1167_7ae9_a3fc_392d_71c76041a208
  6d21b6e1_ee84_8c61_0ab7_2a7fd0ce751b["toString()"]
  fca2e303_5d6d_304a_d0fc_14ab13a1ecb7 -->|method| 6d21b6e1_ee84_8c61_0ab7_2a7fd0ce751b
  d9e70589_d758_5c9d_ac32_e173ee431962["toJSON()"]
  fca2e303_5d6d_304a_d0fc_14ab13a1ecb7 -->|method| d9e70589_d758_5c9d_ac32_e173ee431962

Relationship Graph

Source Code

packages/svelte/src/compiler/utils/compile_diagnostic.js lines 52–107

export class CompileDiagnostic {
	name = 'CompileDiagnostic';

	/**
	 * @param {string} code
	 * @param {string} message
	 * @param {[number, number] | undefined} position
	 */
	constructor(code, message, position) {
		this.code = code;
		this.message = message;

		if (state.filename !== state.UNKNOWN_FILENAME) {
			this.filename = state.filename;
		}

		if (position) {
			this.position = position;
			this.start = state.locator(position[0]);
			this.end = state.locator(position[1]);
			if (this.start && this.end) {
				this.frame = get_code_frame(state.source, this.start.line - 1, this.end.column);
			}
		}
	}

	toString() {
		let out = `${this.code}: ${this.message}`;

		if (this.filename) {
			out += `\n${this.filename}`;

			if (this.start) {
				out += `:${this.start.line}:${this.start.column}`;
			}
		}

		if (this.frame) {
			out += `\n${this.frame}`;
		}

		return out;
	}

	toJSON() {
		return {
			code: this.code,
			message: this.message,
			filename: this.filename,
			start: this.start,
			end: this.end,
			position: this.position,
			frame: this.frame
		};
	}
}

Domain

Frequently Asked Questions

What is the CompileDiagnostic class?
CompileDiagnostic is a class in the svelte codebase, defined in packages/svelte/src/compiler/utils/compile_diagnostic.js.
Where is CompileDiagnostic defined?
CompileDiagnostic is defined in packages/svelte/src/compiler/utils/compile_diagnostic.js at line 52.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free