mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Restore some monomorphism
This commit is contained in:
@@ -2297,7 +2297,7 @@ namespace ts {
|
||||
emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node);
|
||||
writeLinesAndIndent(linesAfterDot, /*writeSpaceIfNotIndenting*/ false);
|
||||
emit(node.name);
|
||||
decreaseIndentIf(linesBeforeDot, linesAfterDot);
|
||||
decreaseIndentIf(linesBeforeDot > 0, linesAfterDot > 0);
|
||||
}
|
||||
|
||||
// 1..toString is a valid property access, emit a dot after the literal
|
||||
@@ -2475,7 +2475,7 @@ namespace ts {
|
||||
case EmitBinaryExpressionState.FinishEmit: {
|
||||
const linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
|
||||
const linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
|
||||
decreaseIndentIf(linesBeforeOperator, linesAfterOperator);
|
||||
decreaseIndentIf(linesBeforeOperator > 0, linesAfterOperator > 0);
|
||||
stackIndex--;
|
||||
break;
|
||||
}
|
||||
@@ -2529,13 +2529,13 @@ namespace ts {
|
||||
emit(node.questionToken);
|
||||
writeLinesAndIndent(linesAfterQuestion, /*writeSpaceIfNotIndenting*/ true);
|
||||
emitExpression(node.whenTrue);
|
||||
decreaseIndentIf(linesBeforeQuestion, linesAfterQuestion);
|
||||
decreaseIndentIf(linesBeforeQuestion > 0, linesAfterQuestion > 0);
|
||||
|
||||
writeLinesAndIndent(linesBeforeColon, /*writeSpaceIfNotIndenting*/ true);
|
||||
emit(node.colonToken);
|
||||
writeLinesAndIndent(linesAfterColon, /*writeSpaceIfNotIndenting*/ true);
|
||||
emitExpression(node.whenFalse);
|
||||
decreaseIndentIf(linesBeforeColon, linesAfterColon);
|
||||
decreaseIndentIf(linesBeforeColon > 0, linesAfterColon > 0);
|
||||
}
|
||||
|
||||
function emitTemplateExpression(node: TemplateExpression) {
|
||||
@@ -4010,7 +4010,7 @@ namespace ts {
|
||||
let shouldEmitInterveningComments = mayEmitInterveningComments;
|
||||
const leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children!, format); // TODO: GH#18217
|
||||
if (leadingLineTerminatorCount) {
|
||||
writeLine(leadingLineTerminatorCount);
|
||||
writeBlankLines(leadingLineTerminatorCount);
|
||||
shouldEmitInterveningComments = false;
|
||||
}
|
||||
else if (format & ListFormat.SpaceBetweenBraces) {
|
||||
@@ -4058,7 +4058,7 @@ namespace ts {
|
||||
shouldDecreaseIndentAfterEmit = true;
|
||||
}
|
||||
|
||||
writeLine(separatingLineTerminatorCount);
|
||||
writeBlankLines(separatingLineTerminatorCount);
|
||||
shouldEmitInterveningComments = false;
|
||||
}
|
||||
else if (previousSibling && format & ListFormat.SpaceBetweenSiblings) {
|
||||
@@ -4115,7 +4115,7 @@ namespace ts {
|
||||
// Write the closing line terminator or closing whitespace.
|
||||
const closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children!, format);
|
||||
if (closingLineTerminatorCount) {
|
||||
writeLine(closingLineTerminatorCount);
|
||||
writeBlankLines(closingLineTerminatorCount);
|
||||
}
|
||||
else if (format & ListFormat.SpaceBetweenBraces) {
|
||||
writeSpace();
|
||||
@@ -4185,10 +4185,8 @@ namespace ts {
|
||||
writer.writeProperty(s);
|
||||
}
|
||||
|
||||
function writeLine(count = 1) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
writer.writeLine(i > 0);
|
||||
}
|
||||
function writeLine() {
|
||||
writer.writeLine();
|
||||
}
|
||||
|
||||
function increaseIndent() {
|
||||
@@ -4244,10 +4242,21 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function writeBlankLines(lineCount: number) {
|
||||
for (let i = 0; i < lineCount; i++) {
|
||||
if (i === 0) {
|
||||
writer.writeLine();
|
||||
}
|
||||
else {
|
||||
writer.forceWriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function writeLinesAndIndent(lineCount: number, writeSpaceIfNotIndenting: boolean) {
|
||||
if (lineCount) {
|
||||
increaseIndent();
|
||||
writeLine(lineCount);
|
||||
writeBlankLines(lineCount);
|
||||
}
|
||||
else if (writeSpaceIfNotIndenting) {
|
||||
writeSpace();
|
||||
@@ -4258,7 +4267,7 @@ namespace ts {
|
||||
// previous indent values to be considered at a time. This also allows caller to just
|
||||
// call this once, passing in all their appropriate indent values, instead of needing
|
||||
// to call this helper function multiple times.
|
||||
function decreaseIndentIf(value1: boolean | number, value2: boolean | number) {
|
||||
function decreaseIndentIf(value1: boolean, value2: boolean) {
|
||||
if (value1) {
|
||||
decreaseIndent();
|
||||
}
|
||||
|
||||
@@ -3753,7 +3753,7 @@ namespace ts {
|
||||
writeParameter(text: string): void;
|
||||
writeProperty(text: string): void;
|
||||
writeSymbol(text: string, symbol: Symbol): void;
|
||||
writeLine(force?: boolean): void;
|
||||
writeLine(): void;
|
||||
increaseIndent(): void;
|
||||
decreaseIndent(): void;
|
||||
clear(): void;
|
||||
@@ -6328,6 +6328,7 @@ namespace ts {
|
||||
getText(): string;
|
||||
rawWrite(s: string): void;
|
||||
writeLiteral(s: string): void;
|
||||
forceWriteLine(): void;
|
||||
getTextPos(): number;
|
||||
getLine(): number;
|
||||
getColumn(): number;
|
||||
|
||||
@@ -3569,13 +3569,17 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function writeLine(force?: boolean) {
|
||||
if (!lineStart || force) {
|
||||
output += newLine;
|
||||
lineCount++;
|
||||
linePos = output.length;
|
||||
lineStart = true;
|
||||
hasTrailingComment = false;
|
||||
function forceWriteLine() {
|
||||
output += newLine;
|
||||
lineCount++;
|
||||
linePos = output.length;
|
||||
lineStart = true;
|
||||
hasTrailingComment = false;
|
||||
}
|
||||
|
||||
function writeLine() {
|
||||
if (!lineStart) {
|
||||
forceWriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3590,6 +3594,7 @@ namespace ts {
|
||||
rawWrite,
|
||||
writeLiteral,
|
||||
writeLine,
|
||||
forceWriteLine,
|
||||
increaseIndent: () => { indent++; },
|
||||
decreaseIndent: () => { indent--; },
|
||||
getIndent: () => indent,
|
||||
|
||||
Reference in New Issue
Block a user