Home / Function/ enhancedProvideCompletionItems() — astro Function Reference

enhancedProvideCompletionItems() — astro Function Reference

Architecture documentation for the enhancedProvideCompletionItems() function in completions.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  b356dfc5_2c3a_14ab_6e1d_073ec0ce567f["enhancedProvideCompletionItems()"]
  37356a62_09a0_ac45_a671_abc9e2985f77["completions.ts"]
  b356dfc5_2c3a_14ab_6e1d_073ec0ce567f -->|defined in| 37356a62_09a0_ac45_a671_abc9e2985f77
  style b356dfc5_2c3a_14ab_6e1d_073ec0ce567f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/language-tools/language-server/src/plugins/typescript/completions.ts lines 11–33

export function enhancedProvideCompletionItems(completions: CompletionList): CompletionList {
	completions.items = completions.items.filter(isValidCompletion).map((completion) => {
		const source = completion?.data?.originalItem?.source;
		if (source) {
			// Sort completions starting with `astro:` higher than other imports
			if (source.startsWith('astro:')) {
				completion.sortText = '\u0000' + (completion.sortText ?? completion.label);
			}

			// For components import, use the file kind and sort them first, as they're often what the user want over something else
			if (['.astro', '.svelte', '.vue'].some((ext) => source.endsWith(ext))) {
				completion.kind = CompletionItemKind.File;
				completion.detail = completion.detail + '\n\n' + source;
				completion.sortText = '\u0001' + (completion.sortText ?? completion.label);
				completion.data.isComponent = true;
			}
		}

		return completion;
	});

	return completions;
}

Domain

Subdomains

Frequently Asked Questions

What does enhancedProvideCompletionItems() do?
enhancedProvideCompletionItems() is a function in the astro codebase, defined in packages/language-tools/language-server/src/plugins/typescript/completions.ts.
Where is enhancedProvideCompletionItems() defined?
enhancedProvideCompletionItems() is defined in packages/language-tools/language-server/src/plugins/typescript/completions.ts at line 11.

Analyze Your Own Codebase

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

Try Supermodel Free