language.ts — astro Source File
Architecture documentation for language.ts, a typescript file in the astro codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 6dfcea35_46db_2e95_f1a2_dd2af9c2da08["language.ts"] 60049c9b_c0dc_0ac5_6e86_9ac7b1783c3b["./astro2tsx.js"] 6dfcea35_46db_2e95_f1a2_dd2af9c2da08 --> 60049c9b_c0dc_0ac5_6e86_9ac7b1783c3b 040ca79b_dadf_4383_efd2_c0b13744e9f1["language-core"] 6dfcea35_46db_2e95_f1a2_dd2af9c2da08 --> 040ca79b_dadf_4383_efd2_c0b13744e9f1 41525615_7e06_b0e8_f601_674c57b118ee["typescript"] 6dfcea35_46db_2e95_f1a2_dd2af9c2da08 --> 41525615_7e06_b0e8_f601_674c57b118ee style 6dfcea35_46db_2e95_f1a2_dd2af9c2da08 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/// <reference types="@volar/typescript" />
import {
type CodeMapping,
forEachEmbeddedCode,
type LanguagePlugin,
type VirtualCode,
} from '@volar/language-core';
import type ts from 'typescript';
import { astro2tsx } from './astro2tsx.js';
export function getLanguagePlugin(): LanguagePlugin<string, AstroVirtualCode> {
return {
getLanguageId(fileName) {
if (fileName.endsWith('.astro')) {
return 'astro';
}
},
createVirtualCode(fileName, languageId, snapshot) {
if (languageId === 'astro') {
return new AstroVirtualCode(fileName, snapshot);
}
},
typescript: {
extraFileExtensions: [{ extension: 'astro', isMixedContent: true, scriptKind: 7 }],
getServiceScript(astroCode) {
for (const code of forEachEmbeddedCode(astroCode)) {
if (code.id === 'tsx') {
return {
code,
extension: '.tsx',
scriptKind: 4 satisfies ts.ScriptKind.TSX,
};
}
}
},
},
};
}
export class AstroVirtualCode implements VirtualCode {
id = 'root';
languageId = 'astro';
mappings!: CodeMapping[];
embeddedCodes!: VirtualCode[];
codegenStacks = [];
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: false,
},
},
];
this.embeddedCodes = [];
const tsx = astro2tsx(this.snapshot.getText(0, this.snapshot.getLength()), this.fileName);
this.embeddedCodes.push(tsx.virtualFile);
}
}
Domain
Subdomains
Functions
Classes
Dependencies
- ./astro2tsx.js
- language-core
- typescript
Source
Frequently Asked Questions
What does language.ts do?
language.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, CoreMiddleware subdomain.
What functions are defined in language.ts?
language.ts defines 1 function(s): getLanguagePlugin.
What does language.ts depend on?
language.ts imports 3 module(s): ./astro2tsx.js, language-core, typescript.
Where is language.ts in the architecture?
language.ts is located at packages/language-tools/ts-plugin/src/language.ts (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/language-tools/ts-plugin/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free