Skip to content

Commit 4eaa1b3

Browse files
[autofix.ci] apply automated fixes
1 parent ab0b2cc commit 4eaa1b3

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

packages/language-server/src/codegen/context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Code } from "../types";
1+
import type { Code } from "../types";
22

33
class CodegenContext {
44
needCaptureReturn = 0;
5-
returnType: (Code[] | null)[] = []
5+
returnType: (Code[] | null)[] = [];
66
}
77

88
// TODO: Make this not singleton

packages/language-server/src/codegen/function.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import type { SyntaxNode } from "tree-sitter";
22
import type { Code } from "../types";
33
import { generateBlock, generateExpression, generateIdentifier, generateSelf } from ".";
4-
import { codeFeatures } from "../utils/codeFeatures";
54
import { context } from "./context";
65
import { generateType } from "./type";
7-
import { between, generateChildren, wrapWith } from "./utils";
6+
import { between, generateChildren } from "./utils";
87

98
export enum FunctionKind {
109
Declaration,
@@ -18,7 +17,6 @@ export function* generateFunction(
1817
kind: FunctionKind,
1918
selfType?: SyntaxNode,
2019
): Generator<Code> {
21-
2220
if (kind === FunctionKind.Declaration && node.namedChildren[0]?.type === "visibility_modifier") {
2321
yield `export `;
2422
}
@@ -38,7 +36,8 @@ export function* generateFunction(
3836
yield `: `;
3937
yield* typeCode;
4038
context.returnType.push(typeCode);
41-
} else {
39+
}
40+
else {
4241
context.returnType.push(null);
4342
}
4443

packages/language-server/src/codegen/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { SyntaxNode } from "tree-sitter";
2-
import { UserError, type Code } from "../types";
2+
import type { Code } from "../types";
3+
import { UserError } from "../types";
34
import { codeFeatures } from "../utils/codeFeatures";
45
import { context } from "./context";
56
import { generateEnum } from "./enum";
@@ -29,10 +30,12 @@ export function* generateBlock(node: SyntaxNode, implicitReturn: boolean): Gener
2930
yield* wrapWith(node.startIndex, node.endIndex, codeFeatures.verification, "return");
3031
yield " ";
3132
yield* generateExpression(node);
32-
} else {
33+
}
34+
else {
3335
yield* generateStatement(node);
3436
}
35-
} else {
37+
}
38+
else {
3639
yield* generateStatement(node);
3740
}
3841
}
@@ -339,7 +342,7 @@ function* generateReturnExpression(node: SyntaxNode): Generator<Code> {
339342
if (context.needCaptureReturn) {
340343
const typeCode = context.returnType[context.returnType.length - 1];
341344
if (typeCode) {
342-
yield `(`
345+
yield `(`;
343346
if (value) {
344347
yield* generateExpression(value);
345348
}
@@ -353,7 +356,8 @@ function* generateReturnExpression(node: SyntaxNode): Generator<Code> {
353356
yield ` `;
354357
yield* typeCode;
355358
yield `)`;
356-
} else {
359+
}
360+
else {
357361
yield new UserError(node, "Return type must be specified explicitly");
358362
}
359363
}

0 commit comments

Comments
 (0)