mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 21:06:50 -05:00
Merge branch 'release-1.1'
Conflicts: Jakefile src/compiler/tsc.ts
This commit is contained in:
@@ -591,17 +591,65 @@ module ts {
|
||||
recordSourceMapSpan(comment.end);
|
||||
}
|
||||
|
||||
var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\u2028\u2029\u0085]/g;
|
||||
var escapedCharsMap: Map<string> = {
|
||||
"\t": "\\t",
|
||||
"\v": "\\v",
|
||||
"\f": "\\f",
|
||||
"\b": "\\b",
|
||||
"\0": "\\0",
|
||||
"\r": "\\r",
|
||||
"\n": "\\n",
|
||||
"\"": "\\\"",
|
||||
"\u2028": "\\u2028", // lineSeparator
|
||||
"\u2029": "\\u2029", // paragraphSeparator
|
||||
"\u0085": "\\u0085" // nextLine
|
||||
};
|
||||
|
||||
function serializeSourceMapContents(version: number, file: string, sourceRoot: string, sources: string[], names: string[], mappings: string) {
|
||||
if (typeof JSON !== "undefined") {
|
||||
return JSON.stringify({
|
||||
version: version,
|
||||
file: file,
|
||||
sourceRoot: sourceRoot,
|
||||
sources: sources,
|
||||
names: names,
|
||||
mappings: mappings
|
||||
});
|
||||
}
|
||||
|
||||
return "{\"version\":" + version + ",\"file\":\"" + escapeString(file) + "\",\"sourceRoot\":\"" + escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + escapeString(mappings) + "\"}";
|
||||
|
||||
/** This does not support the full escape characters, it only supports the subset that can be used in file names
|
||||
* or string literals. If the information encoded in the map changes, this needs to be revisited. */
|
||||
function escapeString(s: string): string {
|
||||
return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, c => {
|
||||
return escapedCharsMap[c] || c;
|
||||
}) : s;
|
||||
}
|
||||
|
||||
function serializeStringArray(list: string[]): string {
|
||||
var output = "";
|
||||
for (var i = 0, n = list.length; i < n; i++) {
|
||||
if (i) {
|
||||
output += ",";
|
||||
}
|
||||
output += "\"" + escapeString(list[i]) + "\"";
|
||||
}
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
function writeJavaScriptAndSourceMapFile(emitOutput: string, writeByteOrderMark: boolean) {
|
||||
// Write source map file
|
||||
encodeLastRecordedSourceMapSpan();
|
||||
writeFile(sourceMapData.sourceMapFilePath, JSON.stringify({
|
||||
version: 3,
|
||||
file: sourceMapData.sourceMapFile,
|
||||
sourceRoot: sourceMapData.sourceMapSourceRoot,
|
||||
sources: sourceMapData.sourceMapSources,
|
||||
names: sourceMapData.sourceMapNames,
|
||||
mappings: sourceMapData.sourceMapMappings
|
||||
}), /*writeByteOrderMark*/ false);
|
||||
writeFile(sourceMapData.sourceMapFilePath, serializeSourceMapContents(
|
||||
3,
|
||||
sourceMapData.sourceMapFile,
|
||||
sourceMapData.sourceMapSourceRoot,
|
||||
sourceMapData.sourceMapSources,
|
||||
sourceMapData.sourceMapNames,
|
||||
sourceMapData.sourceMapMappings), /*writeByteOrderMark*/ false);
|
||||
sourceMapDataList.push(sourceMapData);
|
||||
|
||||
// Write sourcemap url to the js file and write the js file
|
||||
|
||||
@@ -819,7 +819,7 @@ module ts {
|
||||
// applying some stricter checks on that node.
|
||||
function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void {
|
||||
var span = getErrorSpanForNode(node);
|
||||
var start = skipTrivia(file.text, span.pos);
|
||||
var start = span.end > span.pos ? skipTrivia(file.text, span.pos) : span.pos;
|
||||
var length = span.end - start;
|
||||
|
||||
file.syntacticErrors.push(createFileDiagnostic(file, start, length, message, arg0, arg1, arg2));
|
||||
|
||||
@@ -202,6 +202,11 @@ module ts {
|
||||
var compilerOptions = commandLine.options;
|
||||
|
||||
if (compilerOptions.locale) {
|
||||
if (typeof JSON === "undefined") {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"));
|
||||
return sys.exit(1);
|
||||
}
|
||||
|
||||
validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user