@vizualmodel/vmblu-cli 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/commands/init/init-project.js +24 -29
- package/commands/profile/index.js +36 -3
- package/commands/profile/profile.bundle.js +23342 -0
- package/package.json +13 -2
- package/templates/0.8.2/{srcdoc.schema.json → profile.schema.json} +1 -1
- package/templates/0.8.2/seed.md +4 -4
- package/commands/profile/find-handlers.js +0 -351
- package/commands/profile/find-transmissions.js +0 -54
- package/commands/profile/profile.js +0 -272
- package/commands/profile/rollup.config.js +0 -22
package/package.json
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizualmodel/vmblu-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"vmblu": "bin/vmblu.js"
|
|
7
7
|
},
|
|
8
8
|
"files": [
|
|
9
9
|
"bin",
|
|
10
|
-
"commands",
|
|
10
|
+
"commands/init",
|
|
11
|
+
"commands/profile/index.js",
|
|
12
|
+
"commands/profile/profile.bundle.js",
|
|
11
13
|
"templates",
|
|
12
14
|
"README.md",
|
|
13
15
|
"LICENSE"
|
|
14
16
|
],
|
|
15
17
|
"engines": {
|
|
16
18
|
"node": ">=18"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"typescript": "^5.8.3",
|
|
22
|
+
"ts-morph": "^26.0.0"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"vmblu": "vmblu",
|
|
26
|
+
"local": "node ./bin/vmblu.js profile ../browser/vmblu.vmblu",
|
|
27
|
+
"build:profile": "rollup -c ./commands/profile/rollup.config.js"
|
|
17
28
|
}
|
|
18
29
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://vmblu.dev/schema/
|
|
3
|
+
"$id": "https://vmblu.dev/schema/profile/0.2/profile.schema.json",
|
|
4
4
|
"title": "vmblu Source Documentation (grouped by node)",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"required": ["version", "generatedAt", "entries"],
|
package/templates/0.8.2/seed.md
CHANGED
|
@@ -4,14 +4,14 @@ vmblu (Vizual Model Blueprint) is a graphical editor that maintains a visual, ru
|
|
|
4
4
|
vmblu models software as interconnected nodes that pass messages via pins.
|
|
5
5
|
|
|
6
6
|
The model has a well defined format described by a schema. An additional annex gives semantic background information about the schema.
|
|
7
|
-
The parameter profiles of messages and where messages are received and sent in the actual source code, are stored in a second file, the
|
|
8
|
-
The
|
|
7
|
+
The parameter profiles of messages and where messages are received and sent in the actual source code, are stored in a second file, the profile file.
|
|
8
|
+
The profile file is generated automatically by vmblu and is only to be consulted, not written, at the start of a project it does not yet exist
|
|
9
9
|
|
|
10
10
|
You are an expert **architecture + code copilot** for **vmblu** .
|
|
11
|
-
You can find the location of the model file, the model schema, the model annex, the
|
|
11
|
+
You can find the location of the model file, the model schema, the model annex, the profile file and the profile schema in the 'manifest.json' file of this project. Read these files.
|
|
12
12
|
|
|
13
13
|
The location of all other files in the project can be found via the model file.
|
|
14
14
|
|
|
15
15
|
Your job is to co-design the architecture and the software for the system.
|
|
16
16
|
For modifications of the model, always follow the schema.
|
|
17
|
-
If the
|
|
17
|
+
If the profile does not exist yet or does notcontain profile information it could be that the code for the node has not been written yet, this should not stop you from continuing.
|
|
@@ -1,351 +0,0 @@
|
|
|
1
|
-
// extractHandlersFromFile.js
|
|
2
|
-
|
|
3
|
-
import ts from 'typescript';
|
|
4
|
-
|
|
5
|
-
export let currentNode = null;
|
|
6
|
-
export let topLevelClass = null
|
|
7
|
-
let nodeMap = null
|
|
8
|
-
let filePath = null
|
|
9
|
-
|
|
10
|
-
export function findHandlers(sourceFile, _filePath, _nodeMap) {
|
|
11
|
-
|
|
12
|
-
// Reset any node context carried over from previous files.
|
|
13
|
-
currentNode = null;
|
|
14
|
-
|
|
15
|
-
// The fallback name is the top-level class
|
|
16
|
-
topLevelClass = sourceFile.getClasses()[0]?.getName?.() || null;
|
|
17
|
-
nodeMap = _nodeMap
|
|
18
|
-
filePath = _filePath
|
|
19
|
-
|
|
20
|
-
// Check all the functions in the sourcefile - typically generator functions
|
|
21
|
-
sourceFile.getFunctions().forEach(fn => {
|
|
22
|
-
|
|
23
|
-
// Capture node annotations on generator-style functions and harvest handlers returned from them.
|
|
24
|
-
const jsdoc = getFullJsDoc(fn);
|
|
25
|
-
updateNodeFromJsdoc(jsdoc);
|
|
26
|
-
|
|
27
|
-
const name = fn.getName();
|
|
28
|
-
|
|
29
|
-
if (isHandler(name)) {
|
|
30
|
-
|
|
31
|
-
const line = fn.getNameNode()?.getStartLineNumber() ?? fn.getStartLineNumber();
|
|
32
|
-
const docTags = getParamDocs(fn);
|
|
33
|
-
const params = fn.getParameters().flatMap(p => describeParam(p, docTags));
|
|
34
|
-
|
|
35
|
-
collect(name, params, line, jsdoc);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
collectHandlersFromFunctionReturns(fn);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// Check the variable declarations in the sourcefile
|
|
42
|
-
sourceFile.getVariableDeclarations().forEach(decl => {
|
|
43
|
-
|
|
44
|
-
// check the name
|
|
45
|
-
const name = decl.getName();
|
|
46
|
-
const init = decl.getInitializer();
|
|
47
|
-
const line = decl.getStartLineNumber();
|
|
48
|
-
const jsdoc = getFullJsDoc(decl);
|
|
49
|
-
updateNodeFromJsdoc(jsdoc);
|
|
50
|
-
|
|
51
|
-
// check if the name is a handler and initialised with a function
|
|
52
|
-
if (isHandler(name) && init && init.getKindName().includes('Function')) {
|
|
53
|
-
|
|
54
|
-
const docTags = getParamDocs(decl);
|
|
55
|
-
const params = init.getParameters().flatMap(p => describeParam(p, docTags));
|
|
56
|
-
|
|
57
|
-
collect(name, params, line, jsdoc);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (init && init.getKind() === ts.SyntaxKind.ObjectLiteralExpression) {
|
|
61
|
-
collectObjectLiteralHandlers(init);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// check all the classes in the file
|
|
66
|
-
sourceFile.getClasses().forEach(cls => {
|
|
67
|
-
|
|
68
|
-
// get the name of the node
|
|
69
|
-
const nodeName = cls.getName?.() || topLevelClass;
|
|
70
|
-
|
|
71
|
-
// check all the methods
|
|
72
|
-
cls.getMethods().forEach(method => {
|
|
73
|
-
|
|
74
|
-
// check the name
|
|
75
|
-
const name = method.getName();
|
|
76
|
-
if (!isHandler(name)) return;
|
|
77
|
-
|
|
78
|
-
// extract
|
|
79
|
-
const line = method.getNameNode()?.getStartLineNumber() ?? method.getStartLineNumber();
|
|
80
|
-
const jsdoc = getFullJsDoc(method);
|
|
81
|
-
const docTags = getParamDocs(method);
|
|
82
|
-
const params = method.getParameters().flatMap(p => describeParam(p, docTags));
|
|
83
|
-
|
|
84
|
-
// and collect
|
|
85
|
-
collect(name, params, line, jsdoc, nodeName);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// check all the statements
|
|
90
|
-
sourceFile.getStatements().forEach(stmt => {
|
|
91
|
-
|
|
92
|
-
// only binary expressions
|
|
93
|
-
if (!stmt.isKind(ts.SyntaxKind.ExpressionStatement)) return;
|
|
94
|
-
const expr = stmt.getExpression();
|
|
95
|
-
if (!expr.isKind(ts.SyntaxKind.BinaryExpression)) return;
|
|
96
|
-
|
|
97
|
-
// get the two parts of the statement
|
|
98
|
-
const left = expr.getLeft().getText();
|
|
99
|
-
const right = expr.getRight();
|
|
100
|
-
|
|
101
|
-
// check for protype
|
|
102
|
-
if (left.includes('.prototype.') && right.isKind(ts.SyntaxKind.FunctionExpression)) {
|
|
103
|
-
|
|
104
|
-
// get the name and check
|
|
105
|
-
const parts = left.split('.');
|
|
106
|
-
const name = parts[parts.length - 1];
|
|
107
|
-
if (!isHandler(name)) return;
|
|
108
|
-
|
|
109
|
-
// extract
|
|
110
|
-
const line = expr.getStartLineNumber();
|
|
111
|
-
const params = right.getParameters().flatMap(p => describeParam(p));
|
|
112
|
-
const jsdoc = getFullJsDoc(expr);
|
|
113
|
-
|
|
114
|
-
// and save in nodemap
|
|
115
|
-
collect(name, params, line, jsdoc);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (left.endsWith('.prototype') && right.isKind(ts.SyntaxKind.ObjectLiteralExpression)) {
|
|
119
|
-
collectObjectLiteralHandlers(right);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
function collectHandlersFromFunctionReturns(fn) {
|
|
126
|
-
|
|
127
|
-
// Look for factory-style returns that expose handlers via object literals.
|
|
128
|
-
fn.getDescendantsOfKind(ts.SyntaxKind.ReturnStatement).forEach(ret => {
|
|
129
|
-
const expr = ret.getExpression();
|
|
130
|
-
if (!expr || expr.getKind() !== ts.SyntaxKind.ObjectLiteralExpression) return;
|
|
131
|
-
|
|
132
|
-
collectObjectLiteralHandlers(expr);
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function collectObjectLiteralHandlers(objectLiteral) {
|
|
137
|
-
|
|
138
|
-
// Reuse the same extraction logic for any handler stored on an object literal shape.
|
|
139
|
-
objectLiteral.getProperties().forEach(prop => {
|
|
140
|
-
|
|
141
|
-
const propName = prop.getName?.();
|
|
142
|
-
if (!isHandler(propName)) return;
|
|
143
|
-
|
|
144
|
-
let params = [];
|
|
145
|
-
if (prop.getKind() === ts.SyntaxKind.MethodDeclaration) {
|
|
146
|
-
const docTags = getParamDocs(prop);
|
|
147
|
-
params = prop.getParameters().flatMap(p => describeParam(p, docTags));
|
|
148
|
-
} else if (prop.getKind() === ts.SyntaxKind.PropertyAssignment) {
|
|
149
|
-
const fn = prop.getInitializerIfKind(ts.SyntaxKind.FunctionExpression) || prop.getInitializerIfKind(ts.SyntaxKind.ArrowFunction);
|
|
150
|
-
if (fn) {
|
|
151
|
-
const docTags = getParamDocs(fn);
|
|
152
|
-
params = fn.getParameters().flatMap(p => describeParam(p, docTags));
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const jsdoc = getFullJsDoc(prop);
|
|
157
|
-
const line = prop.getStartLineNumber();
|
|
158
|
-
|
|
159
|
-
collect(propName, params, line, jsdoc);
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function updateNodeFromJsdoc(jsdoc = {}) {
|
|
164
|
-
|
|
165
|
-
const nodeTag = jsdoc.tags?.find(t => t.tagName === 'node')?.comment;
|
|
166
|
-
if (nodeTag) currentNode = nodeTag.trim();
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function collect(rawName, params, line, jsdoc = {}) {
|
|
170
|
-
|
|
171
|
-
//if (!isHandler(rawName)) return;
|
|
172
|
-
const cleanHandler = rawName.replace(/^['"]|['"]$/g, '');
|
|
173
|
-
|
|
174
|
-
let pin = null;
|
|
175
|
-
let node = null;
|
|
176
|
-
|
|
177
|
-
const pinTag = jsdoc.tags?.find(t => t.tagName === 'pin')?.comment;
|
|
178
|
-
const nodeTag = jsdoc.tags?.find(t => t.tagName === 'node')?.comment;
|
|
179
|
-
const mcpTag = jsdoc.tags?.find(t => t.tagName === 'mcp')?.comment ?? null;
|
|
180
|
-
|
|
181
|
-
// if there is a node tag, change the name of the current node
|
|
182
|
-
if (nodeTag) currentNode = nodeTag.trim();
|
|
183
|
-
|
|
184
|
-
// check the pin tag to get a pin name and node name
|
|
185
|
-
if (pinTag) {
|
|
186
|
-
|
|
187
|
-
if (pinTag.includes('@')) {
|
|
188
|
-
const [p, n] = pinTag.split('@').map(s => s.trim());
|
|
189
|
-
pin = p;
|
|
190
|
-
node = n;
|
|
191
|
-
}
|
|
192
|
-
else pin = pinTag.trim();
|
|
193
|
-
|
|
194
|
-
// Use the current context when the pin tag does not specify a node.
|
|
195
|
-
if (!node) node = currentNode || topLevelClass || null;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// check the pin tag to get a pin name and node name
|
|
199
|
-
// if (pinTag && pinTag.includes('@')) {
|
|
200
|
-
// const [p, n] = pinTag.split('@').map(s => s.trim());
|
|
201
|
-
// pin = p;
|
|
202
|
-
// node = n;
|
|
203
|
-
// }
|
|
204
|
-
else {
|
|
205
|
-
|
|
206
|
-
// no explicit tag - try these...
|
|
207
|
-
node = currentNode || topLevelClass || null;
|
|
208
|
-
|
|
209
|
-
// deduct the pin name from the handler name
|
|
210
|
-
if (cleanHandler.startsWith('on')) {
|
|
211
|
-
pin = cleanHandler.slice(2).replace(/([A-Z])/g, ' $1').trim().toLowerCase();
|
|
212
|
-
} else if (cleanHandler.startsWith('->')) {
|
|
213
|
-
pin = cleanHandler.slice(2).trim();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// if there is no node we just don't save the data
|
|
218
|
-
if (!node) return
|
|
219
|
-
|
|
220
|
-
// check if we have an entry for the node
|
|
221
|
-
if (!nodeMap.has(node)) nodeMap.set(node, { handles: [], transmits: [] });
|
|
222
|
-
|
|
223
|
-
// The handler data to save
|
|
224
|
-
const handlerData = {
|
|
225
|
-
pin,
|
|
226
|
-
handler: cleanHandler,
|
|
227
|
-
file: filePath,
|
|
228
|
-
line,
|
|
229
|
-
summary: jsdoc.summary || '',
|
|
230
|
-
returns: jsdoc.returns || '',
|
|
231
|
-
examples: jsdoc.examples || [],
|
|
232
|
-
params
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
// extract the data from an mcp tag if present
|
|
236
|
-
if (mcpTag !== null) {
|
|
237
|
-
handlerData.mcp = true;
|
|
238
|
-
if (mcpTag.includes('name:') || mcpTag.includes('description:')) {
|
|
239
|
-
const nameMatch = /name:\s*\"?([^\"]+)\"?/.exec(mcpTag);
|
|
240
|
-
const descMatch = /description:\s*\"?([^\"]+)\"?/.exec(mcpTag);
|
|
241
|
-
if (nameMatch) handlerData.mcpName = nameMatch[1];
|
|
242
|
-
if (descMatch) handlerData.mcpDescription = descMatch[1];
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// and put it in the nodemap
|
|
247
|
-
nodeMap.get(node).handles.push(handlerData);
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
// determines if a name is the name for a handler
|
|
251
|
-
function isHandler(name) {
|
|
252
|
-
// must be a string
|
|
253
|
-
if (typeof name !== 'string') return false;
|
|
254
|
-
|
|
255
|
-
// get rid of " and '
|
|
256
|
-
const clean = name.replace(/^['"]|['"]$/g, '');
|
|
257
|
-
|
|
258
|
-
// check that it starts with the right symbols...
|
|
259
|
-
return clean.startsWith('on') || clean.startsWith('->');
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// Get the parameter description from the function or method
|
|
263
|
-
function getParamDocs(fnOrMethod) {
|
|
264
|
-
|
|
265
|
-
// extract
|
|
266
|
-
const docs = fnOrMethod.getJsDocs?.() ?? [];
|
|
267
|
-
const tags = docs.flatMap(d => d.getTags());
|
|
268
|
-
const paramDocs = {};
|
|
269
|
-
|
|
270
|
-
// check the tags
|
|
271
|
-
for (const tag of tags) {
|
|
272
|
-
if (tag.getTagName() === 'param') {
|
|
273
|
-
const name = tag.getNameNode()?.getText?.() || tag.getName();
|
|
274
|
-
const desc = tag.getComment() ?? '';
|
|
275
|
-
const type = tag.getTypeNode?.()?.getText?.() || tag.getTypeExpression()?.getTypeNode()?.getText();
|
|
276
|
-
paramDocs[name] = { description: desc, type };
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
return paramDocs;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// Get the jsdoc
|
|
283
|
-
function getFullJsDoc(node) {
|
|
284
|
-
|
|
285
|
-
const docs = node.getJsDocs?.() ?? [];
|
|
286
|
-
const summary = docs.map(d => d.getComment()).filter(Boolean).join('\n');
|
|
287
|
-
const tags = docs.flatMap(d => d.getTags()).map(t => ({
|
|
288
|
-
tagName: t.getTagName(),
|
|
289
|
-
comment: t.getComment() || ''
|
|
290
|
-
}));
|
|
291
|
-
|
|
292
|
-
const returns = tags.find(t => t.tagName === 'returns')?.comment || '';
|
|
293
|
-
const examples = tags.filter(t => t.tagName === 'example').map(t => t.comment);
|
|
294
|
-
|
|
295
|
-
return { summary, returns, examples, tags };
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
// make a parameter description
|
|
299
|
-
function describeParam(p, docTags = {}) {
|
|
300
|
-
|
|
301
|
-
const nameNode = p.getNameNode();
|
|
302
|
-
|
|
303
|
-
// const func = p.getParent();
|
|
304
|
-
// const funcName = func.getName?.() || '<anonymous>';
|
|
305
|
-
// console.log(funcName)
|
|
306
|
-
|
|
307
|
-
if (nameNode.getKindName() === 'ObjectBindingPattern') {
|
|
308
|
-
|
|
309
|
-
const objType = p.getType();
|
|
310
|
-
const properties = objType.getProperties();
|
|
311
|
-
const isTSFallback = objType.getText() === 'any' || objType.getText() === 'string' || properties.length === 0;
|
|
312
|
-
|
|
313
|
-
return nameNode.getElements().map(el => {
|
|
314
|
-
|
|
315
|
-
const subName = el.getName();
|
|
316
|
-
const doc = docTags[subName] ?? {};
|
|
317
|
-
let tsType = null;
|
|
318
|
-
|
|
319
|
-
if (!isTSFallback) {
|
|
320
|
-
const symbol = objType.getProperty(subName);
|
|
321
|
-
if (symbol) {
|
|
322
|
-
const resolvedType = symbol.getTypeAtLocation(el);
|
|
323
|
-
const text = resolvedType.getText();
|
|
324
|
-
if (text && text !== 'any') {
|
|
325
|
-
tsType = text;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
const type = tsType || doc.type || 'string';
|
|
331
|
-
const description = doc.description || '';
|
|
332
|
-
return { name: subName, type, description };
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
const name = p.getName();
|
|
337
|
-
const doc = docTags[name] ?? {};
|
|
338
|
-
const tsType = p.getType().getText();
|
|
339
|
-
|
|
340
|
-
// const isTSFallback = tsType === 'any' || tsType === 'string';
|
|
341
|
-
// if (isTSFallback && !doc.type) {
|
|
342
|
-
// console.warn(`⚠️ No type info for param "${name}" in function "${funcName}"`);
|
|
343
|
-
// }
|
|
344
|
-
|
|
345
|
-
return {
|
|
346
|
-
name,
|
|
347
|
-
type: doc.type || tsType || 'string',
|
|
348
|
-
description: doc.description || '',
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { SyntaxKind } from 'ts-morph';
|
|
2
|
-
import {currentNode, topLevelClass} from './find-handlers.js'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Finds tx.send or this.tx.send calls and maps them to their node context.
|
|
6
|
-
*
|
|
7
|
-
* @param {import('ts-morph').SourceFile} sourceFile - The source file being analyzed
|
|
8
|
-
* @param {string} filePath - The (relative) path of the source file
|
|
9
|
-
* @param {Map} nodeMap - Map from node name to metadata
|
|
10
|
-
* @param {string|null} currentNode - Explicitly set node name (takes priority)
|
|
11
|
-
*/
|
|
12
|
-
export function findTransmissions(sourceFile, filePath, nodeMap) {
|
|
13
|
-
|
|
14
|
-
// Search all call expressions
|
|
15
|
-
sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression).forEach(node => {
|
|
16
|
-
const expr = node.getExpression();
|
|
17
|
-
|
|
18
|
-
// check
|
|
19
|
-
if (expr.getKind() !== SyntaxKind.PropertyAccessExpression) return
|
|
20
|
-
|
|
21
|
-
// Match tx.send or this.tx.send - regular expression could be : expr.getText().match(/\w+\.tx\.send/)
|
|
22
|
-
const text = expr.getText()
|
|
23
|
-
|
|
24
|
-
// check
|
|
25
|
-
if (! (text === 'tx.send' || text === 'this.tx.send' || text.endsWith('.tx.send'))) return;
|
|
26
|
-
|
|
27
|
-
const args = node.getArguments();
|
|
28
|
-
if (args.length === 0 || !args[0].isKind(SyntaxKind.StringLiteral)) return;
|
|
29
|
-
|
|
30
|
-
const pin = args[0].getLiteralText();
|
|
31
|
-
|
|
32
|
-
// Try to infer the class context of the tx.send call
|
|
33
|
-
const method = node.getFirstAncestorByKind(SyntaxKind.MethodDeclaration);
|
|
34
|
-
const classDecl = method?.getFirstAncestorByKind(SyntaxKind.ClassDeclaration) ?? node.getFirstAncestorByKind(SyntaxKind.ClassDeclaration);
|
|
35
|
-
const className = classDecl?.getName?.();
|
|
36
|
-
|
|
37
|
-
// Priority order: currentNode > className > topLevelClass > 'global'
|
|
38
|
-
const nodeName = currentNode || className || topLevelClass || null;
|
|
39
|
-
|
|
40
|
-
// check
|
|
41
|
-
if (!nodeName) return
|
|
42
|
-
|
|
43
|
-
// check if there is an entry for the node or create it
|
|
44
|
-
nodeMap.has(nodeName) || nodeMap.set(nodeName, { handles: [], transmits: [] });
|
|
45
|
-
|
|
46
|
-
// add the entry to the transmits array
|
|
47
|
-
nodeMap.get(nodeName).transmits.push({
|
|
48
|
-
pin,
|
|
49
|
-
file: filePath,
|
|
50
|
-
line: node.getStartLineNumber()
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|