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

(-)a/java.source/nbproject/project.xml (+9 lines)
Lines 191-196 Link Here
191
                    <compile-dependency/>
191
                    <compile-dependency/>
192
                    <run-dependency>
192
                    <run-dependency>
193
                        <specification-version>1.0</specification-version>
193
                        <specification-version>1.0</specification-version>
194
                    </run-dependency>
195
                </dependency>
196
                <dependency>
197
                    <code-name-base>org.netbeans.modules.java.project</code-name-base>
198
                    <build-prerequisite/>
199
                    <compile-dependency/>
200
                    <run-dependency>
201
                        <release-version>1</release-version>
202
                        <specification-version>1.18</specification-version>
194
                    </run-dependency>
203
                    </run-dependency>
195
                </dependency>
204
                </dependency>
196
                <dependency>
205
                <dependency>
(-)a/java.source/src/META-INF/services/org.netbeans.spi.java.project.support.ui.PackagesProvider (+1 lines)
Line 0 Link Here
1
org.netbeans.modules.java.source.usages.PackagesProviderImpl
(-)a/java.source/src/org/netbeans/modules/java/source/usages/PackagesProviderImpl.java (+106 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 * 
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 * 
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 * 
35
 * Contributor(s):
36
 * 
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.java.source.usages;
41
42
import java.io.IOException;
43
import org.netbeans.api.project.SourceGroup;
44
import org.netbeans.spi.java.project.support.ui.PackagesProvider;
45
import org.openide.filesystems.FileObject;
46
import org.openide.util.Exceptions;
47
48
/**
49
 *
50
 * @author Jan Lahoda
51
 */
52
public class PackagesProviderImpl implements PackagesProvider {
53
54
    public void compute(Request request, Response response) {
55
        try {
56
            String packages = RepositoryUpdater.getAttribute(request.getSourceGroup().getRootFolder().getURL(), "contained-packages", null);
57
            
58
            if (packages == null) {
59
                return;
60
            }
61
            
62
            FileObject current = request.getSourceGroup().getRootFolder();
63
            
64
            process(current, packages, new int[1], request.getSourceGroup(), response);
65
            
66
            response.finish();
67
        } catch (IOException ex) {
68
            Exceptions.printStackTrace(ex);
69
        }
70
    }
71
72
    private void process(FileObject current, String packages, int[] index, SourceGroup sg, Response response) {
73
        StringBuilder name = new StringBuilder();
74
        
75
        while (packages.charAt(index[0]) != '(') {
76
            name.append(packages.charAt(index[0]));
77
            index[0]++;
78
        }
79
80
        FileObject f = current.getFileObject(name.toString());
81
82
        index[0]++;
83
        
84
        boolean hasSubPackages = packages.charAt(index[0]) != ')';
85
86
        while (packages.charAt(index[0]) != ')') {
87
            process(f, packages, index, sg, response);
88
        }
89
        
90
        index[0]++;
91
        
92
        boolean hasFiles = packages.charAt(index[0]) == '+';
93
        
94
        index[0]++;
95
        
96
        if (f == null) {
97
            //XXX: warn
98
            return;
99
        }
100
        
101
        if (!hasSubPackages || hasFiles) {
102
            response.addPackage(sg, f, !hasFiles);
103
        }
104
    }
105
106
}
(-)a/java.source/src/org/netbeans/modules/java/source/usages/RepositoryUpdater.java (-10 / +23 lines)
Lines 2166-2171 Link Here
2166
                final Map<URI, List<String>> misplacedSource2FQNs = new HashMap<URI, List<String>>();
2166
                final Map<URI, List<String>> misplacedSource2FQNs = new HashMap<URI, List<String>>();
2167
                Map <String,List<File>> resources = getAllClassFiles(classCache, FileObjects.getRelativePath(rootFile,folderFile),true);
2167
                Map <String,List<File>> resources = getAllClassFiles(classCache, FileObjects.getRelativePath(rootFile,folderFile),true);
2168
                final FileList children = new FileList(folderFile);
2168
                final FileList children = new FileList(folderFile);
2169
                children.init();
2170
                setAttribute(root, "contained-packages", children.tree);
2169
                Set<File> compiledFiles = new HashSet<File>();
2171
                Set<File> compiledFiles = new HashSet<File>();
2170
                parseFiles(root, classCache, isInitialCompilation,
2172
                parseFiles(root, classCache, isInitialCompilation,
2171
                        children.getJavaFiles(), children.getVirtualJavaFiles(),
2173
                        children.getJavaFiles(), children.getVirtualJavaFiles(),
Lines 2696-2701 Link Here
2696
        private final List<File> javaFiles = new LinkedList<File>();
2698
        private final List<File> javaFiles = new LinkedList<File>();
2697
        private final List<File> virtualJavaFiles = new LinkedList<File>();
2699
        private final List<File> virtualJavaFiles = new LinkedList<File>();
2698
        private boolean initialized;
2700
        private boolean initialized;
2701
        private String tree;
2699
2702
2700
        public FileList (final File root) {
2703
        public FileList (final File root) {
2701
            assert root != null;
2704
            assert root != null;
Lines 2714-2744 Link Here
2714
        }
2717
        }
2715
        
2718
        
2716
        private synchronized void init () {
2719
        private synchronized void init () {
2717
            if (!initialized) {                
2720
            if (!initialized) {
2718
                collectFiles (root, javaFiles, virtualJavaFiles);
2721
                StringBuilder tree = new StringBuilder();
2722
                collectFiles (root, javaFiles, virtualJavaFiles, tree);
2723
                this.tree = tree.toString();
2719
                initialized = true;
2724
                initialized = true;
2720
            }
2725
            }
2721
        }
2726
        }
2722
        
2727
        
2723
        private static void collectFiles (final File root, final List<? super File> javaFiles,
2728
        private static void collectFiles (final File root, final List<? super File> javaFiles,
2724
                final List<? super File> virtualJavaFiles) {
2729
                final List<? super File> virtualJavaFiles, StringBuilder tree) {
2730
            tree.append('(');
2725
            final File[] content = root.listFiles();
2731
            final File[] content = root.listFiles();
2732
            boolean hasFiles = false;
2726
            if (content != null) {
2733
            if (content != null) {
2727
                for (File child : content) {
2734
                for (File child : content) {
2728
                    final String name = child.getName();
2735
                    final String name = child.getName();
2729
                    if (child.isDirectory() && !ignoredDirectories.contains(name)) {
2736
                    if (child.isDirectory() && !ignoredDirectories.contains(name)) {
2730
                        collectFiles(child, javaFiles, virtualJavaFiles);
2737
                        tree.append(name);
2738
                        collectFiles(child, javaFiles, virtualJavaFiles, tree);
2731
                    }
2739
                    }
2732
                    else if (name.endsWith('.'+JavaDataLoader.JAVA_EXTENSION)) { //NOI18N
2740
                    else {
2733
                        if (!PACKAGE_INFO.equals(name) && child.length()>0) {
2741
                        if (name.endsWith('.' + JavaDataLoader.JAVA_EXTENSION)) { //NOI18N
2734
                            javaFiles.add(child);
2742
                            if (!PACKAGE_INFO.equals(name) && child.length() > 0) {
2743
                                javaFiles.add(child);
2744
                            }
2745
                        } else if (VirtualSourceProviderQuery.hasVirtualSource(child)) {
2746
                            virtualJavaFiles.add(child);
2735
                        }
2747
                        }
2736
                    }
2748
                        
2737
                    else if (VirtualSourceProviderQuery.hasVirtualSource(child)) {
2749
                        hasFiles = true;
2738
                        virtualJavaFiles.add(child);
2739
                    }
2750
                    }
2740
                }
2751
                }
2741
            }
2752
            }
2753
            tree.append(')');
2754
            tree.append(hasFiles ? '+' : '-');
2742
        }        
2755
        }        
2743
    }
2756
    }
2744
2757

Return to bug 134555