This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 211855
Collapse All | Expand All

(-)a/api.search/apichanges.xml (+26 lines)
Lines 105-110 Link Here
105
    <!-- ACTUAL CHANGES BEGIN HERE: -->
105
    <!-- ACTUAL CHANGES BEGIN HERE: -->
106
106
107
    <changes>
107
    <changes>
108
        <change id="UriSupport">
109
            <api name="api.search"/>
110
            <summary>Support for URI-based searching</summary>
111
            <version major="1" minor="1.4"/>
112
            <date day="27" month="4" year="2012"/>
113
            <author login="jhavlin"/>
114
            <compatibility addition="yes"/>
115
            <description>
116
                <p>
117
                    Previous versions of this API supported searching based on
118
                    traversing of <code>FileObject</code>s only. In some cases
119
                    (e.g. remote filesystems), working with
120
                    <code>FileObjects</code> is too expensive and slow.
121
                    This API change make it possible to work with
122
                    <code>URI</code> objects as an alternative to
123
                    <code>FileObjects</code>.
124
                </p>
125
            </description>
126
            <class package="org.netbeans.api.search" name="SearchRoot"/>
127
            <class package="org.netbeans.api.search.provider" name="FileNameMatcher"/>
128
            <class package="org.netbeans.api.search.provider" name="SearchFilter"/>
129
            <class package="org.netbeans.api.search.provider" name="SearchInfo"/>
130
            <class package="org.netbeans.api.search.provider" name="SearchListener"/>
131
            <class package="org.netbeans.spi.search" name="SearchFilterDefinition"/>
132
            <class package="org.netbeans.spi.search" name="SearchInfoDefinition"/>
133
        </change>
108
        <change id="SearchPatternController">
134
        <change id="SearchPatternController">
109
            <api name="api.search"/>
135
            <api name="api.search"/>
110
            <summary>Added class
136
            <summary>Added class
(-)a/api.search/manifest.mf (-1 / +1 lines)
Lines 2-6 Link Here
2
OpenIDE-Module: org.netbeans.api.search
2
OpenIDE-Module: org.netbeans.api.search
3
OpenIDE-Module-Install: org/netbeans/api/search/impl/Installer.class
3
OpenIDE-Module-Install: org/netbeans/api/search/impl/Installer.class
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/api/search/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/api/search/Bundle.properties
5
OpenIDE-Module-Specification-Version: 1.3
5
OpenIDE-Module-Specification-Version: 1.4
6
6
(-)a/api.search/src/org/netbeans/api/search/SearchRoot.java (+53 lines)
Lines 41-52 Link Here
41
 */
41
 */
42
package org.netbeans.api.search;
42
package org.netbeans.api.search;
43
43
44
import java.io.File;
45
import java.net.URI;
44
import java.util.Collections;
46
import java.util.Collections;
45
import java.util.List;
47
import java.util.List;
48
import java.util.logging.Level;
49
import java.util.logging.Logger;
46
import org.netbeans.api.annotations.common.NonNull;
50
import org.netbeans.api.annotations.common.NonNull;
47
import org.netbeans.api.annotations.common.NullAllowed;
51
import org.netbeans.api.annotations.common.NullAllowed;
48
import org.netbeans.api.search.provider.SearchFilter;
52
import org.netbeans.api.search.provider.SearchFilter;
49
import org.openide.filesystems.FileObject;
53
import org.openide.filesystems.FileObject;
54
import org.openide.filesystems.FileUtil;
50
import org.openide.util.Parameters;
55
import org.openide.util.Parameters;
51
56
52
/**
57
/**
Lines 57-64 Link Here
57
62
58
    private List<SearchFilter> filters;
63
    private List<SearchFilter> filters;
59
    private FileObject rootFile;
64
    private FileObject rootFile;
65
    private URI rootUri;
60
    private static final List<SearchFilter> EMPTY_FILTER_LIST =
66
    private static final List<SearchFilter> EMPTY_FILTER_LIST =
61
            Collections.emptyList();
67
            Collections.emptyList();
68
    private static final Logger LOG = Logger.getLogger(
69
            SearchRoot.class.getName());
62
70
63
    /**
71
    /**
64
     * Create a new search root, defined by a folder and a set of filters.
72
     * Create a new search root, defined by a folder and a set of filters.
Lines 75-80 Link Here
75
    }
83
    }
76
84
77
    /**
85
    /**
86
     * Create a new search root, defined by a folder and a set of filters.
87
     *
88
     * @param rootUri Root URI, cannot be null.
89
     * @param filters List of default filters, can be null.
90
     *
91
     * @since org.netbeans.api.search/1.4
92
     */
93
    public SearchRoot(@NonNull URI rootUri,
94
            @NullAllowed List<SearchFilter> filters) {
95
96
        Parameters.notNull("rootFile", rootFile);                       //NOI18N
97
        this.rootUri = rootUri;
98
        this.filters = filters == null ? EMPTY_FILTER_LIST : filters;
99
    }
100
101
    /**
78
     * Get list of filters.
102
     * Get list of filters.
79
     *
103
     *
80
     * @return List of default filters. Can be empty list, but never null.
104
     * @return List of default filters. Can be empty list, but never null.
Lines 89-94 Link Here
89
     * @return Root file (regular file or folder). Never null.
113
     * @return Root file (regular file or folder). Never null.
90
     */
114
     */
91
    public @NonNull FileObject getFileObject() {
115
    public @NonNull FileObject getFileObject() {
116
        if (rootFile == null) {
117
            try {
118
                FileObject fo = FileUtil.toFileObject(new File(rootUri));
119
                if (fo == null) {
120
                    rootFile = createFakeFile(rootUri, null);
121
                } else {
122
                    rootFile = fo;
123
                }
124
            } catch (Exception e) {
125
                rootFile = createFakeFile(rootUri, e);
126
            }
127
        }
92
        return rootFile;
128
        return rootFile;
93
    }
129
    }
130
131
    /**
132
     * Get URI of the search root.
133
     *
134
     * @since org.netbeans.api.search/1.4
135
     */
136
    public @NonNull URI getUri() {
137
        if (rootUri == null) {
138
            rootUri = rootFile.toURI();
139
        }
140
        return rootUri;
141
    }
142
143
    private FileObject createFakeFile(URI uri, Throwable t) {
144
        LOG.log(Level.INFO, "Invalid URI: " + uri, t);                  //NOI18N
145
        return FileUtil.createMemoryFileSystem().getRoot();
146
    }
