Skip to content

Commit 483e6c5

Browse files
pjurczynskiclaude
andcommitted
Sort MethodNodeExpander methods following step-down rule
Apply RefakTS sort-methods command to reorder methods from high-level public interface to low-level utilities, demonstrating dogfooding approach. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent cf906c3 commit 483e6c5

1 file changed

Lines changed: 23 additions & 25 deletions

File tree

src/core/locators/method-node-expander.ts

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ export class MethodNodeExpander {
2424
];
2525
}
2626

27+
private getJsDocNodes(method: MethodDeclaration | ConstructorDeclaration): ts.Node[] {
28+
return method.getJsDocs().map((jsDoc: JSDoc) => jsDoc.compilerNode);
29+
}
30+
2731
private getDecoratorNodes(method: MethodDeclaration | ConstructorDeclaration): ts.Node[] {
2832
if (!Node.isMethodDeclaration(method)) return [];
2933
return method.getDecorators().map((decorator: Decorator) => decorator.compilerNode);
3034
}
3135

32-
private getJsDocNodes(method: MethodDeclaration | ConstructorDeclaration): ts.Node[] {
33-
return method.getJsDocs().map((jsDoc: JSDoc) => jsDoc.compilerNode);
34-
}
35-
3636
private createWrapperNode(
3737
method: MethodDeclaration | ConstructorDeclaration,
3838
metadata: ts.Node[],
@@ -44,21 +44,6 @@ export class MethodNodeExpander {
4444
return createWrappedNode(wrapperNode, { sourceFile: sourceFile.compilerNode });
4545
}
4646

47-
private createBlockNode(allNodes: ts.Node[]): ts.Block {
48-
return ts.factory.createBlock(
49-
allNodes.map(node => this.nodeToStatement(node)),
50-
false
51-
);
52-
}
53-
54-
55-
private nodeToStatement(node: ts.Node): ts.Statement {
56-
if (ts.isStatement(node)) {
57-
return node;
58-
}
59-
return ts.factory.createExpressionStatement(node as ts.Expression);
60-
}
61-
6247
private setWrapperRange(
6348
wrapperNode: ts.Block,
6449
allNodes: ts.Node[],
@@ -70,6 +55,14 @@ export class MethodNodeExpander {
7055
this.setNodeEnd(wrapperNode, this.calculateEndPosition(allNodes));
7156
}
7257

58+
private calculateEndPosition(allNodes: ts.Node[]): number {
59+
return Math.max(...allNodes.map(node => node.end));
60+
}
61+
62+
private setNodeEnd(node: ts.Node, endPosition: number): void {
63+
Object.defineProperty(node, 'end', { value: endPosition, writable: false });
64+
}
65+
7366
private calculateStartPosition(allNodes: ts.Node[], sourceFile: SourceFile): number {
7467
return Math.min(...allNodes.map(node => {
7568
const leadingComments = ts.getLeadingCommentRanges(sourceFile.getFullText(), node.pos) || [];
@@ -79,17 +72,22 @@ export class MethodNodeExpander {
7972
}));
8073
}
8174

82-
private calculateEndPosition(allNodes: ts.Node[]): number {
83-
return Math.max(...allNodes.map(node => node.end));
84-
}
85-
8675
private setNodePosition(node: ts.Node, position: number): void {
8776
Object.defineProperty(node, 'pos', { value: position, writable: false });
8877
}
8978

90-
private setNodeEnd(node: ts.Node, endPosition: number): void {
91-
Object.defineProperty(node, 'end', { value: endPosition, writable: false });
79+
private createBlockNode(allNodes: ts.Node[]): ts.Block {
80+
return ts.factory.createBlock(
81+
allNodes.map(node => this.nodeToStatement(node)),
82+
false
83+
);
9284
}
9385

9486

87+
private nodeToStatement(node: ts.Node): ts.Statement {
88+
if (ts.isStatement(node)) {
89+
return node;
90+
}
91+
return ts.factory.createExpressionStatement(node as ts.Expression);
92+
}
9593
}

0 commit comments

Comments
 (0)