Bug 562185 - Resource Filter Include Not working as expected
Summary: Resource Filter Include Not working as expected
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 4.13   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Resources-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-15 19:07 EDT by pav48856 pav48856 CLA
Modified: 2020-04-23 10:23 EDT (History)
2 users (show)

See Also:


Attachments
Resource Filter Settings (58.73 KB, image/jpeg)
2020-04-16 15:16 EDT, pav48856 pav48856 CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description pav48856 pav48856 CLA 2020-04-15 19:07:58 EDT
Pre-Condition:
There are a lot of files and folders added to eclipse

Action:
1. To filter only specific files and folders create Resource Filter 
2. Select "Filter type" as "Include only"
3. Select "Applies to" as "Files and folders"
4. Select "All children (recursive)"
5. Select "File and Folder Attributes"
6. In Filter Details select "Project Relative Path" "matches" 
7. Enter the path eg: blah/*

Expected: folder and files under blah need to be shown

Actual Result: folder and files under blah are NOT being shown

This issue is occuring all the time

Note:
At step 3 if  Select "Applies to" is set as "Files" then folder and files under blah are being shown. This setting has side effect it shows other unwanted folders also.


-- Configuration Details --
Product: Eclipse IDE 4.13.0.20190917-0000 (org.eclipse.epp.package.cpp.product)Installed Features:
 org.eclipse.platform 4.13.0.v20190916-1323
Comment 1 Rolf Theunissen CLA 2020-04-16 02:19:42 EDT
It seems to me that the view you are using is not provided by Eclipse Platform.
- In which view are you trying to make this filter? e.g. 'Project Explorer'
- Where is the 'create Resource Filter' button/menu located?
Comment 2 Thomas Wolf CLA 2020-04-16 02:53:36 EDT
(In reply to Rolf Theunissen from comment #1)
> It seems to me that the view you are using is not provided by Eclipse
It _is_ provided by platform. Open the properties on any Eclipse project in project explorer or package explorer; there it's under Resource->Resource Filters.

(In reply to pav48856 pav48856 from comment #0)
> 7. Enter the path eg: blah/*
> 
> Expected: folder and files under blah need to be shown
> 
> Actual Result: folder and files under blah are NOT being shown
That filter excludes the top-level folder "blah" itself since "blah" doesn't match "blah/*".

You could combine it using an OR group with a filter to include "blah", too.

Or, depending on your folder names, you could use the single filter you defined but use the pattern "blah*" (without the slash), but that would also include a folder called "blahblah".
Comment 3 pav48856 pav48856 CLA 2020-04-16 15:16:46 EDT
Created attachment 282481 [details]
Resource Filter Settings
Comment 4 pav48856 pav48856 CLA 2020-04-16 15:32:39 EDT
(In reply to Thomas Wolf from comment #2)
The project I am working has lots of source files & folders. The folder names are repeated at several locations.

My goal is to include files under specific directories into the eclipse project. So that eclipse can only index these files and also browsing will be easy for me.

Can you please let me know how i can achieve this. 
Is using Resource Filters>>Include Only is the best approach?

eg: folders
vendor/abc/
vendor/xyz/
drivers/abc/
drivers/xyz

I would like to include only these files only in to my eclipse project
vendor/abc/
drivers/xyz/

Note: This is just simple example.

I am new to eclipse, your help is very much appreciated.
Comment 5 Thomas Wolf CLA 2020-04-16 16:34:12 EDT
For this example you could use two "include only" filters, files & folders, recursive, project-relative path matches, with the regular expression patterns

  vendor(/abc(/.*)?)?
  drivers(/xyz(/.*)?)?

This is because the pattern must match the parent folders, too. If a parent folder doesn't match, it and all its children are pruned because the file tree is traversed and filtered top-down. This is why a simpler pattern like vendor/abc* wouldn't work: it doesn't match the first-level folder "vendor", so the traversal never even gets to vendor/abc, much less the children of that.
Comment 6 pav48856 pav48856 CLA 2020-04-22 17:49:40 EDT
(In reply to Thomas Wolf from comment #5)
> For this example you could use two "include only" filters, files & folders,
> recursive, project-relative path matches, with the regular expression
> patterns
> 
>   vendor(/abc(/.*)?)?
>   drivers(/xyz(/.*)?)?
> 
> This is because the pattern must match the parent folders, too. If a parent
> folder doesn't match, it and all its children are pruned because the file
> tree is traversed and filtered top-down. This is why a simpler pattern like
> vendor/abc* wouldn't work: it doesn't match the first-level folder "vendor",
> so the traversal never even gets to vendor/abc, much less the children of
> that.

Thanks for the info.

Sorry for my delayed reply, i tried it out this is working. 
This solution seems a bit complex for people who are not familiar with regular expressions. Is there any simple way without using regex?

It will be nice, if the same result can be achieved by just mentioning the relative path of the whole directory which needs to be included.
Comment 7 Thomas Wolf CLA 2020-04-22 17:57:07 EDT
If you prefer non-regexes, you could try or-ing filters:

* OR
  * vendor
  * vendor/abc
  * vendor/abc/*
* OR
  * drivers
  * drivers/xyz
  * drivers/xyz/*
Comment 8 pav48856 pav48856 CLA 2020-04-23 10:23:19 EDT
Tried out this method also works. But it will become tedious when the paths are big.

I would really recommend if eclipse can just accept the path and do all the necessary work by itself then it becomes quite easy usable for the end user.
Other editors are functioning this way.

Please consider this as a feature request/enhancement. Let me know if i need to raise a separate ticket for this request/enhancement.