94
}
147
}
(-)a/api.search/src/org/netbeans/api/search/provider/FileNameMatcher.java (-3 / +47 lines)
Lines 42-47 Link Here
42
package org.netbeans.api.search.provider;
42
package org.netbeans.api.search.provider;
43
43
44
import java.io.File;
44
import java.io.File;
45
import java.net.URI;
45
import java.util.regex.Pattern;
46
import java.util.regex.Pattern;
46
import org.netbeans.api.search.RegexpUtil;
47
import org.netbeans.api.search.RegexpUtil;
47
import org.netbeans.api.search.SearchScopeOptions;
48
import org.netbeans.api.search.SearchScopeOptions;
Lines 81-86 Link Here
81
    public abstract boolean pathMatches(FileObject fileObject);
82
    public abstract boolean pathMatches(FileObject fileObject);
82
83
83
    /**
84
    /**
85
     * @param uri URI whose name or path should be matched.
86
     * @return True if the URI matches required criteria, false otherwise.
87
     *
88
     * @since org.netbeans.api.search/1.4
89
     */
90
    public abstract boolean pathMatches(URI uri);
91
92
    /**
84
     * Create an appripriate matcher for specific search options.
93
     * Create an appripriate matcher for specific search options.
85
     */
94
     */
86
    public static FileNameMatcher create(SearchScopeOptions options) {
95
    public static FileNameMatcher create(SearchScopeOptions options) {
Lines 111-116 Link Here
111
        public boolean pathMatches(FileObject fileObject) {
120
        public boolean pathMatches(FileObject fileObject) {
112
            return true;
121
            return true;
113
        }
122
        }
123
124
        @Override
125
        public boolean pathMatches(URI uri) {
126
            return true;
127
        }
114
    }
128
    }
115
129
116
    /**
130
    /**
Lines 130-138 Link Here
130
            this.extWithDotLen = ext.length() + 1;
144
            this.extWithDotLen = ext.length() + 1;
131
        }
145
        }
132
146
133
        @Override
147
        private boolean pathMatches(String fileName) {
134
        public boolean pathMatches(File file) {
135
            String fileName = file.getName();
136
            if (fileName == null || fileName.length() <= extWithDotLen) {
148
            if (fileName == null || fileName.length() <= extWithDotLen) {
137
                return false;
149
                return false;
138
            }
150
            }
Lines 141-150 Link Here
141
        }
153
        }
142
154
143
        @Override
155
        @Override
156
        public boolean pathMatches(File file) {
157
            String fileName = file.getName();
158
            return pathMatches(fileName);
159
        }
160
161
        @Override
144
        public boolean pathMatches(FileObject fileObject) {
162
        public boolean pathMatches(FileObject fileObject) {
145
            String fileExt = fileObject.getExt();
163
            String fileExt = fileObject.getExt();
146
            return fileExt != null && fileExt.equalsIgnoreCase(ext);
164
            return fileExt != null && fileExt.equalsIgnoreCase(ext);
147
        }
165
        }
166
167
        @Override
168
        public boolean pathMatches(URI uri) {
169
            String fileName = uri.getPath();
170
            return pathMatches(fileName);
171
        }
148
    }
172
    }
149
173
150
    /**
174
    /**
Lines 172-177 Link Here
172
        public boolean pathMatches(FileObject fileObject) {
196
        public boolean pathMatches(FileObject fileObject) {
173
            return pattern.matcher(fileObject.getPath()).find();
197
            return pattern.matcher(fileObject.getPath()).find();
174
        }
198
        }
199
200
        @Override
201
        public boolean pathMatches(URI uri) {
202
            return pattern.matcher(uri.getPath()).find();
203
        }
175
    }
204
    }
176
205
177
    /**
206
    /**
Lines 199-203 Link Here
199
        public boolean pathMatches(FileObject fileObject) {
228
        public boolean pathMatches(FileObject fileObject) {
200
            return pattern.matcher(fileObject.getNameExt()).matches();
229
            return pattern.matcher(fileObject.getNameExt()).matches();
201
        }
230
        }
231
232
        @Override
233
        public boolean pathMatches(URI uri) {
234
            String path = uri.getPath();
235
            int lastSeparator = path.lastIndexOf("\\");
236
            if (lastSeparator == -1) {
237
                lastSeparator = path.lastIndexOf("/");
238
            }
239
            if (lastSeparator == -1) {
240
                return false;
241
            } else {
242
                String name = path.substring(lastSeparator + 1, path.length());
243
                return pattern.matcher(name).matches();
244
            }
245
        }
202
    }
246
    }
203
}
247
}
(-)a/api.search/src/org/netbeans/api/search/provider/SearchFilter.java (+31 lines)
Lines 41-46 Link Here
41
 */
41
 */
42
package org.netbeans.api.search.provider;
42
package org.netbeans.api.search.provider;
43
43
44
import java.net.URI;
44
import org.netbeans.api.annotations.common.NonNull;
45
import org.netbeans.api.annotations.common.NonNull;
45
import org.openide.filesystems.FileObject;
46
import org.openide.filesystems.FileObject;
46
47
Lines 88-93 Link Here
88
            throws IllegalArgumentException;
89
            throws IllegalArgumentException;
89
90
90
    /**
91
    /**
92
     * Answers a question whether a given URI should be searched. The URI must
93
     * stand for a plain file (not folder).
94
     *
95
     * @return
96
     * <code>true</code> if the given file should be searched;
97
     * <code>false</code> if not
98
     * @exception java.lang.IllegalArgumentException if the passed
99
     * <code>URI</code> is a folder
100
     *
101
     * @since org.netbeans.api.search/1.4
102
     */
103
    public abstract boolean searchFile(@NonNull URI fileUri);
104
105
    /**
91
     * Answers a questions whether a given folder should be traversed (its
106
     * Answers a questions whether a given folder should be traversed (its
92
     * contents searched). The passed argument must be a folder.
107
     * contents searched). The passed argument must be a folder.
93
     *
108
     *
Lines 100-103 Link Here
100
     */
115
     */
101
    public abstract @NonNull FolderResult traverseFolder(
116
    public abstract @NonNull FolderResult traverseFolder(
102
            @NonNull FileObject folder) throws IllegalArgumentException;
117
            @NonNull FileObject folder) throws IllegalArgumentException;
