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

(-)a/java.sourceui/src/org/netbeans/modules/java/source/ui/JavaTypeProvider.java (-16 / +55 lines)
Lines 29-34 Link Here
29
 * The Original Software is NetBeans. The Initial Developer of the Original
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
31
 * Microsystems, Inc. All Rights Reserved.
32
 * 
33
 * markiewb@netbeans.org
32
 *
34
 *
33
 * If you wish your version of this file to be governed by only the CDDL
35
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
36
 * or only the GPL Version 2, indicate your decision by adding
Lines 58-63 Link Here
58
import org.netbeans.api.java.queries.SourceForBinaryQuery;
60
import org.netbeans.api.java.queries.SourceForBinaryQuery;
59
import org.netbeans.api.java.source.ClassIndex;
61
import org.netbeans.api.java.source.ClassIndex;
60
import org.netbeans.api.java.source.ClassIndex.NameKind;
62
import org.netbeans.api.java.source.ClassIndex.NameKind;
63
import org.netbeans.api.java.source.ClassIndex.SearchScope;
64
import org.netbeans.api.java.source.ClassIndex.SearchScopeType;
61
import org.netbeans.api.java.source.ClasspathInfo;
65
import org.netbeans.api.java.source.ClasspathInfo;
62
import org.netbeans.api.java.source.ElementHandle;
66
import org.netbeans.api.java.source.ElementHandle;
63
import org.netbeans.api.java.source.SourceUtils;
67
import org.netbeans.api.java.source.SourceUtils;
Lines 87-93 Link Here
87
import org.openide.util.NbBundle;
91
import org.openide.util.NbBundle;
88
92
89
/**
93
/**
94
 * Type provider which searches for declared class/enum types. It supports
95
 * searching for fully qualified names - for example "java.util.Collections". As
96
 * a side effect it supports matches of (sub-)packages based on the given
97
 * package name - for example "java.C" searches in (sub-)packages with the
98
 * prefix 'java' for types with the prefix 'C'.
99
 *
90
 * @author Petr Hrebejk
100
 * @author Petr Hrebejk
101
 * @author markiewb
91
 */
102
 */
