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 191146
Collapse All | Expand All

(-)a/csl.api/nbproject/project.xml (-1 / +1 lines)
Lines 173-179 Link Here
173
                    <compile-dependency/>
173
                    <compile-dependency/>
174
                    <run-dependency>
174
                    <run-dependency>
175
                        <release-version>1</release-version>
175
                        <release-version>1</release-version>
176
                        <specification-version>1.2</specification-version>
176
                        <specification-version>1.20</specification-version>
177
                    </run-dependency>
177
                    </run-dependency>
178
                </dependency>
178
                </dependency>
179
                <dependency>
179
                <dependency>
(-)a/csl.api/src/org/netbeans/modules/csl/core/TypeAndSymbolProvider.java (-18 / +4 lines)
Lines 54-59 Link Here
54
import org.netbeans.modules.csl.navigation.Icons;
54
import org.netbeans.modules.csl.navigation.Icons;
55
import org.netbeans.modules.parsing.api.Source;
55
import org.netbeans.modules.parsing.api.Source;
56
import org.netbeans.modules.parsing.spi.indexing.support.QuerySupport;
56
import org.netbeans.modules.parsing.spi.indexing.support.QuerySupport;
57
import org.netbeans.spi.jumpto.support.NameMatcherFactory;
57
import org.netbeans.spi.jumpto.symbol.SymbolDescriptor;
58
import org.netbeans.spi.jumpto.symbol.SymbolDescriptor;
58
import org.netbeans.spi.jumpto.symbol.SymbolProvider;
59
import org.netbeans.spi.jumpto.symbol.SymbolProvider;
59
import org.netbeans.spi.jumpto.type.SearchType;
60
import org.netbeans.spi.jumpto.type.SearchType;
Lines 262-292 Link Here
262
            case CASE_INSENSITIVE_PREFIX:
263
            case CASE_INSENSITIVE_PREFIX:
263
                return new Object [] { QuerySupport.Kind.CASE_INSENSITIVE_PREFIX, text };
264
                return new Object [] { QuerySupport.Kind.CASE_INSENSITIVE_PREFIX, text };
264
            case REGEXP:
265
            case REGEXP:
265
                return new Object [] { QuerySupport.Kind.REGEXP, wildcards2regexp(text) };
266
                return new Object [] { QuerySupport.Kind.REGEXP, NameMatcherFactory.wildcardsToRegexp(text,true) };
266
            case CASE_INSENSITIVE_REGEXP:
267
            case CASE_INSENSITIVE_REGEXP:
267
                return new Object [] { QuerySupport.Kind.CASE_INSENSITIVE_REGEXP, wildcards2regexp(text) };
268
                return new Object [] { QuerySupport.Kind.CASE_INSENSITIVE_REGEXP, NameMatcherFactory.wildcardsToRegexp(text,true) };
268
            case CAMEL_CASE:
269
            case CAMEL_CASE:
269
                return new Object [] { QuerySupport.Kind.CAMEL_CASE, text };
270
                return new Object [] { QuerySupport.Kind.CAMEL_CASE, text };
270
            default:
271
            default:
271
                throw new IllegalStateException("Can't translate " + searchType + " to QuerySupport.Kind"); //NOI18N
272
                throw new IllegalStateException("Can't translate " + searchType + " to QuerySupport.Kind"); //NOI18N
272
        }
273
        }
273
    }
274
    }
274
275
    
275
    private static String wildcards2regexp(String pattern) {
276
        return pattern.
277
                replace("{","").
278
                replace("}","").
279
                replace("[","").
280
                replace("]","").
281
                replace("(","").
282
                replace(")","").
283
                replace("\\","").
284
                replace(".", "\\.").
285
                replace( "*", ".*" ).
286
                replace( '?', '.' ).
287
                concat(".*"); //NOI18N
288
    }
