deveco_hmigbot 0.1.1 → 0.1.2
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/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -181,11 +181,16 @@ let builderStateByValue = 0;
|
|
|
181
181
|
for (const [f, c] of codes) {
|
|
182
182
|
const state = new Set([...c.matchAll(STATE_DECOR)].map(m => m[1]));
|
|
183
183
|
if (!state.size) continue;
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
// 同名撞车防护:裸调用 name( 只认本文件声明或 import 进来的全局 builder;this.name( 只认本文件的 @Builder 方法
|
|
185
|
+
const localGlobals = new Set([...c.matchAll(BUILDER_FN_G)].filter(m => m[2].trim()).map(m => m[1]));
|
|
186
|
+
const imported = new Set([...c.matchAll(/import\s*\{([^}]*)\}\s*from/g)].flatMap(m => m[1].split(',').map(x => x.trim().split(/\s+as\s+/).pop()).filter(Boolean)));
|
|
187
|
+
const methods = new Set([...c.matchAll(BUILDER_FN_M)].filter(m => m[2].trim() && m[1] !== 'function').map(m => m[1]));
|
|
188
|
+
const names = new Set([...globalBuilders].filter(n => localGlobals.has(n) || imported.has(n)).concat([...methods]));
|
|
186
189
|
for (const name of names) {
|
|
187
190
|
for (const m of c.matchAll(new RegExp(`(?<![\\w$.])(?:this\\.)?${name}\\s*\\(`, 'g'))) {
|
|
188
191
|
if (/@Builder\s*(?:export\s+)?(?:function\s+)?(?:(?:private|public|protected|static)\s+)*$/.test(c.slice(Math.max(0, m.index - 60), m.index))) continue;
|
|
192
|
+
const viaThis = m[0].startsWith('this.');
|
|
193
|
+
if (viaThis ? !methods.has(name) : !(localGlobals.has(name) || imported.has(name))) continue;
|
|
189
194
|
const a = callArgs(c, m.index + m[0].length - 1); if (!a) continue;
|
|
190
195
|
const bad = a.map(x => x.trim()).filter(t => t && !t.startsWith('{') && !/=>/.test(t) && !/^function\b/.test(t) && [...t.matchAll(/\bthis\.([\w$]+)/g)].some(mm => state.has(mm[1])));
|
|
191
196
|
if (!bad.length) continue;
|