118
119
    /**
120
     * Answers a questions whether a given URI should be traversed (its
121
     * contents searched). The passed URI must stand for a folder.
122
     *
123
     * @return One of constants of {@link FolderResult}. If
124
     * <code>TRAVERSE_ALL_SUBFOLDERS</code> is returned, this filter will not be
125
     * applied on the folder's children (both direct and indirect, both files
126
     * and folders)
127
     * @exception java.lang.IllegalArgumentException if the passed
128
     * <code>URI</code> is not a folder
129
     *
130
     * @since org.netbeans.api.search/1.4
131
     */
132
    public abstract @NonNull FolderResult traverseFolder(
133
            @NonNull URI folderUri) throws IllegalArgumentException;
103
}
134
}
(-)a/api.search/src/org/netbeans/api/search/provider/SearchInfo.java (+67 lines)
Lines 41-46 Link Here
41
 */
41
 */
42
package org.netbeans.api.search.provider;
42
package org.netbeans.api.search.provider;
43
43
44
import java.net.URI;
44
import java.util.Iterator;
45
import java.util.Iterator;
45
import java.util.List;
46
import java.util.List;
46
import java.util.concurrent.atomic.AtomicBoolean;
47
import java.util.concurrent.atomic.AtomicBoolean;
Lines 95-100 Link Here
95
            @NonNull AtomicBoolean terminated);
96
            @NonNull AtomicBoolean terminated);
96
97
97
    /**
98
    /**
99
     * Create {@link Iterator} that iterates over all URIs in the search scope
100
     * that comply with search options and search filters.
101
     *
102
     * @param options Custom options. This object encapsulates custom search
103
     * filters, file name pattern and general search settings.
104
     * @param listener Listener that is notified when some important event
105
     * occurs during searching. Listener passed to {@link SearchComposition}
106
     * should be used here.
107
     * @param terminated Object that can be asked by the iterator whether the
108
     * search has been terminated.
109
     *
110
     * @return Iterator over all URIs that comply with specified options (in
111
     * the scope of this search info).
112
     *
113
     * @since org.netbeans.api.search/1.4
114
     */
115
    protected abstract @NonNull Iterator<URI> createUrisToSearchIterator(
116
            @NonNull SearchScopeOptions options,
117
            @NonNull SearchListener listener,
118
            @NonNull AtomicBoolean terminated);
119
120
    /**
98
     * Get {@link Iterable} that iterates over all files in the search scope
121
     * Get {@link Iterable} that iterates over all files in the search scope
99
     * that comply with search options and search filters.
122
     * that comply with search options and search filters.
100
     *
123
     *
Lines 135-138 Link Here
135
            }
158
            }
136
        };
159
        };
137
    }
160
    }
161
162
    /**
163
     * Get {@link Iterable} that iterates over all URIs in the search scope
164
     * that comply with search options and search filters.
165
     *
166
     * @param options Custom options. This object encapsulates custom search
167
     * filters, file name pattern and general search settings.
168
     * @param listener Listener that is notified when some important event
169
     * occurs during searching. Listener passed to {@link SearchComposition}
170
     * should be used here.
171
     * @param terminated Object that can be asked by the iterator whether
172
     * the search has been terminated.
173
     *
174
     * <div class="nonnormative">
175
     * <p>
176
     *  This method can be used in for-each loops:
177
     * </p>
178
     * <pre>
179
     * {@code
180
     * for (URI uri: searchInfo.getUrisToSearch(opts,listnr,term) {
181
     *   ResultType result = somehowCheckFileContentMatches(fo);
182
     *   if (result != null) {
183
     *     searchResultsDisplayer.addMatchingObject(result);
184
     *   }
185
     * }}
186
     * </pre>
187
     * </div>
188
     *
189
     * @since org.netbeans.api.search/1.4
190
     */
191
    public final @NonNull Iterable<URI> getUrisToSearch(
192
            @NonNull final SearchScopeOptions options,
193
            @NonNull final SearchListener listener,
194
            @NonNull final AtomicBoolean terminated) {
195
196
        return new Iterable<URI>() {
197
198
            @Override
199
            public Iterator<URI> iterator() {
200
                return createUrisToSearchIterator(options, listener,
201
                        terminated);
202
            }
203
        };
204
    }
138
}
205
}
(-)a/api.search/src/org/netbeans/api/search/provider/SearchListener.java (+15 lines)
Lines 41-46 Link Here
41
 */
41
 */
42
package org.netbeans.api.search.provider;
42
package org.netbeans.api.search.provider;
43
43
44
import java.net.URI;
44
import org.netbeans.api.annotations.common.NonNull;
45
import org.netbeans.api.annotations.common.NonNull;
45
import org.netbeans.api.annotations.common.NullAllowed;
46
import org.netbeans.api.annotations.common.NullAllowed;
46
import org.netbeans.spi.search.SearchFilterDefinition;
47
import org.netbeans.spi.search.SearchFilterDefinition;
Lines 69-74 Link Here
69
    }
70
    }
70
71
71
    /**
72
    /**
73
     * Called when a file is skipped - filtered out by a filter.
74
     *
75
     * @param uri the skipped URI.
76
     * @param filter filter that filtered out the file (can be null).
77
     * @param message message describing reasons for skipping (can be null).
78
     *
79
     * @since org.netbeans.api.search/1.4
80
     */
81
    public void fileSkipped(@NonNull URI uri,
82
            @NullAllowed SearchFilterDefinition filter,
83
            @NullAllowed String message) {
84
    }
85
86
    /**
72
     * Called when a directory was visited.
87
     * Called when a directory was visited.
73
     *
88
     *
74
     * @param path Path of the visited directory.
89
     * @param path Path of the visited directory.
(-)a/api.search/src/org/netbeans/api/search/provider/impl/AbstractCompoundIterator.java (+172 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.api.search.provider.impl;
43
44
import java.util.Iterator;
45
import java.util.NoSuchElementException;
46
import java.util.concurrent.atomic.AtomicBoolean;
47
import org.netbeans.api.search.SearchScopeOptions;
48
import org.netbeans.api.search.provider.SearchListener;
49
50
/**
51
 *
52
 * @author jhavlin
53
 */
