Skip to content

Commit 4d61173

Browse files
committed
Remove unnecessary path parameters
1 parent d7eed72 commit 4d61173

11 files changed

Lines changed: 18 additions & 19 deletions

src/slang-nodes/ConstructorAttributes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ export class ConstructorAttributes extends SlangNode {
3232
}
3333

3434
print(path: AstPath<ConstructorAttributes>, print: PrintFunction): Doc {
35-
return path.map((item) => [line, print(item)], 'items');
35+
return path.map(() => [line, print(path)], 'items');
3636
}
3737
}

src/slang-nodes/FallbackFunctionAttributes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ export class FallbackFunctionAttributes extends SlangNode {
3232
}
3333

3434
print(path: AstPath<FallbackFunctionAttributes>, print: PrintFunction): Doc {
35-
return path.map((item) => [line, print(item)], 'items');
35+
return path.map(() => [line, print(path)], 'items');
3636
}
3737
}

src/slang-nodes/FunctionAttributes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ export class FunctionAttributes extends SlangNode {
3232
}
3333

3434
print(path: AstPath<FunctionAttributes>, print: PrintFunction): Doc {
35-
return path.map((item) => [line, print(item)], 'items');
35+
return path.map(() => [line, print(path)], 'items');
3636
}
3737
}

src/slang-nodes/FunctionTypeAttributes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ export class FunctionTypeAttributes extends SlangNode {
2727
}
2828

2929
print(path: AstPath<FunctionTypeAttributes>, print: PrintFunction): Doc {
30-
return path.map((item) => [line, print(item)], 'items');
30+
return path.map(() => [line, print(path)], 'items');
3131
}
3232
}

src/slang-nodes/ModifierAttributes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ export class ModifierAttributes extends SlangNode {
2727
}
2828

2929
print(path: AstPath<ModifierAttributes>, print: PrintFunction): Doc {
30-
return path.map((item) => [line, print(item)], 'items');
30+
return path.map(() => [line, print(path)], 'items');
3131
}
3232
}

src/slang-nodes/ReceiveFunctionAttributes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ export class ReceiveFunctionAttributes extends SlangNode {
3232
}
3333

3434
print(path: AstPath<ReceiveFunctionAttributes>, print: PrintFunction): Doc {
35-
return path.map((item) => [line, print(item)], 'items');
35+
return path.map(() => [line, print(path)], 'items');
3636
}
3737
}

src/slang-nodes/StateVariableAttributes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ export class StateVariableAttributes extends SlangNode {
2727
}
2828

2929
print(path: AstPath<StateVariableAttributes>, print: PrintFunction): Doc {
30-
return path.map((item) => [line, print(item)], 'items');
30+
return path.map(() => [line, print(path)], 'items');
3131
}
3232
}

src/slang-nodes/UnnamedFunctionAttributes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ export class UnnamedFunctionAttributes extends SlangNode {
3232
}
3333

3434
print(path: AstPath<UnnamedFunctionAttributes>, print: PrintFunction): Doc {
35-
return path.map((item) => [line, print(item)], 'items');
35+
return path.map(() => [line, print(path)], 'items');
3636
}
3737
}

src/slang-printers/print-comments.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ export function printComments(
2424
if (node.comments === undefined) return [];
2525
return joinExisting(
2626
line,
27-
path.map((commentPath, index, comments: Comment[]) => {
28-
const comment = commentPath.node;
27+
path.map(({ node: comment }, index, comments: Comment[]) => {
2928
if (!isPrintable(comment)) {
3029
return '';
3130
}
@@ -34,7 +33,7 @@ export function printComments(
3433
index === comments.length - 1 ||
3534
comments.slice(index + 1).findIndex(isPrintable) === -1;
3635
return [
37-
printComment(commentPath),
36+
printComment(path),
3837
!isLast && util.isNextLineEmpty(options.originalText, locEnd(comment))
3938
? hardline
4039
: ''

src/slang-printers/print-preserving-empty-lines.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,17 @@ export function printPreservingEmptyLines(
1616
options: ParserOptions<AstNode>
1717
): Doc {
1818
return node.items.length > 0
19-
? path.map((childPath) => {
20-
const node = childPath.node;
21-
19+
? path.map(({ node, isFirst, isLast }) => {
2220
return [
2321
// Only attempt to prepend an empty line if `node` is not the first item
24-
!childPath.isFirst &&
22+
!isFirst &&
2523
// YulLabel adds a dedented line so we don't have to prepend a hardline.
2624
node.kind !== NonterminalKind.YulLabel
2725
? hardline
2826
: '',
29-
print(childPath),
27+
print(path),
3028
// Only attempt to append an empty line if `node` is not the last item
31-
!childPath.isLast &&
29+
!isLast &&
3230
// Append an empty line if the original text already had an one after the
3331
// current `node`
3432
util.isNextLineEmpty(options.originalText, locEnd(node))

0 commit comments

Comments
 (0)