Skip to content

Commit 9539422

Browse files
committed
Merge branch 'release-1.1'
Conflicts: Jakefile src/compiler/tsc.ts
2 parents f7a2922 + dbf8764 commit 9539422

File tree

13 files changed

+1014
-1643
lines changed

13 files changed

+1014
-1643
lines changed

Jakefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ var harnessSources = [
6363
"sourceMapRecorder.ts",
6464
"harnessLanguageService.ts",
6565
"fourslash.ts",
66-
"external/json2.ts",
6766
"runnerbase.ts",
6867
"compilerRunner.ts",
6968
"typeWriter.ts",
@@ -318,7 +317,7 @@ function exec(cmd, completeHandler) {
318317
complete();
319318
})
320319
try{
321-
ex.run();
320+
ex.run();
322321
} catch(e) {
323322
console.log('Exception: ' + e)
324323
}
@@ -342,7 +341,7 @@ function cleanTestDirs() {
342341
function writeTestConfigFile(tests, testConfigFile) {
343342
console.log('Running test(s): ' + tests);
344343
var testConfigContents = '{\n' + '\ttest: [\'' + tests + '\']\n}';
345-
fs.writeFileSync('test.config', testConfigContents);
344+
fs.writeFileSync('test.config', testConfigContents);
346345
}
347346

348347
function deleteTemporaryProjectOutput() {
@@ -385,7 +384,7 @@ desc("Generates code coverage data via instanbul")
385384
task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
386385
var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run;
387386
console.log(cmd);
388-
exec(cmd);
387+
exec(cmd);
389388
}, { async: true });
390389

391390
// Browser tests

ThirdPartyNoticeText.txt

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -19,67 +19,6 @@ limitations under the License.
1919
---------------------------------------------
2020
Third Party Code Components
2121
--------------------------------------------
22-
---- Mozilla Developer Code---------
23-
The following Mozilla Developer Code is under Public Domain as updated after Aug. 20, 2012, see, https://developer.mozilla.org/en-US/docs/Project:Copyrights
24-
1. Array filter Compatibility Method,
25-
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/filter
26-
Any copyright is dedicated to the Public Domain.
27-
28-
2. Array forEach Compatibility Method,
29-
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach
30-
Any copyright is dedicated to the Public Domain.
31-
32-
3. Array indexOf Compatibility Method,
33-
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf
34-
Any copyright is dedicated to the Public Domain.
35-
36-
4. Array map Compatibility Method,
37-
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map
38-
Any copyright is dedicated to the Public Domain.
39-
40-
5. Array Reduce Compatibility Method,
41-
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/Reduce
42-
Any copyright is dedicated to the Public Domain.
43-
44-
6. String Trim Compatibility Method,
45-
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/Trim
46-
Any copyright is dedicated to the Public Domain.
47-
48-
7. Date now Compatibility Method,
49-
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/now
50-
Any copyright is dedicated to the Public Domain.
51-
52-
------------JSON2 Script------------------------
53-
json2.js 2012-10-08
54-
Public Domain.
55-
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
56-
See, http://www.JSON.org/js.html
57-
58-
--------------r.js----------------------
59-
Copyright (c) 2010-2011 Dojo Foundation. All Rights Reserved.
60-
Originally License under MIT License
61-
-------------------------------------------------------------------------
62-
Provided for Informational Purposes Only
63-
MIT License
64-
65-
Permission is hereby granted, free of charge, to any person obtaining
66-
a copy of this software and associated documentation files (the
67-
"Software"), to deal in the Software without restriction, including
68-
without limitation the rights to use, copy, modify, merge, publish,
69-
distribute, sublicense, and/or sell copies of the Software, and to
70-
permit persons to whom the Software is furnished to do so, subject to
71-
the following conditions:
72-
73-
The above copyright notice and this permission notice shall be
74-
included in all copies or substantial portions of the Software.
75-
76-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
77-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
78-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
79-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
80-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
81-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
82-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8322

8423
------------------- DefinitelyTyped --------------------
8524
This file is based on or incorporates material from the projects listed below (collectively ?Third Party Code?). Microsoft is not the original author of the Third Party Code. The original copyright notice and the license, under which Microsoft received such Third Party Code, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft, not the third party, licenses the Third Party Code to you under the terms set forth in the EULA for the Microsoft Product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise.

