mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-05 07:15:39 +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:
parent
0a59ebf2a1
commit
cfd86803bb
1 changed files with 46 additions and 19 deletions
|
@ -773,7 +773,6 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable
|
||||||
|
|
||||||
ArrayList calculatedResults = new ArrayList();
|
ArrayList calculatedResults = new ArrayList();
|
||||||
|
|
||||||
|
|
||||||
StringComparePatternMatcher fmatcher = new StringComparePatternMatcher(filter);
|
StringComparePatternMatcher fmatcher = new StringComparePatternMatcher(filter);
|
||||||
|
|
||||||
// the filter may be a subset of existing filters
|
// the filter may be a subset of existing filters
|
||||||
|
@ -786,10 +785,9 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable
|
||||||
// KM: we need to match with the key to ensure that the filter is a subset
|
// KM: we need to match with the key to ensure that the filter is a subset
|
||||||
StringComparePatternMatcher matcher = new StringComparePatternMatcher(key);
|
StringComparePatternMatcher matcher = new StringComparePatternMatcher(key);
|
||||||
|
|
||||||
if (matcher.stringMatches(filter))
|
if (matcher.stringMatches(filter)) {
|
||||||
{
|
|
||||||
// get all children, i.e. the superset
|
// get all children, i.e. the superset
|
||||||
Object[] all = (Object[])filters.get(key);
|
Object[] all = (Object[]) filters.get(key);
|
||||||
|
|
||||||
if (all != null) {
|
if (all != null) {
|
||||||
|
|
||||||
|
@ -797,18 +795,34 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable
|
||||||
|
|
||||||
Object subContent = all[s];
|
Object subContent = all[s];
|
||||||
|
|
||||||
if (!calculatedResults.contains(subContent))
|
if (!calculatedResults.contains(subContent)) {
|
||||||
{
|
|
||||||
if (subContent instanceof IRemoteFile)
|
if (subContent instanceof IRemoteFile) {
|
||||||
{
|
|
||||||
// match with the filter to take out those that do not match the filter
|
IRemoteFile temp = (IRemoteFile) subContent;
|
||||||
if (fmatcher.stringMatches(((IRemoteFile)subContent).getName()))
|
|
||||||
{
|
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);
|
calculatedResults.add(subContent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
calculatedResults.add(subContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
calculatedResults.add(subContent);
|
calculatedResults.add(subContent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -820,7 +834,20 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable
|
||||||
return calculatedResults.toArray();
|
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) {
|
public void setIsContainer(boolean con) {
|
||||||
isContainer = con;
|
isContainer = con;
|
||||||
|
|
Loading…
Add table
Reference in a new issue