mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
Fix-ups around formatting and assertions
This commit is contained in:
@@ -624,10 +624,11 @@ namespace ts.formatting {
|
||||
return inheritedIndentation;
|
||||
}
|
||||
|
||||
if (isToken(child)) {
|
||||
// JSX text shouldn't affect indenting
|
||||
if (isToken(child) && child.kind !== SyntaxKind.JsxText) {
|
||||
// if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules
|
||||
const tokenInfo = formattingScanner.readTokenInfo(child);
|
||||
Debug.assert(tokenInfo.token.end === child.end);
|
||||
Debug.assert(tokenInfo.token.end === child.end, "Token end is child end");
|
||||
consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child);
|
||||
return inheritedIndentation;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
export function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner {
|
||||
Debug.assert(scanner === undefined);
|
||||
Debug.assert(scanner === undefined, "Scanner should be undefined");
|
||||
scanner = sourceFile.languageVariant === LanguageVariant.JSX ? jsxScanner : standardScanner;
|
||||
|
||||
scanner.setText(sourceFile.text);
|
||||
@@ -62,7 +62,7 @@ namespace ts.formatting {
|
||||
};
|
||||
|
||||
function advance(): void {
|
||||
Debug.assert(scanner !== undefined);
|
||||
Debug.assert(scanner !== undefined, "Scanner should be present");
|
||||
|
||||
lastTokenInfo = undefined;
|
||||
const isStarted = scanner.getStartPos() !== startPos;
|
||||
|
||||
@@ -35,8 +35,8 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
private GetRuleBucketIndex(row: number, column: number): number {
|
||||
Debug.assert(row <= SyntaxKind.LastKeyword && column <= SyntaxKind.LastKeyword, "Must compute formatting context from tokens");
|
||||
const rulesBucketIndex = (row * this.mapRowLength) + column;
|
||||
// Debug.Assert(rulesBucketIndex < this.map.Length, "Trying to access an index outside the array.");
|
||||
return rulesBucketIndex;
|
||||
}
|
||||
|
||||
|
||||
@@ -750,7 +750,7 @@ namespace ts {
|
||||
return find(startNode || sourceFile);
|
||||
|
||||
function findRightmostToken(n: Node): Node {
|
||||
if (isToken(n) || n.kind === SyntaxKind.JsxText) {
|
||||
if (isToken(n)) {
|
||||
return n;
|
||||
}
|
||||
|
||||
@@ -761,7 +761,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function find(n: Node): Node {
|
||||
if (isToken(n) || n.kind === SyntaxKind.JsxText) {
|
||||
if (isToken(n)) {
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user