Complete support for multi-source mapping in plugin mode#197
Complete support for multi-source mapping in plugin mode#197johnsoncodehk merged 4 commits intovolarjs:masterfrom
Conversation
packages/language-core/index.ts
Outdated
| mapCache.set( | ||
| sourceScript.snapshot, | ||
| new SourceMap(virtualCode.mappings) | ||
| new SourceMap(allMappings, sourceScript.id) |
There was a problem hiding this comment.
When using the map for generated file, we need to be able to map from generated range to all of the local and associated mappings.
packages/source-map/lib/sourceMap.ts
Outdated
| private generatedCodeOffsetsMemo: MappingMemo | undefined; | ||
|
|
||
| constructor(public readonly mappings: Mapping<Data>[]) { } | ||
| constructor(public readonly mappings: ({ source?: T } & Mapping<Data>)[], private scriptId?: T) { } |
There was a problem hiding this comment.
We need SourceMap of the generated file to be able to map from generated offset to any of the local and associated offsets
| if (serviceScript) { | ||
| for (const [id, _snapshot, map] of language.maps.forEach(serviceScript.code)) { | ||
| if (id === sourceId) { | ||
| return [serviceScript, sourceScript, map] as const |
There was a problem hiding this comment.
We return here target source script to be able to perform analysis, but we keep map from the original source file to properly map from source to generated offset.
|
@piotrtomiak Thanks for the PR! I will review it soon, can you share any sample repo that can test this behavior? |
|
@johnsoncodehk - it is difficult to share the whole repo, as templates are transpiled on JVM side for performance reasons - you need to build the whole Angular application model first. Here is the plugin project: https://drive.google.com/file/d/1y7hDmtP7l1VsWWR48jxv0PngFGLPGU3X/view?usp=sharing. It is only the TypeScript side, which runs as TSC plugin. You can see that transpiled template is sent to the server with |
Thanks! Very useful. 👍
Update: I seem to have broken the use case of doing a find definition jump from .html to .ts and am trying to fix it. |
It should be fixed by 511b4c1. |
…gin mode (#197) Co-Authored-By: Piotr Tomiak <piotr.tomiak@gmail.com>
|
@johnsoncodehk - thanks for working on this PR and all the fixes! Really appreciated! |
Also, support disablement of code assist in associated non-TS files