mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 375859 - Refresh scope becomes empty after closing/opening project
if left to default
This commit is contained in:
parent
a686aafa3c
commit
6091c93f7b
9 changed files with 120 additions and 94 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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$
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue