mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Bug 272969 #checkBuildSystemChange should not reorder project natures
This commit is contained in:
parent
3bc0e2a9d1
commit
19354a7c8d
1 changed files with 26 additions and 17 deletions
|
@ -10,6 +10,7 @@
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
* James Blackburn (Broadcom Corp.)
|
* James Blackburn (Broadcom Corp.)
|
||||||
|
* Alex Blewitt Bug 132511 - nature order not preserved
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.settings.model;
|
package org.eclipse.cdt.internal.core.settings.model;
|
||||||
|
|
||||||
|
@ -22,14 +23,15 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import com.ibm.icu.text.MessageFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -126,6 +128,8 @@ import org.w3c.dom.NodeList;
|
||||||
import org.w3c.dom.ProcessingInstruction;
|
import org.w3c.dom.ProcessingInstruction;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.ibm.icu.text.MessageFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The CProjectDescriptionManager is to marshall the loading and storing
|
* The CProjectDescriptionManager is to marshall the loading and storing
|
||||||
* of CDT Project Descriptions.
|
* of CDT Project Descriptions.
|
||||||
|
@ -719,25 +723,30 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
CConfigurationDataProviderDescriptor newDr = newBsId != null ? getCfgProviderDescriptor(newBsId) : null;
|
CConfigurationDataProviderDescriptor newDr = newBsId != null ? getCfgProviderDescriptor(newBsId) : null;
|
||||||
CConfigurationDataProviderDescriptor oldDr = oldBsId != null ? getCfgProviderDescriptor(oldBsId) : null;
|
CConfigurationDataProviderDescriptor oldDr = oldBsId != null ? getCfgProviderDescriptor(oldBsId) : null;
|
||||||
|
|
||||||
String newNatures[] = newDr != null ? newDr.getNatureIds() : new String[0];
|
List<String> newNatures, oldNatures, conflictingNatures;
|
||||||
String oldNatures[] = oldDr != null ? oldDr.getNatureIds() : new String[0];
|
newNatures = oldNatures = conflictingNatures = Collections.emptyList();
|
||||||
String conflictingNatures[] = newDr != null ? newDr.getConflictingNatureIds() : new String[0];
|
if (oldDr != null)
|
||||||
String natureIds[] = des.getNatureIds();
|
oldNatures = Arrays.asList(oldDr.getNatureIds());
|
||||||
|
if (newDr != null) {
|
||||||
|
newNatures = Arrays.asList(newDr.getNatureIds());
|
||||||
|
conflictingNatures = Arrays.asList(newDr.getConflictingNatureIds());
|
||||||
|
}
|
||||||
|
|
||||||
Set<String> curSet = new HashSet<String>(Arrays.asList(natureIds));
|
// List of existing natureIds
|
||||||
// Set newSet = new HashSet(Arrays.asList(newNatures));
|
final String[] natureIds = des.getNatureIds();
|
||||||
// Set oldSet = new HashSet(Arrays.asList(oldNatures));
|
|
||||||
HashSet<String> newCurSet = new HashSet<String>(curSet);
|
|
||||||
// newSet.removeAll(oldSet);
|
|
||||||
// oldSet.removeAll(tmp);
|
|
||||||
|
|
||||||
|
// Get the set of items to remove ({oldNatures} - {newNatures}) + conflictingNatures
|
||||||
|
Set<String> toRemove = new HashSet<String>(oldNatures);
|
||||||
|
toRemove.removeAll(newNatures); // Don't remove items we're re-adding
|
||||||
|
toRemove.addAll(conflictingNatures); // Add conflicting natures for removal
|
||||||
|
// Modify an ordered set of the existing natures with the changes
|
||||||
|
final LinkedHashSet<String> cur = new LinkedHashSet<String>(Arrays.asList(natureIds));
|
||||||
|
cur.addAll(newNatures);
|
||||||
|
cur.removeAll(toRemove);
|
||||||
|
|
||||||
newCurSet.removeAll(Arrays.asList(oldNatures));
|
final String[] newNatureIds = cur.toArray(new String[cur.size()]);
|
||||||
newCurSet.addAll(Arrays.asList(newNatures));
|
if (!Arrays.equals(newNatureIds, natureIds)) {
|
||||||
newCurSet.removeAll(Arrays.asList(conflictingNatures));
|
des.setNatureIds(newNatureIds);
|
||||||
|
|
||||||
if(!newCurSet.equals(curSet)){
|
|
||||||
des.setNatureIds(newCurSet.toArray(new String[newCurSet.size()]));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue