Bug 134627 - File Name Pattern Exclusion
Summary: File Name Pattern Exclusion
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Search (show other bugs)
Version: 3.2   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: 3.2 RC2   Edit
Assignee: Platform-Search-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 86962 136193 (view as bug list)
Depends on:
Blocks: 346889
  Show dependency tree
 
Reported: 2006-04-03 17:47 EDT by Sharmarke Aden CLA
Modified: 2013-02-15 03:56 EST (History)
4 users (show)

See Also:


Attachments
implements solution 3 (5.60 KB, patch)
2006-04-13 08:03 EDT, Markus Schorn CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sharmarke Aden CLA 2006-04-03 17:47:12 EDT
Eclipse search currently does not support file name pattern exclusion.
The only way to exclude certain file types from a search is to specify
all the other file types in your file search scope.

I would like to propose support for the concept of "NOT" Boolean logic
within file name search pattern strings. For example:

1. If one wanted to search for content within all files in the
workspace/project except for *.log files one could simply enter
"!*.log" as the file name search patter.

2. If one wanted to search for content within all files except for
*.log and *.xml files one would enter "!*.log, !*.xml" as their file
name search patter.

3. If one wanted to search for content within *.xjl files but not
*.xml files or *.xsl, one would enter "!*.x*l, *.xjl"

I have already implemented this enhancement and I'm using it for my
own needs. I would be more than happy to submit a patch to the Eclipse
search plug-in project if there's interest in the enhancement.
Comment 1 Martin Aeschlimann CLA 2006-04-04 08:43:17 EDT
We'd be happy to use have a look at patch! Try to keep is as minimal as possible, then the chance is high that I can release it as is.
Comment 2 Martin Aeschlimann CLA 2006-04-12 03:05:24 EDT
*** Bug 136193 has been marked as a duplicate of this bug. ***
Comment 3 Markus Schorn CLA 2006-04-12 10:51:51 EDT
The example 3 in comment 1: "!*.x*l, *.xjl" does not make sense, as just "*.xjl"
should suffice.

The tough question is, what do we do with files that match both a positive and a negative pattern? For example does "*.a? !*.?b" match the file "test.ab".

Solution 1 (first match wins): 
test.ab is searched, because *.a? is the first pattern that matches.

Solution 2 (last match wins):  test.ab is not searched, *.?b is the last pattern that matches and is negated.

Solution 3 (order independent): test.ab is not searched as there is a negative pattern that matches.

I prefer solution 3, because it is easily explained:
A file is searched if it matches at least one positive pattern and no negative pattern. If there is no positive pattern the pattern '*' may implicitly be added.
Comment 4 Markus Schorn CLA 2006-04-13 08:03:21 EDT
Created attachment 38503 [details]
implements solution 3

In the absence of any comment I chose to implement solution 3.
Comment 5 Sharmarke Aden CLA 2006-04-15 13:39:36 EDT
Apologies for the late response. I original had an patch for Eclipse 3.1 search plug-in release. Things have changed quite a bit for the 3.2 search plug-in release. I'll need to do some catching up.
Comment 6 Sharmarke Aden CLA 2006-04-15 14:06:58 EDT
You're right, example 3 doesn't indeed make sense at all.

As for what we do with files that match both a positive and a negative pattern I am in favor of having inclusion taking precedence over exclusion by default. More often than not user expectation will be the inclusion of hits matching their inclusion pattern. Perhaps there should be an option (check-box) to specify the precedence.

(In reply to comment #3)
> The example 3 in comment 1: "!*.x*l, *.xjl" does not make sense, as just
> "*.xjl"
> should suffice.
> 
> The tough question is, what do we do with files that match both a positive and
> a negative pattern? For example does "*.a? !*.?b" match the file "test.ab".
> 
> Solution 1 (first match wins): 
> test.ab is searched, because *.a? is the first pattern that matches.
> 
> Solution 2 (last match wins):  test.ab is not searched, *.?b is the last
> pattern that matches and is negated.
> 
> Solution 3 (order independent): test.ab is not searched as there is a negative
> pattern that matches.
> 
> I prefer solution 3, because it is easily explained:
> A file is searched if it matches at least one positive pattern and no negative
> pattern. If there is no positive pattern the pattern '*' may implicitly be
> added.
> 

Comment 7 Martin Aeschlimann CLA 2006-04-18 09:37:20 EDT
patch released > 20060416

Thanks Markus!

For the bookkeeping: that this a search polish that I couldn't release at time in RC1.
Comment 8 Dani Megert CLA 2013-02-15 03:56:14 EST
*** Bug 86962 has been marked as a duplicate of this bug. ***