Skip to content

Commit 04eaf25

Browse files
committed
Renaming edge case for comments in a hub node
1 parent 45d44e5 commit 04eaf25

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/slang-nodes/IdentifierPath.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class IdentifierPath implements SlangNode {
1818
separators: string[];
1919

2020
constructor(ast: ast.IdentifierPath, offset: number) {
21-
const metadata = getNodeMetadata(ast, offset, true);
21+
const metadata = getNodeMetadata(ast, offset);
2222
const { offsets } = metadata;
2323

2424
this.items = ast.items.map(

src/slang-utils/metadata.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function getLeadingOffset(children: Node[]): number {
2929
export function getNodeMetadata(
3030
ast: SlangAstNode,
3131
initialOffset: number,
32-
isHubNode = false
32+
includePeripheralComments = false
3333
): Metadata {
3434
if (typeof initialOffset === 'undefined') {
3535
throw new Error("Can't initiate metadata with an undefined initialOffset");
@@ -78,8 +78,12 @@ export function getNodeMetadata(
7878
return offsetsArray;
7979
}, []);
8080

81-
const leadingOffset = isHubNode ? 0 : getLeadingOffset(children);
82-
const trailingOffset = isHubNode ? 0 : getLeadingOffset(children.reverse());
81+
const leadingOffset = includePeripheralComments
82+
? 0
83+
: getLeadingOffset(children);
84+
const trailingOffset = includePeripheralComments
85+
? 0
86+
: getLeadingOffset(children.reverse());
8387
const loc = {
8488
start: initialOffset + leadingOffset,
8589
end: initialOffset + ast.cst.textLength.utf8 - trailingOffset,

0 commit comments

Comments
 (0)