289
290
    private static final class TypeWrapper extends TypeDescriptor {
276
    private static final class TypeWrapper extends TypeDescriptor {
291
277
292
        private final IndexSearcher.Descriptor delegated;
278
        private final IndexSearcher.Descriptor delegated;
(-)a/java.sourceui/nbproject/project.xml (-1 / +1 lines)
Lines 98-104 Link Here
98
                    <compile-dependency/>
98
                    <compile-dependency/>
99
                    <run-dependency>
99
                    <run-dependency>
100
                        <release-version>1</release-version>
100
                        <release-version>1</release-version>
101
                        <specification-version>1.2</specification-version>
101
                        <specification-version>1.20</specification-version>
102
                    </run-dependency>
102
                    </run-dependency>
103
                </dependency>
103
                </dependency>
104
                <dependency>
104
                <dependency>
(-)a/java.sourceui/src/org/netbeans/modules/java/source/ui/JavaSymbolProvider.java (-2 / +3 lines)
Lines 82-87 Link Here
82
import org.netbeans.modules.java.source.usages.ClasspathInfoAccessor;
82
import org.netbeans.modules.java.source.usages.ClasspathInfoAccessor;
83
import org.netbeans.modules.java.source.usages.DocumentUtil;
83
import org.netbeans.modules.java.source.usages.DocumentUtil;
84
import org.netbeans.modules.parsing.spi.indexing.support.QuerySupport;
84
import org.netbeans.modules.parsing.spi.indexing.support.QuerySupport;
85
import org.netbeans.spi.jumpto.support.NameMatcherFactory;
85
import org.netbeans.spi.jumpto.symbol.SymbolProvider;
86
import org.netbeans.spi.jumpto.symbol.SymbolProvider;
86
import org.netbeans.spi.jumpto.type.SearchType;
87
import org.netbeans.spi.jumpto.type.SearchType;
87
import org.openide.filesystems.FileObject;
88
import org.openide.filesystems.FileObject;
Lines 126-132 Link Here
126
                case REGEXP:
127
                case REGEXP:
127
                    _kind = ClassIndex.NameKind.REGEXP;
128
                    _kind = ClassIndex.NameKind.REGEXP;
128
                    _ident[0] = removeNonJavaChars(_ident[0]);
129
                    _ident[0] = removeNonJavaChars(_ident[0]);
129
                    _ident[0] = Util.wildcardsToRegexp(_ident[0],true);
130
                    _ident[0] = NameMatcherFactory.wildcardsToRegexp(_ident[0],true);
130
                    _caseSensitive = true;
131
                    _caseSensitive = true;
131
                    break;
132
                    break;
132
                case CAMEL_CASE:
133
                case CAMEL_CASE:
Lines 149-155 Link Here
149
                case CASE_INSENSITIVE_REGEXP:
150
                case CASE_INSENSITIVE_REGEXP:
150
                    _kind = ClassIndex.NameKind.CASE_INSENSITIVE_REGEXP;
151
                    _kind = ClassIndex.NameKind.CASE_INSENSITIVE_REGEXP;
151
                    _ident[0] = removeNonJavaChars(_ident[0]);            
152
                    _ident[0] = removeNonJavaChars(_ident[0]);            
152
                    _ident[0] = Util.wildcardsToRegexp(_ident[0],true);
153
                    _ident[0] = NameMatcherFactory.wildcardsToRegexp(_ident[0],true);
153
                    _caseSensitive = false;
154
                    _caseSensitive = false;
154
                    break;
155
                    break;
155
                default:
156
                default:
(-)a/java.sourceui/src/org/netbeans/modules/java/source/ui/JavaTypeProvider.java (-1 / +2 lines)
Lines 73-78 Link Here
73
import org.netbeans.modules.java.source.usages.ClassIndexManagerListener;
73
import org.netbeans.modules.java.source.usages.ClassIndexManagerListener;
74
import org.netbeans.modules.parsing.spi.indexing.support.QuerySupport;
74
import org.netbeans.modules.parsing.spi.indexing.support.QuerySupport;
75
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
75
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
76
import org.netbeans.spi.jumpto.support.NameMatcherFactory;
76
import org.netbeans.spi.jumpto.type.SearchType;
77
import org.netbeans.spi.jumpto.type.SearchType;
77
import org.netbeans.spi.jumpto.type.TypeProvider;
78
import org.netbeans.spi.jumpto.type.TypeProvider;
78
import org.openide.filesystems.FileObject;
79
import org.openide.filesystems.FileObject;
Lines 293-299 Link Here
293
            case REGEXP:
294
            case REGEXP:
294
            case CASE_INSENSITIVE_REGEXP:
295
            case CASE_INSENSITIVE_REGEXP:
295
                text = removeNonJavaChars(text);
296
                text = removeNonJavaChars(text);
296
                textForQuery = Util.wildcardsToRegexp(text, searchType != SearchType.CASE_INSENSITIVE_EXACT_NAME);
297
                textForQuery = NameMatcherFactory.wildcardsToRegexp(text, searchType != SearchType.CASE_INSENSITIVE_EXACT_NAME);
297
                break;
298
                break;
298
            default:
299
            default:
299
                textForQuery = text;
300
                textForQuery = text;
(-)a/java.sourceui/src/org/netbeans/modules/java/source/ui/Util.java (-73 lines)
Lines 1-73 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 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
 * 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 2010 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.java.source.ui;
44
45
/**
46
 *
47
 * @author Tomas Zezula
48
 */
49
final class Util {
50
    
51
    private Util() {}
52
    
53
    
54
    //XXX move into jump to
55
    static String wildcardsToRegexp(final String pattern, boolean prefix) {
56
        String result = pattern.
57
                replace("{","").        //NOI18N
58
                replace("}","").        //NOI18N
59
                replace("[","").        //NOI18N
60
                replace("]","").        //NOI18N
61
                replace("(","").        //NOI18N
62
                replace(")","").        //NOI18N
63
                replace("\\","").       //NOI18N
64
                replace(".", "\\.").    //NOI18N
65
                replace( "*", ".*" ).   //NOI18N
66
                replace( '?', '.' );    //NOI18N
67
        if (prefix) {
68
            result = result.concat(".*");   //NOI18N
69
        }
70
        return result;
71
    }
72
73
}
(-)a/jumpto/apichanges.xml (+14 lines)
Lines 108-113 Link Here
108
    <!-- ACTUAL CHANGES BEGIN HERE: -->
108
    <!-- ACTUAL CHANGES BEGIN HERE: -->
109
109
110
    <changes>
110
    <changes>
111
        <change id="Wildcard-to-Regexp">
112
            <api name="general"/>
113
            <summary>Added a method converting Go To Type (File) wildcards into regexp</summary>
114
            <version major="1" minor="20"/>
115
            <date day="21" month="10" year="2010"/>
116
            <author login="tzezula"/>
117
            <compatibility addition="yes">
118
            </compatibility>
119
            <description>
120
                Added a method converting Go To Type (File) wildcards into string accepted by java.util.regex.Pattern
121
            </description>
122
            <class package="org.netbeans.spi.jumpto.support" name="NameMatcherFactory"/>
123
            <issue number="191145"/>
124
        </change>
111
        <change id="Support">
125
        <change id="Support">
112
            <api name="general"/>
126
            <api name="general"/>
113
            <summary>Added support SPI to implement name filters</summary>
127
            <summary>Added support SPI to implement name filters</summary>
(-)a/jumpto/manifest.mf (-1 / +1 lines)
Lines 2-6 Link Here
2
OpenIDE-Module: org.netbeans.modules.jumpto/1
2
OpenIDE-Module: org.netbeans.modules.jumpto/1
3
OpenIDE-Module-Layer: org/netbeans/modules/jumpto/resources/layer.xml
3
OpenIDE-Module-Layer: org/netbeans/modules/jumpto/resources/layer.xml
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jumpto/resources/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jumpto/resources/Bundle.properties
5
OpenIDE-Module-Specification-Version: 1.19
5
OpenIDE-Module-Specification-Version: 1.20
6
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Show-In-Client: false
(-)a/jumpto/src/org/netbeans/modules/jumpto/file/FileSearchAction.java (-20 / +5 lines)
Lines 487-497 Link Here
487
                        break;
487
                        break;
488
                    case CASE_INSENSITIVE_REGEXP:
488
                    case CASE_INSENSITIVE_REGEXP:
489
                        searchField = FileIndexer.FIELD_CASE_INSENSITIVE_NAME;
489
                        searchField = FileIndexer.FIELD_CASE_INSENSITIVE_NAME;
490
                        indexQueryText = wildcards2regexp(text);
490
                        indexQueryText = NameMatcherFactory.wildcardsToRegexp(text,true);
491
                        Pattern.compile(indexQueryText);    //Verify the pattern
491
                        break;
492
                        break;
492
                    case REGEXP:                        
493
                    case REGEXP:                        
493
                        searchField = FileIndexer.FIELD_NAME;
494
                        searchField = FileIndexer.FIELD_NAME;
494
                        indexQueryText = wildcards2regexp(text);
495
                        indexQueryText = NameMatcherFactory.wildcardsToRegexp(text,true);
496
                        Pattern.compile(indexQueryText);    //Verify the pattern
495
                        break;
497
                        break;
496
                    default:
498
                    default:
497
                        searchField = FileIndexer.FIELD_NAME;
499
                        searchField = FileIndexer.FIELD_NAME;
Lines 607-630 Link Here
607
                LOGGER.log(Level.WARNING, null, ioe);
609
                LOGGER.log(Level.WARNING, null, ioe);
608
                return Collections.<FileDescriptor>emptyList();
610
                return Collections.<FileDescriptor>emptyList();
609
            }
611
            }
