1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 14:55:41 +02:00

[173905] Remote file getContents() does not account for file type filters. It processes all filters as name filters. This is fixed.

This commit is contained in:
Kushal Munir 2007-02-12 21:09:09 +00:00
parent 0a59ebf2a1
commit cfd86803bb

View file

@ -773,7 +773,6 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable
ArrayList calculatedResults = new ArrayList();
StringComparePatternMatcher fmatcher = new StringComparePatternMatcher(filter);
// the filter may be a subset of existing filters
@ -786,8 +785,7 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable
// KM: we need to match with the key to ensure that the filter is a subset
StringComparePatternMatcher matcher = new StringComparePatternMatcher(key);
if (matcher.stringMatches(filter))
{
if (matcher.stringMatches(filter)) {
// get all children, i.e. the superset
Object[] all = (Object[]) filters.get(key);
@ -797,18 +795,34 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable
Object subContent = all[s];
if (!calculatedResults.contains(subContent))
{
if (subContent instanceof IRemoteFile)
{
// match with the filter to take out those that do not match the filter
if (fmatcher.stringMatches(((IRemoteFile)subContent).getName()))
{
if (!calculatedResults.contains(subContent)) {
if (subContent instanceof IRemoteFile) {
IRemoteFile temp = (IRemoteFile) subContent;
if (temp.isFile()) {
String compareTo = null;
boolean filterForFileTypes = isFilterForFileTypes(filter);
if (!filterForFileTypes) {
compareTo = temp.getName();
}
else {
compareTo = temp.getExtension();
}
// match with the filter to take out those
// that do not match the filter
if (compareTo != null && fmatcher.stringMatches(compareTo)) {
calculatedResults.add(subContent);
}
}
else
{
else {
calculatedResults.add(subContent);
}
}
else {
calculatedResults.add(subContent);
}
}
@ -820,7 +834,20 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable
return calculatedResults.toArray();
}
/**
* Returns whether filter is for file types.
* @param filter the filter.
* @return <code>true</code> if filter is for file types, <code>false</code> otherwise.
*/
private boolean isFilterForFileTypes(String filter) {
if (filter.endsWith(",")) {
return true;
}
else {
return false;
}
}
public void setIsContainer(boolean con) {
isContainer = con;