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

(-)a/refactoring.api/apichanges.xml (+18 lines)
Lines 49-54 Link Here
49
    <apidef name="refactoring">Refactoring API</apidef>
49
    <apidef name="refactoring">Refactoring API</apidef>
50
</apidefs>
50
</apidefs>
51
<changes>
51
<changes>
52
    <change id="Scope">
53
        <api name="refactoring"/>
54
        <summary>Scope added to allow to specify a limited scope for WhereUsedQuery</summary>
55
        <version major="1" minor="18"/>
56
        <date day="30" month="6" year="2011"/>
57
        <author login="ralphbenjamin"/>
58
        <compatibility addition="yes"/>
59
        <description>
60
            <p>
61
                Scope is used to limit the WhereUsedQuery to a specific scope.<br />
62
                An instance is added to the context of WhereUsedQuery to limit the
63
                scope. A custom scope can be any combination of source roots, folders
64
                and files.
65
            </p>    
66
        </description>
67
        <class package="org.netbeans.modules.refactoring.api" name="Scope"/>
68
        <issue number="199779"/>
69
    </change>
52
    <change id="ExplorerContext">
70
    <change id="ExplorerContext">
53
        <api name="refactoring"/>
71
        <api name="refactoring"/>
54
        <summary>ExplorerContext added to allow handling of Explorer's Move, Copy, Delete and Rename actions</summary>
72
        <summary>ExplorerContext added to allow handling of Explorer's Move, Copy, Delete and Rename actions</summary>
(-)a/refactoring.api/manifest.mf (-1 / +1 lines)
Lines 2-7 Link Here
2
OpenIDE-Module: org.netbeans.modules.refactoring.api
2
OpenIDE-Module: org.netbeans.modules.refactoring.api
3
OpenIDE-Module-Layer: org/netbeans/modules/refactoring/api/resources/layer.xml
3
OpenIDE-Module-Layer: org/netbeans/modules/refactoring/api/resources/layer.xml
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/refactoring/api/resources/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/refactoring/api/resources/Bundle.properties
5
OpenIDE-Module-Specification-Version: 1.17
5
OpenIDE-Module-Specification-Version: 1.18
6
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Show-In-Client: false
7
7
(-)a/refactoring.api/src/org/netbeans/modules/refactoring/api/Scope.java (+124 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 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 2011 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.refactoring.api;
43
44
import java.util.Collections;
45
import java.util.HashMap;
46
import java.util.HashSet;
47
import java.util.Map;
48
import java.util.Set;
49
import javax.tools.FileObject;
50
import org.netbeans.api.annotations.common.NonNull;
51
import org.netbeans.api.fileinfo.NonRecursiveFolder;
52
import org.openide.util.Parameters;
53
54
55
/**
56
 * Scope is used to limit the WhereUsedQuery to a specific scope.
57
 * Add an instance of this class to the context of the WhereUsedQuery to limit
58
 * the scope. A custom scope can be any combination of source roots, folders and
59
 * files.
60
 * 
61
 * @author Ralph Ruijs
62
 * @see Context
63
 * @since 1.18
64
 */
65
public final class Scope {
66
67
    private final Set<FileObject> sourceRoots;
68
    private final Map<FileObject, Set<NonRecursiveFolder>> folders;
69
    private final Set<FileObject> files;
70
71
    /**
72
     * Creates a new empty scope.
73
     */
74
    public Scope() {
75
        folders = new HashMap<FileObject, Set<NonRecursiveFolder>>();
76
        sourceRoots = new HashSet<FileObject>();
77
        files = new HashSet<FileObject>();
78
    }
79
80
    /**
81
     * Add files to this Set to include them in the where used query.
82
     * 
83
     * @return the files to include in the where used query
84
     */
85
    public @NonNull Set<FileObject> getFiles() {
86
        return files;
87
    }
88
89
    /**
90
     * Add NonRecursiveFolders to this Set to include them in the where used query.
91
     * 
92
     * @param sourceRoot - the source root, the folders belong to
93
     * @return the folders to include in the where used query
94
     */
95
    public @NonNull Set<NonRecursiveFolder> getFolders(@NonNull FileObject sourceRoot) {
96
        Parameters.notNull("sourceRoot", sourceRoot);
97
        Set<NonRecursiveFolder> folderSet = folders.get(sourceRoot);
98
        if (folderSet == null) {
99
            folderSet = new HashSet<NonRecursiveFolder>();
100
            folders.put(sourceRoot, folderSet);
101
        }
102
        return folderSet;
103
    }
104
105
    /**
106
     * Use the source roots returned by this method to find all the available
107
     * folders in this custom scope.
108
     * 
109
     * @see Scope#getFolders(org.openide.filesystems.FileObject) 
110
     * @return an unmodifiable Set of the source roots used for folders
111
     */
112
    public @NonNull Set<FileObject> getFoldersSourceRoots() {
113
        return Collections.unmodifiableSet(folders.keySet());
114
    }
115
116
    /**
117
     * Add SourceRoots to this Set to include them as a whole in the where used query.
118
     * 
119
     * @return the source roots to include in the where used query
120
     */
121
    public @NonNull Set<FileObject> getSourceRoots() {
122
        return sourceRoots;
123
    }
124
}

Return to bug 199779