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

Declaration maps and transparent goto definition using them #22658

Merged
merged 34 commits into from
Mar 26, 2018
Merged
Changes from 2 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ab7cb27
Add compiler option to enable declaration sourcemaps
weswigham Feb 15, 2018
91cc19c
Transparent goto definition for sourcemapped declaration files
weswigham Feb 17, 2018
c291828
Post-rebase touchups
weswigham Mar 16, 2018
2b26a27
Rename API methods
weswigham Mar 16, 2018
ec44da5
Fix lints
weswigham Mar 16, 2018
ffb7f85
Fix typo in name XD
weswigham Mar 16, 2018
589ac28
Log sourcemap decode errors
weswigham Mar 16, 2018
5584a2d
Share the cache more, but also invalidate it more
weswigham Mar 16, 2018
238ba98
Remove todo
weswigham Mar 16, 2018
ff158cf
Enable mapping on go to implementation as well
weswigham Mar 17, 2018
b9f6149
Allow fourslash to test declaration maps mroe easily
weswigham Mar 19, 2018
53f72de
more test
weswigham Mar 19, 2018
29c732e
Merge branch 'master' into decl-maps
weswigham Mar 19, 2018
6070108
Handle sourceRoot
weswigham Mar 19, 2018
0a63553
Add tests documenting current behavior with other sourcemapping flags
weswigham Mar 19, 2018
d8480b2
Ignore inline options for declaration file maps, simplify dispatch in…
weswigham Mar 20, 2018
ca88d5e
Change program diagnostic
weswigham Mar 20, 2018
2b231d7
Fix nit
weswigham Mar 20, 2018
fed6132
Use charCodeAt
weswigham Mar 20, 2018
509e4f3
Rename internal methods + veriables
weswigham Mar 20, 2018
0c44ba1
Avoid filter
weswigham Mar 20, 2018
c8620e3
span -> position
weswigham Mar 20, 2018
5687e10
Use character codes
weswigham Mar 20, 2018
e64e73d
Dont parse our sourcemap names until we need to start using them
weswigham Mar 20, 2018
47e701a
zero-index parsed positions
weswigham Mar 20, 2018
6a467ba
Handle sourceMappingURL comments, including base64 encoded ones
weswigham Mar 20, 2018
f2c8d3f
Unittest b64 decoder, make mroe robust to handle unicode properly
weswigham Mar 20, 2018
bd9cccf
Fix lint
weswigham Mar 20, 2018
c7a5296
declarationMaps -> declarationMap
weswigham Mar 20, 2018
f6e81f2
Merge branch 'master' into decl-maps
weswigham Mar 24, 2018
d0a5e28
Even more feedback
weswigham Mar 24, 2018
943dc12
USE Mroe lenient combined regexp
weswigham Mar 26, 2018
265cc1a
only match base64 characters
weswigham Mar 26, 2018
e34a6bd
Fix nit
weswigham Mar 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1582,8 +1582,7 @@ namespace ts {


const sourceMapCommentRegExp = /^\/\/[@#] sourceMappingURL=(.+)$/gm;
const dataURLRegExp = /^data:/;
const base64UrlRegExp = /^data:application\/json;charset=utf-8;base64,(.+)$/;
const base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/;
function scanForSourcemapURL(fileName: string) {
const mappedFile = sourcemappedFileCache.get(toPath(fileName, currentDirectory, getCanonicalFileName));
if (!mappedFile) {
Expand Down Expand Up @@ -1627,12 +1626,13 @@ namespace ts {
return file.sourceMapper;
}
let mapFileName = scanForSourcemapURL(fileName);
if (mapFileName && dataURLRegExp.exec(mapFileName)) {
const b64EncodedMatch = base64UrlRegExp.exec(mapFileName);
if (b64EncodedMatch) {
const base64Object = b64EncodedMatch[1];
let match: RegExpExecArray;
if (mapFileName && (match = base64UrlRegExp.exec(mapFileName))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd just use a nested if to avoid having match declared outside of the block since it isn't used elsewhere.

if (match[1]) {
const base64Object = match[1];
return convertDocumentToSourceMapper(file, base64decode(sys, base64Object), fileName);
}
// Not a data URL we can parse, skip it
mapFileName = undefined;
}
const possibleMapLocations: string[] = [];
Expand Down