mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug #182820: fix for "canExclude()"
This commit is contained in:
parent
1214623cf9
commit
1aa3d8f62f
2 changed files with 33 additions and 5 deletions
|
@ -577,12 +577,38 @@ public class CDataUtil {
|
||||||
|
|
||||||
public static boolean canExclude(IPath path, boolean isFolder, boolean excluded, ICSourceEntry[] entries){
|
public static boolean canExclude(IPath path, boolean isFolder, boolean excluded, ICSourceEntry[] entries){
|
||||||
try {
|
try {
|
||||||
return setExcluded(path, isFolder, excluded, entries, false) != null;
|
ICSourceEntry[] out = setExcluded(path, isFolder, excluded, entries, false);
|
||||||
} catch (CoreException e) {
|
return !isEqual(entries, out);
|
||||||
}
|
} catch (CoreException e) { }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param ein - initial source entries
|
||||||
|
* @param aus - resulting source entries
|
||||||
|
* @return - true if they are equal
|
||||||
|
*/
|
||||||
|
public static boolean isEqual(ICSourceEntry[] ein, ICSourceEntry[] aus) {
|
||||||
|
if (ein == null || aus == null) return (ein == null && aus == null);
|
||||||
|
if (ein.length != aus.length) return false;
|
||||||
|
for (int i=0; i<ein.length; i++) {
|
||||||
|
boolean found = false;
|
||||||
|
for (int j=0; j<aus.length; j++) {
|
||||||
|
if (!ein[i].equalsByName(aus[j]))
|
||||||
|
continue;
|
||||||
|
if (ein[i].equalsByContents(aus[j])) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false; // contents is changed !
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
return false; // name is not found !
|
||||||
|
}
|
||||||
|
return true; // all entries are equal by name and contents
|
||||||
|
}
|
||||||
|
|
||||||
public static ICSourceEntry[] setExcluded(IPath path, boolean isFolder, boolean excluded, ICSourceEntry[] entries) throws CoreException {
|
public static ICSourceEntry[] setExcluded(IPath path, boolean isFolder, boolean excluded, ICSourceEntry[] entries) throws CoreException {
|
||||||
return setExcluded(path, isFolder, excluded, entries, true);
|
return setExcluded(path, isFolder, excluded, entries, true);
|
||||||
}
|
}
|
||||||
|
@ -635,7 +661,7 @@ public class CDataUtil {
|
||||||
includeList.add(new CSourceEntry(path, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED));
|
includeList.add(new CSourceEntry(path, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED));
|
||||||
} else {
|
} else {
|
||||||
if(throwExceptionOnErr)
|
if(throwExceptionOnErr)
|
||||||
throw ExceptionFactory.createCoreException("can not create a source entry for individual file");
|
throw ExceptionFactory.createCoreException("can not create a source entry for individual file"); //$NON-NLS-1$
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -804,6 +804,8 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC
|
||||||
if(newEntries == null){
|
if(newEntries == null){
|
||||||
try {
|
try {
|
||||||
newEntries = CDataUtil.setExcluded(path, isFolder, exclude, getResolvedSourceEntries(), false);
|
newEntries = CDataUtil.setExcluded(path, isFolder, exclude, getResolvedSourceEntries(), false);
|
||||||
|
if (CDataUtil.isEqual(newEntries, getResolvedSourceEntries()))
|
||||||
|
newEntries = null;
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue