diff --git a/csl.api/nbproject/project.xml b/csl.api/nbproject/project.xml --- a/csl.api/nbproject/project.xml +++ b/csl.api/nbproject/project.xml @@ -173,7 +173,7 @@ 1 - 1.2 + 1.20 diff --git a/csl.api/src/org/netbeans/modules/csl/core/TypeAndSymbolProvider.java b/csl.api/src/org/netbeans/modules/csl/core/TypeAndSymbolProvider.java --- a/csl.api/src/org/netbeans/modules/csl/core/TypeAndSymbolProvider.java +++ b/csl.api/src/org/netbeans/modules/csl/core/TypeAndSymbolProvider.java @@ -54,6 +54,7 @@ import org.netbeans.modules.csl.navigation.Icons; import org.netbeans.modules.parsing.api.Source; import org.netbeans.modules.parsing.spi.indexing.support.QuerySupport; +import org.netbeans.spi.jumpto.support.NameMatcherFactory; import org.netbeans.spi.jumpto.symbol.SymbolDescriptor; import org.netbeans.spi.jumpto.symbol.SymbolProvider; import org.netbeans.spi.jumpto.type.SearchType; @@ -262,31 +263,16 @@ case CASE_INSENSITIVE_PREFIX: return new Object [] { QuerySupport.Kind.CASE_INSENSITIVE_PREFIX, text }; case REGEXP: - return new Object [] { QuerySupport.Kind.REGEXP, wildcards2regexp(text) }; + return new Object [] { QuerySupport.Kind.REGEXP, NameMatcherFactory.wildcardsToRegexp(text,true) }; case CASE_INSENSITIVE_REGEXP: - return new Object [] { QuerySupport.Kind.CASE_INSENSITIVE_REGEXP, wildcards2regexp(text) }; + return new Object [] { QuerySupport.Kind.CASE_INSENSITIVE_REGEXP, NameMatcherFactory.wildcardsToRegexp(text,true) }; case CAMEL_CASE: return new Object [] { QuerySupport.Kind.CAMEL_CASE, text }; default: throw new IllegalStateException("Can't translate " + searchType + " to QuerySupport.Kind"); //NOI18N } } - - private static String wildcards2regexp(String pattern) { - return pattern. - replace("{",""). - replace("}",""). - replace("[",""). - replace("]",""). - replace("(",""). - replace(")",""). - replace("\\",""). - replace(".", "\\."). - replace( "*", ".*" ). - replace( '?', '.' ). - concat(".*"); //NOI18N - } - + private static final class TypeWrapper extends TypeDescriptor { private final IndexSearcher.Descriptor delegated; diff --git a/java.sourceui/nbproject/project.xml b/java.sourceui/nbproject/project.xml --- a/java.sourceui/nbproject/project.xml +++ b/java.sourceui/nbproject/project.xml @@ -98,7 +98,7 @@ 1 - 1.2 + 1.20 diff --git a/java.sourceui/src/org/netbeans/modules/java/source/ui/JavaSymbolProvider.java b/java.sourceui/src/org/netbeans/modules/java/source/ui/JavaSymbolProvider.java --- a/java.sourceui/src/org/netbeans/modules/java/source/ui/JavaSymbolProvider.java +++ b/java.sourceui/src/org/netbeans/modules/java/source/ui/JavaSymbolProvider.java @@ -82,6 +82,7 @@ import org.netbeans.modules.java.source.usages.ClasspathInfoAccessor; import org.netbeans.modules.java.source.usages.DocumentUtil; import org.netbeans.modules.parsing.spi.indexing.support.QuerySupport; +import org.netbeans.spi.jumpto.support.NameMatcherFactory; import org.netbeans.spi.jumpto.symbol.SymbolProvider; import org.netbeans.spi.jumpto.type.SearchType; import org.openide.filesystems.FileObject; @@ -126,7 +127,7 @@ case REGEXP: _kind = ClassIndex.NameKind.REGEXP; _ident[0] = removeNonJavaChars(_ident[0]); - _ident[0] = Util.wildcardsToRegexp(_ident[0],true); + _ident[0] = NameMatcherFactory.wildcardsToRegexp(_ident[0],true); _caseSensitive = true; break; case CAMEL_CASE: @@ -149,7 +150,7 @@ case CASE_INSENSITIVE_REGEXP: _kind = ClassIndex.NameKind.CASE_INSENSITIVE_REGEXP; _ident[0] = removeNonJavaChars(_ident[0]); - _ident[0] = Util.wildcardsToRegexp(_ident[0],true); + _ident[0] = NameMatcherFactory.wildcardsToRegexp(_ident[0],true); _caseSensitive = false; break; default: diff --git a/java.sourceui/src/org/netbeans/modules/java/source/ui/JavaTypeProvider.java b/java.sourceui/src/org/netbeans/modules/java/source/ui/JavaTypeProvider.java --- a/java.sourceui/src/org/netbeans/modules/java/source/ui/JavaTypeProvider.java +++ b/java.sourceui/src/org/netbeans/modules/java/source/ui/JavaTypeProvider.java @@ -73,6 +73,7 @@ import org.netbeans.modules.java.source.usages.ClassIndexManagerListener; import org.netbeans.modules.parsing.spi.indexing.support.QuerySupport; import org.netbeans.spi.java.classpath.support.ClassPathSupport; +import org.netbeans.spi.jumpto.support.NameMatcherFactory; import org.netbeans.spi.jumpto.type.SearchType; import org.netbeans.spi.jumpto.type.TypeProvider; import org.openide.filesystems.FileObject; @@ -293,7 +294,7 @@ case REGEXP: case CASE_INSENSITIVE_REGEXP: text = removeNonJavaChars(text); - textForQuery = Util.wildcardsToRegexp(text, searchType != SearchType.CASE_INSENSITIVE_EXACT_NAME); + textForQuery = NameMatcherFactory.wildcardsToRegexp(text, searchType != SearchType.CASE_INSENSITIVE_EXACT_NAME); break; default: textForQuery = text; diff --git a/java.sourceui/src/org/netbeans/modules/java/source/ui/Util.java b/java.sourceui/src/org/netbeans/modules/java/source/ui/Util.java deleted file mode 100644 --- a/java.sourceui/src/org/netbeans/modules/java/source/ui/Util.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2010 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): - * - * Portions Copyrighted 2010 Sun Microsystems, Inc. - */ - -package org.netbeans.modules.java.source.ui; - -/** - * - * @author Tomas Zezula - */ -final class Util { - - private Util() {} - - - //XXX move into jump to - static String wildcardsToRegexp(final String pattern, boolean prefix) { - String result = pattern. - replace("{",""). //NOI18N - replace("}",""). //NOI18N - replace("[",""). //NOI18N - replace("]",""). //NOI18N - replace("(",""). //NOI18N - replace(")",""). //NOI18N - replace("\\",""). //NOI18N - replace(".", "\\."). //NOI18N - replace( "*", ".*" ). //NOI18N - replace( '?', '.' ); //NOI18N - if (prefix) { - result = result.concat(".*"); //NOI18N - } - return result; - } - -} diff --git a/jumpto/apichanges.xml b/jumpto/apichanges.xml --- a/jumpto/apichanges.xml +++ b/jumpto/apichanges.xml @@ -108,6 +108,20 @@ + + + Added a method converting Go To Type (File) wildcards into regexp + + + + + + + Added a method converting Go To Type (File) wildcards into string accepted by java.util.regex.Pattern + + + + Added support SPI to implement name filters diff --git a/jumpto/manifest.mf b/jumpto/manifest.mf --- a/jumpto/manifest.mf +++ b/jumpto/manifest.mf @@ -2,5 +2,5 @@ OpenIDE-Module: org.netbeans.modules.jumpto/1 OpenIDE-Module-Layer: org/netbeans/modules/jumpto/resources/layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jumpto/resources/Bundle.properties -OpenIDE-Module-Specification-Version: 1.19 +OpenIDE-Module-Specification-Version: 1.20 AutoUpdate-Show-In-Client: false diff --git a/jumpto/src/org/netbeans/modules/jumpto/file/FileSearchAction.java b/jumpto/src/org/netbeans/modules/jumpto/file/FileSearchAction.java --- a/jumpto/src/org/netbeans/modules/jumpto/file/FileSearchAction.java +++ b/jumpto/src/org/netbeans/modules/jumpto/file/FileSearchAction.java @@ -487,11 +487,13 @@ break; case CASE_INSENSITIVE_REGEXP: searchField = FileIndexer.FIELD_CASE_INSENSITIVE_NAME; - indexQueryText = wildcards2regexp(text); + indexQueryText = NameMatcherFactory.wildcardsToRegexp(text,true); + Pattern.compile(indexQueryText); //Verify the pattern break; case REGEXP: searchField = FileIndexer.FIELD_NAME; - indexQueryText = wildcards2regexp(text); + indexQueryText = NameMatcherFactory.wildcardsToRegexp(text,true); + Pattern.compile(indexQueryText); //Verify the pattern break; default: searchField = FileIndexer.FIELD_NAME; @@ -607,24 +609,7 @@ LOGGER.log(Level.WARNING, null, ioe); return Collections.emptyList(); } - } - - private String wildcards2regexp(String pattern) throws PatternSyntaxException { - final String result = pattern. - replace("{",""). //NOI18N - replace("}",""). //NOI18N - replace("[",""). //NOI18N - replace("]",""). //NOI18N - replace("(",""). //NOI18N - replace(")",""). //NOI18N - replace("\\",""). //NOI18N - replace(".", "\\."). //NOI18N - replace( "*", ".*" ). //NOI18N - replace( '?', '.' ). //NOI18N - concat(".*"); //NOI18N - Pattern.compile(result); - return result; - } + } private SearchType toJumpToSearchType(final QuerySupport.Kind searchType) { switch (searchType) { diff --git a/jumpto/src/org/netbeans/spi/jumpto/support/NameMatcherFactory.java b/jumpto/src/org/netbeans/spi/jumpto/support/NameMatcherFactory.java --- a/jumpto/src/org/netbeans/spi/jumpto/support/NameMatcherFactory.java +++ b/jumpto/src/org/netbeans/spi/jumpto/support/NameMatcherFactory.java @@ -165,9 +165,9 @@ case PREFIX: return new PrefixNameMatcher(text); case REGEXP: - return new RegExpNameMatcher(wildcards2regexp(text), true); + return new RegExpNameMatcher(wildcardsToRegexp(text, true), true); case CASE_INSENSITIVE_REGEXP: - return new RegExpNameMatcher(wildcards2regexp(text), false); + return new RegExpNameMatcher(wildcardsToRegexp(text, true), false); case CASE_INSENSITIVE_PREFIX: return new CaseInsensitivePrefixNameMatcher(text); case CAMEL_CASE: @@ -181,8 +181,15 @@ } } - private static String wildcards2regexp(String pattern) { - return pattern. + /** + * Translates the wildcard pattern into regexp + * @param pattern the wildcard pattern to be translated into regexp + * @param prefix if true the pattern is extended by * + * @return the regular expression + * @since 1.20 + */ + public static String wildcardsToRegexp(final String pattern, boolean prefix) { + String result = pattern. replace("{",""). //NOI18N replace("}",""). //NOI18N replace("[",""). //NOI18N @@ -192,7 +199,10 @@ replace("\\",""). //NOI18N replace(".", "\\."). //NOI18N replace( "*", ".*" ). //NOI18N - replace( '?', '.' ). //NOI18N - concat(".*"); //NOI18N + replace( '?', '.' ); //NOI18N + if (prefix) { + result = result.concat(".*"); //NOI18N + } + return result; } }