Merge branch 'master' into exportDefault

Conflicts:
	tests/baselines/reference/es5ExportDefaultFunctionDeclaration.js
	tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js
This commit is contained in:
Anders Hejlsberg
2015-03-30 02:45:10 -07:00
1982 changed files with 11621 additions and 29459 deletions

View File

@@ -140,18 +140,6 @@ module ts {
description: Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation,
experimental: true
},
{
name: "preserveNewLines",
type: "boolean",
description: Diagnostics.Preserve_new_lines_when_emitting_code,
experimental: true
},
{
name: "cacheDownlevelForOfLength",
type: "boolean",
description: "Cache length access when downlevel emitting for-of statements",
experimental: true,
},
{
name: "target",
shortName: "t",

View File

@@ -88,7 +88,6 @@ module ts {
let writeLine = writer.writeLine;
let increaseIndent = writer.increaseIndent;
let decreaseIndent = writer.decreaseIndent;
let preserveNewLines = compilerOptions.preserveNewLines || false;
let currentSourceFile: SourceFile;
@@ -730,7 +729,7 @@ module ts {
increaseIndent();
if (preserveNewLines && nodeStartPositionsAreOnSameLine(parent, nodes[0])) {
if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) {
if (spacesBetweenBraces) {
write(" ");
}
@@ -741,7 +740,7 @@ module ts {
for (let i = 0, n = nodes.length; i < n; i++) {
if (i) {
if (preserveNewLines && nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) {
if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) {
write(", ");
}
else {
@@ -759,7 +758,7 @@ module ts {
decreaseIndent();
if (preserveNewLines && nodeEndPositionsAreOnSameLine(parent, lastOrUndefined(nodes))) {
if (nodeEndPositionsAreOnSameLine(parent, lastOrUndefined(nodes))) {
if (spacesBetweenBraces) {
write(" ");
}
@@ -1658,7 +1657,7 @@ module ts {
// If the code is not indented, an optional valueToWriteWhenNotIndenting will be
// emitted instead.
function indentIfOnDifferentLines(parent: Node, node1: Node, node2: Node, valueToWriteWhenNotIndenting?: string): boolean {
let realNodesAreOnDifferentLines = preserveNewLines && !nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2);
let realNodesAreOnDifferentLines = !nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2);
// Always use a newline for synthesized code if the synthesizer desires it.
let synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2);
@@ -1966,7 +1965,7 @@ module ts {
}
function emitBlock(node: Block) {
if (preserveNewLines && isSingleLineEmptyBlock(node)) {
if (isSingleLineEmptyBlock(node)) {
emitToken(SyntaxKind.OpenBraceToken, node.pos);
write(" ");
emitToken(SyntaxKind.CloseBraceToken, node.statements.end);
@@ -2168,8 +2167,6 @@ module ts {
let counter = createTempVariable(TempFlags._i);
let rhsReference = rhsIsIdentifier ? <Identifier>node.expression : createTempVariable(TempFlags.Auto);
var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(TempFlags._n) : undefined;
// This is the let keyword for the counter and rhsReference. The let keyword for
// the LHS will be emitted inside the body.
emitStart(node.expression);
@@ -2190,14 +2187,6 @@ module ts {
emitEnd(node.expression);
}
if (cachedLength) {
write(", ");
emitNodeWithoutSourceMap(cachedLength);
write(" = ");
emitNodeWithoutSourceMap(rhsReference);
write(".length");
}
write("; ");
// _i < _a.length;
@@ -2205,13 +2194,8 @@ module ts {
emitNodeWithoutSourceMap(counter);
write(" < ");
if (cachedLength) {
emitNodeWithoutSourceMap(cachedLength);
}
else {
emitNodeWithoutSourceMap(rhsReference);
write(".length");
}
emitNodeWithoutSourceMap(rhsReference);
write(".length");
emitEnd(node.initializer);
write("; ");
@@ -2350,7 +2334,7 @@ module ts {
write("default:");
}
if (preserveNewLines && node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) {
if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) {
write(" ");
emit(node.statements[0]);
}
@@ -3090,7 +3074,7 @@ module ts {
// If we didn't have to emit any preamble code, then attempt to keep the arrow
// function on one line.
if (preserveNewLines && !preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) {
if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) {
write(" ");
emitStart(body);
write("return ");
@@ -3138,7 +3122,7 @@ module ts {
let preambleEmitted = writer.getTextPos() !== initialTextPos;
if (preserveNewLines && !preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) {
if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) {
for (let statement of body.statements) {
write(" ");
emit(statement);

View File

@@ -1588,8 +1588,6 @@ module ts {
version?: boolean;
watch?: boolean;
/* @internal */ stripInternal?: boolean;
/* @internal */ preserveNewLines?: boolean;
/* @internal */ cacheDownlevelForOfLength?: boolean;
[option: string]: string | number | boolean;
}

View File

@@ -1008,10 +1008,6 @@ module Harness {
options.outDir = setting.value;
break;
case 'preservenewlines':
options.preserveNewLines = !!setting.value;
break;
case 'sourceroot':
options.sourceRoot = setting.value;
break;
@@ -1465,7 +1461,7 @@ module Harness {
var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
// List of allowed metadata names
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "preservenewlines", "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal"];
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal"];
function extractCompilerSettings(content: string): CompilerSetting[] {