Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] bug 43348 Long workbench shutdown times


Here's a patch that simplifies how workspace scopes are built - instead of getting info from the CModelManager, we go straight to the workspace. This will improve shutdown/search performance.

Automation suite run on Windows + Linux.


- Bogdan

Index: search/org/eclipse/cdt/internal/core/search/CSearchScope.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/CSearchScope.java,v
retrieving revision 1.3
diff -u -r1.3 CSearchScope.java
--- search/org/eclipse/cdt/internal/core/search/CSearchScope.java	11 Aug 2003 13:42:47 -0000	1.3
+++ search/org/eclipse/cdt/internal/core/search/CSearchScope.java	29 Sep 2003 21:15:00 -0000
@@ -14,11 +14,13 @@
 import java.util.ArrayList;
 import java.util.HashSet;
 
+import org.eclipse.cdt.core.CProjectNature;
 import org.eclipse.cdt.core.model.ICElement;
 import org.eclipse.cdt.core.model.ICProject;
 import org.eclipse.cdt.core.model.IMember;
 import org.eclipse.cdt.core.search.ICSearchScope;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
@@ -82,6 +84,53 @@
 				}	
 			}
 		  }
+   }
+   /**
+	* @param project
+	* @param b
+	* @param set
+	*/
+   public void add(IProject project, boolean includesPrereqProjects, HashSet visitedProjects) {
+	
+		if (!project.isAccessible() || !visitedProjects.add(project)) return;
+		
+		IProjectDescription projDesc = null;
+		try {
+			projDesc = project.getDescription();
+		} catch (CoreException e) {}
+		
+		if (projDesc == null)
+			return;
+			
+		String[] natures = projDesc.getNatureIds();
+		
+		boolean flag = false;
+		for (int i=0; i< natures.length; i++){
+			if (natures[i].equals(CProjectNature.C_NATURE_ID)){	
+			  flag=true;
+			  break;
+			} 
+		}
+		
+		if (!flag)
+		 //CNature not found; not a CDT project
+		 return;
+		 
+		this.addEnclosingProject(project.getFullPath());
+	
+		if (includesPrereqProjects){
+			IProject[] refProjects=null;
+			try {
+				refProjects = project.getReferencedProjects();
+			} catch (CoreException e) {
+			}
+			for (int i=0; i<refProjects.length; i++){
+				ICProject cProj= (ICProject)refProjects[i].getAdapter(ICElement.class);
+				if (cProj != null){
+					this.add(cProj, true, visitedProjects);
+				}	
+			}
+		 }  
    }
    /**
     * Adds the given path to this search scope. Remember if subfolders need to be included as well.
Index: search/org/eclipse/cdt/internal/core/search/CWorkspaceScope.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/CWorkspaceScope.java,v
retrieving revision 1.1
diff -u -r1.1 CWorkspaceScope.java
--- search/org/eclipse/cdt/internal/core/search/CWorkspaceScope.java	11 Jul 2003 22:12:35 -0000	1.1
+++ search/org/eclipse/cdt/internal/core/search/CWorkspaceScope.java	29 Sep 2003 21:15:00 -0000
@@ -13,10 +13,10 @@
 
 import java.util.HashSet;
 
-import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.CCorePlugin;
 import org.eclipse.cdt.core.model.ICElement;
 import org.eclipse.cdt.core.model.ICElementDelta;
-import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IPath;
 
 public class CWorkspaceScope extends CSearchScope {
@@ -24,10 +24,16 @@
 	protected boolean needsInitialize;
 
 	public boolean encloses(String resourcePath) {
+		//Workspace scope encloses all elements in the workspace -
+		//as long as we add the proper projects to enclosingProjects,
+		//we  can return true for all paths
 		return true;
 	}
 
 	public boolean encloses(ICElement element) {
+		//Workspace scope encloses all elements in the workspace -
+		//as long as we add the proper projects to enclosingProjects,
+		//we  can return true for all paths
 		return true;
 	}
 
@@ -40,7 +46,7 @@
 	
 	public void initialize() {
 		super.initialize();
-		ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects(); //  ModelManager ;//.getJavaModelManager().getJavaModel().getJavaProjects();
+		IProject[] projects = CCorePlugin.getWorkspace().getRoot().getProjects();
 		for (int i = 0, length = projects.length; i < length; i++)
 				this.add(projects[i], false, new HashSet(2));
 		this.needsInitialize = false;

Back to the top