-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Complete support for multi-source mapping in plugin mode #197
Complete support for multi-source mapping in plugin mode #197
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 sourceCodeOffsetsMemo: MappingMemo | undefined; | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
@johnsoncodehk - thanks for working on this PR and all the fixes! Really appreciated! |
Also, support disablement of code assist in associated non-TS files