54
public abstract class AbstractCompoundIterator<E, T> implements Iterator<T> {
55
56
    /**
57
     *
58
     */
59
    private final E[] elements;
60
    /**
61
     *
62
     */
63
    private int elementIndex;
64
    /**
65
     *
66
     */
67
    private Iterator<T> elementIterator = null;
68
    /**
69
     *
70
     */
71
    private T nextObject;
72
    /**
73
     *
74
     */
75
    private boolean upToDate;
76
    private SearchScopeOptions options;
77
    private SearchListener listener;
78
    private AtomicBoolean terminated;
79
80
    /**
81
     * Creates a new instance of
82
     * <code>CompoundSearchIterator</code>.
83
     *
84
     * @param elements elements of the compound iterator
85
     * @exception java.lang.IllegalArgumentException if the argument is
86
     * <code>null</code>
87
     */
88
    public AbstractCompoundIterator(E[] elements,
89
            SearchScopeOptions options, SearchListener listener,
90
            AtomicBoolean terminated) {
91
92
        if (elements == null) {
93
            throw new IllegalArgumentException("Elements are null");    //NOI18N
94
        } else if (options == null) {
95
            throw new IllegalArgumentException("Options are null");     //NOI18N
96
        }
97
98
        this.options = options;
99
100
        if (elements.length == 0) {
101
            this.elements = null;
102
            elementIndex = 0;
103
            upToDate = true;                //hasNext() returns always false
104
        } else {
105
            this.elements = elements;
106
            upToDate = false;
107
        }
108
        this.listener = listener;
109
        this.terminated = terminated;
110
    }
111
112
    /**
113
     */
114
    @Override
115
    public boolean hasNext() {
116
        if (!upToDate) {
117
            update();
118
        }
119
        return (elements != null) && (elementIndex < elements.length);
120
    }
121
122
    /**
123
     */
124
    @Override
125
    public T next() {
126
        if (!hasNext()) {
127
            throw new NoSuchElementException();
128
        }
129
130
        upToDate = false;
131
        return nextObject;
132
    }
133
134
    /**
135
     */
136
    private void update() {
137
        assert upToDate == false;
138
139
        if (elementIterator == null) {
140
            elementIterator = getIteratorFor(elements[elementIndex = 0], options,
141
                    listener, terminated);
142
        }
143
144
        while (!elementIterator.hasNext()) {
145
            elements[elementIndex] = null;
146
147
            if (++elementIndex == elements.length) {
148
                break;
149
            }
150
            elementIterator = getIteratorFor(elements[elementIndex], options,
151
                    listener, terminated);
152
        }
153
154
        if (elementIndex < elements.length) {
155
            nextObject = elementIterator.next();
156
        } else {
157
            elementIterator = null;
158
            nextObject = null;
159
        }
160
161
        upToDate = true;
162
    }
163
164
    @Override
165
    public void remove() {
166
        throw new UnsupportedOperationException();
167
    }
168
169
    protected abstract Iterator<T> getIteratorFor(E element,
170
            SearchScopeOptions options, SearchListener listener,
171
            AtomicBoolean terminated);
172
}
(-)a/api.search/src/org/netbeans/api/search/provider/impl/CompoundSearchInfo.java (-2 / +40 lines)
Lines 43-48 Link Here
43
 */
43
 */
44
package org.netbeans.api.search.provider.impl;
44
package org.netbeans.api.search.provider.impl;
45
45
46
import java.net.URI;
46
import java.util.ArrayList;
47
import java.util.ArrayList;
47
import java.util.Collections;
48
import java.util.Collections;
48
import java.util.Iterator;
49
import java.util.Iterator;
Lines 114-123 Link Here
114
                searchableElements.add(element);
115
                searchableElements.add(element);
115
            }
116
            }
116
        }
117
        }
117
        return new CompoundSearchIterator(
118
        return new AbstractCompoundIterator<SearchInfo, FileObject>(
118
                searchableElements.toArray(
119
                searchableElements.toArray(
119
                new SearchInfo[searchableElements.size()]),
120
                new SearchInfo[searchableElements.size()]),
120
                options, listener, terminated);
121
                options, listener, terminated) {
122
            @Override
123
            protected Iterator<FileObject> getIteratorFor(SearchInfo element,
124
                    SearchScopeOptions options, SearchListener listener,
125
                    AtomicBoolean terminated) {
126
                return element.getFilesToSearch(options, listener,
127
                        terminated).iterator();
128
            }
129
        };
130
    }
131
132
    @Override
133
    protected Iterator<URI> createUrisToSearchIterator(
134
            SearchScopeOptions options, SearchListener listener,
135
            AtomicBoolean terminated) {
136
        if (elements == null) {
137
            return Collections.<URI>emptyList().iterator();
138
        }
139
140
        List<SearchInfo> searchableElements =
141
                new ArrayList<SearchInfo>(elements.length);
142
        for (SearchInfo element : elements) {
143
            if (element.canSearch()) {
144
                searchableElements.add(element);
145
            }
146
        }
147
        return new AbstractCompoundIterator<SearchInfo, URI>(
148
                searchableElements.toArray(
149
                new SearchInfo[searchableElements.size()]),
150
                options, listener, terminated) {
151
            @Override
152
            protected Iterator<URI> getIteratorFor(SearchInfo element,
153
                    SearchScopeOptions options, SearchListener listener,
154
                    AtomicBoolean terminated) {
155
                return element.getUrisToSearch(
156
                        options, listener, terminated).iterator();
157
            }
158
        };
121
    }
159
    }
122
160
123
    @Override
161
    @Override
(-)a/api.search/src/org/netbeans/api/search/provider/impl/CompoundSearchIterator.java (-167 lines)
Lines 1-167 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 2004-2007 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
package org.netbeans.api.search.provider.impl;
45
46
import java.util.Iterator;
47
import java.util.NoSuchElementException;
48
import java.util.concurrent.atomic.AtomicBoolean;
49
import org.netbeans.api.search.SearchScopeOptions;
50
import org.netbeans.api.search.provider.SearchInfo;
51
import org.netbeans.api.search.provider.SearchListener;
52
import org.openide.filesystems.FileObject;
53
54
/**
55
 *
56
 * @author Marian Petras
57
 */