610
        }
612
        }                
611
        
612
        private String wildcards2regexp(String pattern) throws PatternSyntaxException {                        
613
            final String result = pattern.
614
                    replace("{","").        //NOI18N
615
                    replace("}","").        //NOI18N
616
                    replace("[","").        //NOI18N
617
                    replace("]","").        //NOI18N
618
                    replace("(","").        //NOI18N
619
                    replace(")","").        //NOI18N
620
                    replace("\\","").       //NOI18N
621
                    replace(".", "\\.").    //NOI18N
622
                    replace( "*", ".*" ).   //NOI18N
623
                    replace( '?', '.' ).    //NOI18N
624
                    concat(".*"); //NOI18N
625
            Pattern.compile(result);
626
            return result;
627
        }
628
        
613
        
629
        private SearchType toJumpToSearchType(final QuerySupport.Kind searchType) {
614
        private SearchType toJumpToSearchType(final QuerySupport.Kind searchType) {
630
            switch (searchType) {
615
            switch (searchType) {
(-)a/jumpto/src/org/netbeans/spi/jumpto/support/NameMatcherFactory.java (-6 / +16 lines)
Lines 165-173 Link Here
165
                case PREFIX:
165
                case PREFIX:
166
                    return new PrefixNameMatcher(text);
166
                    return new PrefixNameMatcher(text);
167
                case REGEXP:
167
                case REGEXP:
168
                    return new RegExpNameMatcher(wildcards2regexp(text), true);
168
                    return new RegExpNameMatcher(wildcardsToRegexp(text, true), true);
169
                case CASE_INSENSITIVE_REGEXP:
169
                case CASE_INSENSITIVE_REGEXP:
170
                    return new RegExpNameMatcher(wildcards2regexp(text), false);
170
                    return new RegExpNameMatcher(wildcardsToRegexp(text, true), false);
171
                case CASE_INSENSITIVE_PREFIX:
171
                case CASE_INSENSITIVE_PREFIX:
172
                     return new CaseInsensitivePrefixNameMatcher(text);
172
                     return new CaseInsensitivePrefixNameMatcher(text);
173
                case CAMEL_CASE:
173
                case CAMEL_CASE:
Lines 181-188 Link Here
181
        }
181
        }
182
    }
182
    }
