mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
PR feedback and baseline updates
This commit is contained in:
parent
eec39c2fc5
commit
609036a2d6
@ -150,20 +150,22 @@ module ts {
|
||||
return !nodeIsMissing(node);
|
||||
}
|
||||
|
||||
export function getTokenPosOfNode(node: Node, sourceFile?: SourceFile, skipDecorators?: boolean): number {
|
||||
export function getTokenPosOfNode(node: Node, sourceFile?: SourceFile): number {
|
||||
// With nodes that have no width (i.e. 'Missing' nodes), we actually *don't*
|
||||
// want to skip trivia because this will launch us forward to the next token.
|
||||
if (nodeIsMissing(node)) {
|
||||
return node.pos;
|
||||
}
|
||||
|
||||
let pos = node.pos;
|
||||
if (skipDecorators && node.decorators) {
|
||||
// Skip past decorators
|
||||
pos = node.decorators.end;
|
||||
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
|
||||
}
|
||||
|
||||
export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFile): number {
|
||||
if (nodeIsMissing(node) || !node.decorators) {
|
||||
return getTokenPosOfNode(node, sourceFile);
|
||||
}
|
||||
|
||||
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, pos);
|
||||
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end);
|
||||
}
|
||||
|
||||
export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string {
|
||||
|
||||
@ -330,7 +330,7 @@ module ts.formatting {
|
||||
let startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line;
|
||||
let undecoratedStartLine = startLine;
|
||||
if (enclosingNode.decorators) {
|
||||
undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile, /*skipDecorators*/ true)).line;
|
||||
undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line;
|
||||
}
|
||||
|
||||
let delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile);
|
||||
@ -561,7 +561,7 @@ module ts.formatting {
|
||||
|
||||
let undecoratedChildStartLine = childStartLine;
|
||||
if (child.decorators) {
|
||||
undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(child.getStart(sourceFile, /*skipDecorators*/ true)).line;
|
||||
undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(getNonDecoratorTokenPosOfNode(child, sourceFile)).line;
|
||||
}
|
||||
|
||||
// if child is a list item - try to get its indentation
|
||||
|
||||
@ -670,18 +670,10 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
static NodeIsInDecoratorContext(node: Node): boolean {
|
||||
if (node.parserContextFlags & ParserContextFlags.Decorator) {
|
||||
return true;
|
||||
while (isExpression(node)) {
|
||||
node = node.parent;
|
||||
}
|
||||
while (node) {
|
||||
if (isExpression(node)) {
|
||||
node = node.parent;
|
||||
}
|
||||
else {
|
||||
return node.kind === SyntaxKind.Decorator;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return node.kind === SyntaxKind.Decorator;
|
||||
}
|
||||
|
||||
static IsStartOfVariableDeclarationList(context: FormattingContext): boolean {
|
||||
|
||||
@ -19,7 +19,7 @@ module ts {
|
||||
getChildCount(sourceFile?: SourceFile): number;
|
||||
getChildAt(index: number, sourceFile?: SourceFile): Node;
|
||||
getChildren(sourceFile?: SourceFile): Node[];
|
||||
getStart(sourceFile?: SourceFile, skipDecorators?: boolean): number;
|
||||
getStart(sourceFile?: SourceFile): number;
|
||||
getFullStart(): number;
|
||||
getEnd(): number;
|
||||
getWidth(sourceFile?: SourceFile): number;
|
||||
@ -149,8 +149,8 @@ module ts {
|
||||
return getSourceFileOfNode(this);
|
||||
}
|
||||
|
||||
public getStart(sourceFile?: SourceFile, skipDecorators?: boolean): number {
|
||||
return getTokenPosOfNode(this, sourceFile, skipDecorators);
|
||||
public getStart(sourceFile?: SourceFile): number {
|
||||
return getTokenPosOfNode(this, sourceFile);
|
||||
}
|
||||
|
||||
public getFullStart(): number {
|
||||
|
||||
@ -237,9 +237,9 @@ export function delint(sourceFile: ts.SourceFile) {
|
||||
>sourceFile : ts.SourceFile
|
||||
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
|
||||
>node.getStart() : number
|
||||
>node.getStart : (sourceFile?: ts.SourceFile, skipDecorators?: boolean) => number
|
||||
>node.getStart : (sourceFile?: ts.SourceFile) => number
|
||||
>node : ts.Node
|
||||
>getStart : (sourceFile?: ts.SourceFile, skipDecorators?: boolean) => number
|
||||
>getStart : (sourceFile?: ts.SourceFile) => number
|
||||
|
||||
console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`);
|
||||
>console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`) : any
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
/////*1*/ @ decorator1
|
||||
/////*1*/ @ decorator1
|
||||
/////*2*/ @ decorator2
|
||||
/////*3*/ @decorator3
|
||||
/////*4*/ @ decorator4 @ decorator5
|
||||
/////*5*/class C {
|
||||
/////*6*/ @ decorator6
|
||||
/////*6*/ @ decorator6
|
||||
/////*7*/ @ decorator7
|
||||
/////*8*/ @decorator8
|
||||
/////*9*/ method1() { }
|
||||
@ -13,7 +13,7 @@
|
||||
/////*10*/ @ decorator9 @ decorator10 @decorator11 method2() { }
|
||||
////
|
||||
//// method3(
|
||||
/////*11*/ @ decorator12
|
||||
/////*11*/ @ decorator12
|
||||
/////*12*/ @ decorator13
|
||||
/////*13*/ @decorator14
|
||||
/////*14*/ x) { }
|
||||
@ -21,21 +21,21 @@
|
||||
//// method4(
|
||||
/////*15*/ @ decorator15 @ decorator16 @decorator17 x) { }
|
||||
////
|
||||
/////*16*/ @ decorator18
|
||||
/////*16*/ @ decorator18
|
||||
/////*17*/ @ decorator19
|
||||
/////*18*/ @decorator20
|
||||
/////*18*/ @decorator20
|
||||
/////*19*/ ["computed1"]() { }
|
||||
////
|
||||
/////*20*/ @ decorator21 @ decorator22 @decorator23 ["computed2"]() { }
|
||||
////
|
||||
/////*21*/ @ decorator24
|
||||
/////*21*/ @ decorator24
|
||||
/////*22*/ @ decorator25
|
||||
/////*23*/ @decorator26
|
||||
/////*24*/ get accessor1() { }
|
||||
////
|
||||
/////*25*/ @ decorator27 @ decorator28 @decorator29 get accessor2() { }
|
||||
////
|
||||
/////*26*/ @ decorator30
|
||||
/////*26*/ @ decorator30
|
||||
/////*27*/ @ decorator31
|
||||
/////*28*/ @decorator32
|
||||
/////*29*/ property1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user