This is an automated email from the ASF dual-hosted git repository.

thurka pushed a commit to branch vsnetbeans_2299
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/vsnetbeans_2299 by this push:
     new 803afc10cc2 Micronaut: Clear symbol cache on ClasspathInfo changes.
803afc10cc2 is described below

commit 803afc10cc2bbbeaf7032fed399ad41f714a16ea
Author: Dusan Balek <[email protected]>
AuthorDate: Mon Jul 8 14:00:07 2024 +0200

    Micronaut: Clear symbol cache on ClasspathInfo changes.
    
    (cherry picked from commit 83ec87bf3a45a9d9712ae7b5e1df1d948bd7f726)
---
 .../netbeans/modules/micronaut/symbol/MicronautSymbolFinder.java   | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git 
a/enterprise/micronaut/src/org/netbeans/modules/micronaut/symbol/MicronautSymbolFinder.java
 
b/enterprise/micronaut/src/org/netbeans/modules/micronaut/symbol/MicronautSymbolFinder.java
index a7390b0b941..701dd22d1fc 100644
--- 
a/enterprise/micronaut/src/org/netbeans/modules/micronaut/symbol/MicronautSymbolFinder.java
+++ 
b/enterprise/micronaut/src/org/netbeans/modules/micronaut/symbol/MicronautSymbolFinder.java
@@ -59,6 +59,7 @@ import javax.lang.model.type.TypeVariable;
 import javax.lang.model.util.ElementFilter;
 import javax.lang.model.util.Elements;
 import javax.lang.model.util.Types;
+import javax.swing.event.ChangeListener;
 import javax.tools.JavaFileObject;
 import org.netbeans.api.editor.mimelookup.MimeRegistration;
 import org.netbeans.api.java.classpath.ClassPath;
@@ -111,6 +112,11 @@ public final class MicronautSymbolFinder extends 
EmbeddingIndexer implements Pro
 
     private final Map<FileObject, Boolean> map = new WeakHashMap<>();
     private final Map<ClasspathInfo, List<ClassSymbolLocation>> cache = new 
WeakHashMap<>();
+    private final ChangeListener cacheCleaner = (evt) -> {
+        if (cache.keySet().contains(evt.getSource())) {
+            cache.clear();
+        }
+    };
 
     @Override
     protected void index(Indexable indexable, Parser.Result parserResult, 
Context context) {
@@ -510,6 +516,7 @@ public final class MicronautSymbolFinder extends 
EmbeddingIndexer implements Pro
     public static List<ClassSymbolLocation> 
getSymbolsFromDependencies(ClasspathInfo info, String textForQuery) {
         List<ClassSymbolLocation> cached = INSTANCE.cache.get(info);
         if (cached == null) {
+            info.addChangeListener(INSTANCE.cacheCleaner);
             List<ClassSymbolLocation> ret = new ArrayList<>();
             ClassIndex ci = info.getClassIndex();
             Set<ElementHandle<TypeElement>> beanHandles = new HashSet<>();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to