Skip to content

Commit d2da7a0

Browse files
committed
fixing some file extensions
1 parent f8b0a25 commit d2da7a0

5 files changed

Lines changed: 17 additions & 18 deletions

File tree

src/slang-nodes/ContractSpecifier.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { StorageLayoutSpecifier } from './StorageLayoutSpecifier.js';
55

66
import type * as ast from '@nomicfoundation/slang/ast';
77
import type { AstPath, Doc, ParserOptions } from 'prettier';
8-
import type { AstNode } from './types.js';
9-
import type { PrintFunction, SlangNode } from '../types.js';
8+
import type { AstNode } from './types.d.ts';
9+
import type { PrintFunction, SlangNode } from '../types.d.ts';
1010

1111
export class ContractSpecifier implements SlangNode {
1212
readonly kind = NonterminalKind.ContractSpecifier;

src/slang-nodes/ContractSpecifiers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { ContractSpecifier } from './ContractSpecifier.js';
77

88
import type * as ast from '@nomicfoundation/slang/ast';
99
import type { AstPath, Doc, ParserOptions } from 'prettier';
10-
import type { AstNode } from './types.js';
11-
import type { PrintFunction, SlangNode } from '../types.js';
10+
import type { AstNode } from './types.d.ts';
11+
import type { PrintFunction, SlangNode } from '../types.d.ts';
1212

1313
const { group, ifBreak, line, softline } = doc.builders;
1414

src/slang-nodes/StorageLayoutSpecifier.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { Expression } from './Expression.js';
66

77
import type * as ast from '@nomicfoundation/slang/ast';
88
import type { AstPath, Doc, ParserOptions } from 'prettier';
9-
import type { AstNode } from './types.js';
10-
import type { PrintFunction, SlangNode } from '../types.js';
9+
import type { AstNode } from './types.d.ts';
10+
import type { PrintFunction, SlangNode } from '../types.d.ts';
1111

1212
const { line } = doc.builders;
1313

src/slang-printers/print-binary-operation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
BinaryOperation,
1111
StrictAstNode
1212
} from '../slang-nodes/types.d.ts';
13-
import type { PrintFunction } from '../types.js';
13+
import type { PrintFunction } from '../types.d.ts';
1414

1515
const { group, indent } = doc.builders;
1616

src/slang-utils/metadata.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,21 @@ export function getNodeMetadata(
5353
}
5454
};
5555
}
56+
const { cst: parent } = ast;
57+
const children = parent.children().map(({ node }) => node);
5658

57-
const children = ast.cst.children().map((child) => {
58-
return child.node;
59-
});
60-
61-
const initialOffset = offsets.get(ast.cst.id) || 0;
59+
const initialOffset = offsets.get(parent.id) || 0;
6260
let offset = initialOffset;
6361

6462
const comments = children.reduce((commentsArray: Comment[], child) => {
63+
const { id, kind, textLength } = child;
6564
if (child.isNonterminalNode()) {
66-
offsets.set(child.id, offset);
65+
offsets.set(id, offset);
6766
} else {
6867
if (isComment(child)) {
69-
offsets.set(child.id, offset);
68+
offsets.set(id, offset);
7069
}
71-
switch (child.kind) {
70+
switch (kind) {
7271
// Since the fetching the comments and calculating offsets are both done
7372
// as we iterate over the children and the comment also depends on the
7473
// offset, it's hard to separate these responsibilities into different
@@ -91,12 +90,12 @@ export function getNodeMetadata(
9190
// functions, etc...
9291
// Since a user can add comments to this section of the code as well,
9392
// we need to track the offsets.
94-
offsets.set(child.id, offset);
93+
offsets.set(id, offset);
9594
break;
9695
}
9796
}
9897

99-
offset += child.textLength.utf16;
98+
offset += textLength.utf16;
10099
return commentsArray;
101100
}, []);
102101

@@ -108,7 +107,7 @@ export function getNodeMetadata(
108107
: getLeadingOffset(children.reverse());
109108
const loc = {
110109
start: initialOffset + leadingOffset,
111-
end: initialOffset + ast.cst.textLength.utf16 - trailingOffset,
110+
end: initialOffset + parent.textLength.utf16 - trailingOffset,
112111
leadingOffset,
113112
trailingOffset
114113
};

0 commit comments

Comments
 (0)