58
public class CompoundSearchIterator extends AbstractFileObjectIterator {
59
60
    /**
61
     *
62
     */
63
    private final SearchInfo[] elements;
64
    /**
65
     *
66
     */
67
    private int elementIndex;
68
    /**
69
     *
70
     */
71
    private Iterator<FileObject> elementIterator = null;
72
    /**
73
     *
74
     */
75
    private FileObject nextObject;
76
    /**
77
     *
78
     */
79
    private boolean upToDate;
80
    private SearchScopeOptions options;
81
    private SearchListener listener;
82
    private AtomicBoolean terminated;
83
84
    /**
85
     * Creates a new instance of
86
     * <code>CompoundSearchIterator</code>.
87
     *
88
     * @param elements elements of the compound iterator
89
     * @exception java.lang.IllegalArgumentException if the argument is
90
     * <code>null</code>
91
     */
92
    public CompoundSearchIterator(SearchInfo[] elements,
93
            SearchScopeOptions options, SearchListener listener,
94
            AtomicBoolean terminated) {
95
96
        if (elements == null) {
97
            throw new IllegalArgumentException("Elements are null");    //NOI18N
98
        } else if (options == null) {
99
            throw new IllegalArgumentException("Options are null");     //NOI18N
100
        }
101
102
        this.options = options;
103
104
        if (elements.length == 0) {
105
            this.elements = null;
106
            elementIndex = 0;
107
            upToDate = true;                //hasNext() returns always false
108
        } else {
109
            this.elements = elements;
110
            upToDate = false;
111
        }
112
        this.listener = listener;
113
        this.terminated = terminated;
114
    }
115
116
    /**
117
     */
118
    @Override
119
    public boolean hasNext() {
120
        if (!upToDate) {
121
            update();
122
        }
123
        return (elements != null) && (elementIndex < elements.length);
124
    }
125
126
    /**
127
     */
128
    @Override
129
    public FileObject next() {
130
        if (!hasNext()) {
131
            throw new NoSuchElementException();
132
        }
133
134
        upToDate = false;
135
        return nextObject;
136
    }
137
138
    /**
139
     */
140
    private void update() {
141
        assert upToDate == false;
142
143
        if (elementIterator == null) {
144
            elementIterator = elements[elementIndex = 0].getFilesToSearch(options,
145
                    listener, terminated).iterator();
146
        }
147
148
        while (!elementIterator.hasNext()) {
149
            elements[elementIndex] = null;
150
151
            if (++elementIndex == elements.length) {
152
                break;
153
            }
154
            elementIterator = elements[elementIndex].getFilesToSearch(options,
155
                    listener, terminated).iterator();
156
        }
157
158
        if (elementIndex < elements.length) {
159
            nextObject = elementIterator.next();
160
        } else {
161
            elementIterator = null;
162
            nextObject = null;
163
        }
164
165
        upToDate = true;
166
    }
167
}
(-)a/api.search/src/org/netbeans/api/search/provider/impl/DelegatingSearchFilter.java (-3 / +18 lines)
Lines 41-46 Link Here
41
 */
41
 */
42
package org.netbeans.api.search.provider.impl;
42
package org.netbeans.api.search.provider.impl;
43
43
44
import java.net.URI;
44
import org.netbeans.api.search.provider.SearchFilter;
45
import org.netbeans.api.search.provider.SearchFilter;
45
import org.netbeans.spi.search.SearchFilterDefinition;
46
import org.netbeans.spi.search.SearchFilterDefinition;
46
import org.openide.filesystems.FileObject;
47
import org.openide.filesystems.FileObject;
Lines 63-74 Link Here
63
    }
64
    }
64
65
65
    @Override
66
    @Override
67
    public boolean searchFile(URI fileUri) {
68
        return definition.searchFile(fileUri);
69
    }
70
71
    @Override
72
    public FolderResult traverseFolder(URI folderUri)
73
            throws IllegalArgumentException {
74
        return definitionToClientFolderResult(
75
                definition.traverseFolder(folderUri));
76
    }
77
78
    @Override
66
    public FolderResult traverseFolder(FileObject folder)
79
    public FolderResult traverseFolder(FileObject folder)
67
            throws IllegalArgumentException {
80
            throws IllegalArgumentException {
81
        return definitionToClientFolderResult(
82
                definition.traverseFolder(folder));
83
    }
68
84
69
        SearchFilterDefinition.FolderResult result =
85
    private FolderResult definitionToClientFolderResult(
70
                definition.traverseFolder(folder);
86
            SearchFilterDefinition.FolderResult result) {
71
72
        switch (result) {
87
        switch (result) {
73
            case DO_NOT_TRAVERSE:
88
            case DO_NOT_TRAVERSE:
74
                return FolderResult.DO_NOT_TRAVERSE;
89
                return FolderResult.DO_NOT_TRAVERSE;
(-)a/api.search/src/org/netbeans/api/search/provider/impl/DelegatingSearchInfo.java (+8 lines)
Lines 41-46 Link Here
41
 */
41
 */
42
package org.netbeans.api.search.provider.impl;
42
package org.netbeans.api.search.provider.impl;
43
43
44
import java.net.URI;
44
import java.util.Iterator;
45
import java.util.Iterator;
45
import java.util.List;
46
import java.util.List;
46
import java.util.concurrent.atomic.AtomicBoolean;
47
import java.util.concurrent.atomic.AtomicBoolean;
Lines 76-81 Link Here
76
    }
77
    }
77
78
78
    @Override
79
    @Override
80
    protected Iterator<URI> createUrisToSearchIterator(
81
            SearchScopeOptions options, SearchListener listener,
82
            AtomicBoolean terminated) {
83
        return delegate.urisToSearch(options, listener, terminated);
84
    }
85
86
    @Override
79
    public boolean canSearch() {
87
    public boolean canSearch() {
80
        return delegate.canSearch();
88
        return delegate.canSearch();
81
    }
89
    }
(-)a/api.search/src/org/netbeans/api/search/provider/impl/EmptySearchInfo.java (+9 lines)
Lines 41-46 Link Here
41
 */
41
 */
42
package org.netbeans.api.search.provider.impl;
42
package org.netbeans.api.search.provider.impl;
43
43
44
import java.net.URI;
44
import java.util.Collections;
45
import java.util.Collections;
45
import java.util.Iterator;
46
import java.util.Iterator;
46
import java.util.List;
47
import java.util.List;
Lines 75-78 Link Here
75
76
76
        return Collections.<FileObject>emptyList().iterator();
77
        return Collections.<FileObject>emptyList().iterator();
77
    }
78
    }
79
80
    @Override
81
    public Iterator<URI> createUrisToSearchIterator(
82
            SearchScopeOptions options, SearchListener listener,
83
            AtomicBoolean terminated) {
84
85
        return Collections.<URI>emptyList().iterator();
86
    }