183
183
184
    private static String wildcards2regexp(String pattern) {
184
    /**
185
        return pattern.
185
     * Translates the wildcard pattern into regexp
186
     * @param pattern the wildcard pattern to be translated into regexp
187
     * @param prefix if true the pattern is extended by *
188
     * @return the regular expression
189
     * @since 1.20
190
     */
191
    public static String wildcardsToRegexp(final String pattern, boolean prefix) {
192
        String result = pattern.
186
                replace("{","").        //NOI18N
193
                replace("{","").        //NOI18N
187
                replace("}","").        //NOI18N
194
                replace("}","").        //NOI18N
188
                replace("[","").        //NOI18N
195
                replace("[","").        //NOI18N
Lines 192-198 Link Here
192
                replace("\\","").       //NOI18N
199
                replace("\\","").       //NOI18N
193
                replace(".", "\\.").    //NOI18N
200
                replace(".", "\\.").    //NOI18N
194
                replace( "*", ".*" ).   //NOI18N
201
                replace( "*", ".*" ).   //NOI18N
195
                replace( '?', '.' ).    //NOI18N
202
                replace( '?', '.' );    //NOI18N
196
                concat(".*"); //NOI18N
203
        if (prefix) {
204
            result = result.concat(".*");   //NOI18N
205
        }
206
        return result;
197
    }
207
    }
198
}
208
}

Return to bug 191146