bin/tsc.js

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,7 +3003,7 @@ var ts;
30033003
}
30043004
function grammarErrorOnNode(node, message, arg0, arg1, arg2) {
30053005
var span = getErrorSpanForNode(node);
3006-
var start = ts.skipTrivia(file.text, span.pos);
3006+
var start = span.end > span.pos ? ts.skipTrivia(file.text, span.pos) : span.pos;
30073007
var length = span.end - start;
30083008
file.syntacticErrors.push(ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2));
30093009
}
@@ -6297,16 +6297,51 @@ var ts;
62976297
writeCommentRange(comment, writer);
62986298
recordSourceMapSpan(comment.end);
62996299
}
6300+
var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\u2028\u2029\u0085]/g;
6301+
var escapedCharsMap = {
6302+
"\t": "\\t",
6303+
"\v": "\\v",
6304+
"\f": "\\f",
6305+
"\b": "\\b",
6306+
"\0": "\\0",
6307+
"\r": "\\r",
6308+
"\n": "\\n",
6309+
"\"": "\\\"",
6310+
"\u2028": "\\u2028",
6311+
"\u2029": "\\u2029",
6312+
"\u0085": "\\u0085"
6313+
};
6314+
function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) {
6315+
if (typeof JSON !== "undefined") {
6316+
return JSON.stringify({
6317+
version: version,
6318+
file: file,
6319+
sourceRoot: sourceRoot,
6320+
sources: sources,
6321+
names: names,
6322+
mappings: mappings
6323+
});
6324+
}
6325+
return "{\"version\":" + version + ",\"file\":\"" + escapeString(file) + "\",\"sourceRoot\":\"" + escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + escapeString(mappings) + "\"}";
6326+
function escapeString(s) {
6327+
return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, function (c) {
6328+
return escapedCharsMap[c] || c;
6329+
}) : s;
6330+
}
6331+
function serializeStringArray(list) {
6332+
var output = "";
6333+
for (var i = 0, n = list.length; i < n; i++) {
6334+
if (i) {
6335+
output += ",";
6336+
}
6337+
output += "\"" + escapeString(list[i]) + "\"";
6338+
}
6339+
return output;
6340+
}
6341+
}
63006342
function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) {
63016343
encodeLastRecordedSourceMapSpan();
6302-
writeFile(sourceMapData.sourceMapFilePath, JSON.stringify({
6303-
version: 3,
6304-
file: sourceMapData.sourceMapFile,
6305-
sourceRoot: sourceMapData.sourceMapSourceRoot,
6306-
sources: sourceMapData.sourceMapSources,
6307-
names: sourceMapData.sourceMapNames,
6308-
mappings: sourceMapData.sourceMapMappings
6309-
}), false);
6344+
writeFile(sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false);
63106345
sourceMapDataList.push(sourceMapData);
63116346
writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark);
63126347
}
@@ -14777,6 +14812,10 @@ var ts;
1477714812
function executeCommandLine(args) {
1477814813
var commandLine = ts.parseCommandLine(args);
1477914814
if (commandLine.options.locale) {
14815+
if (typeof JSON === "undefined") {
14816+
reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"));
14817+
return sys.exit(1);
14818+
}
1478014819
validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors);
1478114820
}
1478214821
if (commandLine.errors.length > 0) {

bin/typescriptServices.js

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,7 +2808,7 @@ var ts;
28082808
}
28092809
function grammarErrorOnNode(node, message, arg0, arg1, arg2) {
28102810
var span = getErrorSpanForNode(node);
2811-
var start = ts.skipTrivia(file.text, span.pos);
2811+
var start = span.end > span.pos ? ts.skipTrivia(file.text, span.pos) : span.pos;
28122812
var length = span.end - start;
28132813
file.syntacticErrors.push(ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2));
28142814
}
@@ -6102,16 +6102,51 @@ var ts;
61026102
writeCommentRange(comment, writer);
61036103
recordSourceMapSpan(comment.end);
61046104
}
6105+
var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\u2028\u2029\u0085]/g;
6106+
var escapedCharsMap = {
6107+
"\t": "\\t",
6108+
"\v": "\\v",
6109+
"\f": "\\f",
6110+
"\b": "\\b",
6111+
"\0": "\\0",
6112+
"\r": "\\r",
6113+
"\n": "\\n",
6114+
"\"": "\\\"",
6115+
"\u2028": "\\u2028",
6116+
"\u2029": "\\u2029",
6117+
"\u0085": "\\u0085"
6118+
};
6119+
function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) {
6120+
if (typeof JSON !== "undefined") {
6121+
return JSON.stringify({
6122+
version: version,
6123+
file: file,
6124+
sourceRoot: sourceRoot,
6125+
sources: sources,
6126+
names: names,
6127+
mappings: mappings
6128+
});
6129+
}
6130+
return "{\"version\":" + version + ",\"file\":\"" + escapeString(file) + "\",\"sourceRoot\":\"" + escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + escapeString(mappings) + "\"}";
6131+
function escapeString(s) {
6132+
return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, function (c) {
6133+
return escapedCharsMap[c] || c;
6134+
}) : s;
6135+
}
6136+
function serializeStringArray(list) {
6137+
var output = "";
6138+
for (var i = 0, n = list.length; i < n; i++) {
6139+
if (i) {
6140+
output += ",";
6141+
}
6142+
output += "\"" + escapeString(list[i]) + "\"";
6143+
}
6144+
return output;
6145+
}
6146+
}
61056147
function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) {
61066148
encodeLastRecordedSourceMapSpan();
6107-
writeFile(sourceMapData.sourceMapFilePath, JSON.stringify({
6108-
version: 3,
6109-
file: sourceMapData.sourceMapFile,
6110-
sourceRoot: sourceMapData.sourceMapSourceRoot,
6111-
sources: sourceMapData.sourceMapSources,
6112-
names: sourceMapData.sourceMapNames,
6113-
mappings: sourceMapData.sourceMapMappings
6114-
}), false);
6149+
writeFile(sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false);
61156150
sourceMapDataList.push(sourceMapData);
61166151
writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark);
61176152
}