92
@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.jumpto.type.TypeProvider.class)
103
@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.jumpto.type.TypeProvider.class)
93
public class JavaTypeProvider implements TypeProvider {
104
public class JavaTypeProvider implements TypeProvider {
Lines 133-139 Link Here
133
    @Override
144
    @Override
134
    public void computeTypeNames(Context context, final Result res) {
145
    public void computeTypeNames(Context context, final Result res) {
135
        isCanceled = false;
146
        isCanceled = false;
136
        String text = context.getText();
147
        String originalText = context.getText();
137
        SearchType searchType = context.getSearchType();
148
        SearchType searchType = context.getSearchType();
138
149
139
        boolean hasBinaryOpen = Lookup.getDefault().lookup(BinaryElementOpen.class) != null;
150
        boolean hasBinaryOpen = Lookup.getDefault().lookup(BinaryElementOpen.class) != null;
Lines 291-308 Link Here
291
        } else {
302
        } else {
292
            res.setMessage(null);
303
            res.setMessage(null);
293
        }
304
        }
305
        int lastIndexOfDot = originalText.lastIndexOf(".");
306
        boolean isFullyQualifiedName = -1 != lastIndexOfDot;
307
        final String packageName = (isFullyQualifiedName) ? originalText.substring(0, lastIndexOfDot) : "";
308
        final String typeName = (isFullyQualifiedName) ? originalText.substring(lastIndexOfDot + 1) : originalText;
309
        final String textForQuery = getTextForQuery(typeName, nameKind, context.getSearchType());
294
310
295
        final String textForQuery;
311
        LOGGER.log(Level.FINE, "Text For Query ''{0}''.", originalText);
296
        switch( nameKind ) {
297
            case REGEXP:
298
            case CASE_INSENSITIVE_REGEXP:
299
                text = removeNonJavaChars(text);
300
                textForQuery = NameMatcherFactory.wildcardsToRegexp(text, searchType != SearchType.CASE_INSENSITIVE_EXACT_NAME);
301
                break;
302
            default:
303
                textForQuery = text;
304
        }
305
        LOGGER.log(Level.FINE, "Text For Query ''{0}''.", text);
306
        if (customizer != null) {
312
        if (customizer != null) {
307
            c = getCache();
313
            c = getCache();
308
            if (c != null) {
314
            if (c != null) {
Lines 351-359 Link Here
351
                                if (isCanceled) {
357
                                if (isCanceled) {
352
                                    return null;
358
                                    return null;
353
                                }
359
                                }
354
                                final Set<ElementHandle<TypeElement>> names = new HashSet<ElementHandle<TypeElement>> (ci.getDeclaredTypes(textForQuery,nameKind));
360
                                final Set<ElementHandle<TypeElement>> names = new HashSet<ElementHandle<TypeElement>> (ci.getDeclaredTypes(packageName, textForQuery,nameKind));
355
                                if (nameKind == ClassIndex.NameKind.CAMEL_CASE) {
361
                                if (nameKind == ClassIndex.NameKind.CAMEL_CASE) {
356
                                    names.addAll(ci.getDeclaredTypes(textForQuery, ClassIndex.NameKind.CASE_INSENSITIVE_PREFIX));
362
                                    names.addAll(ci.getDeclaredTypes(packageName, textForQuery, ClassIndex.NameKind.CASE_INSENSITIVE_PREFIX));
357
                                }
363
                                }
358
                                for (ElementHandle<TypeElement> name : names) {
364
                                for (ElementHandle<TypeElement> name : names) {
359
                                    JavaTypeDescription td = new JavaTypeDescription(ci, name);
365
                                    JavaTypeDescription td = new JavaTypeDescription(ci, name);
Lines 415-420 Link Here
415
        this.cache = cache;
421
        this.cache = cache;
416
    }
422
    }
417
423
424
    public static String getTextForQuery(String text, final NameKind nameKind, SearchType searchType) {
425
        String textForQuery;
426
        switch (nameKind) {
427
            case REGEXP:
428
            case CASE_INSENSITIVE_REGEXP:
429
                textForQuery = NameMatcherFactory.wildcardsToRegexp(removeNonJavaChars(text), searchType != SearchType.CASE_INSENSITIVE_EXACT_NAME);
430
                break;
431
            default:
432
                textForQuery = text;
433
        }
434
        return textForQuery;
435
    }
436
418
    //@NotTreadSafe
437
    //@NotTreadSafe
419
    static final class CacheItem {
438
    static final class CacheItem {
420
        
439
        
Lines 492-498 Link Here
492
            return cpInfo;
511
            return cpInfo;
493
        }
512
        }
494
        
513
        
495
        public  Set<ElementHandle<TypeElement>> getDeclaredTypes(final String name, final NameKind kind) {
514
        public  Set<ElementHandle<TypeElement>> getDeclaredTypes(final String packageName, final String typeName, final NameKind kind) {
496
            if (index == null) {
515
            if (index == null) {
497
                final ClassPath cp = ClassPathSupport.createClassPath(root);
516
                final ClassPath cp = ClassPathSupport.createClassPath(root);
498
                index = isBinary ? 
517
                index = isBinary ? 
Lines 501-507 Link Here
501
                        JavaSourceAccessor.getINSTANCE().createClassIndex(ClassPath.EMPTY,cp,ClassPath.EMPTY,false):
520
                        JavaSourceAccessor.getINSTANCE().createClassIndex(ClassPath.EMPTY,cp,ClassPath.EMPTY,false):
502
                    JavaSourceAccessor.getINSTANCE().createClassIndex(ClassPath.EMPTY,ClassPath.EMPTY,cp,false);
521
                    JavaSourceAccessor.getINSTANCE().createClassIndex(ClassPath.EMPTY,ClassPath.EMPTY,cp,false);
503
            }
522
            }
504
            return index.getDeclaredTypes(name,kind,EnumSet.of(isBinary?ClassIndex.SearchScope.DEPENDENCIES:ClassIndex.SearchScope.SOURCE));
523
            SearchScope baseSearchScope = isBinary ? ClassIndex.SearchScope.DEPENDENCIES : ClassIndex.SearchScope.SOURCE;
524
            SearchScopeType searchScope;
525
            // support FQN
526
            if (!"".equals(packageName)) {
527
                // has package in context (is fully qualified name), then limit the search to the package and its subpackages
528
                Set<String> subPackageNames = index.getPackageNames(packageName + ".", false, asSet(baseSearchScope));
529
                Set<String> allPackages = new HashSet<String>();
530
                allPackages.add(packageName);
531
                allPackages.addAll(subPackageNames);
532
                searchScope = ClassIndex.createPackageSearchScope(baseSearchScope, allPackages.toArray(new String[allPackages.size()]));
533
            } else {
534
                // else default behaviour
535
                searchScope = baseSearchScope;
536
            }
537
538
539
            Set<SearchScopeType> searchScopeSet = asSet(searchScope);
540
            return index.getDeclaredTypes(typeName, kind, Collections.unmodifiableSet(searchScopeSet));
505
        }
541
        }
506
542
507
        private void initProjectInfo() {
543
        private void initProjectInfo() {
Lines 517-521 Link Here
517
            }
553
            }
518
        }
554
        }
519
555
556
        private Set<SearchScopeType> asSet(SearchScopeType searchScope) {
557
            return new HashSet<SearchScopeType>(Arrays.asList(searchScope));
558
        }
520
    }
559
    }
521
}
560
}
(-)a/java.sourceui/test/unit/src/org/netbeans/modules/java/source/ui/JavaTypeProviderTest.java (+383 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-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
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
package org.netbeans.modules.java.source.ui;
45
46
import org.netbeans.api.java.source.*;
47
import com.sun.org.apache.bcel.internal.generic.AALOAD;
48
import java.beans.PropertyChangeListener;
49
import java.beans.PropertyChangeSupport;
50
import java.io.File;
51
import java.io.IOException;
52
import java.io.OutputStreamWriter;
53
import java.io.PrintWriter;
54
import java.net.URL;
55
import java.util.*;
56
import java.util.concurrent.CountDownLatch;
57
import java.util.concurrent.TimeUnit;
58
import javax.lang.model.element.ElementKind;
59
import javax.lang.model.element.TypeElement;
60
import javax.swing.event.ChangeListener;
61
import org.netbeans.api.java.classpath.ClassPath;
62
import org.netbeans.api.java.classpath.GlobalPathRegistry;
63
import org.netbeans.api.java.platform.JavaPlatformManager;
64
import org.netbeans.api.java.queries.SourceForBinaryQuery;
65
import org.netbeans.junit.MockServices;
66
import org.netbeans.junit.NbTestCase;
67
import org.netbeans.modules.java.source.parsing.FileObjects;
68
import org.netbeans.modules.java.source.ui.JavaTypeProvider;
69
import org.netbeans.modules.java.source.usages.ClassIndexManager;
70
import org.netbeans.modules.java.source.usages.ClassIndexManagerEvent;
71
import org.netbeans.modules.java.source.usages.ClassIndexManagerListener;
72
import org.netbeans.modules.java.source.usages.IndexUtil;
73
import org.netbeans.modules.parsing.api.indexing.IndexingManager;
74
import org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater;
75
import org.netbeans.modules.parsing.lucene.support.IndexManager;
76
import org.netbeans.spi.java.classpath.ClassPathFactory;
77
import org.netbeans.spi.java.classpath.ClassPathImplementation;
78
import org.netbeans.spi.java.classpath.ClassPathProvider;
79
import org.netbeans.spi.java.classpath.PathResourceImplementation;
80
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
81
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
82
import org.netbeans.spi.jumpto.type.JumptoAccessor;
83
import org.netbeans.spi.jumpto.type.SearchType;
84
import org.netbeans.spi.jumpto.type.TypeDescriptor;
85
import org.netbeans.spi.jumpto.type.TypeProvider;
86
import org.openide.filesystems.FileLock;
87
import org.openide.filesystems.FileObject;
88
import org.openide.filesystems.FileStateInvalidException;
89
import org.openide.filesystems.FileSystem;
90
import org.openide.filesystems.FileUtil;
91
92
/**
93
 * Test setup taken from org.netbeans.api.java.source.ClassIndexTest.
94
 *
95
 * @author Tomas Zezula
96
 * @author markiewb
97
 */
98
public class JavaTypeProviderTest extends NbTestCase {
99
100
    private static FileObject srcRoot;
101
    private static FileObject binRoot2;
102
    private static FileObject libSrc2;
103
    private static ClassPath sourcePath;
104
    private static ClassPath compilePath;
105
    private static ClassPath bootPath;
106
    private static JavaTypeProviderTest.MutableCp spiCp;
107
    private static JavaTypeProviderTest.MutableCp spiSrc;
108
    private JavaTypeProvider provider;
109
110
    public JavaTypeProviderTest(String name) {
111
        super(name);
112
    }
113
    String[] cA = {"ClassA", "org.me.pkg1"};
114
    String[] cB = {"ClassA", "org.me.pkg1sibling"};
115
    String[] cC = {"ClassA", "org.me.pkg1.subpackage"};
116
    String[] cD = {"ClassB", "org.me.pkg2"};
117
    String[] cE = {"ClassA", "com.other"};
118
119
    @Override
120
    protected void setUp() throws Exception {
121
        clearWorkDir();
122
        File cache = new File(getWorkDir(), "cache");       //NOI18N
123
        cache.mkdirs();
124
        IndexUtil.setCacheFolder(cache);
125
        File src = new File(getWorkDir(), "src");           //NOI18N
126
        src.mkdirs();
127
        srcRoot = FileUtil.toFileObject(src);
128
        srcRoot.createFolder("foo");                        //NOI18N
129
        src = new File(getWorkDir(), "src2");               //NOI18N
130
        src.mkdirs();
131
        src = new File(getWorkDir(), "lib");               //NOI18N
132
        src.mkdirs();
133
        src = new File(getWorkDir(), "lib2");               //NOI18N
134
        src.mkdirs();
135
        binRoot2 = FileUtil.toFileObject(src);
136
        src = new File(getWorkDir(), "lib2Src");            //NOI18N
137
        src.mkdirs();
138
        libSrc2 = FileUtil.toFileObject(src);
139
        spiSrc = new JavaTypeProviderTest.MutableCp(Collections.singletonList(ClassPathSupport.createResource(srcRoot.getURL())));
140
        sourcePath = ClassPathFactory.createClassPath(spiSrc);
141
        spiCp = new JavaTypeProviderTest.MutableCp();
142
        compilePath = ClassPathFactory.createClassPath(spiCp);
143
        bootPath = JavaPlatformManager.getDefault().getDefaultPlatform().getBootstrapLibraries();
144
        MockServices.setServices(JavaTypeProviderTest.ClassPathProviderImpl.class, JavaTypeProviderTest.SFBQ.class);
145
146
        //create some types to be searched for later
147
        String[][] testTypes = {
148
            cA, cB, cC, cD, cE
149
        };
150
151
        for (String[] entry : testTypes) {
152
            createJavaFile(srcRoot, entry[1], entry[0]);
153
        }
154
        IndexingManager.getDefault().refreshIndexAndWait(srcRoot.getURL(), null, true);
155
        final ClassPath scp = ClassPathSupport.createClassPath(srcRoot);
156
        final ClasspathInfo cpInfo = ClasspathInfo.create(
157
                ClassPathSupport.createClassPath(new URL[0]),
158
                ClassPathSupport.createClassPath(new URL[0]),
159
                scp);
160
        provider = new JavaTypeProvider(cpInfo, null);
161
162
    }
163
164
    @Override
165
    protected void tearDown() throws Exception {
166
        MockServices.setServices();
167
    }
168
169
    /**
170
     * A full FQN should result in one class type.
171
     *
172
     * @throws Exception
173
     */
174
    public void testGetDeclaredTypesScopes_FullyQualifiedName_Full() throws Exception {
175
        //original behaviour - without packagename
176
        {
177
            String[][] expectedResults = {cE, cA, cC, cB};
178
            assertComputeTypeNames(expectedResults, "ClassA", provider);
179
        }
180
        //original behaviour - without packagename
181
        {
182
            String[][] expectedResults = {cD};
183
            assertComputeTypeNames(expectedResults, "ClassB", provider);
184
        }
185
186
    }
187
188
    /**
189
     * Tests the behaviour, when no package name is included in searchText.
190
     * Packagenames should be ignored.
191
     *
192
     * @throws Exception
193
     */
194
    public void testGetDeclaredTypesScopes_DefaultBehaviour() throws Exception {
195
        //original behaviour - without packagename
196
        {
197
            String[][] expectedResults = {cE, cA, cC, cB};
198
            assertComputeTypeNames(expectedResults, "ClassA", provider);
199
        }
200
        //original behaviour - without packagename
201
        {
202
            String[][] expectedResults = {cD};
203
            assertComputeTypeNames(expectedResults, "ClassB", provider);
204
        }
205
206
    }
207
208
    /**
209
     * A partially given FQN may result in more than one class type. The
210
     * packagename is used for retrival of package and subpackages, which
211
     * results in more results.
212
     *
213
     * @throws Exception
214
     */
215
    public void testGetDeclaredTypesScopes_FullyQualifiedName_Partial() throws Exception {
216
        //search for classes with prefix "ClassA" and packages with (sub-)package "org.me.pkg1"
217
        {
218
            String[][] expectedResults = {cA, cC};
219
            assertComputeTypeNames(expectedResults, "org.me.pkg1.ClassA", provider);
220
        }
221
        //search for classes with prefix "ClassA" and packages with (sub-)package "org"
222
        {
223
            String[][] expectedResults = {cA, cC, cB};
224
            assertComputeTypeNames(expectedResults, "org.ClassA", provider);
225
        }
226
        //search for classes with prefix "ClassA" and packages with (sub-)package "org.me"
227
        {
228
            String[][] expectedResults = {cA, cC, cB};
229
            assertComputeTypeNames(expectedResults, "org.me.ClassA", provider);
230
        }
231
        //search for classes with prefix "Cl" and packages with (sub-)package "org.me"
232
        {
233
            String[][] expectedResults = {cA, cC, cB, cD};
234
            assertComputeTypeNames(expectedResults, "org.me.Cl", provider);
235
        }
236
    }
237
238
    private FileObject createJavaFile(
239
            final FileObject root,
240
            final String pkg,
241
            final String name,
242
            final String content) throws IOException {
243
        final FileObject file = FileUtil.createData(
244
                root,
245
                String.format("%s/%s.java",
246
                FileObjects.convertPackage2Folder(pkg),
247
                name));
248
        final FileLock lck = file.lock();
249
        try {
250
            final PrintWriter out = new PrintWriter(new OutputStreamWriter(file.getOutputStream(lck)));
251
            try {
252
                out.print(content);
253
            } finally {
254
                out.close();
255
            }
256
        } finally {
257
            lck.releaseLock();
258
        }
259
        return file;
260
    }
261
262
    private void assertComputeTypeNames(String[][] expectedResults, String searchText, TypeProvider provider) {
263
        List<TypeDescriptor> results = new ArrayList<TypeDescriptor>();
264
        TypeProvider.Result res = JumptoAccessor.createResult(results);
265
        TypeProvider.Context c = JumptoAccessor.createContext(null, searchText, SearchType.PREFIX);
266
267
        provider.computeTypeNames(c, res);
268
269
        assertEquals(expectedResults.length, results.size());
270
        //sort to make the result test run reproducable
271
        Collections.sort(results, new Comparator<TypeDescriptor>() {
272
            @Override
273
            public int compare(TypeDescriptor o1, TypeDescriptor o2) {
274
                int compareValue = o1.getSimpleName().compareToIgnoreCase(o2.getSimpleName());
275
                if (compareValue != 0) {
276
                    return compareValue;
277
                }
278
                return o1.getContextName().compareToIgnoreCase(o2.getContextName());
279
            }
280
        });
281
282
        for (int i = 0; i < results.size(); i++) {
283
284
            assertEquals("not equals at index " + i, expectedResults[i][0], results.get(i).getSimpleName());
285
            assertEquals("not equals at index " + i, " (" + expectedResults[i][1] + ")", results.get(i).getContextName());
286
        }
287
    }
288
289
    private FileObject createJavaFile(FileObject srcRoot1, String packageName, String className) throws IOException {
290
        return createJavaFile(srcRoot1, packageName, className, "package " + packageName + ";\npublic class " + className + " {}\n");
291
    }
292
293
    public static class ClassPathProviderImpl implements ClassPathProvider {
294
295
        public ClassPath findClassPath(final FileObject file, final String type) {
296
            final FileObject[] roots = sourcePath.getRoots();
297
            for (FileObject root : roots) {
298
                if (root.equals(file) || FileUtil.isParentOf(root, file)) {
299
                    if (type == ClassPath.SOURCE) {
300
                        return sourcePath;
301
                    }
302
                    if (type == ClassPath.COMPILE) {
303
                        return compilePath;
304
                    }
305
                    if (type == ClassPath.BOOT) {
306
                        return bootPath;
307
                    }
308
                }
309
            }
310
            if (libSrc2.equals(file) || FileUtil.isParentOf(libSrc2, file)) {
311
                if (type == ClassPath.SOURCE) {
312
                    return ClassPathSupport.createClassPath(new FileObject[]{libSrc2});
313
                }
314
                if (type == ClassPath.COMPILE) {
315
                    return ClassPathSupport.createClassPath(new URL[0]);
316
                }
317
                if (type == ClassPath.BOOT) {
318
                    return bootPath;
319
                }
320
            }
321
            return null;
322
        }
323
    }
324
325
    public static class SFBQ implements SourceForBinaryQueryImplementation {
326
327
        public SourceForBinaryQuery.Result findSourceRoots(URL binaryRoot) {
328
            try {
329
                if (binaryRoot.equals(binRoot2.getURL())) {
330
                    return new SourceForBinaryQuery.Result() {
331
                        public FileObject[] getRoots() {
332
                            return new FileObject[]{libSrc2};
333
                        }
334
335
                        public void addChangeListener(ChangeListener l) {
336
                        }
337
338
                        public void removeChangeListener(ChangeListener l) {
339
                        }
340
                    };
341
                }
342
            } catch (FileStateInvalidException e) {
343
            }
344
            return null;
345
        }
346
    }
347
348
    private static final class MutableCp implements ClassPathImplementation {
349
350
        private final PropertyChangeSupport support;
351
        private List<? extends PathResourceImplementation> impls;
352
353
        public MutableCp() {
354
            this(Collections.<PathResourceImplementation>emptyList());
355
        }
356
357
        public MutableCp(final List<? extends PathResourceImplementation> impls) {
358
            assert impls != null;
359
            support = new PropertyChangeSupport(this);
360
            this.impls = impls;
361
        }
362
363
        public List<? extends PathResourceImplementation> getResources() {
364
            return impls;
365
        }
366
367
        public void addPropertyChangeListener(final PropertyChangeListener listener) {
368
            assert listener != null;
369
            this.support.addPropertyChangeListener(listener);
370
        }
371
372
        public void removePropertyChangeListener(final PropertyChangeListener listener) {
373
            assert listener != null;
374
            this.support.removePropertyChangeListener(listener);
375
        }
376
377
        void setImpls(final List<? extends PathResourceImplementation> impls) {
378
            assert impls != null;
379
            this.impls = impls;
380
            this.support.firePropertyChange(PROP_RESOURCES, null, null);
381
        }
382
    }
383
}
(-)a/java.sourceui/test/unit/src/org/netbeans/spi/jumpto/type/JumptoAccessor.java (-1 / +2 lines)
Lines 57-62 Link Here
57
    }
57
    }
58
    
58
    
59
    public static Result createResult(List<? super TypeDescriptor> r) {
59
    public static Result createResult(List<? super TypeDescriptor> r) {
60
        return new Result(r, new String[0]);
60
        //may cause http://netbeans.org/bugzilla/show_bug.cgi?id=217180
61
        return new Result(r, new String[1]);
61
    }
62
    }
62
}
63
}

Return to bug 217187