mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 21:06:50 -05:00
remove for-loops
This commit is contained in:
@@ -6764,6 +6764,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
return leadingComments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all but the pinned or triple slash comments.
|
||||
* @param ranges The array to be filtered
|
||||
* @param onlyPinnedOrTripleSlashComments whether the filtering should be performed.
|
||||
*
|
||||
* This probably shouldn't be a parameter at all. It appears that in every call, the argument is
|
||||
* precisely 'compilerOptions.removeComments'.
|
||||
*
|
||||
* How to fix this?
|
||||
*/
|
||||
function filterComments(ranges: CommentRange[], onlyPinnedOrTripleSlashComments: boolean): CommentRange[] {
|
||||
// If we're removing comments, then we want to strip out all but the pinned or
|
||||
// triple slash comments.
|
||||
|
||||
@@ -260,26 +260,30 @@ namespace ts {
|
||||
}
|
||||
|
||||
public getFirstToken(sourceFile?: SourceFile): Node {
|
||||
let children = this.getChildren();
|
||||
for (let child of children) {
|
||||
if (child.kind < SyntaxKind.FirstNode) {
|
||||
return child;
|
||||
}
|
||||
let children = this.getChildren(); // why isn't sourceFile passed as an argument??
|
||||
if (!(children && children.length > 0)) { return undefined; }
|
||||
|
||||
return child.getFirstToken(sourceFile);
|
||||
let child = children[0];
|
||||
|
||||
if (child.kind < SyntaxKind.FirstNode) {
|
||||
return child;
|
||||
}
|
||||
|
||||
return child.getFirstToken(sourceFile);
|
||||
}
|
||||
|
||||
public getLastToken(sourceFile?: SourceFile): Node {
|
||||
let children = this.getChildren(sourceFile);
|
||||
for (let i = children.length - 1; i >= 0; i--) {
|
||||
let child = children[i];
|
||||
if (child.kind < SyntaxKind.FirstNode) {
|
||||
return child;
|
||||
}
|
||||
if (!children) { return undefined; }
|
||||
|
||||
return child.getLastToken(sourceFile);
|
||||
let child = lastOrUndefined(children);
|
||||
if (!child) { return undefined; }
|
||||
|
||||
if (child.kind < SyntaxKind.FirstNode) {
|
||||
return child;
|
||||
}
|
||||
|
||||
return child.getLastToken(sourceFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user