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

Method getDefaultValueForNode

scripts/docs/lib/comments.ts:33–61  ·  view source on GitHub ↗
(
    node: ts.Node,
    sourceFile: ts.SourceFile,
  )

Source from the content-addressed store, hash-verified

31 }
32
33 static getDefaultValueForNode(
34 node: ts.Node,
35 sourceFile: ts.SourceFile,
36 ): string | undefined {
37 const fullText = sourceFile.getFullText();
38 const commentRanges = ts.getLeadingCommentRanges(
39 fullText,
40 node.getFullStart(),
41 );
42
43 if (!commentRanges) return "";
44 let defaultValue: string | undefined = undefined;
45
46 for (const comment of commentRanges) {
47 let commentText = fullText.substring(comment.pos, comment.end);
48 commentText = Comments.removeCommentSyntax(commentText);
49
50 for (const line of commentText.split("\n")) {
51 if (line.includes("@default")) {
52 defaultValue = line.split("@default")[1].trim();
53 break;
54 }
55 }
56
57 if (defaultValue !== undefined) break;
58 }
59
60 return defaultValue;
61 }
62
63 static removeCommentSyntax(commentText: string): string {
64 return commentText

Callers 1

visitMethod · 0.80

Calls 1

removeCommentSyntaxMethod · 0.80

Tested by

no test coverage detected