MCPcopy Index your code
hub / github.com/CopilotKit/CopilotKit / extractMethodDefinition

Method extractMethodDefinition

scripts/docs/lib/source.ts:287–315  ·  view source on GitHub ↗

* Extracts the method definition from a method declaration.

(
    member: ts.MethodDeclaration,
  )

Source from the content-addressed store, hash-verified

285 * Extracts the method definition from a method declaration.
286 */
287 private extractMethodDefinition(
288 member: ts.MethodDeclaration,
289 ): MethodDefinition {
290 const functionComments = Comments.getTsDocCommentsForFunction(
291 member,
292 this.sourceFile,
293 );
294 const name = ts.isConstructorDeclaration(member)
295 ? "constructor"
296 : member.name.getText();
297 let signature =
298 name +
299 "(" +
300 member.parameters.map((param) => param.getText()).join(", ") +
301 ")";
302 signature = signature.replace(/</g, "&lt;").replace(/>/g, "&gt;");
303 return {
304 signature,
305 comment: functionComments.comment,
306 parameters: member.parameters.map((param) => {
307 return {
308 name: param.name.getText(),
309 type: param.type?.getText() || "unknown",
310 required: !param.questionToken,
311 comment: functionComments.params[param.name.getText()] || "",
312 };
313 }),
314 };
315 }
316
317 /**
318 * Get the constructor definition of a class.

Callers 1

visitMethod · 0.95

Calls 2

joinMethod · 0.65

Tested by

no test coverage detected