--- a/refactoring.api/apichanges.xml +++ a/refactoring.api/apichanges.xml @@ -49,6 +49,24 @@ Refactoring API + + + Scope added to allow to specify a limited scope for WhereUsedQuery + + + + + +

+ Scope is used to limit the WhereUsedQuery to a specific scope.
+ An instance is added to the context of WhereUsedQuery to limit the + scope. A custom scope can be any combination of source roots, folders + and files. +

+
+ + +
ExplorerContext added to allow handling of Explorer's Move, Copy, Delete and Rename actions --- a/refactoring.api/manifest.mf +++ a/refactoring.api/manifest.mf @@ -2,6 +2,6 @@ OpenIDE-Module: org.netbeans.modules.refactoring.api OpenIDE-Module-Layer: org/netbeans/modules/refactoring/api/resources/layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/refactoring/api/resources/Bundle.properties -OpenIDE-Module-Specification-Version: 1.17 +OpenIDE-Module-Specification-Version: 1.18 AutoUpdate-Show-In-Client: false --- a/refactoring.api/src/org/netbeans/modules/refactoring/api/Scope.java +++ a/refactoring.api/src/org/netbeans/modules/refactoring/api/Scope.java @@ -0,0 +1,123 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 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 2011 Sun Microsystems, Inc. + */ +package org.netbeans.modules.refactoring.api; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import org.netbeans.api.annotations.common.NonNull; +import org.netbeans.api.annotations.common.NullAllowed; +import org.netbeans.api.fileinfo.NonRecursiveFolder; +import org.openide.filesystems.FileObject; + + +/** + * Scope is used to limit the WhereUsedQuery to a specific scope. + * Add an instance of this class to the context of the WhereUsedQuery to limit + * the scope. A custom scope can be any combination of source roots, folders and + * files. + * + * @author Ralph Ruijs + * @see Context + * @since 1.18 + */ +public final class Scope { + + private final Set sourceRoots; + private final Set folders; + private final Set files; + + private Scope() { + folders = new HashSet(); + sourceRoots = new HashSet(); + files = new HashSet(); + } + + /** + * Get the files to include in the where used query. + * @return an unmodifiable set of the files + */ + public @NonNull Set getFiles() { + return Collections.unmodifiableSet(files); + } + + /** + * Get the non recursive folders to include in the where used query. + * @return an unmodifiable set of the folders + */ + public @NonNull Set getFolders() { + return Collections.unmodifiableSet(folders); + } + + /** + * Get the source roots to include in the where used query. + * @return an unmodifiable set of the source roots + */ + public @NonNull Set getSourceRoots() { + return Collections.unmodifiableSet(sourceRoots); + } + + /** + * Creates a new scope. + * A custom scope can be any combination of source roots, folders and files. + * + * @param sourceRoots the source roots to include in this scope + * @param folders the non recursive folders to include in this scope + * @param files the files to include in this scope + */ + public static @NonNull Scope create(@NullAllowed Collection sourceRoots, + @NullAllowed Collection folders, + @NullAllowed Collection files) { + Scope scope = new Scope(); + if (files != null) { + scope.files.addAll(files); + } + if (folders != null) { + scope.folders.addAll(folders); + } + if (sourceRoots != null) { + scope.sourceRoots.addAll(sourceRoots); + } + return scope; + } +}