@@ -6,7 +6,7 @@ import { logger } from '../utils'
66/**
77 * 文件内容缓存
88 */
9- const fileContentCache = new Map < string , { content : string ; timestamp : number } > ( )
9+ const fileContentCache = new Map < string , { content : string , timestamp : number } > ( )
1010const CACHE_TTL = 60000 // 1分钟缓存
1111
1212/**
@@ -55,12 +55,12 @@ export class GolangFinder implements LanguageFinder {
5555 // 并行处理候选文件,但限制并发数
5656 // 注意:候选文件已经通过预过滤,包含方法名和 func,所以 searchInFile 中不需要再次检查
5757 const chunks = this . chunkArray ( candidateFiles , this . MAX_CONCURRENT_FILES )
58-
58+
5959 for ( const chunk of chunks ) {
6060 const chunkResults = await Promise . all (
6161 chunk . map ( file => this . searchInFile ( file , patterns ) ) ,
6262 )
63-
63+
6464 for ( const result of chunkResults ) {
6565 locations . push ( ...result )
6666 }
@@ -106,7 +106,7 @@ export class GolangFinder implements LanguageFinder {
106106 // 使用快速文本搜索预过滤文件
107107 // 构建搜索模式:必须包含方法名,可选包含类型名
108108 const searchPattern = this . buildSearchPattern ( methodName , inputBaseType , outputBaseType )
109-
109+
110110 // 并行检查文件是否包含关键词
111111 const chunks = this . chunkArray ( allGoFiles , this . MAX_CONCURRENT_FILES )
112112 const candidateFiles : Uri [ ] = [ ]
@@ -150,7 +150,7 @@ export class GolangFinder implements LanguageFinder {
150150 methodName : string ,
151151 inputBaseType ?: string ,
152152 outputBaseType ?: string ,
153- ) : { required : string [ ] ; optional : string [ ] } {
153+ ) : { required : string [ ] , optional : string [ ] } {
154154 const required : string [ ] = [ methodName , 'func' ]
155155 const optional : string [ ] = [ ]
156156
@@ -170,7 +170,7 @@ export class GolangFinder implements LanguageFinder {
170170 */
171171 private matchesSearchPattern (
172172 content : string ,
173- pattern : { required : string [ ] ; optional : string [ ] } ,
173+ pattern : { required : string [ ] , optional : string [ ] } ,
174174 ) : boolean {
175175 // 检查必需关键词
176176 for ( const keyword of pattern . required ) {
@@ -192,7 +192,6 @@ export class GolangFinder implements LanguageFinder {
192192 const locations : Location [ ] = [ ]
193193
194194 try {
195-
196195 // 打开文档进行精确匹配
197196 const document = await workspace . openTextDocument ( file )
198197 const text = document . getText ( )
@@ -237,9 +236,9 @@ export class GolangFinder implements LanguageFinder {
237236
238237 const document = await workspace . openTextDocument ( file )
239238 const content = document . getText ( )
240-
239+
241240 fileContentCache . set ( filePath , { content, timestamp : now } )
242-
241+
243242 // 限制缓存大小,避免内存泄漏
244243 if ( fileContentCache . size > 1000 ) {
245244 const firstKey = fileContentCache . keys ( ) . next ( ) . value
0 commit comments