diff --git a/api.java/apichanges.xml b/api.java/apichanges.xml --- a/api.java/apichanges.xml +++ b/api.java/apichanges.xml @@ -73,6 +73,21 @@ + + + Support for delegating SourceForBinaryQueryImplementation2 + + + + + +

+ Added support base class for SourceForBinaryQueryImplementation2 which delegates to other SourceForBinaryQueryImplementations. +

+
+ + +
Support for passing hint to the java infrastructure whether it should prefer source or binary diff --git a/api.java/manifest.mf b/api.java/manifest.mf --- a/api.java/manifest.mf +++ b/api.java/manifest.mf @@ -1,6 +1,6 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.api.java/1 -OpenIDE-Module-Specification-Version: 1.15 +OpenIDE-Module-Specification-Version: 1.16 OpenIDE-Module-Localizing-Bundle: org/netbeans/api/java/classpath/Bundle.properties AutoUpdate-Show-In-Client: false diff --git a/api.java/nbproject/project.xml b/api.java/nbproject/project.xml --- a/api.java/nbproject/project.xml +++ b/api.java/nbproject/project.xml @@ -100,6 +100,7 @@ org.netbeans.spi.java.classpath org.netbeans.spi.java.classpath.support org.netbeans.spi.java.queries + org.netbeans.spi.java.queries.support diff --git a/api.java/src/org/netbeans/api/java/queries/SourceForBinaryQuery.java b/api.java/src/org/netbeans/api/java/queries/SourceForBinaryQuery.java --- a/api.java/src/org/netbeans/api/java/queries/SourceForBinaryQuery.java +++ b/api.java/src/org/netbeans/api/java/queries/SourceForBinaryQuery.java @@ -48,6 +48,7 @@ import java.util.logging.Logger; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import org.netbeans.modules.java.queries.SFBQImpl2Result; import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation; import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation2; import org.openide.filesystems.FileObject; @@ -115,13 +116,13 @@ if (impl instanceof SourceForBinaryQueryImplementation2) { SourceForBinaryQueryImplementation2.Result _result = ((SourceForBinaryQueryImplementation2)impl).findSourceRoots2(binaryRoot); if (_result != null) { - result = new Result2New(_result); + result = new Result2(_result); } } else { Result _result = impl.findSourceRoots(binaryRoot); if (_result != null) { - result = new Result2(_result); + result = new Result2(new SFBQImpl2Result(_result)); } } if (result != null) { @@ -183,12 +184,12 @@ */ public static class Result2 implements Result { - private final Result delegate; + SourceForBinaryQueryImplementation2.Result delegate; //@GuardedBy(this) private ChangeListener spiListener; private final ChangeSupport changeSupport; - private Result2 (final Result result) { + private Result2 (final SourceForBinaryQueryImplementation2.Result result) { assert result != null; this.delegate = result; this.changeSupport = new ChangeSupport(this); @@ -225,33 +226,12 @@ * @return true if sources should be used by the java infrastructure */ public boolean preferSources() { - //Preserve the old behavior from 4.0 to 6.1, ignore sources inside archives - final FileObject[] roots = this.delegate.getRoots(); - for (FileObject root : roots) { - if (FileUtil.getArchiveFile(root) != null) { - return false; - } - } - return true; - } - } - - private static final class Result2New extends Result2 { - - private final SourceForBinaryQueryImplementation2.Result delegate; - - private Result2New (final SourceForBinaryQueryImplementation2.Result delegate) { - super (delegate); - this.delegate = delegate; - } - - public boolean preferSources() { return this.delegate.preferSources(); } } private static final Result EMPTY_RESULT = new EmptyResult(); - private static final Result2 EMPTY_RESULT2 = new Result2 (EMPTY_RESULT); + private static final Result2 EMPTY_RESULT2 = new Result2 (new SFBQImpl2Result(EMPTY_RESULT)); private static final class EmptyResult implements Result { private static final FileObject[] NO_ROOTS = new FileObject[0]; EmptyResult() {} diff --git a/api.java/src/org/netbeans/modules/java/queries/SFBQImpl2Result.java b/api.java/src/org/netbeans/modules/java/queries/SFBQImpl2Result.java new file mode 100644 --- /dev/null +++ b/api.java/src/org/netbeans/modules/java/queries/SFBQImpl2Result.java @@ -0,0 +1,83 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 2008 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.java.queries; + +import javax.swing.event.ChangeListener; +import org.netbeans.api.java.queries.SourceForBinaryQuery; +import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation2; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; + +/** + * + * @author Tomas Zezula + */ +public class SFBQImpl2Result implements SourceForBinaryQueryImplementation2.Result { + + private final SourceForBinaryQuery.Result delegate; + + public SFBQImpl2Result (final SourceForBinaryQuery.Result result) { + assert result != null; + this.delegate = result; + } + + public boolean preferSources() { + //Preserve the old behavior from 4.0 to 6.1, ignore sources inside archives + final FileObject[] roots = this.delegate.getRoots(); + for (FileObject root : roots) { + if (FileUtil.getArchiveFile(root) != null) { + return false; + } + } + return true; + } + + public FileObject[] getRoots () { + return this.delegate.getRoots(); + } + + public void addChangeListener(ChangeListener l) { + this.delegate.addChangeListener(l); + } + + public void removeChangeListener(ChangeListener l) { + this.delegate.removeChangeListener(l); + } +} diff --git a/api.java/src/org/netbeans/spi/java/queries/SourceForBinaryQueryImplementation2.java b/api.java/src/org/netbeans/spi/java/queries/SourceForBinaryQueryImplementation2.java --- a/api.java/src/org/netbeans/spi/java/queries/SourceForBinaryQueryImplementation2.java +++ b/api.java/src/org/netbeans/spi/java/queries/SourceForBinaryQueryImplementation2.java @@ -81,5 +81,4 @@ */ public boolean preferSources(); } - } diff --git a/api.java/src/org/netbeans/spi/java/queries/support/SourceForBinaryQueryimplementation2Base.java b/api.java/src/org/netbeans/spi/java/queries/support/SourceForBinaryQueryimplementation2Base.java new file mode 100644 --- /dev/null +++ b/api.java/src/org/netbeans/spi/java/queries/support/SourceForBinaryQueryimplementation2Base.java @@ -0,0 +1,66 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 2008 Sun Microsystems, Inc. + */ + +package org.netbeans.spi.java.queries.support; + +import org.netbeans.api.java.queries.SourceForBinaryQuery; +import org.netbeans.modules.java.queries.SFBQImpl2Result; +import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation2; + +/** + * Base class for {@link SourceForBinaryQueryImplementation2} which need to delegate + * to other {@link SourceForBinaryQueryImplementation}. + * @since 1.16 + * @author Tomas Zezula + */ +public abstract class SourceForBinaryQueryimplementation2Base implements SourceForBinaryQueryImplementation2 { + + /** + * Creates a wrapper for {@link SourceForBinaryQuery.Result}. This method + * should be used by delegating {@link SourceForBinaryQueryImplementation2} + * which need to delegate to {@link SourceForBinaryQueryImplementation}. + * @param result returned by {@link SourceForBinaryQueryImplementation}, + * if null the method returns null. + * @return a {@link SourceForBinaryQueryImplementation2.Result}, returns + * null when result parameter is null. + */ + protected final Result asResult (SourceForBinaryQuery.Result result) { + return result == null ? null : new SFBQImpl2Result(result); + } +} diff --git a/api.java/test/unit/src/org/netbeans/api/java/queries/SourceForBinaryQueryTest.java b/api.java/test/unit/src/org/netbeans/api/java/queries/SourceForBinaryQueryTest.java new file mode 100644 --- /dev/null +++ b/api.java/test/unit/src/org/netbeans/api/java/queries/SourceForBinaryQueryTest.java @@ -0,0 +1,309 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 2008 Sun Microsystems, Inc. + */ + +package org.netbeans.api.java.queries; + +import java.io.File; +import java.io.FileOutputStream; +import java.net.URL; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import org.netbeans.api.java.queries.SourceForBinaryQuery.Result; +import org.netbeans.junit.MockServices; +import org.netbeans.junit.NbTestCase; +import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation; +import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation2; +import org.netbeans.spi.java.queries.support.SourceForBinaryQueryimplementation2Base; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.util.ChangeSupport; + +/** + * + * @author Tomas Zezula + */ +public class SourceForBinaryQueryTest extends NbTestCase { + + public SourceForBinaryQueryTest (final String name) { + super (name); + } + + private FileObject br1; + private FileObject br2; + private FileObject sr1; + private FileObject sr2; + + private static final Map> map = new HashMap>(); + + @Override + protected void setUp() throws Exception { + this.clearWorkDir(); + super.setUp(); + File wd = this.getWorkDir(); + FileObject wdfo = FileUtil.toFileObject(wd); + br1 = wdfo.createFolder("bin1"); + br2 = wdfo.createFolder("bin2"); + sr1 = wdfo.createFolder("src1"); + File zf = new File (wd,"src2.zip"); + ZipOutputStream zos = new ZipOutputStream (new FileOutputStream (zf)); + zos.putNextEntry(new ZipEntry("foo.java")); + zos.closeEntry(); + zos.close(); + sr2 = FileUtil.getArchiveRoot(FileUtil.toFileObject(zf)); + map.put(br1.getURL(), Collections.singletonList(sr1)); + map.put(br2.getURL(), Collections.singletonList(sr2)); + } + + public void testSFBQImpl () throws Exception { + MockServices.setServices(LegacySFBQImpl.class); + SourceForBinaryQuery.Result2 res = SourceForBinaryQuery.findSourceRoots2(br1.getURL()); + assertNotNull(res); + assertEquals(1, res.getRoots().length); + assertEquals(Collections.singletonList(sr1), Arrays.asList(res.getRoots())); + assertTrue(res.preferSources()); + + res = SourceForBinaryQuery.findSourceRoots2(br2.getURL()); + assertNotNull(res); + assertEquals(1, res.getRoots().length); + assertEquals(Collections.singletonList(sr2), Arrays.asList(res.getRoots())); + assertFalse(res.preferSources()); + + res = SourceForBinaryQuery.findSourceRoots2(getWorkDir().toURI().toURL()); + assertNotNull(res); + assertEquals(0, res.getRoots().length); + assertTrue(res.preferSources()); + } + + public void testSFBQImpl2 () throws Exception { + MockServices.setServices(LeafSFBQImpl.class); + SourceForBinaryQuery.Result2 res = SourceForBinaryQuery.findSourceRoots2(br1.getURL()); + assertNotNull(res); + assertEquals(1, res.getRoots().length); + assertEquals(Collections.singletonList(sr1), Arrays.asList(res.getRoots())); + assertFalse(res.preferSources()); + + res = SourceForBinaryQuery.findSourceRoots2(br2.getURL()); + assertNotNull(res); + assertEquals(1, res.getRoots().length); + assertEquals(Collections.singletonList(sr2), Arrays.asList(res.getRoots())); + assertTrue(res.preferSources()); + + res = SourceForBinaryQuery.findSourceRoots2(getWorkDir().toURI().toURL()); + assertNotNull(res); + assertEquals(0, res.getRoots().length); + assertTrue(res.preferSources()); + + } + + + public void testSFBQDelegatingImpl () throws Exception { + DelegatingSFBImpl.impl = new LegacySFBQImpl(); + MockServices.setServices(DelegatingSFBImpl.class); + SourceForBinaryQuery.Result2 res = SourceForBinaryQuery.findSourceRoots2(br1.getURL()); + assertNotNull(res); + assertEquals(1, res.getRoots().length); + assertEquals(Collections.singletonList(sr1), Arrays.asList(res.getRoots())); + assertTrue(res.preferSources()); + + res = SourceForBinaryQuery.findSourceRoots2(br2.getURL()); + assertNotNull(res); + assertEquals(1, res.getRoots().length); + assertEquals(Collections.singletonList(sr2), Arrays.asList(res.getRoots())); + assertFalse(res.preferSources()); + + res = SourceForBinaryQuery.findSourceRoots2(getWorkDir().toURI().toURL()); + assertNotNull(res); + assertEquals(0, res.getRoots().length); + assertTrue(res.preferSources()); + + } + + + public void testSFBQDelegatingImpl2 () throws Exception { + DelegatingSFBImpl.impl = new LeafSFBQImpl(); + MockServices.setServices(DelegatingSFBImpl.class); + SourceForBinaryQuery.Result2 res = SourceForBinaryQuery.findSourceRoots2(br1.getURL()); + assertNotNull(res); + assertEquals(1, res.getRoots().length); + assertEquals(Collections.singletonList(sr1), Arrays.asList(res.getRoots())); + assertFalse(res.preferSources()); + + res = SourceForBinaryQuery.findSourceRoots2(br2.getURL()); + assertNotNull(res); + assertEquals(1, res.getRoots().length); + assertEquals(Collections.singletonList(sr2), Arrays.asList(res.getRoots())); + assertTrue(res.preferSources()); + + res = SourceForBinaryQuery.findSourceRoots2(getWorkDir().toURI().toURL()); + assertNotNull(res); + assertEquals(0, res.getRoots().length); + assertTrue(res.preferSources()); + } + + + public void testListening () throws Exception { + DelegatingSFBImpl.impl = new LeafSFBQImpl(); + MockServices.setServices(DelegatingSFBImpl.class); + SourceForBinaryQuery.Result2 res = SourceForBinaryQuery.findSourceRoots2(br1.getURL()); + final AtomicBoolean fired = new AtomicBoolean (); + ChangeListener l; + res.addChangeListener( l = new ChangeListener() { + public void stateChanged(ChangeEvent e) { + fired.set(true); + } + }); + ((LeafSFBQImpl)DelegatingSFBImpl.impl).lastResult.fire(); + res.removeChangeListener(l); + assertTrue(fired.get()); + } + + //Prefers sources for archives => behaves opposite to default + public static class LeafSFBQImpl implements SourceForBinaryQueryImplementation2 { + + static R2 lastResult; + + public Result findSourceRoots2(URL binaryRoot) { + lastResult = null; + List data = map.get(binaryRoot); + if (data != null) { + return lastResult = new R2(data.toArray(new FileObject[data.size()]), prefSources(data)); + } + return null; + } + + private static boolean prefSources(List l) { + for (FileObject f : l ) { + if (FileUtil.getArchiveFile(f) != null) { + return true; + } + } + return false; + } + + public Result findSourceRoots(URL binaryRoot) { + return this.findSourceRoots2(binaryRoot); + } + + } + + public static class DelegatingSFBImpl extends SourceForBinaryQueryimplementation2Base { + + private static SourceForBinaryQueryImplementation impl; + + + public Result findSourceRoots2(URL binaryRoot) { + if (this.impl == null) { + throw new IllegalStateException (); + } + else if (this.impl instanceof SourceForBinaryQueryImplementation2) { + return ((SourceForBinaryQueryImplementation2)this.impl).findSourceRoots2(binaryRoot); + } + else { + return asResult(this.impl.findSourceRoots(binaryRoot)); + } + } + + public Result findSourceRoots(URL binaryRoot) { + return this.findSourceRoots2(binaryRoot); + } + + } + + public static class LegacySFBQImpl implements SourceForBinaryQueryImplementation { + + public Result findSourceRoots(URL binaryRoot) { + List data = map.get(binaryRoot); + if (data != null) { + return new R(data.toArray(new FileObject[data.size()])); + } + return null; + } + + } + + private static class R implements SourceForBinaryQuery.Result { + + final FileObject[] roots; + private final ChangeSupport chs = new ChangeSupport(this); + + public R (final FileObject[] roots) { + this.roots = roots; + } + + public FileObject[] getRoots() { + return this.roots; + } + + public void addChangeListener(ChangeListener l) { + chs.addChangeListener(l); + } + + public void removeChangeListener(ChangeListener l) { + chs.removeChangeListener(l); + } + + void fire () { + chs.fireChange(); + } + + } + + private static class R2 extends R implements SourceForBinaryQueryImplementation2.Result { + + final boolean ps; + + public R2 (final FileObject[] roots, final boolean ps) { + super (roots); + this.ps = ps; + } + + public boolean preferSources() { + return ps; + } + } + +} diff --git a/java.platform/src/org/netbeans/modules/java/platform/queries/PlatformSourceForBinaryQuery.java b/java.platform/src/org/netbeans/modules/java/platform/queries/PlatformSourceForBinaryQuery.java --- a/java.platform/src/org/netbeans/modules/java/platform/queries/PlatformSourceForBinaryQuery.java +++ b/java.platform/src/org/netbeans/modules/java/platform/queries/PlatformSourceForBinaryQuery.java @@ -50,7 +50,6 @@ import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; import org.openide.filesystems.URLMapper; -import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation; import org.netbeans.api.java.classpath.ClassPath; import org.netbeans.api.java.platform.JavaPlatformManager; import org.netbeans.api.java.platform.JavaPlatform; diff --git a/java.project/src/org/netbeans/modules/java/project/ProjectSourceForBinaryQuery.java b/java.project/src/org/netbeans/modules/java/project/ProjectSourceForBinaryQuery.java --- a/java.project/src/org/netbeans/modules/java/project/ProjectSourceForBinaryQuery.java +++ b/java.project/src/org/netbeans/modules/java/project/ProjectSourceForBinaryQuery.java @@ -46,13 +46,15 @@ import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.project.Project; import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation; +import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation2; +import org.netbeans.spi.java.queries.support.SourceForBinaryQueryimplementation2Base; /** * Finds sources corresponding to binaries. * Assumes an instance of SourceForBinaryQueryImplementation is in project's lookup. * @author Jesse Glick, Tomas Zezula */ -public class ProjectSourceForBinaryQuery implements SourceForBinaryQueryImplementation { +public class ProjectSourceForBinaryQuery extends SourceForBinaryQueryimplementation2Base { /** Default constructor for lookup. */ public ProjectSourceForBinaryQuery() {} @@ -67,5 +69,22 @@ } return null; } + + + public Result findSourceRoots2(URL binaryRoot) { + Project project = FileOwnerQuery.getOwner(URI.create(binaryRoot.toString())); + if (project != null) { + SourceForBinaryQueryImplementation sfbqi = project.getLookup().lookup(SourceForBinaryQueryImplementation.class); + if (sfbqi != null) { + if (sfbqi instanceof SourceForBinaryQueryImplementation2) { + return ((SourceForBinaryQueryImplementation2)sfbqi).findSourceRoots2(binaryRoot); + } + else { + return asResult (sfbqi.findSourceRoots(binaryRoot)); + } + } + } + return null; + } } diff --git a/java.project/src/org/netbeans/spi/java/project/support/LookupMergerSupport.java b/java.project/src/org/netbeans/spi/java/project/support/LookupMergerSupport.java --- a/java.project/src/org/netbeans/spi/java/project/support/LookupMergerSupport.java +++ b/java.project/src/org/netbeans/spi/java/project/support/LookupMergerSupport.java @@ -45,6 +45,8 @@ import org.netbeans.api.java.queries.SourceForBinaryQuery; import org.netbeans.spi.java.queries.JavadocForBinaryQueryImplementation; import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation; +import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation2; +import org.netbeans.spi.java.queries.support.SourceForBinaryQueryimplementation2Base; import org.netbeans.spi.project.LookupMerger; import org.openide.util.Lookup; @@ -88,7 +90,7 @@ } - private static class SFBIMerged implements SourceForBinaryQueryImplementation { + private static class SFBIMerged extends SourceForBinaryQueryimplementation2Base { private Lookup lookup; public SFBIMerged(Lookup lkp) { @@ -100,6 +102,25 @@ SourceForBinaryQuery.Result res = impl.findSourceRoots(binaryRoot); if (res != null) { return res; + } + } + return null; + } + + public Result findSourceRoots2(URL binaryRoot) { + Collection col = lookup.lookupAll(SourceForBinaryQueryImplementation.class); + for (SourceForBinaryQueryImplementation impl : col) { + if (impl instanceof SourceForBinaryQueryImplementation2) { + SourceForBinaryQueryImplementation2.Result res = ((SourceForBinaryQueryImplementation2)impl).findSourceRoots2(binaryRoot); + if (res != null) { + return res; + } + } + else { + SourceForBinaryQuery.Result res = impl.findSourceRoots(binaryRoot); + if (res != null) { + return asResult(res); + } } } return null;