Home / Function/ constructor() — astro Function Reference

constructor() — astro Function Reference

Architecture documentation for the constructor() function in index.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  daabf67b_260e_4861_5614_7e9d0bac041d["constructor()"]
  0f9bebbf_2381_aa6d_9fed_bd6c8978c2c3["AstroVirtualCode"]
  daabf67b_260e_4861_5614_7e9d0bac041d -->|defined in| 0f9bebbf_2381_aa6d_9fed_bd6c8978c2c3
  style daabf67b_260e_4861_5614_7e9d0bac041d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/language-tools/language-server/src/core/index.ts lines 153–195

	constructor(
		public fileName: string,
		public snapshot: ts.IScriptSnapshot,
	) {
		this.mappings = [
			{
				sourceOffsets: [0],
				generatedOffsets: [0],
				lengths: [this.snapshot.getLength()],
				data: {
					verification: true,
					completion: true,
					semantic: true,
					navigation: true,
					structure: true,
					format: true,
				},
			},
		];

		const tsx = astro2tsx(this.snapshot.getText(0, this.snapshot.getLength()), this.fileName);
		const astroMetadata = getAstroMetadata(
			this.fileName,
			this.snapshot.getText(0, this.snapshot.getLength()),
		);

		const { htmlDocument, virtualCode: htmlVirtualCode } = parseHTML(
			this.snapshot,
			astroMetadata.frontmatter.status === 'closed'
				? astroMetadata.frontmatter.position.end.offset
				: 0,
		);

		this.htmlDocument = htmlDocument;
		htmlVirtualCode.embeddedCodes = [
			...extractStylesheets(tsx.ranges.styles),
			...extractScriptTags(tsx.ranges.scripts),
		];

		this.astroMeta = { ...astroMetadata, tsxRanges: tsx.ranges };
		this.compilerDiagnostics = [...tsx.diagnostics, ...astroMetadata.diagnostics];
		this.embeddedCodes = [htmlVirtualCode, tsx.virtualCode];
	}

Domain

Subdomains

Frequently Asked Questions

What does constructor() do?
constructor() is a function in the astro codebase, defined in packages/language-tools/language-server/src/core/index.ts.
Where is constructor() defined?
constructor() is defined in packages/language-tools/language-server/src/core/index.ts at line 153.

Analyze Your Own Codebase

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

Try Supermodel Free