[hg] main-silver: Fixed LogicalView when 2 projects use the same...

  • From: Tomas Zezula < >
  • To:
  • Subject: [hg] main-silver: Fixed LogicalView when 2 projects use the same...
  • Date: Fri, 26 Apr 2013 11:10:45 -0700

changeset 1adb1ee4f0b4 in main-silver (jdk_profiles)
details: http://hg.netbeans.org/main-silver/rev/1adb1ee4f0b4
description:
        Fixed LogicalView when 2 projects use the same file.

diffstat:

 code.analysis/src/org/netbeans/modules/analysis/RunAnalysis.java |   2 +-
 code.analysis/src/org/netbeans/modules/analysis/ui/Nodes.java    |  28 
+++++++++-
 2 files changed, 27 insertions(+), 3 deletions(-)

diffs (79 lines):

diff --git a/code.analysis/src/org/netbeans/modules/analysis/RunAnalysis.java 
b/code.analysis/src/org/netbeans/modules/analysis/RunAnalysis.java
--- a/code.analysis/src/org/netbeans/modules/analysis/RunAnalysis.java
+++ b/code.analysis/src/org/netbeans/modules/analysis/RunAnalysis.java
@@ -149,7 +149,7 @@
                         progress.switchToDeterminate(MAX_WORK);
 
                         final Map<AnalyzerFactory, List<ErrorDescription>> 
result = new HashMap<AnalyzerFactory, List<ErrorDescription>>();
-                        final Map<ErrorDescription, Project> 
errorsToProjects = new HashMap<>();
+                        final Map<ErrorDescription, Project> 
errorsToProjects = new IdentityHashMap<>();
                         Collection<MissingPlugin> missingPlugins = new 
ArrayList<MissingPlugin>();
                         Collection<AnalysisProblem> additionalProblems = new 
ArrayList<AnalysisProblem>();
                         
diff --git a/code.analysis/src/org/netbeans/modules/analysis/ui/Nodes.java 
b/code.analysis/src/org/netbeans/modules/analysis/ui/Nodes.java
--- a/code.analysis/src/org/netbeans/modules/analysis/ui/Nodes.java
+++ b/code.analysis/src/org/netbeans/modules/analysis/ui/Nodes.java
@@ -50,11 +50,13 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.IdentityHashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.swing.Action;
@@ -282,7 +284,7 @@
 
     private static List<Node> constructSemiLogicalViewNodes(LogicalViewCache 
lvc, Map<FileObject, Map<AnalyzerFactory, List<ErrorDescription>>> errors, 
Map<ErrorDescription, Project> errorsToProjects) {
         Map<Project, Map<FileObject, Map<AnalyzerFactory, 
List<ErrorDescription>>>> projects = new IdentityHashMap<Project, 
Map<FileObject, Map<AnalyzerFactory, List<ErrorDescription>>>>();
-        
+        Map<FileObject,Set<Project>> file2Projects = new HashMap<>();
         for (Map.Entry<FileObject, Map<AnalyzerFactory, 
List<ErrorDescription>>> fileEntry : errors.entrySet()) {
             if (!errorsToProjects.isEmpty()) {
                 for 
(Iterator<Map.Entry<AnalyzerFactory,List<ErrorDescription>>> analyzerEntryIt 
= fileEntry.getValue().entrySet().iterator(); analyzerEntryIt.hasNext();) {
@@ -291,6 +293,12 @@
                         final ErrorDescription error = errorIt.next();
                         Project project = errorsToProjects.get(error);
                         if (project != null) {
+                            Set<Project> inProjects = 
file2Projects.get(fileEntry.getKey());
+                            if (inProjects == null) {
+                                inProjects = new HashSet<>();
+                                file2Projects.put(fileEntry.getKey(), 
inProjects);
+                            }
+                            inProjects.add(project);
                             Map<FileObject, Map<AnalyzerFactory, 
List<ErrorDescription>>> projectErrors = projects.get(project);
                             if (projectErrors == null) {
                                 projects.put(project, projectErrors = new 
HashMap<>());
@@ -333,10 +341,26 @@
         }
         
         projects.remove(null);
-        
+        Map<Project,Set<FileObject>> needsCacheClean = new HashMap<>();
+        for (Map.Entry<FileObject,Set<Project>> f2p : 
file2Projects.entrySet()) {
+            if (f2p.getValue().size() > 1) {
+                for (Project p : f2p.getValue()) {
+                    Set<FileObject> filesToClear = needsCacheClean.get(p);
+                    if (filesToClear == null) {
+                        filesToClear = new HashSet<>();
+                        needsCacheClean.put(p, filesToClear);
+                    }
+                    filesToClear.add(f2p.getKey());
+                }
+            }
+        }
         List<Node> nodes = new ArrayList<Node>(projects.size());
         
         for (Project p : projects.keySet()) {
+            final Set<FileObject> filesToClear = needsCacheClean.get(p);
+            if (filesToClear != null) {
+                lvc.file2FileNode.keySet().removeAll(filesToClear);
+            }
             nodes.add(constructSemiLogicalView(p, lvc, projects.get(p)));
         }
 

[hg] main-silver: Fixed LogicalView when 2 projects use the same...

Tomas Zezula 04/26/2013

Project Features

About this Project

Editor was started in November 2009, is owned by Martin Ryzl, and has 147 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close