Home / Function/ getLanguageServer() — astro Function Reference

getLanguageServer() — astro Function Reference

Architecture documentation for the getLanguageServer() function in server.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  9cf7acc9_e2e5_26e3_64f0_7304d1983c86["getLanguageServer()"]
  923db4e1_01a0_98ab_9c38_dfe16dd4bada["server.ts"]
  9cf7acc9_e2e5_26e3_64f0_7304d1983c86 -->|defined in| 923db4e1_01a0_98ab_9c38_dfe16dd4bada
  style 9cf7acc9_e2e5_26e3_64f0_7304d1983c86 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/language-tools/language-server/test/server.ts lines 19–75

export async function getLanguageServer(): Promise<LanguageServer> {
	if (!serverHandle) {
		serverHandle = startLanguageServer(
			path.resolve('./bin/nodeServer.js'),
			fileURLToPath(new URL('./fixture', import.meta.url)),
		);

		initializeResult = await serverHandle.initialize(
			URI.file(fileURLToPath(new URL('./fixture', import.meta.url))).toString(),
			{
				typescript: {
					tsdk: path.join(
						path.dirname(fileURLToPath(import.meta.url)),
						'../',
						'node_modules',
						'typescript',
						'lib',
					),
				},
				contentIntellisense: true,
			},
			{
				textDocument: {
					definition: {
						linkSupport: true,
					},
				},
				workspace: {
					// Needed for tests that use didChangeWatchedFiles
					didChangeWatchedFiles: {},
					configuration: true,
				},
			},
		);
		// Ensure that our first test does not suffer from a TypeScript overhead
		await serverHandle.sendCompletionRequest(
			'file://doesnt-exists',
			protocol.Position.create(0, 0),
		);
	}

	if (!initializeResult || !serverHandle) {
		throw new Error('Server not initialized');
	}

	return {
		handle: serverHandle,
		initializeResult: initializeResult,
		openFakeDocument: async (content: string, languageId: string) => {
			const hash = createHash('sha256').update(content).digest('base64url');
			const uri = URI.file(`does-not-exists-${hash}-.astro`).toString();
			const textDocument = await serverHandle!.openInMemoryDocument(uri, languageId, content);

			return textDocument;
		},
	};
}

Domain

Subdomains

Frequently Asked Questions

What does getLanguageServer() do?
getLanguageServer() is a function in the astro codebase, defined in packages/language-tools/language-server/test/server.ts.
Where is getLanguageServer() defined?
getLanguageServer() is defined in packages/language-tools/language-server/test/server.ts at line 19.

Analyze Your Own Codebase

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

Try Supermodel Free