78
}
87
}
(-)a/api.search/src/org/netbeans/api/search/ui/ComponentUtils.java (-2 / +2 lines)
Lines 149-155 Link Here
149
     * @since api.search/1.1
149
     * @since api.search/1.1
150
     */
150
     */
151
    public static @NonNull SearchPatternController adjustComboForSearchPattern(
151
    public static @NonNull SearchPatternController adjustComboForSearchPattern(
152
            @NonNull JComboBox comboBox) {
152
            @NonNull JComboBox jComboBox) {
153
        return new SearchPatternController(comboBox);
153
        return new SearchPatternController(jComboBox);
154
    }
154
    }
155
}
155
}
(-)a/api.search/src/org/netbeans/modules/search/GraphicalSearchListener.java (-1 / +8 lines)
Lines 42-47 Link Here
42
package org.netbeans.modules.search;
42
package org.netbeans.modules.search;
43
43
44
import java.lang.reflect.InvocationTargetException;
44
import java.lang.reflect.InvocationTargetException;
45
import java.net.URI;
45
import java.util.ArrayList;
46
import java.util.ArrayList;
46
import java.util.Collection;
47
import java.util.Collection;
47
import java.util.List;
48
import java.util.List;
Lines 217-224 Link Here
217
    @Override
218
    @Override
218
    public void fileSkipped(FileObject fileObject,
219
    public void fileSkipped(FileObject fileObject,
219
            SearchFilterDefinition filter, String message) {
220
            SearchFilterDefinition filter, String message) {
221
        fileSkipped(fileObject.toURI(), filter, message);
222
    }
223
224
    @Override
225
    public void fileSkipped(URI uri, SearchFilterDefinition filter,
226
            String message) {
220
        LOG.log(Level.FINE, "{0} skipped {1} {2}", new Object[]{ //NOI18N
227
        LOG.log(Level.FINE, "{0} skipped {1} {2}", new Object[]{ //NOI18N
221
                    fileObject.getPath(),
228
                    uri.toString(),
222
                    filter != null ? filter.getClass().getName() : "", //NOI18N
229
                    filter != null ? filter.getClass().getName() : "", //NOI18N
223
                    message != null ? message : ""});                   //NOI18N
230
                    message != null ? message : ""});                   //NOI18N
224
    }
231
    }
(-)a/api.search/src/org/netbeans/spi/search/SearchFilterDefinition.java (+73 lines)
Lines 43-50 Link Here
43
 */
43
 */
44
package org.netbeans.spi.search;
44
package org.netbeans.spi.search;
45
45
46
import java.io.File;
47
import java.net.URI;
48
import java.util.logging.Level;
49
import java.util.logging.Logger;
46
import org.netbeans.api.annotations.common.NonNull;
50
import org.netbeans.api.annotations.common.NonNull;
47
import org.openide.filesystems.FileObject;
51
import org.openide.filesystems.FileObject;
52
import org.openide.filesystems.FileUtil;
48
53
49
/**
54
/**
50
 * Implementations of this class define which files and folders should be
55
 * Implementations of this class define which files and folders should be
Lines 55-60 Link Here
55
 */
60
 */
56
public abstract class SearchFilterDefinition {
61
public abstract class SearchFilterDefinition {
57
62
63
    private static final Logger LOG =
64
            Logger.getLogger(SearchFilterDefinition.class.getName());
58
    /**
65
    /**
59
     * Result of filtering a folder.
66
     * Result of filtering a folder.
60
     */
67
     */
Lines 107-110 Link Here
107
     */
114
     */
108
    public abstract @NonNull FolderResult traverseFolder(
115
    public abstract @NonNull FolderResult traverseFolder(
109
            @NonNull FileObject folder) throws IllegalArgumentException;
116
            @NonNull FileObject folder) throws IllegalArgumentException;
117
118
    /**
119
     * Answers a question whether a file with given URI should be searched. The
120
     * file must be URI of a plain file (not folder).
121
     *
122
     * The default implementation creates a {@link FileObject} instance for each
123
     * URI and passes it to {@link #searchFile(FileObject)}. Override to improve
124
     * performance.
125
     *
126
     * @return
127
     * <code>true</code> if the given file should be searched;
128
     * <code>false</code> if not
129
     * @exception java.lang.IllegalArgumentException if the passed
130
     * <code>FileObject</code> is a folder
131
     *
132
     * @since org.netbeans.api.search/1.4
133
     */
134
    public boolean searchFile(@NonNull URI uri) {
135
        File f = null;
136
        try {
137
            f = new File(uri);
138
        } catch (IllegalArgumentException iae) {
139
            LOG.log(Level.INFO, null, iae);
140
            return false;
141
        }
142
        FileObject fo = FileUtil.toFileObject(f);
143
        if (fo == null) {
144
            return false;
145
        } else {
146
            return searchFile(fo);
147
        }
148
    }
149
150
    /**
151
     * Answers a questions whether a folder with given URI should be traversed
152
     * (its contents searched). The passed argument must be URI of a folder.
153
     *
154
     * The default implementation creates a {@link FileObject} instance for each
155
     * URI and passes it to {@link #traverseFolder(FileObject)}. Override to
156
     * improve performance.
157
     *
158
     * @return One of constants of {@link FolderResult}. If
159
     * <code>TRAVERSE_ALL_SUBFOLDERS</code> is returned, this filter will not be
160
     * applied on the folder's children (both direct and indirect, both files
161
     * and folders)
162
     * @exception java.lang.IllegalArgumentException if the passed
163
     * <code>FileObject</code> is not a folder
164
     *
165
     * @since org.netbeans.api.search/1.4
166
     */
167
    public @NonNull FolderResult traverseFolder(
168
            @NonNull URI uri) throws IllegalArgumentException {
169
        File f = null;
170
        try {
171
            f = new File(uri);
172
        } catch (IllegalArgumentException iae) {
173
            LOG.log(Level.INFO, null, iae);
174
            return FolderResult.DO_NOT_TRAVERSE;
175
        }
176
        FileObject fo = FileUtil.toFileObject(f);
177
        if (fo == null) {
178
            return FolderResult.DO_NOT_TRAVERSE;
179
        } else {
180
            return traverseFolder(fo);
181
        }
182
    }
110
}
183
}
(-)a/api.search/src/org/netbeans/spi/search/SearchInfoDefinition.java (+49 lines)
Lines 43-48 Link Here
43
 */
