gitlab-ai-review 3.8.3 → 3.9.0

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.
@@ -195,6 +195,48 @@ export function extractChangedSymbols(diff, fileName) {
195
195
  };
196
196
  }
197
197
 
198
+ /**
199
+ * 检查一行代码中的符号使用是否可能有局部定义
200
+ * @param {string} line - 代码行
201
+ * @param {string} symbol - 符号名
202
+ * @returns {boolean} 是否可能有局部定义
203
+ */
204
+ function hasLocalDefinition(line, symbol) {
205
+ const trimmedLine = line.trim();
206
+
207
+ // 检查是否是局部变量定义
208
+ const varPatterns = [
209
+ new RegExp(`(const|let|var)\\s+${symbol}\\s*[=:]`), // const symbol = ...
210
+ new RegExp(`(const|let|var)\\s*{[^}]*\\b${symbol}\\b[^}]*}`), // const { symbol } = ...
211
+ new RegExp(`function\\s+\\w+\\([^)]*\\b${symbol}\\b[^)]*\\)`), // function foo(symbol)
212
+ new RegExp(`\\([^)]*\\b${symbol}\\b[^)]*\\)\\s*=>`), // (symbol) => ...
213
+ new RegExp(`\\b${symbol}\\s*:`), // symbol: in object or parameter
214
+ ];
215
+
216
+ return varPatterns.some(pattern => pattern.test(trimmedLine));
217
+ }
218
+
219
+ /**
220
+ * 检查一行代码中是否有导入语句
221
+ * @param {string} line - 代码行
222
+ * @param {string} symbol - 符号名
223
+ * @returns {boolean} 是否有导入
224
+ */
225
+ function hasImportStatement(line, symbol) {
226
+ const trimmedLine = line.trim();
227
+
228
+ // 检查各种导入模式
229
+ const importPatterns = [
230
+ new RegExp(`import\\s+${symbol}\\s+from`), // import symbol from ...
231
+ new RegExp(`import\\s*{[^}]*\\b${symbol}\\b[^}]*}\\s+from`), // import { symbol } from ...
232
+ new RegExp(`import\\s*\\*\\s+as\\s+${symbol}\\s+from`), // import * as symbol from ...
233
+ new RegExp(`require\\([^)]*\\)\\.${symbol}`), // require(...).symbol
234
+ new RegExp(`const\\s+${symbol}\\s*=\\s*require`), // const symbol = require(...)
235
+ ];
236
+
237
+ return importPatterns.some(pattern => pattern.test(trimmedLine));
238
+ }
239
+
198
240
  /**
199
241
  * 检查文件内部是否使用了指定的符号
200
242
  * @param {string} content - 文件内容
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitlab-ai-review",
3
- "version": "3.8.3",
3
+ "version": "3.9.0",
4
4
  "description": "GitLab AI Review SDK with Impact Analysis - 支持影响分析、删除符号检测、注释代码识别、文件内部冲突检查、智能文件过滤的智能代码审查工具",
5
5
  "main": "index.js",
6
6
  "type": "module",