mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
bug 299858: Project Explorer is not notified when FolderDescription is created for an existing folder
This commit is contained in:
parent
f9be7ba9d5
commit
2c098ef25a
2 changed files with 39 additions and 37 deletions
|
@ -1975,7 +1975,12 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CElementDelta> generateCElementDeltasFromResourceDelta(ICProject cProject, ICDescriptionDelta delta, List<CElementDelta> list){
|
/**
|
||||||
|
* The method maps {@link ICDescriptionDelta} to {@link CElementDelta} which are added to the {@code list}.
|
||||||
|
* The delta will indicate modification of CElement for a given resource plus language settings
|
||||||
|
* if they changed (relative to parent resource description if the resource has no its own).
|
||||||
|
*/
|
||||||
|
private void generateCElementDeltasFromResourceDelta(ICProject cProject, ICDescriptionDelta delta, List<CElementDelta> list){
|
||||||
int kind = delta.getDeltaKind();
|
int kind = delta.getDeltaKind();
|
||||||
ICDescriptionDelta parentDelta = delta.getParent();
|
ICDescriptionDelta parentDelta = delta.getParent();
|
||||||
|
|
||||||
|
@ -1989,23 +1994,19 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
newRcDes = ((ICConfigurationDescription)parentDelta.getNewSetting()).getResourceDescription(path, false);
|
newRcDes = ((ICConfigurationDescription)parentDelta.getNewSetting()).getResourceDescription(path, false);
|
||||||
break;
|
break;
|
||||||
case ICDescriptionDelta.ADDED:
|
case ICDescriptionDelta.ADDED:
|
||||||
newRcDes = (ICResourceDescription)delta.getNewSetting();
|
|
||||||
path = newRcDes.getPath();
|
|
||||||
oldRcDes = null;
|
|
||||||
break;
|
|
||||||
case ICDescriptionDelta.CHANGED:
|
|
||||||
// if((delta.getChangeFlags() & ICProjectDescriptionDelta.PATH) == 0){
|
|
||||||
newRcDes = (ICResourceDescription)delta.getNewSetting();
|
|
||||||
path = newRcDes.getPath();
|
|
||||||
oldRcDes = (ICResourceDescription)delta.getOldSetting();
|
|
||||||
break;
|
|
||||||
// }
|
|
||||||
// //if path changed treat as default
|
|
||||||
default:
|
|
||||||
newRcDes = (ICResourceDescription)delta.getNewSetting();
|
newRcDes = (ICResourceDescription)delta.getNewSetting();
|
||||||
path = newRcDes.getPath();
|
path = newRcDes.getPath();
|
||||||
oldRcDes = ((ICConfigurationDescription)parentDelta.getOldSetting()).getResourceDescription(path, false);
|
oldRcDes = ((ICConfigurationDescription)parentDelta.getOldSetting()).getResourceDescription(path, false);
|
||||||
break;
|
break;
|
||||||
|
case ICDescriptionDelta.CHANGED:
|
||||||
|
newRcDes = (ICResourceDescription)delta.getNewSetting();
|
||||||
|
path = newRcDes.getPath();
|
||||||
|
oldRcDes = (ICResourceDescription)delta.getOldSetting();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Not possible
|
||||||
|
CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, SettingsModelMessages.getString("CProjectDescriptionManager.illegalDeltaKind")+kind)); //$NON-NLS-1$
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
path = path.makeRelative();
|
path = path.makeRelative();
|
||||||
|
|
||||||
|
@ -2013,11 +2014,15 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
try {
|
try {
|
||||||
el = cProject.findElement(path);
|
el = cProject.findElement(path);
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
return list;
|
return;
|
||||||
}
|
}
|
||||||
IResource rc = el.getResource();
|
IResource rc = el.getResource();
|
||||||
|
|
||||||
if(rc != null){
|
if(rc != null){
|
||||||
|
CElementDelta ceRcDelta = new CElementDelta(el.getCModel());
|
||||||
|
ceRcDelta.changed(el, ICElementDelta.F_MODIFIERS);
|
||||||
|
list.add(ceRcDelta);
|
||||||
|
|
||||||
if(rc.getType() == IResource.FILE){
|
if(rc.getType() == IResource.FILE){
|
||||||
String fileName = path.lastSegment();
|
String fileName = path.lastSegment();
|
||||||
ICLanguageSetting newLS = getLanguageSetting(newRcDes, fileName);
|
ICLanguageSetting newLS = getLanguageSetting(newRcDes, fileName);
|
||||||
|
@ -2025,34 +2030,29 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
ICDescriptionDelta ld = createDelta(newLS, oldLS);
|
ICDescriptionDelta ld = createDelta(newLS, oldLS);
|
||||||
generateCElementDeltasFromLanguageDelta(el, ld, list);
|
generateCElementDeltasFromLanguageDelta(el, ld, list);
|
||||||
} else {
|
} else {
|
||||||
if(newRcDes.getType() == ICSettingBase.SETTING_FOLDER){
|
if(newRcDes.getType() != ICSettingBase.SETTING_FOLDER){
|
||||||
ICFolderDescription oldFoDes = null;
|
CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, SettingsModelMessages.getString("CProjectDescriptionManager.wrongTypeOfResourceDescription")+newRcDes)); //$NON-NLS-1$
|
||||||
if (oldRcDes != null) {
|
return;
|
||||||
if (oldRcDes.getType() == ICSettingBase.SETTING_FOLDER)
|
}
|
||||||
oldFoDes = (ICFolderDescription)oldRcDes;
|
ICFolderDescription newFoDes = (ICFolderDescription)newRcDes;
|
||||||
}
|
|
||||||
ICDescriptionDelta folderDelta = createDelta((ICFolderDescription)newRcDes, oldFoDes);
|
if(oldRcDes.getType() != ICSettingBase.SETTING_FOLDER){
|
||||||
if(folderDelta != null){
|
CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, SettingsModelMessages.getString("CProjectDescriptionManager.wrongTypeOfResourceDescription")+oldRcDes)); //$NON-NLS-1$
|
||||||
CElementDelta cElDelta = new CElementDelta(el.getCModel());
|
return;
|
||||||
cElDelta.changed(el, ICElementDelta.F_MODIFIERS);
|
}
|
||||||
list.add(cElDelta);
|
ICFolderDescription oldFoDes = (ICFolderDescription)oldRcDes;
|
||||||
|
|
||||||
ICDescriptionDelta children[] = folderDelta.getChildren();
|
ICDescriptionDelta folderDelta = createDelta(newFoDes, oldFoDes);
|
||||||
ICDescriptionDelta child;
|
if (folderDelta != null) {
|
||||||
for(int i = 0; i < children.length; i++){
|
for (ICDescriptionDelta child : folderDelta.getChildren()) {
|
||||||
child = children[i];
|
if(child.getSettingType() == ICSettingBase.SETTING_LANGUAGE){
|
||||||
if(child.getSettingType() == ICSettingBase.SETTING_LANGUAGE){
|
generateCElementDeltasFromLanguageDelta(el, child, list);
|
||||||
generateCElementDeltasFromLanguageDelta(el, child, list);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
//ERROR?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICLanguageSetting getLanguageSetting(ICResourceDescription rcDes, String fileName){
|
private ICLanguageSetting getLanguageSetting(ICResourceDescription rcDes, String fileName){
|
||||||
|
|
|
@ -38,6 +38,8 @@ CProjectDescriptionManager.15=Preference Configuration
|
||||||
CProjectDescriptionManager.16=attempt to set description for the non-openned project
|
CProjectDescriptionManager.16=attempt to set description for the non-openned project
|
||||||
CProjectDescriptionManager.17=unable to apply the invalid project description for project
|
CProjectDescriptionManager.17=unable to apply the invalid project description for project
|
||||||
CProjectDescriptionManager.cfgIDAlreadyExists=Configuration with ID: {0} already exists in passed in settings storage
|
CProjectDescriptionManager.cfgIDAlreadyExists=Configuration with ID: {0} already exists in passed in settings storage
|
||||||
|
CProjectDescriptionManager.illegalDeltaKind=Illegal delta kind
|
||||||
|
CProjectDescriptionManager.wrongTypeOfResourceDescription=Wrong type of resource description:
|
||||||
CFolderDescription.0=data was not created
|
CFolderDescription.0=data was not created
|
||||||
CFolderDescription.1=expected proxy of type ICLanguageSetting, but was
|
CFolderDescription.1=expected proxy of type ICLanguageSetting, but was
|
||||||
CFolderDescription.2=data was not created
|
CFolderDescription.2=data was not created
|
||||||
|
|
Loading…
Add table
Reference in a new issue