43
 */
44
package org.netbeans.spi.search;
44
package org.netbeans.spi.search;
45
45
46
import java.net.URI;
46
import java.util.Iterator;
47
import java.util.Iterator;
47
import java.util.List;
48
import java.util.List;
48
import java.util.concurrent.atomic.AtomicBoolean;
49
import java.util.concurrent.atomic.AtomicBoolean;
Lines 153-156 Link Here
153
     * @return List of search roots.
154
     * @return List of search roots.
154
     */
155
     */
155
    public abstract @NonNull List<SearchRoot> getSearchRoots();
156
    public abstract @NonNull List<SearchRoot> getSearchRoots();
157
158
    /**
159
     * Specifies which
160
     * <code>URIs</code>s should be searched. The returned
161
     * <code>Iterator</code> needn't implement method
162
     * {@link java.util.Iterator#remove remove()} (i.e. it may throw
163
     * <code>UnsupportedOperationException</code> instead of actual
164
     * implementation).
165
     *
166
     * The default implementation uses internaly FileObject iterator returned by
167
     * {@link #filesToSearch(SearchScopeOptions, SearchListener, AtomicBoolean)}
168
     *
169
     * @param options File name pattern, traversing options and custom filters.
170
     * @param listener Listener that should be notified about important events
171
     * and progress.
172
     * @param terminated Object that can be asked whether the search has been
173
     * terminated by the user.
174
     * @return iterator which iterates over
175
     * <code>FileObject</code>s to be searched
176
     *
177
     * @since org.netbeans.api.search/1.4
178
     */
179
    public @NonNull
180
    Iterator<URI> urisToSearch(
181
            @NonNull SearchScopeOptions options,
182
            @NonNull SearchListener listener,
183
            @NonNull AtomicBoolean terminated) {
184
185
        final Iterator<FileObject> inner = filesToSearch(options,
186
                listener, terminated);
187
        return new Iterator<URI>() {
188
            @Override
189
            public boolean hasNext() {
190
                return inner.hasNext();
191
            }
192
193
            @Override
194
            public URI next() {
195
                FileObject next = inner.next();
196
                return next == null ? null : next.toURI();
197
            }
198
199
            @Override
200
            public void remove() {
201
                throw new UnsupportedOperationException();
202
            }
203
        };
204
    }
156
}
205
}
(-)a/api.search/src/org/netbeans/spi/search/impl/CompoundSearchInfoDefinition.java (-7 / +43 lines)
Lines 43-48 Link Here
43
 */
43
 */
44
package org.netbeans.spi.search.impl;
44
package org.netbeans.spi.search.impl;
45
45
46
import java.net.URI;
46
import java.util.ArrayList;
47
import java.util.ArrayList;
47
import java.util.Collections;
48
import java.util.Collections;
48
import java.util.Iterator;
49
import java.util.Iterator;
Lines 51-57 Link Here
51
import java.util.concurrent.atomic.AtomicBoolean;
52
import java.util.concurrent.atomic.AtomicBoolean;
52
import org.netbeans.api.search.SearchRoot;
53
import org.netbeans.api.search.SearchRoot;
53
import org.netbeans.api.search.SearchScopeOptions;
54
import org.netbeans.api.search.SearchScopeOptions;
54
import org.netbeans.api.search.provider.SearchInfo;
55
import org.netbeans.api.search.provider.SearchListener;
55
import org.netbeans.api.search.provider.SearchListener;
56
import org.netbeans.api.search.provider.impl.*;
56
import org.netbeans.api.search.provider.impl.*;
57
import org.netbeans.spi.search.SearchInfoDefinition;
57
import org.netbeans.spi.search.SearchInfoDefinition;
Lines 108-124 Link Here
108
            return Collections.<FileObject>emptyList().iterator();
108
            return Collections.<FileObject>emptyList().iterator();
109
        }
109
        }
110
110
111
        List<SearchInfo> searchableElements =
111
        List<SearchInfoDefinition> searchableElements =
112
                new ArrayList<SearchInfo>(elements.length);
112
                new ArrayList<SearchInfoDefinition>(elements.length);
113
        for (SearchInfoDefinition element : elements) {
113
        for (SearchInfoDefinition element : elements) {
114
            if (element.canSearch()) {
114
            if (element.canSearch()) {
115
                searchableElements.add(new DelegatingSearchInfo(element));
115
                searchableElements.add(element);
116
            }
116
            }
117
        }
117
        }
118
        return new CompoundSearchIterator(
118
        return new AbstractCompoundIterator<SearchInfoDefinition, FileObject>(
119
                searchableElements.toArray(
119
                searchableElements.toArray(
120
                new SearchInfo[searchableElements.size()]),
120
                new SearchInfoDefinition[searchableElements.size()]),
121
                options, listener, terminated);
121
                options, listener, terminated) {
122
            @Override
123
            protected Iterator<FileObject> getIteratorFor(
124
                    SearchInfoDefinition element, SearchScopeOptions options,
125
                    SearchListener listener, AtomicBoolean terminated) {
126
                return element.filesToSearch(options, listener, terminated);
127
            }
128
        };
129
    }
130
131
    /**
132
     */
133
    @Override
134
    public Iterator<URI> urisToSearch(SearchScopeOptions options,
135
            SearchListener listener, AtomicBoolean terminated) {
136
        if (elements == null) {
137
            return Collections.<URI>emptyList().iterator();
138
        }
139
140
        List<SearchInfoDefinition> searchableElements =
141
                new ArrayList<SearchInfoDefinition>(elements.length);
142
        for (SearchInfoDefinition element : elements) {
143
            if (element.canSearch()) {
144
                searchableElements.add(element);
145
            }
146
        }
147
        return new AbstractCompoundIterator<SearchInfoDefinition, URI>(
148
                searchableElements.toArray(
149
                new SearchInfoDefinition[searchableElements.size()]),
150
                options, listener, terminated) {
151
            @Override
152
            protected Iterator<URI> getIteratorFor(
153
                    SearchInfoDefinition element, SearchScopeOptions options,
154
                    SearchListener listener, AtomicBoolean terminated) {
155
                return element.urisToSearch(options, listener, terminated);
156
            }
157
        };
122
    }
158
    }
123
159
124
    @Override
160
    @Override
