Skip to content

Commit 1a42fe6

Browse files
authored
Merge pull request #199 from tmr232/reorder-args
Reorder arguments for `extractFunctionName`
2 parents de661a6 + 6807f8e commit 1a42fe6

File tree

10 files changed

+16
-10
lines changed

10 files changed

+16
-10
lines changed

src/control-flow/cfg-cpp.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,9 @@ function extractCppFunctionName(func: SyntaxNode): string | undefined {
233233
return undefined;
234234
}
235235

236-
// Find the binding variable of a lambda function
236+
/**
237+
* Find the binding variable of a lambda function
238+
*/
237239
function findVariableBinding(func: SyntaxNode): string | undefined {
238240
const parent = func.parent;
239241
if (!parent) return undefined;

src/control-flow/cfg-go.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,9 @@ const functionQuery = {
445445
captureName: "name",
446446
};
447447

448-
// Find the variable or field name bound to a function literal
448+
/**
449+
* Find the variable or field name bound to a function literal
450+
*/
449451
function findVariableBinding(func: SyntaxNode): string | undefined {
450452
const parent = func.parent;
451453
if (!parent) return undefined;

src/control-flow/cfg-typescript.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,9 @@ function extractTypeScriptFunctionName(func: SyntaxNode): string | undefined {
403403
}
404404
}
405405

406-
// Find the variable, parameter, or field that this function is bound to
406+
/**
407+
* Finds the variable, parameter, or field that this function is bound to
408+
*/
407409
function findVariableBinding(func: SyntaxNode): string | undefined {
408410
const parent = func.parent;
409411
if (!parent) return undefined;

src/control-flow/cfg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ export function newCFGBuilder(
5959
}
6060

6161
export function extractFunctionName(
62-
func: SyntaxNode,
6362
language: Language,
63+
func: SyntaxNode,
6464
): string | undefined {
6565
return languageDefinitions[language].extractFunctionName(func);
6666
}

src/render/src/App.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ function updateMetadata(CFG: CFG, func?: SyntaxNode, language?: Language) {
293293
| undefined = undefined;
294294
295295
if (func && language) {
296-
name = extractFunctionName(func, language) ?? "<anonymous>";
296+
name = extractFunctionName(language, func) ?? "<anonymous>";
297297
lineCount = func.endPosition.row - func.startPosition.row + 1;
298298
functionData = { name, lineCount, language };
299299
}

src/test/extractNameC.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { extractFunctionName } from "../control-flow/cfg.ts";
33
import { iterFunctions } from "../file-parsing/bun.ts";
44

55
const namesFrom = (code: string) =>
6-
[...iterFunctions(code, "C")].map((f) => extractFunctionName(f, "C"));
6+
[...iterFunctions(code, "C")].map((f) => extractFunctionName("C", f));
77
describe("C: function name extraction", () => {
88
test.each([
99
[

src/test/extractNameCpp.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { extractFunctionName } from "../control-flow/cfg.ts";
33
import { iterFunctions } from "../file-parsing/bun.ts";
44

55
const namesFrom = (code: string) =>
6-
[...iterFunctions(code, "C++")].map((f) => extractFunctionName(f, "C++"));
6+
[...iterFunctions(code, "C++")].map((f) => extractFunctionName("C++", f));
77

88
describe("C++: basic functions & namespaces", () => {
99
test.each([

src/test/extractNameGo.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { extractFunctionName } from "../control-flow/cfg.ts";
33
import { iterFunctions } from "../file-parsing/bun.ts";
44

55
const namesFrom = (code: string) =>
6-
[...iterFunctions(code, "Go")].map((f) => extractFunctionName(f, "Go"));
6+
[...iterFunctions(code, "Go")].map((f) => extractFunctionName("Go", f));
77

88
describe("Go: basic functions", () => {
99
test("named top-level functions", () => {

src/test/extractNamePython.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { iterFunctions } from "../file-parsing/bun.ts";
44

55
const namesFrom = (code: string) =>
66
[...iterFunctions(code, "Python")].map((f) =>
7-
extractFunctionName(f, "Python"),
7+
extractFunctionName("Python", f),
88
);
99

1010
describe("Python: function definitions", () => {

src/test/extractNameTypescript.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { iterFunctions } from "../file-parsing/bun.ts";
44

55
const namesFrom = (code: string) =>
66
[...iterFunctions(code, "TypeScript")].map((f) =>
7-
extractFunctionName(f, "TypeScript"),
7+
extractFunctionName("TypeScript", f),
88
);
99

1010
describe("TypeScript: arrow functions", () => {

0 commit comments

Comments
 (0)