4242import org .springframework .ide .vscode .boot .index .cache .IndexCacheKey ;
4343import org .springframework .ide .vscode .boot .java .beans .BeanUtils ;
4444import org .springframework .ide .vscode .boot .java .beans .BeansIndexer ;
45- import org .springframework .ide .vscode .boot .java .beans .CachedBean ;
45+ import org .springframework .ide .vscode .boot .java .beans .CachedIndexElement ;
4646import org .springframework .ide .vscode .commons .java .IClasspathUtil ;
4747import org .springframework .ide .vscode .commons .java .IJavaProject ;
4848import org .springframework .ide .vscode .commons .protocol .java .Classpath ;
@@ -67,7 +67,7 @@ public class SpringFactoriesIndexer implements SpringIndexer {
6767 private static final String GENERATION = "GEN-14" ;
6868
6969 private static final String SYMBOL_KEY = "symbols" ;
70- private static final String BEANS_KEY = "beans " ;
70+ private static final String INDEX_KEY = "index " ;
7171
7272 private static final String FILE_PATTERN = "**/META-INF/spring/*.factories" ;
7373
@@ -190,37 +190,37 @@ public void initializeProject(IJavaProject project, boolean clean) throws Except
190190 log .info ("scan factories files for symbols for project: " + project .getElementName () + " - no. of files: " + files .size ());
191191
192192 IndexCacheKey symbolsCacheKey = getCacheKey (project , SYMBOL_KEY );
193- IndexCacheKey beansCacheKey = getCacheKey (project , BEANS_KEY );
193+ IndexCacheKey indexCacheKey = getCacheKey (project , INDEX_KEY );
194194
195195 CachedSymbol [] symbols = this .cache .retrieveSymbols (symbolsCacheKey , filesStr , CachedSymbol .class );
196- CachedBean [] beans = this .cache .retrieveSymbols (beansCacheKey , filesStr , CachedBean .class );
196+ CachedIndexElement [] indexElements = this .cache .retrieveSymbols (indexCacheKey , filesStr , CachedIndexElement .class );
197197
198- if (symbols == null || beans == null || clean ) {
198+ if (symbols == null || indexElements == null || clean ) {
199199 List <CachedSymbol > generatedSymbols = new ArrayList <CachedSymbol >();
200- List <CachedBean > generatedBeans = new ArrayList <CachedBean >();
200+ List <CachedIndexElement > generatedIndexElements = new ArrayList <CachedIndexElement >();
201201
202202 for (Path file : files ) {
203203 ScanResult scanResult = scanFile (file );
204204
205205 if (scanResult != null ) {
206206 generatedSymbols .addAll (scanResult .symbols );
207- generatedBeans .addAll (scanResult .beans );
207+ generatedIndexElements .addAll (scanResult .beans );
208208 }
209209 }
210210
211211 this .cache .store (symbolsCacheKey , filesStr , generatedSymbols , null , CachedSymbol .class );
212- this .cache .store (beansCacheKey , filesStr , generatedBeans , null , CachedBean .class );
212+ this .cache .store (indexCacheKey , filesStr , generatedIndexElements , null , CachedIndexElement .class );
213213
214214 symbols = (CachedSymbol []) generatedSymbols .toArray (new CachedSymbol [generatedSymbols .size ()]);
215- beans = (CachedBean []) generatedBeans .toArray (new CachedBean [ generatedBeans .size ()]);
215+ indexElements = (CachedIndexElement []) generatedIndexElements .toArray (new CachedIndexElement [ generatedIndexElements .size ()]);
216216 }
217217 else {
218218 log .info ("scan factories files used cached data: " + project .getElementName () + " - no. of cached symbols retrieved: " + symbols .length );
219219 }
220220
221- if (symbols != null && beans != null ) {
221+ if (symbols != null && indexElements != null ) {
222222 WorkspaceSymbol [] enhancedSymbols = Arrays .stream (symbols ).map (cachedSymbol -> cachedSymbol .getEnhancedSymbol ()).toArray (WorkspaceSymbol []::new );
223- Map <String , List <SpringIndexElement >> beansByDoc = Arrays .stream (beans ).filter (cachedBean -> cachedBean .getBean () != null ).collect (Collectors .groupingBy (CachedBean ::getDocURI , Collectors .mapping (CachedBean :: getBean , Collectors .toList ())));
223+ Map <String , List <SpringIndexElement >> beansByDoc = Arrays .stream (indexElements ).filter (cachedBean -> cachedBean .getIndexElement () != null ).collect (Collectors .groupingBy (CachedIndexElement ::getDocURI , Collectors .mapping (CachedIndexElement :: getIndexElement , Collectors .toList ())));
224224 symbolHandler .addSymbols (project , enhancedSymbols , beansByDoc , null );
225225 }
226226
@@ -233,10 +233,10 @@ public void initializeProject(IJavaProject project, boolean clean) throws Except
233233 @ Override
234234 public void removeProject (IJavaProject project ) throws Exception {
235235 IndexCacheKey symbolsCacheKey = getCacheKey (project , SYMBOL_KEY );
236- IndexCacheKey beansCacheKey = getCacheKey (project , BEANS_KEY );
236+ IndexCacheKey indexCacheKey = getCacheKey (project , INDEX_KEY );
237237
238238 this .cache .remove (symbolsCacheKey );
239- this .cache .remove (beansCacheKey );
239+ this .cache .remove (indexCacheKey );
240240 }
241241
242242 @ Override
@@ -252,30 +252,30 @@ public void updateFile(IJavaProject project, DocumentDescriptor updatedDoc, Stri
252252 ScanResult scanResult = scanFile (path );
253253
254254 List <CachedSymbol > generatedSymbols = Collections .emptyList ();
255- List <CachedBean > generatedBeans = Collections .emptyList ();
255+ List <CachedIndexElement > generatedIndexElements = Collections .emptyList ();
256256
257257 if (scanResult != null ) {
258258 generatedSymbols = scanResult .symbols ;
259- generatedBeans = scanResult .beans ;
259+ generatedIndexElements = scanResult .beans ;
260260 }
261261
262262 IndexCacheKey symbolsCacheKey = getCacheKey (project , SYMBOL_KEY );
263- IndexCacheKey beansCacheKey = getCacheKey (project , BEANS_KEY );
263+ IndexCacheKey indexCacheKey = getCacheKey (project , INDEX_KEY );
264264
265265 String file = new File (new URI (docURI )).getAbsolutePath ();
266266 this .cache .update (symbolsCacheKey , file , updatedDoc .getLastModified (), generatedSymbols , null , CachedSymbol .class );
267- this .cache .update (beansCacheKey , file , updatedDoc .getLastModified (), generatedBeans , null , CachedBean .class );
267+ this .cache .update (indexCacheKey , file , updatedDoc .getLastModified (), generatedIndexElements , null , CachedIndexElement .class );
268268
269269 WorkspaceSymbol [] symbols = generatedSymbols .stream ().map (cachedSymbol -> cachedSymbol .getEnhancedSymbol ()).toArray (WorkspaceSymbol []::new );
270- List <SpringIndexElement > beans = generatedBeans .stream ().filter (cachedBean -> cachedBean .getBean () != null ).map (cachedBean -> cachedBean .getBean ()).toList ();
270+ List <SpringIndexElement > beans = generatedIndexElements .stream ().filter (cachedBean -> cachedBean .getIndexElement () != null ).map (cachedBean -> cachedBean .getIndexElement ()).toList ();
271271 symbolHandler .addSymbols (project , docURI , symbols , beans , null );
272272 }
273273 }
274274
275275 @ Override
276276 public void updateFiles (IJavaProject project , DocumentDescriptor [] updatedDocs ) throws Exception {
277277 IndexCacheKey symbolsCacheKey = getCacheKey (project , SYMBOL_KEY );
278- IndexCacheKey beansCacheKey = getCacheKey (project , BEANS_KEY );
278+ IndexCacheKey indexCacheKey = getCacheKey (project , INDEX_KEY );
279279
280280 List <Path > outputFolders = IClasspathUtil .getOutputFolders (project .getClasspath ()).map (f -> f .toPath ()).collect (Collectors .toList ());
281281
@@ -292,7 +292,7 @@ public void updateFiles(IJavaProject project, DocumentDescriptor[] updatedDocs)
292292 String file = new File (new URI (d .getDocURI ())).getAbsolutePath ();
293293
294294 cache .removeFile (symbolsCacheKey , file , CachedSymbol .class );
295- cache .removeFile (beansCacheKey , file , CachedBean .class );
295+ cache .removeFile (indexCacheKey , file , CachedIndexElement .class );
296296 }
297297 }
298298 }
@@ -309,10 +309,10 @@ public void removeFiles(IJavaProject project, String[] docURIs) throws Exception
309309 }).toArray (String []::new );
310310
311311 IndexCacheKey symbolsCacheKey = getCacheKey (project , SYMBOL_KEY );
312- IndexCacheKey beansCacheKey = getCacheKey (project , SYMBOL_KEY );
312+ IndexCacheKey indexCacheKey = getCacheKey (project , SYMBOL_KEY );
313313
314314 cache .removeFiles (symbolsCacheKey , files , CachedSymbol .class );
315- cache .removeFiles (beansCacheKey , files , CachedBean .class );
315+ cache .removeFiles (indexCacheKey , files , CachedIndexElement .class );
316316 }
317317
318318 private ScanResult scanFile (Path file ) {
@@ -321,7 +321,7 @@ private ScanResult scanFile(Path file) {
321321 String content = Files .readString (file );
322322
323323 ImmutableList .Builder <CachedSymbol > symbols = ImmutableList .builder ();
324- ImmutableList .Builder <CachedBean > beans = ImmutableList .builder ();
324+ ImmutableList .Builder <CachedIndexElement > beans = ImmutableList .builder ();
325325
326326 long lastModified = Files .getLastModifiedTime (file ).toMillis ();
327327 String docUri = file .toUri ().toASCIIString ();
@@ -333,7 +333,7 @@ private ScanResult scanFile(Path file) {
333333 }
334334
335335 for (Bean bean : result .beans ) {
336- beans .add (new CachedBean (docUri , bean ));
336+ beans .add (new CachedIndexElement (docUri , bean ));
337337 }
338338
339339 return new ScanResult (symbols .build (), beans .build ());
@@ -383,7 +383,7 @@ private IndexCacheKey getCacheKey(IJavaProject project, String elementType) {
383383 return new IndexCacheKey (project .getElementName (), "factories" , elementType , DigestUtils .md5Hex (GENERATION + "-" + filesIndentifier ).toUpperCase ());
384384 }
385385
386- private static record ScanResult (List <CachedSymbol > symbols , List <CachedBean > beans ) {}
386+ private static record ScanResult (List <CachedSymbol > symbols , List <CachedIndexElement > beans ) {}
387387 private static record ComputeResult (List <WorkspaceSymbol > symbols , List <Bean > beans ) {}
388388
389389}
0 commit comments