(-)a/api.search/src/org/netbeans/spi/search/impl/SharabilityFilter.java (+24 lines)
Lines 44-49 Link Here
44
package org.netbeans.spi.search.impl;
44
package org.netbeans.spi.search.impl;
45
45
46
import java.io.File;
46
import java.io.File;
47
import java.net.URI;
47
import org.netbeans.api.queries.SharabilityQuery;
48
import org.netbeans.api.queries.SharabilityQuery;
48
import org.netbeans.api.queries.SharabilityQuery.Sharability;
49
import org.netbeans.api.queries.SharabilityQuery.Sharability;
49
import org.netbeans.spi.search.SearchFilterDefinition;
50
import org.netbeans.spi.search.SearchFilterDefinition;
Lines 80-85 Link Here
80
        }
81
        }
81
    }
82
    }
82
83
84
    @Override
85
    public boolean searchFile(URI uri) {
86
        return SharabilityQuery.getSharability(uri)
87
                != Sharability.NOT_SHARABLE;
88
    }
89
90
    @Override
91
    public FolderResult traverseFolder(URI uri)
92
            throws IllegalArgumentException {
93
        switch (SharabilityQuery.getSharability(uri)) {
94
            case SHARABLE:
95
                return FolderResult.TRAVERSE_ALL_SUBFOLDERS;
96
            case MIXED:
97
                return FolderResult.TRAVERSE;
98
            case UNKNOWN:
99
                return FolderResult.TRAVERSE;
100
            case NOT_SHARABLE:
101
                return FolderResult.DO_NOT_TRAVERSE;
102
            default:
103
                return FolderResult.TRAVERSE;
104
        }
105
    }
106
83
    /**
107
    /**
84
     */
108
     */
85
    @Override
109
    @Override
(-)a/api.search/src/org/netbeans/spi/search/impl/SubnodesSearchInfoDefinition.java (-3 / +11 lines)
Lines 54-60 Link Here
54
import org.netbeans.api.search.provider.SearchInfo;
54
import org.netbeans.api.search.provider.SearchInfo;
55
import org.netbeans.api.search.provider.SearchInfoUtils;
55
import org.netbeans.api.search.provider.SearchInfoUtils;
56
import org.netbeans.api.search.provider.SearchListener;
56
import org.netbeans.api.search.provider.SearchListener;
57
import org.netbeans.api.search.provider.impl.CompoundSearchIterator;
57
import org.netbeans.api.search.provider.impl.AbstractCompoundIterator;
58
import org.netbeans.spi.search.SearchInfoDefinition;
58
import org.netbeans.spi.search.SearchInfoDefinition;
59
import org.openide.filesystems.FileObject;
59
import org.openide.filesystems.FileObject;
60
import org.openide.nodes.Children;
60
import org.openide.nodes.Children;
Lines 112-121 Link Here
112
                return searchInfoElements.get(0).getFilesToSearch(
112
                return searchInfoElements.get(0).getFilesToSearch(
113
                        options, listener, terminated).iterator();
113
                        options, listener, terminated).iterator();
114
            default:
114
            default:
115
                return new CompoundSearchIterator(
115
                return new AbstractCompoundIterator<SearchInfo, FileObject>(
116
                        searchInfoElements.toArray(
116
                        searchInfoElements.toArray(
117
                        new SearchInfo[size]),
117
                        new SearchInfo[size]),
118
                        options, listener, terminated);
118
                        options, listener, terminated) {
119
                    @Override
120
                    protected Iterator<FileObject> getIteratorFor(
121
                            SearchInfo element, SearchScopeOptions options,
122
                            SearchListener listener, AtomicBoolean terminated) {
123
                        return element.getFilesToSearch(
124
                                options, listener, terminated).iterator();
125
                    }
126
                };
119
        }
127
        }
120
    }
128
    }
121
129
(-)a/api.search/src/org/netbeans/spi/search/impl/VisibilityFilter.java (+1 lines)
Lines 43-48 Link Here
43
 */
43
 */
44
package org.netbeans.spi.search.impl;
44
package org.netbeans.spi.search.impl;
45
45
46
import java.net.URI;
46
import java.util.logging.Level;
47
import java.util.logging.Level;
47
import java.util.logging.Logger;
48
import java.util.logging.Logger;
48
import org.netbeans.api.queries.VisibilityQuery;
49
import org.netbeans.api.queries.VisibilityQuery;
(-)a/api.search/src/org/netbeans/spi/search/provider/SearchResultsDisplayer.java (-1 / +1 lines)
Lines 127-133 Link Here
127
     * Set node that display information from the search listener.
127
     * Set node that display information from the search listener.
128
     *
128
     *
129
     * This method is called right after a new displayer is created, before
129
     * This method is called right after a new displayer is created, before
130
     * method {@link #getVisualComponent().
130
     * method {@link #getVisualComponent()}.
131
     *
131
     *
132
     * The default implementation does nothing. Override it if you want to add
132
     * The default implementation does nothing. Override it if you want to add
133
     * the info node to your UI.
133
     * the info node to your UI.
(-)a/api.search/test/unit/src/org/netbeans/modules/search/MatchingObjectTest.java (+9 lines)
Lines 42-47 Link Here
42
import java.io.OutputStream;
42
import java.io.OutputStream;
43
import java.io.OutputStreamWriter;
43
import java.io.OutputStreamWriter;
44
import java.lang.reflect.InvocationTargetException;
44
import java.lang.reflect.InvocationTargetException;
45
import java.net.URI;
45
import java.nio.charset.Charset;
46
import java.nio.charset.Charset;
46
import java.util.Collections;
47
import java.util.Collections;
47
import java.util.Iterator;
48
import java.util.Iterator;
Lines 213-218 Link Here
213
        @Override
214
        @Override
214
        public SearchInfo getSearchInfo() {
215
        public SearchInfo getSearchInfo() {
215
            return new SearchInfo() {
216
            return new SearchInfo() {
217
218
                @Override
219
                protected Iterator<URI> createUrisToSearchIterator(
220
                        SearchScopeOptions options, SearchListener listener,
221
                        AtomicBoolean terminated) {
222
                    throw new UnsupportedOperationException(
223
                            "Not supported yet.");                      //NOI18N
224
                }
216
                @Override
225
                @Override
217
                public boolean canSearch() {
226
                public boolean canSearch() {
218
                    return true;
227
                    return true;

Return to bug 211855