Skip to content

Commit 945b4d5

Browse files
committed
Renaming HubNode as CollectionNode
1 parent 7eb71b4 commit 945b4d5

14 files changed

Lines changed: 45 additions & 42 deletions

src/slang-comments/handlers/add-hub-node-first-comment.ts renamed to src/slang-comments/handlers/add-collection-node-first-comment.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { util } from 'prettier';
22

3-
import type { Comment, HubNode } from '../../slang-nodes';
3+
import type { Comment, CollectionNode } from '../../slang-nodes';
44

55
const { addDanglingComment, addLeadingComment } = util;
66

7-
export default function addHubNodeFirstComment(
8-
node: HubNode,
7+
export default function addCollectionNodeFirstComment(
8+
node: CollectionNode,
99
comment: Comment
1010
): void {
1111
if (node.items.length === 0) {

src/slang-comments/handlers/add-hub-node-last-comment.ts renamed to src/slang-comments/handlers/add-collection-node-last-comment.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { util } from 'prettier';
22

3-
import type { Comment, HubNode } from '../../slang-nodes';
3+
import type { Comment, CollectionNode } from '../../slang-nodes';
44

55
const { addDanglingComment, addTrailingComment } = util;
66

7-
export default function addHubNodeLastComment(
8-
node: HubNode,
7+
export default function addCollectionNodeLastComment(
8+
node: CollectionNode,
99
comment: Comment
1010
): void {
1111
if (node.items.length === 0) {

src/slang-comments/handlers/handle-block-comments.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NonterminalKind } from '@nomicfoundation/slang/kinds/index.js';
2-
import addHubNodeFirstComment from './add-hub-node-first-comment.js';
3-
import addHubNodeLastComment from './add-hub-node-last-comment.js';
2+
import addCollectionNodeFirstComment from './add-collection-node-first-comment.js';
3+
import addCollectionNodeLastComment from './add-collection-node-last-comment.js';
44

55
import type { HandlerParams } from './types';
66

@@ -15,12 +15,12 @@ export default function handleBlockComments({
1515
}
1616

1717
if (precedingNode?.kind === NonterminalKind.Statements) {
18-
addHubNodeLastComment(precedingNode, comment);
18+
addCollectionNodeLastComment(precedingNode, comment);
1919
return true;
2020
}
2121

2222
if (followingNode?.kind === NonterminalKind.Statements) {
23-
addHubNodeFirstComment(followingNode, comment);
23+
addCollectionNodeFirstComment(followingNode, comment);
2424
return true;
2525
}
2626

src/slang-comments/handlers/handle-contract-definition-comments.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { NonterminalKind } from '@nomicfoundation/slang/kinds/index.js';
22
import { util } from 'prettier';
33
import { getNextNonSpaceNonCommentCharacter } from '../../slang-utils/backward-compatibility.js';
4-
import addHubNodeFirstComment from './add-hub-node-first-comment.js';
5-
import addHubNodeLastComment from './add-hub-node-last-comment.js';
4+
import addCollectionNodeFirstComment from './add-collection-node-first-comment.js';
5+
import addCollectionNodeLastComment from './add-collection-node-last-comment.js';
66

77
import type { HandlerParams } from './types';
88

@@ -34,7 +34,7 @@ export default function handleContractDefinitionComments({
3434

3535
// The comment is at the end of the body of the ContractDefinition.
3636
if (precedingNode?.kind === NonterminalKind.ContractMembers) {
37-
addHubNodeLastComment(precedingNode, comment);
37+
addCollectionNodeLastComment(precedingNode, comment);
3838
return true;
3939
}
4040

@@ -56,7 +56,7 @@ export default function handleContractDefinitionComments({
5656
// If there's no InheritanceSpecifier, the comment before the body is
5757
// assumed to be intended at the beginning of the body.
5858
if (followingNode?.kind === NonterminalKind.ContractMembers) {
59-
addHubNodeFirstComment(followingNode, comment);
59+
addCollectionNodeFirstComment(followingNode, comment);
6060
return true;
6161
}
6262
}

src/slang-comments/handlers/handle-else-branch-comments.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NonterminalKind } from '@nomicfoundation/slang/kinds/index.js';
22
import { util } from 'prettier';
3-
import addHubNodeFirstComment from './add-hub-node-first-comment.js';
3+
import addCollectionNodeFirstComment from './add-collection-node-first-comment.js';
44

55
import type { HandlerParams } from './types';
66

@@ -20,7 +20,7 @@ export default function handleElseBranchComments({
2020
followingNode.variant.kind === NonterminalKind.IfStatement
2121
) {
2222
if (followingNode.variant.body.variant.kind === NonterminalKind.Block) {
23-
addHubNodeFirstComment(
23+
addCollectionNodeFirstComment(
2424
followingNode.variant.body.variant.statements,
2525
comment
2626
);

src/slang-comments/handlers/handle-if-statement-comments.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NonterminalKind } from '@nomicfoundation/slang/kinds/index.js';
22
import { util } from 'prettier';
33
import { getNextNonSpaceNonCommentCharacter } from '../../slang-utils/backward-compatibility.js';
4-
import addHubNodeFirstComment from './add-hub-node-first-comment.js';
4+
import addCollectionNodeFirstComment from './add-collection-node-first-comment.js';
55

66
import type { HandlerParams } from './types';
77

@@ -42,7 +42,10 @@ export default function handleIfStatementComments({
4242

4343
if (followingNode.kind === NonterminalKind.IfStatement) {
4444
if (followingNode.body.variant.kind === NonterminalKind.Block) {
45-
addHubNodeFirstComment(followingNode.body.variant.statements, comment);
45+
addCollectionNodeFirstComment(
46+
followingNode.body.variant.statements,
47+
comment
48+
);
4649
} else {
4750
addLeadingComment(followingNode.body.variant, comment);
4851
}
@@ -54,7 +57,7 @@ export default function handleIfStatementComments({
5457
// if (a) /* comment */ true
5558
if (enclosingNode.body === followingNode) {
5659
if (followingNode.variant.kind === NonterminalKind.Block) {
57-
addHubNodeFirstComment(followingNode.variant.statements, comment);
60+
addCollectionNodeFirstComment(followingNode.variant.statements, comment);
5861
} else {
5962
addLeadingComment(followingNode, comment);
6063
}

src/slang-comments/handlers/handle-interface-definition-comments.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NonterminalKind } from '@nomicfoundation/slang/kinds/index.js';
22
import { getNextNonSpaceNonCommentCharacter } from '../../slang-utils/backward-compatibility.js';
3-
import addHubNodeFirstComment from './add-hub-node-first-comment.js';
4-
import addHubNodeLastComment from './add-hub-node-last-comment.js';
3+
import addCollectionNodeFirstComment from './add-collection-node-first-comment.js';
4+
import addCollectionNodeLastComment from './add-collection-node-last-comment.js';
55

66
import type { HandlerParams } from './types';
77

@@ -20,7 +20,7 @@ export default function handleInterfaceDefinitionComments({
2020

2121
// The comment is at the end of the body of the InterfaceDefinition.
2222
if (precedingNode?.kind === NonterminalKind.InterfaceMembers) {
23-
addHubNodeLastComment(precedingNode, comment);
23+
addCollectionNodeLastComment(precedingNode, comment);
2424
return true;
2525
}
2626

@@ -29,7 +29,7 @@ export default function handleInterfaceDefinitionComments({
2929
nextCharacter === '{' &&
3030
followingNode?.kind === NonterminalKind.InterfaceMembers
3131
) {
32-
addHubNodeFirstComment(followingNode, comment);
32+
addCollectionNodeFirstComment(followingNode, comment);
3333
return true;
3434
}
3535

src/slang-comments/handlers/handle-library-definition-comments.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NonterminalKind } from '@nomicfoundation/slang/kinds/index.js';
22
import { getNextNonSpaceNonCommentCharacter } from '../../slang-utils/backward-compatibility.js';
3-
import addHubNodeFirstComment from './add-hub-node-first-comment.js';
4-
import addHubNodeLastComment from './add-hub-node-last-comment.js';
3+
import addCollectionNodeFirstComment from './add-collection-node-first-comment.js';
4+
import addCollectionNodeLastComment from './add-collection-node-last-comment.js';
55

66
import type { HandlerParams } from './types';
77

@@ -20,7 +20,7 @@ export default function handleLibraryDefinitionComments({
2020

2121
// The comment is at the end of the body of the ContractDefinition.
2222
if (precedingNode?.kind === NonterminalKind.LibraryMembers) {
23-
addHubNodeLastComment(precedingNode, comment);
23+
addCollectionNodeLastComment(precedingNode, comment);
2424
return true;
2525
}
2626

@@ -29,7 +29,7 @@ export default function handleLibraryDefinitionComments({
2929
nextCharacter === '{' &&
3030
followingNode?.kind === NonterminalKind.LibraryMembers
3131
) {
32-
addHubNodeFirstComment(followingNode, comment);
32+
addCollectionNodeFirstComment(followingNode, comment);
3333
return true;
3434
}
3535

src/slang-comments/handlers/handle-parameters-declaration-comments.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NonterminalKind } from '@nomicfoundation/slang/kinds/index.js';
2-
import addHubNodeFirstComment from './add-hub-node-first-comment.js';
3-
import addHubNodeLastComment from './add-hub-node-last-comment.js';
2+
import addCollectionNodeFirstComment from './add-collection-node-first-comment.js';
3+
import addCollectionNodeLastComment from './add-collection-node-last-comment.js';
44

55
import type { HandlerParams } from './types';
66

@@ -15,12 +15,12 @@ export default function handleBlockComments({
1515
}
1616

1717
if (precedingNode?.kind === NonterminalKind.Parameters) {
18-
addHubNodeLastComment(precedingNode, comment);
18+
addCollectionNodeLastComment(precedingNode, comment);
1919
return true;
2020
}
2121

2222
if (followingNode?.kind === NonterminalKind.Parameters) {
23-
addHubNodeFirstComment(followingNode, comment);
23+
addCollectionNodeFirstComment(followingNode, comment);
2424
return true;
2525
}
2626

src/slang-comments/handlers/handle-positional-arguments-declaration-comments.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NonterminalKind } from '@nomicfoundation/slang/kinds/index.js';
2-
import addHubNodeFirstComment from './add-hub-node-first-comment.js';
3-
import addHubNodeLastComment from './add-hub-node-last-comment.js';
2+
import addCollectionNodeFirstComment from './add-collection-node-first-comment.js';
3+
import addCollectionNodeLastComment from './add-collection-node-last-comment.js';
44

55
import type { HandlerParams } from './types';
66

@@ -15,12 +15,12 @@ export default function handlePositionalArgumentsDeclarationComments({
1515
}
1616

1717
if (precedingNode?.kind === NonterminalKind.PositionalArguments) {
18-
addHubNodeLastComment(precedingNode, comment);
18+
addCollectionNodeLastComment(precedingNode, comment);
1919
return true;
2020
}
2121

2222
if (followingNode?.kind === NonterminalKind.PositionalArguments) {
23-
addHubNodeFirstComment(followingNode, comment);
23+
addCollectionNodeFirstComment(followingNode, comment);
2424
return true;
2525
}
2626

0 commit comments

Comments
 (0)