Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(language-core): pluginized source map factory function #207

Merged
merged 1 commit into from
Jun 22, 2024

Conversation

johnsoncodehk
Copy link
Member

@johnsoncodehk johnsoncodehk commented Jun 21, 2024

Closes #203

Define the factory function of the source map through Language.mapperFactory, which allows the insertion of customized mapping logic.

Motivation

Individual frameworks may require somewhat special mapping processing logic. For example, WebStorm-Angular requires special processing for overlapping mapping ranges. These processing may not be common to all frameworks, so it is best to make the mapping behavior itself customizable.

Usage

After creating the Language instance, set mapperFactory property to override the default SourceMap factory function.

createLanguageServicePlugin((ts, info) => ({
	languagePlugins: [/* ... */],
	setup(language) {
		language.mapperFactory = mappings => new MySourceMap(mappings);
	},
});

@johnsoncodehk johnsoncodehk merged commit e9191e5 into master Jun 22, 2024
6 checks passed
@johnsoncodehk johnsoncodehk deleted the mapper-factory branch June 22, 2024 01:33
alamhubb added a commit to alamhubb/volar.js that referenced this pull request Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support overlapping mapping ranges
1 participant