src/compiler/emitter.ts

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -591,17 +591,65 @@ module ts {
591591
recordSourceMapSpan(comment.end);
592592
}
593593

594+
var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\u2028\u2029\u0085]/g;
595+
var escapedCharsMap: Map<string> = {
596+
"\t": "\\t",
597+
"\v": "\\v",
598+
"\f": "\\f",
599+
"\b": "\\b",
600+
"\0": "\\0",
601+
"\r": "\\r",
602+
"\n": "\\n",
603+
"\"": "\\\"",
604+
"\u2028": "\\u2028", // lineSeparator
605+
"\u2029": "\\u2029", // paragraphSeparator
606+
"\u0085": "\\u0085" // nextLine
607+
};
608+
609+
function serializeSourceMapContents(version: number, file: string, sourceRoot: string, sources: string[], names: string[], mappings: string) {
610+
if (typeof JSON !== "undefined") {
611+
return JSON.stringify({
612+
version: version,
613+
file: file,
614+
sourceRoot: sourceRoot,
615+
sources: sources,
616+
names: names,
617+
mappings: mappings
618+
});
619+
}
620+
621+
return "{\"version\":" + version + ",\"file\":\"" + escapeString(file) + "\",\"sourceRoot\":\"" + escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + escapeString(mappings) + "\"}";
622+
623+
/** This does not support the full escape characters, it only supports the subset that can be used in file names
624+
* or string literals. If the information encoded in the map changes, this needs to be revisited. */
625+
function escapeString(s: string): string {
626+
return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, c => {
627+
return escapedCharsMap[c] || c;
628+
}) : s;
629+
}
630+
631+
function serializeStringArray(list: string[]): string {
632+
var output = "";
633+
for (var i = 0, n = list.length; i < n; i++) {
634+
if (i) {
635+
output += ",";
636+
}
637+
output += "\"" + escapeString(list[i]) + "\"";
638+
}
639+
return output;
640+
}
641+
}
642+
594643
function writeJavaScriptAndSourceMapFile(emitOutput: string, writeByteOrderMark: boolean) {
595644
// Write source map file
596645
encodeLastRecordedSourceMapSpan();
597-
writeFile(sourceMapData.sourceMapFilePath, JSON.stringify({
598-
version: 3,
599-
file: sourceMapData.sourceMapFile,
600-
sourceRoot: sourceMapData.sourceMapSourceRoot,
601-
sources: sourceMapData.sourceMapSources,
602-
names: sourceMapData.sourceMapNames,
603-
mappings: sourceMapData.sourceMapMappings
604-
}), /*writeByteOrderMark*/ false);
646+
writeFile(sourceMapData.sourceMapFilePath, serializeSourceMapContents(
647+
3,
648+
sourceMapData.sourceMapFile,
649+
sourceMapData.sourceMapSourceRoot,
650+
sourceMapData.sourceMapSources,
651+
sourceMapData.sourceMapNames,
652+
sourceMapData.sourceMapMappings), /*writeByteOrderMark*/ false);
605653
sourceMapDataList.push(sourceMapData);
606654

607655
// Write sourcemap url to the js file and write the js file

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ module ts {
819819
// applying some stricter checks on that node.
820820
function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void {
821821
var span = getErrorSpanForNode(node);
822-
var start = skipTrivia(file.text, span.pos);
822+
var start = span.end > span.pos ? skipTrivia(file.text, span.pos) : span.pos;
823823
var length = span.end - start;
824824

825825
file.syntacticErrors.push(createFileDiagnostic(file, start, length, message, arg0, arg1, arg2));

src/compiler/tsc.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ module ts {
202202
var compilerOptions = commandLine.options;
203203

204204
if (compilerOptions.locale) {
205+
if (typeof JSON === "undefined") {
206+
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"));
207+
return sys.exit(1);
208+
}
209+
205210
validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors);
206211
}
207212

0 commit comments

Comments
 (0)