Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Salinas2012-05-22 16:44:53 +0000
committerVivian Kong2012-05-22 16:49:25 +0000
commit6091c93f7b959b88b89e02145118441acd43504f (patch)
tree55af9121eb4edf3be0e6cebbb0822d4ba9987027
parenta686aafa3c159aa926bfd261c8d18ff763a026b8 (diff)
downloadorg.eclipse.cdt-6091c93f7b959b88b89e02145118441acd43504f.tar.gz
org.eclipse.cdt-6091c93f7b959b88b89e02145118441acd43504f.tar.xz
org.eclipse.cdt-6091c93f7b959b88b89e02145118441acd43504f.zip
Bug 375859 - Refresh scope becomes empty after closing/opening project
if left to default
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java5
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ExternalBuildRunner.java3
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java5
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java4
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java4
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RefreshPolicyTab.java3
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java2
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java180
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/BuildRunnerHelper.java8
9 files changed, 120 insertions, 94 deletions
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java
index 9a6eb5609ca..18a64ede80e 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 QNX Software Systems and others.
+ * Copyright (c) 2000, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,6 +11,7 @@
* Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
* Save build output (bug 294106)
* Andrew Gvozdev (Quoin Inc) - Saving build output implemented in different way (bug 306222)
+ * IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.make.core;
@@ -279,7 +280,7 @@ public class MakeBuilder extends ACBuilder {
*/
protected void refreshProject(IProject project) {
if (buildRunnerHelper != null) {
- buildRunnerHelper.refreshProject(null);
+ buildRunnerHelper.refreshProject(null, null);
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ExternalBuildRunner.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ExternalBuildRunner.java
index 75ffcba9195..3198a69760e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ExternalBuildRunner.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ExternalBuildRunner.java
@@ -9,6 +9,7 @@
* Wind River Systems - Initial API and implementation
* James Blackburn (Broadcom Corp.)
* Andrew Gvozdev
+ * IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
@@ -129,7 +130,7 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
buildRunnerHelper.goodbye();
if (state != ICommandLauncher.ILLEGAL_COMMAND) {
- buildRunnerHelper.refreshProject(new SubProgressMonitor(monitor, TICKS_REFRESH_PROJECT, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+ buildRunnerHelper.refreshProject(cfgName, new SubProgressMonitor(monitor, TICKS_REFRESH_PROJECT, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
}
} else {
String msg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.undefined.build.command", builder.getId()); //$NON-NLS-1$
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java
index 92e447a093c..e48974cb29a 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 Wind River Systems and others.
+ * Copyright (c) 2010, 2012 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
* Contributors:
* Wind River Systems - Initial API and implementation
* James Blackburn (Broadcom Corp.)
+ * IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
@@ -136,7 +137,7 @@ public class InternalBuildRunner extends AbstractBuildRunner {
buildRunnerHelper.goodbye();
if (status != ICommandLauncher.ILLEGAL_COMMAND) {
- buildRunnerHelper.refreshProject(new SubProgressMonitor(monitor, TICKS_REFRESH_PROJECT, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+ buildRunnerHelper.refreshProject(cfgName, new SubProgressMonitor(monitor, TICKS_REFRESH_PROJECT, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
}
} catch (Exception e) {
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java
index 5dda8ac90d4..533334735e6 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * Copyright (c) 2007, 2012 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -1211,7 +1211,7 @@ public class CommonBuilder extends ACBuilder {
buildRunnerHelper.goodbye();
if (status != ICommandLauncher.ILLEGAL_COMMAND) {
- buildRunnerHelper.refreshProject(new SubProgressMonitor(monitor, TICKS_REFRESH_PROJECT));
+ buildRunnerHelper.refreshProject(cfgName, new SubProgressMonitor(monitor, TICKS_REFRESH_PROJECT));
}
//Throw a core exception indicating that the clean command failed
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
index 57ad26d3516..cc2297c59a5 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2011 IBM Corporation and others.
+ * Copyright (c) 2002, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -1118,7 +1118,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
// use the refresh scope manager to refresh
RefreshScopeManager refreshManager = RefreshScopeManager.getInstance();
- IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(project);
+ IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(project, cfg.getName());
ResourcesPlugin.getWorkspace().run(runnable, null, IWorkspace.AVOID_UPDATE, null);
} catch (CoreException e) {
monitor.subTask(ManagedMakeMessages
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RefreshPolicyTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RefreshPolicyTab.java
index cf8f9a0afb0..7f3746e5386 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RefreshPolicyTab.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RefreshPolicyTab.java
@@ -144,8 +144,7 @@ public class RefreshPolicyTab extends AbstractCBuildPropertyTab {
private void loadInfo() {
HashMap<String, HashMap<IResource, List<RefreshExclusion>>> configMap = fManager.getConfigurationToResourcesMap(fProject);
- if (configMap != null)
- fConfigurationToResourcesToExclusionsMap = copyHashMap(configMap);
+ fConfigurationToResourcesToExclusionsMap = copyHashMap(configMap);
}
private List<RefreshExclusion> getExclusions(String configName, IResource resource) {
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java
index c6d45b6ffff..a8ef6802ed6 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java
@@ -486,7 +486,7 @@ public class RefreshScopeTests extends TestCase {
createTestFile(path);
// now refresh
- IWorkspaceRunnable runnable = manager.getRefreshRunnable(fProject);
+ IWorkspaceRunnable runnable = manager.getRefreshRunnable(fProject, conf_name);
try {
ResourcesPlugin.getWorkspace().run(runnable, null, IWorkspace.AVOID_UPDATE, null);
} catch (CoreException e) {
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java
index c3cb38ae4e6..39cd795b69e 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java
@@ -11,11 +11,11 @@
package org.eclipse.cdt.core.resources;
import java.util.ArrayList;
-
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
@@ -97,6 +97,7 @@ public class RefreshScopeManager {
private boolean fIsLoaded = false;
private boolean fIsLoading = false;
+ private boolean fIsNewProject = false;
private HashMap<IProject,HashMap<String,HashMap<IResource, List<RefreshExclusion>>>> fProjToConfToResToExcluMap;
private int fVersion = 2;
@@ -214,9 +215,7 @@ public class RefreshScopeManager {
}
private synchronized void clearDataForProject(IProject project) {
- HashMap<String,HashMap<IResource, List<RefreshExclusion>>> configMap = fProjToConfToResToExcluMap.get(project);
- if (configMap != null)
- configMap.clear();
+ fProjToConfToResToExcluMap.remove(project);
}
/**
@@ -286,7 +285,8 @@ public class RefreshScopeManager {
if (resourceMap == null) {
resourceMap = new HashMap<IResource, List<RefreshExclusion>>();
- resourceMap.put(project, new LinkedList<RefreshExclusion>());
+ if (!fIsLoading)
+ resourceMap.put(project, new LinkedList<RefreshExclusion>());
configMap.put(configName, resourceMap);
}
@@ -317,9 +317,24 @@ public class RefreshScopeManager {
return fProjToConfToResToExcluMap;
}
-
+ /**
+ * Refresh the given project using the refresh setting for the active configuration
+ * @param project
+ * @return the refresh runnable for the given project
+ */
public IWorkspaceRunnable getRefreshRunnable(final IProject project) {
+ return getRefreshRunnable(project, null);
+ }
+
+ /**
+ * Refresh the given project using the refresh setting for the configuration with the given name
+ * @param project
+ * @param configName
+ * @return the refresh runnable for the given project
+ * @since 5.4
+ */
+ public IWorkspaceRunnable getRefreshRunnable(final IProject project, final String configName) {
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
/**
@@ -345,13 +360,14 @@ public class RefreshScopeManager {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
-
-
- CProjectDescriptionManager descriptionManager = CProjectDescriptionManager
- .getInstance();
- ICProjectDescription projectDescription = descriptionManager.getProjectDescription(project, false);
- ICConfigurationDescription active_conf = projectDescription.getActiveConfiguration();
- String name = active_conf.getName();
+ String name = configName;
+ if (name == null) {
+ CProjectDescriptionManager descriptionManager = CProjectDescriptionManager
+ .getInstance();
+ ICProjectDescription projectDescription = descriptionManager.getProjectDescription(project, false);
+ ICConfigurationDescription active_conf = projectDescription.getActiveConfiguration();
+ name = active_conf.getName();
+ }
List<IResource> resourcesToRefresh = getResourcesToRefresh(project,name);
for (IResource resource : resourcesToRefresh) {
List<RefreshExclusion> exclusions = getExclusions(project,name,resource);
@@ -473,7 +489,7 @@ public class RefreshScopeManager {
// walk the tree and load the settings
String str = storageElement.getAttribute(VERSION_NUMBER_ATTRIBUTE_NAME);
- if ((str == null) || (str.equals("1"))) { //$NON-NLS-1$
+ if ( (children.length != 0) && ((str == null) || (str.equals("1")))) { //$NON-NLS-1$
ICConfigurationDescription cfgDescs[] = projectDescription.getConfigurations();
for (ICConfigurationDescription cfgDesc : cfgDescs)
loadResourceData(workspaceRoot, project, cfgDesc.getName(), children);
@@ -488,7 +504,9 @@ public class RefreshScopeManager {
// else there are no children, and this is a "new" project.
// so initialize it.
if (children.length == 0) {
+ fIsNewProject = true;
getConfigurationToResourcesMap(project); // this will initialize the config map.
+ fIsNewProject = false;
}
}
}
@@ -506,7 +524,7 @@ public class RefreshScopeManager {
for (ICConfigurationDescription cfgDesc : cfgDescs) {
String configName = cfgDesc.getName();
HashMap<IResource, List<RefreshExclusion>> resourceMap = new HashMap<IResource, List<RefreshExclusion>>();
- if (!fIsLoading)
+ if (!fIsLoading || fIsNewProject) //config settings could be loading and detects a new project and if so, add the default refresh setting
resourceMap.put(project, new LinkedList<RefreshExclusion>());
configMap.put(configName, resourceMap);
}
@@ -520,76 +538,80 @@ public class RefreshScopeManager {
*/
public synchronized void loadResourceData(IWorkspaceRoot workspaceRoot, IProject project, String configName, ICStorageElement[] children) {
- for (ICStorageElement child : children) {
- if (child.getName().equals(RESOURCE_ELEMENT_NAME)) {
-
- // get the resource path
- String resourcePath = child.getAttribute(WORKSPACE_PATH_ATTRIBUTE_NAME);
-
- if (resourcePath == null) {
- // error... skip this resource
- continue;
-
- }
-
- else {
- String resourceTypeString = child
- .getAttribute(RESOURCE_TYPE_ATTRIBUTE_NAME);
-
- if (resourceTypeString == null) {
- // we'll do our best, but we won't be able to create handles to non-existent
- // resources
- resourceTypeString = OTHER_VALUE;
- }
-
- // find the resource
- IResource resource = null;
-
- if (resourceTypeString.equals(PROJECT_VALUE)) {
- resource = workspaceRoot.getProject(resourcePath);
- }
-
- else if (resourceTypeString.equals(FILE_VALUE)) {
- resource = workspaceRoot.getFile(new Path(resourcePath));
- }
-
- else if (resourceTypeString.equals(FOLDER_VALUE)) {
- resource = workspaceRoot.getFolder(new Path(resourcePath));
- }
-
- else {
- // Find arbitrary resource.
- // The only way to do this is to ask the workspace root to find
- // it, if it exists. If it doesn't exist, we have no way of
- // creating a handle to the right type of object, so we must
- // give up. In practice, this would likely happen if we had
- // a virtual group resource that has been deleted somehow since
- // the settings were created, and since the resource is virtual,
- // it's impossible to refresh it if it doesn't exist anyway.
- resource = workspaceRoot.findMember(resourcePath);
- }
-
- if (resource == null) {
- // error.. skip this resource
+ if (children.length == 0) {
+ // we have an empty config to resource map. This call will create an empty resource set for the config name.
+ getResourcesToExclusionsMap(project,configName);
+ } else {
+ for (ICStorageElement child : children) {
+ if (child.getName().equals(RESOURCE_ELEMENT_NAME)) {
+
+ // get the resource path
+ String resourcePath = child.getAttribute(WORKSPACE_PATH_ATTRIBUTE_NAME);
+
+ if (resourcePath == null) {
+ // error... skip this resource
continue;
}
else {
- addResourceToRefresh(project,configName, resource);
+ String resourceTypeString = child
+ .getAttribute(RESOURCE_TYPE_ATTRIBUTE_NAME);
+
+ if (resourceTypeString == null) {
+ // we'll do our best, but we won't be able to create handles to non-existent
+ // resources
+ resourceTypeString = OTHER_VALUE;
+ }
+
+ // find the resource
+ IResource resource = null;
+
+ if (resourceTypeString.equals(PROJECT_VALUE)) {
+ resource = workspaceRoot.getProject(resourcePath);
+ }
+
+ else if (resourceTypeString.equals(FILE_VALUE)) {
+ resource = workspaceRoot.getFile(new Path(resourcePath));
+ }
+
+ else if (resourceTypeString.equals(FOLDER_VALUE)) {
+ resource = workspaceRoot.getFolder(new Path(resourcePath));
+ }
+
+ else {
+ // Find arbitrary resource.
+ // The only way to do this is to ask the workspace root to find
+ // it, if it exists. If it doesn't exist, we have no way of
+ // creating a handle to the right type of object, so we must
+ // give up. In practice, this would likely happen if we had
+ // a virtual group resource that has been deleted somehow since
+ // the settings were created, and since the resource is virtual,
+ // it's impossible to refresh it if it doesn't exist anyway.
+ resource = workspaceRoot.findMember(resourcePath);
+ }
+
+ if (resource == null) {
+ // error.. skip this resource
+ continue;
+ }
+
+ else {
+ addResourceToRefresh(project,configName, resource);
+
+ // load any exclusions
+ List<RefreshExclusion> exclusions;
+ try {
+ exclusions = RefreshExclusion.loadData(
+ child, null, resource, this);
- // load any exclusions
- List<RefreshExclusion> exclusions;
- try {
- exclusions = RefreshExclusion.loadData(
- child, null, resource, this);
-
- // add them
- for (RefreshExclusion exclusion : exclusions) {
- addExclusion(project, configName, resource, exclusion);
+ // add them
+ for (RefreshExclusion exclusion : exclusions) {
+ addExclusion(project, configName, resource, exclusion);
+ }
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
}
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/BuildRunnerHelper.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/BuildRunnerHelper.java
index 6af783585db..ec9e248bd70 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/BuildRunnerHelper.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/BuildRunnerHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2012 Andrew Gvozdev and others.
+ * Copyright (c) 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Andrew Gvozdev - initial API and implementation
+ * IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.internal.core;
@@ -313,10 +314,11 @@ public class BuildRunnerHelper implements Closeable {
/**
* Refresh project in the workspace.
*
+ * @param configName - the configuration to refresh
* @param monitor - progress monitor in the initial state where {@link IProgressMonitor#beginTask(String, int)}
* has not been called yet.
*/
- public void refreshProject(IProgressMonitor monitor) {
+ public void refreshProject(String configName, IProgressMonitor monitor) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
@@ -328,7 +330,7 @@ public class BuildRunnerHelper implements Closeable {
// The caveat is for huge projects, it may take sometimes at every build.
// Use the refresh scope manager to refresh
RefreshScopeManager refreshManager = RefreshScopeManager.getInstance();
- IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(project);
+ IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(project, configName);
ResourcesPlugin.getWorkspace().run(runnable, null, IWorkspace.AVOID_UPDATE, null);
} catch (CoreException e) {
// ignore exceptions

Back to the top