MCPcopy
hub / github.com/jquery/esprima / insertInnerComments

Method insertInnerComments

src/comment-handler.ts:36–53  ·  view source on GitHub ↗
(node, metadata)

Source from the content-addressed store, hash-verified

34 }
35
36 insertInnerComments(node, metadata) {
37 // innnerComments for properties empty block
38 // `function a() {/** comments **\/}`
39 if (node.type === Syntax.BlockStatement && node.body.length === 0) {
40 const innerComments: Comment[] = [];
41 for (let i = this.leading.length - 1; i >= 0; --i) {
42 const entry = this.leading[i];
43 if (metadata.end.offset >= entry.start) {
44 innerComments.unshift(entry.comment);
45 this.leading.splice(i, 1);
46 this.trailing.splice(i, 1);
47 }
48 }
49 if (innerComments.length) {
50 node.innerComments = innerComments;
51 }
52 }
53 }
54
55 findTrailingComments(metadata) {
56 let trailingComments: Comment[] = [];

Callers 1

visitNodeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected