Issue #146852: accept Project in a constructor for SourcesHelper to permit registerExternalRoots to run synch. Can help simplify tests, and makes control flow easier to understand and debug. Also taking advantage of synchronous control flow to optimize class loading in the Eclipse importer. XXX to do: 1. Write test to verify that LookupProvider's can call Project.getLookup for j2seproject. 2. Verify that the problem reported in #142938 is fixed. 3. Check to see if the new constructor should be used in: java.api.common/test/unit/src/org/netbeans/modules/java/api/common/queries/GeneratedSourceRootTest.java mobility.project/src/org/netbeans/modules/mobility/project/J2MEProject.java php.project/src/org/netbeans/modules/php/project/PhpSources.java python.project/src/org/netbeans/modules/python/project/PythonSources.java ruby.merbproject/src/org/netbeans/modules/ruby/merbproject/MerbSources.java ruby.project/src/org/netbeans/modules/ruby/rubyproject/RubySources.java ruby.railsprojects/src/org/netbeans/modules/ruby/railsprojects/RailsSources.java sql.project/src/org/netbeans/modules/sql/project/IcanproProject.java sql.project/src/org/netbeans/modules/sql/project/SQLproProject.java web.project/src/org/netbeans/modules/web/project/WebSources.java xslt.project/src/org/netbeans/modules/xslt/project/XsltproProject.java diff --git a/ant.freeform/nbproject/project.xml b/ant.freeform/nbproject/project.xml --- a/ant.freeform/nbproject/project.xml +++ b/ant.freeform/nbproject/project.xml @@ -61,7 +61,7 @@ 1 - 1.30 + 1.31 diff --git a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformSources.java b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformSources.java --- a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformSources.java +++ b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformSources.java @@ -84,7 +84,7 @@ } private Sources initSources() { - final SourcesHelper h = new SourcesHelper(project.helper(), project.evaluator()); + SourcesHelper h = new SourcesHelper(project, project.helper(), project.evaluator()); Element genldata = project.getPrimaryConfigurationData(); Element foldersE = Util.findElement(genldata, "folders", FreeformProjectType.NS_GENERAL); // NOI18N if (foldersE != null) { @@ -119,11 +119,7 @@ } } } - ProjectManager.mutex().postWriteRequest(new Runnable() { - public void run() { - h.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); - } - }); + h.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); return h.createSources(); } diff --git a/apisupport.project/nbproject/project.xml b/apisupport.project/nbproject/project.xml --- a/apisupport.project/nbproject/project.xml +++ b/apisupport.project/nbproject/project.xml @@ -212,7 +212,7 @@ 1 - 1.30 + 1.31 diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java @@ -58,7 +58,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.Icon; -import javax.swing.ImageIcon; import org.netbeans.api.java.classpath.ClassPath; import org.netbeans.api.java.classpath.GlobalPathRegistry; import org.netbeans.api.java.project.JavaProjectConstants; @@ -179,7 +178,7 @@ } FileBuiltQueryImplementation fileBuilt = helper.createGlobFileBuiltQuery( eval,from.toArray(new String[0]), to.toArray(new String[0])); - final SourcesHelper sourcesHelper = new SourcesHelper(helper, eval); + SourcesHelper sourcesHelper = new SourcesHelper(this, helper, eval); // Temp build dir is always internal; NBM build products go elsewhere, but // difficult to predict statically exactly what they are! // XXX would be good to mark at least the module JAR as owned by this project @@ -204,11 +203,7 @@ /* XXX should schema incl. display name? */entry.getKey().getNameExt(), null, null); } // #56457: support external source roots too. - ProjectManager.mutex().postWriteRequest(new Runnable() { - public void run() { - sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); - } - }); + sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); lookup = createLookup(new Info(), aux, helper, fileBuilt, sourcesHelper); } diff --git a/bpel.project/nbproject/project.xml b/bpel.project/nbproject/project.xml --- a/bpel.project/nbproject/project.xml +++ b/bpel.project/nbproject/project.xml @@ -156,7 +156,7 @@ 1 - 1.30 + 1.31 diff --git a/bpel.project/src/org/netbeans/modules/bpel/project/BpelproProject.java b/bpel.project/src/org/netbeans/modules/bpel/project/BpelproProject.java --- a/bpel.project/src/org/netbeans/modules/bpel/project/BpelproProject.java +++ b/bpel.project/src/org/netbeans/modules/bpel/project/BpelproProject.java @@ -34,15 +34,11 @@ import java.util.Set; import java.util.logging.Logger; import javax.swing.Icon; -import javax.swing.ImageIcon; import org.netbeans.api.java.project.JavaProjectConstants; import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectManager; import org.netbeans.api.project.ant.AntArtifact; -import org.openide.cookies.SaveCookie; -import org.openide.loaders.DataObject; -import org.openide.loaders.DataObjectNotFoundException; import org.openide.filesystems.FileUtil; import org.openide.filesystems.FileChangeListener; import org.openide.filesystems.FileEvent; @@ -50,7 +46,6 @@ import org.openide.filesystems.FileAttributeEvent; import org.openide.filesystems.FileLock; import org.netbeans.modules.compapp.projects.base.spi.JbiArtifactProvider; -import org.netbeans.modules.compapp.projects.base.ui.IcanproCustomizerProvider; import org.netbeans.modules.compapp.projects.base.ui.customizer.IcanproProjectProperties; import org.netbeans.modules.bpel.model.api.support.Utils; import org.netbeans.api.project.ProjectInformation; @@ -77,7 +72,6 @@ import org.openide.util.ImageUtilities; import org.openide.util.Lookup; import org.openide.util.Mutex; -import org.openide.util.Utilities; import org.openide.util.lookup.Lookups; import org.netbeans.spi.java.project.support.ui.BrokenReferencesSupport; import org.netbeans.spi.project.AuxiliaryConfiguration; @@ -170,7 +164,7 @@ new String[] {"${src.dir}/*.java"}, // NOI18N new String[] {"${build.classes.dir}/*.class"} // NOI18N ); - final SourcesHelper sourcesHelper = new SourcesHelper(helper, evaluator()); + SourcesHelper sourcesHelper = new SourcesHelper(this, helper, evaluator()); String webModuleLabel = org.openide.util.NbBundle.getMessage(ProjectLogicalViewProvider.class, "LBL_Node_EJBModule"); //NOI18N String srcJavaLabel = org.openide.util.NbBundle.getMessage(ProjectLogicalViewProvider.class, "LBL_Node_Sources"); //NOI18N @@ -182,11 +176,7 @@ org.netbeans.modules.xml.catalogsupport.ProjectConstants.SOURCES_TYPE_XML, srcJavaLabel, null, null); - ProjectManager.mutex().postWriteRequest(new Runnable() { - public void run() { - sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); - } - }); + sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); return Lookups.fixed(new Object[] { new Info(), aux, diff --git a/cnd.makeproject/nbproject/project.xml b/cnd.makeproject/nbproject/project.xml --- a/cnd.makeproject/nbproject/project.xml +++ b/cnd.makeproject/nbproject/project.xml @@ -81,7 +81,7 @@ 1 - 1.12.1 + 1.31 diff --git a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeSources.java b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeSources.java --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeSources.java +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeSources.java @@ -47,7 +47,6 @@ import java.util.Set; import javax.swing.event.ChangeListener; import org.netbeans.api.project.FileOwnerQuery; -import org.netbeans.api.project.ProjectManager; import org.netbeans.api.project.SourceGroup; import org.netbeans.api.project.Sources; import org.netbeans.modules.cnd.api.utils.IpeUtils; @@ -95,7 +94,7 @@ } private Sources initSources() { - final SourcesHelper h = new SourcesHelper(helper, project.evaluator()); + SourcesHelper h = new SourcesHelper(project, helper, project.evaluator()); ConfigurationDescriptorProvider pdp = project.getLookup().lookup(ConfigurationDescriptorProvider.class); ConfigurationDescriptor pd = pdp.getConfigurationDescriptor(!MakeProjectConfigurationProvider.ASYNC_LOAD); if (pd != null) { @@ -159,12 +158,7 @@ h.addTypedSourceRoot(name, "generic", displayName, null, null); // NOI18N } } - ProjectManager.mutex().postWriteRequest(new Runnable() { - - public void run() { - h.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); - } - }); + h.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); return h.createSources(); } diff --git a/compapp.projects.base/nbproject/project.xml b/compapp.projects.base/nbproject/project.xml --- a/compapp.projects.base/nbproject/project.xml +++ b/compapp.projects.base/nbproject/project.xml @@ -101,7 +101,7 @@ 1 - 1.30 + 1.31 diff --git a/compapp.projects.base/src/org/netbeans/modules/compapp/projects/base/IcanproProject.java b/compapp.projects.base/src/org/netbeans/modules/compapp/projects/base/IcanproProject.java --- a/compapp.projects.base/src/org/netbeans/modules/compapp/projects/base/IcanproProject.java +++ b/compapp.projects.base/src/org/netbeans/modules/compapp/projects/base/IcanproProject.java @@ -26,10 +26,8 @@ import java.nio.charset.Charset; import java.nio.charset.IllegalCharsetNameException; import java.nio.charset.UnsupportedCharsetException; -import java.util.*; import java.util.logging.Logger; import javax.swing.Icon; -import javax.swing.ImageIcon; import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectManager; @@ -59,7 +57,6 @@ import org.openide.util.ImageUtilities; import org.openide.util.Lookup; import org.openide.util.Mutex; -import org.openide.util.Utilities; import org.openide.util.lookup.Lookups; import org.netbeans.spi.project.AuxiliaryConfiguration; import org.netbeans.spi.project.support.ant.AntBasedProjectRegistration; @@ -129,7 +126,7 @@ new String[] {"${src.dir}/*.java"}, // NOI18N new String[] {"${build.classes.dir}/*.class"} // NOI18N ); - final SourcesHelper sourcesHelper = new SourcesHelper(helper, evaluator()); + SourcesHelper sourcesHelper = new SourcesHelper(this, helper, evaluator()); String webModuleLabel = org.openide.util.NbBundle.getMessage(IcanproCustomizerProvider.class, "LBL_Node_EJBModule"); //NOI18N String srcJavaLabel = org.openide.util.NbBundle.getMessage(IcanproCustomizerProvider.class, "LBL_Node_Sources"); //NOI18N @@ -138,11 +135,7 @@ sourcesHelper.addTypedSourceRoot("${"+IcanproProjectProperties.SRC_DIR+"}", SOURCES_TYPE_ICANPRO, srcJavaLabel, /*XXX*/null, null); // sourcesHelper.addTypedSourceRoot("${"+IcanproProjectProperties.SRC_DIR+"}", JavaProjectConstants.SOURCES_TYPE_JAVA, srcJavaLabel, /*XXX*/null, null); - ProjectManager.mutex().postWriteRequest(new Runnable() { - public void run() { - sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); - } - }); + sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); return Lookups.fixed(new Object[] { new Info(), aux, diff --git a/compapp.projects.jbi/nbproject/project.xml b/compapp.projects.jbi/nbproject/project.xml --- a/compapp.projects.jbi/nbproject/project.xml +++ b/compapp.projects.jbi/nbproject/project.xml @@ -117,6 +117,24 @@ + org.netbeans.libs.httpunit + + + + 1 + 1.10 + + + + org.netbeans.libs.jaxb + + + + 1 + 1.3 + + + org.netbeans.libs.xerces @@ -201,7 +219,7 @@ 1 - 1.30 + 1.31 @@ -241,15 +259,6 @@ - org.netbeans.libs.jaxb - - - - 1 - 1.3 - - - org.netbeans.modules.websvc.jaxws21 @@ -302,15 +311,6 @@ - org.netbeans.libs.httpunit - - - - 1 - 1.10 - - - org.netbeans.soa.libs.jbiadmincommon diff --git a/compapp.projects.jbi/src/org/netbeans/modules/compapp/projects/jbi/JbiProject.java b/compapp.projects.jbi/src/org/netbeans/modules/compapp/projects/jbi/JbiProject.java --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/projects/jbi/JbiProject.java +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/projects/jbi/JbiProject.java @@ -69,7 +69,6 @@ import org.openide.util.ImageUtilities; import org.openide.util.Lookup; import org.openide.util.Mutex; -import org.openide.util.Utilities; import org.openide.util.lookup.Lookups; import org.openide.windows.TopComponent; import org.w3c.dom.Element; @@ -86,13 +85,10 @@ import java.util.*; import java.util.logging.Logger; import javax.swing.Icon; -import javax.swing.ImageIcon; import javax.swing.SwingUtilities; import org.netbeans.api.queries.FileEncodingQuery; -import org.netbeans.modules.compapp.projects.jbi.ComponentInfoGenerator; import org.netbeans.modules.compapp.projects.jbi.queries.JbiProjectEncodingQueryImpl; import org.netbeans.modules.sun.manager.jbi.management.model.ComponentInformationParser; -import org.netbeans.modules.sun.manager.jbi.management.model.JBIComponentDocument; import org.netbeans.modules.sun.manager.jbi.management.model.JBIComponentStatus; import org.openide.filesystems.FileChangeAdapter; import org.openide.filesystems.FileChangeListener; @@ -253,7 +249,7 @@ helper.getStandardPropertyEvaluator(), new String[] {"${src.dir}/*.java"}, // NOI18N new String[] {"${build.classes.dir}/*.class"} // NOI18N ); - final SourcesHelper sourcesHelper = new SourcesHelper(helper, evaluator()); + SourcesHelper sourcesHelper = new SourcesHelper(this, helper, evaluator()); String webModuleLabel = org.openide.util.NbBundle.getMessage( JbiCustomizerProvider.class, "LBL_Node_EJBModule" // NOI18N ); @@ -279,15 +275,9 @@ srcJavaLabel, /*XXX*/ null, null ); - ProjectManager.mutex().postWriteRequest( - new Runnable() { - public void run() { - sourcesHelper.registerExternalRoots( - FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT - ); - } - } - ); + sourcesHelper.registerExternalRoots( + FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT + ); casaFileListener = new FileChangeAdapter() { @Override diff --git a/etl.project/nbproject/project.xml b/etl.project/nbproject/project.xml --- a/etl.project/nbproject/project.xml +++ b/etl.project/nbproject/project.xml @@ -117,7 +117,7 @@ 1 - 1.11.1 + 1.31 diff --git a/etl.project/src/org/netbeans/modules/etl/project/EtlproProject.java b/etl.project/src/org/netbeans/modules/etl/project/EtlproProject.java --- a/etl.project/src/org/netbeans/modules/etl/project/EtlproProject.java +++ b/etl.project/src/org/netbeans/modules/etl/project/EtlproProject.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.io.File; import javax.swing.Icon; -import javax.swing.ImageIcon; import net.java.hulp.i18n.Logger; import org.netbeans.api.java.project.JavaProjectConstants; import org.netbeans.api.project.FileOwnerQuery; @@ -53,7 +52,6 @@ import org.openide.util.ImageUtilities; import org.openide.util.Lookup; import org.openide.util.Mutex; -import org.openide.util.Utilities; import org.openide.util.lookup.Lookups; import org.netbeans.modules.compapp.projects.base.spi.JbiArtifactProvider; import org.netbeans.modules.etl.project.ui.EtlproLogicalViewProvider; @@ -133,7 +131,7 @@ new String[]{"${src.dir}/*.java"}, // NOI18N new String[]{"${build.classes.dir}/*.class"} // NOI18N ); - final SourcesHelper sourcesHelper = new SourcesHelper(helper, evaluator()); + SourcesHelper sourcesHelper = new SourcesHelper(this, helper, evaluator()); /*String nbBundle1 = mLoc.t("BUND711: EJB Module"); String nbBundle2 = mLoc.t("BUND712: Source Packages"); String webModuleLabel = nbBundle1.substring(15); //NOI18N @@ -147,12 +145,7 @@ sourcesHelper.addTypedSourceRoot("${" + IcanproProjectProperties.SRC_DIR + "}", SOURCES_TYPE_ICANPRO, srcJavaLabel, /*XXX*/ null, null); sourcesHelper.addTypedSourceRoot("${" + IcanproProjectProperties.SRC_DIR + "}", JavaProjectConstants.SOURCES_TYPE_JAVA, srcJavaLabel, /*XXX*/ null, null); - ProjectManager.mutex().postWriteRequest(new Runnable() { - - public void run() { - sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); - } - }); + sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); return Lookups.fixed(new Object[]{ new Info(), aux, diff --git a/iep.project/nbproject/project.xml b/iep.project/nbproject/project.xml --- a/iep.project/nbproject/project.xml +++ b/iep.project/nbproject/project.xml @@ -108,7 +108,7 @@ 1 - 1.12.1 + 1.31 diff --git a/iep.project/src/org/netbeans/modules/iep/project/IepProject.java b/iep.project/src/org/netbeans/modules/iep/project/IepProject.java --- a/iep.project/src/org/netbeans/modules/iep/project/IepProject.java +++ b/iep.project/src/org/netbeans/modules/iep/project/IepProject.java @@ -29,14 +29,11 @@ import java.io.File; import java.io.IOException; import javax.swing.Icon; -import javax.swing.ImageIcon; -import org.netbeans.modules.xml.catalogsupport.ProjectConstants; import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectInformation; import org.netbeans.api.project.ProjectManager; import org.netbeans.api.project.ant.AntArtifact; -import org.netbeans.modules.iep.project.ui.customizer.IepProjectCustomizerProvider; import org.netbeans.spi.java.project.support.ui.BrokenReferencesSupport; import org.netbeans.spi.project.AuxiliaryConfiguration; import org.netbeans.spi.project.SubprojectProvider; @@ -59,7 +56,6 @@ import org.openide.util.ImageUtilities; import org.openide.util.Lookup; import org.openide.util.Mutex; -import org.openide.util.Utilities; import org.openide.util.lookup.Lookups; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -131,7 +127,7 @@ new String[] {"${src.dir}/*.java"}, // NOI18N new String[] {"${build.classes.dir}/*.class"} // NOI18N ); - final SourcesHelper sourcesHelper = new SourcesHelper(helper, evaluator()); + SourcesHelper sourcesHelper = new SourcesHelper(this, helper, evaluator()); String webModuleLabel = org.openide.util.NbBundle.getMessage(IcanproCustomizerProvider.class, "LBL_Node_EJBModule"); //NOI18N String srcJavaLabel = org.openide.util.NbBundle.getMessage(IepProjectLogicalViewProvider.class, "LBL_Node_Sources"); //NOI18N @@ -142,11 +138,7 @@ sourcesHelper.addTypedSourceRoot("${"+IcanproProjectProperties.SRC_DIR+"}", org.netbeans.modules.xml.catalogsupport.ProjectConstants.SOURCES_TYPE_XML, srcJavaLabel, /*XXX*/null, null); - ProjectManager.mutex().postWriteRequest(new Runnable() { - public void run() { - sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); - } - }); + sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); return Lookups.fixed(new Object[] { new Info(), aux, diff --git a/j2ee.clientproject/nbproject/project.xml b/j2ee.clientproject/nbproject/project.xml --- a/j2ee.clientproject/nbproject/project.xml +++ b/j2ee.clientproject/nbproject/project.xml @@ -236,7 +236,7 @@ 1 - 1.30 + 1.31 diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientProject.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientProject.java --- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientProject.java +++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientProject.java @@ -54,12 +54,10 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.Icon; -import javax.swing.ImageIcon; import javax.swing.JButton; import org.netbeans.api.java.classpath.ClassPath; import org.netbeans.api.java.classpath.GlobalPathRegistry; import org.netbeans.api.java.project.JavaProjectConstants; -import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectInformation; import org.netbeans.api.project.ProjectManager; @@ -115,7 +113,6 @@ import org.netbeans.spi.project.support.ant.PropertyEvaluator; import org.netbeans.spi.project.support.ant.PropertyUtils; import org.netbeans.spi.project.support.ant.ReferenceHelper; -import org.netbeans.spi.project.support.ant.SourcesHelper; import org.netbeans.spi.project.ui.PrivilegedTemplates; import org.netbeans.spi.project.ui.ProjectOpenedHook; import org.netbeans.spi.project.ui.RecommendedTemplates; @@ -294,18 +291,6 @@ private Lookup createLookup(AuxiliaryConfiguration aux, ClassPathProviderImpl cpProvider) { SubprojectProvider spp = refHelper.createSubprojectProvider(); - - final SourcesHelper sourcesHelper = new SourcesHelper(helper, evaluator()); - String configFilesLabel = NbBundle.getMessage(AppClientLogicalViewProvider.class, "LBL_Node_ConfFiles"); //NOI18N - - //sourcesHelper.addPrincipalSourceRoot("${"+AppClientProjectProperties.SOURCE_ROOT+"}", ejbModuleLabel, /*XXX*/null, null); - sourcesHelper.addPrincipalSourceRoot("${"+AppClientProjectProperties.META_INF+"}", configFilesLabel, /*XXX*/null, null); // NOI18N - - ProjectManager.mutex().postWriteRequest(new Runnable() { - public void run() { - sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); - } - }); FileEncodingQueryImplementation encodingQuery = QuerySupport.createFileEncodingQuery(evaluator(), AppClientProjectProperties.SOURCE_ENCODING); Lookup base = Lookups.fixed(new Object[] { new Info(), @@ -325,7 +310,7 @@ UILookupMergerSupport.createProjectOpenHookMerger(new ProjectOpenedHookImpl()), QuerySupport.createUnitTestForSourceQuery(getSourceRoots(),getTestSourceRoots()), QuerySupport.createSourceLevelQuery(evaluator()), - new AppClientSources(this.helper, evaluator(), getSourceRoots(), getTestSourceRoots()), + new AppClientSources(this, helper, evaluator(), getSourceRoots(), getTestSourceRoots()), QuerySupport.createSharabilityQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots(), AppClientProjectProperties.META_INF), QuerySupport.createFileBuiltQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()), diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientSources.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientSources.java --- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientSources.java +++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientSources.java @@ -54,6 +54,7 @@ import org.netbeans.api.project.ProjectManager; import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.java.project.JavaProjectConstants; +import org.netbeans.api.project.Project; import org.netbeans.modules.j2ee.clientproject.ui.AppClientLogicalViewProvider; import org.netbeans.modules.java.api.common.SourceRoots; import org.netbeans.modules.java.api.common.project.ProjectProperties; @@ -70,20 +71,18 @@ private static final String BUILD_DIR_PROP = "${" + AppClientProjectProperties.BUILD_DIR + "}"; //NOI18N private static final String DIST_DIR_PROP = "${" + AppClientProjectProperties.DIST_DIR + "}"; //NOI18N + private final Project project; private final AntProjectHelper helper; private final PropertyEvaluator evaluator; private final SourceRoots sourceRoots; private final SourceRoots testRoots; private SourcesHelper sourcesHelper; private Sources delegate; - /** - * Flag to forbid multiple invocation of {@link SourcesHelper#registerExternalRoots} - **/ - private boolean externalRootsRegistered; private final List listeners = new ArrayList(); - AppClientSources(AntProjectHelper helper, PropertyEvaluator evaluator, + AppClientSources(Project project, AntProjectHelper helper, PropertyEvaluator evaluator, SourceRoots sourceRoots, SourceRoots testRoots) { + this.project = project; this.helper = helper; this.evaluator = evaluator; this.sourceRoots = sourceRoots; @@ -118,7 +117,7 @@ } private Sources initSources() { - sourcesHelper = new SourcesHelper(helper, evaluator); + sourcesHelper = new SourcesHelper(project, helper, evaluator); register(sourceRoots); register(testRoots); @@ -129,15 +128,7 @@ sourcesHelper.addNonSourceRoot(BUILD_DIR_PROP); sourcesHelper.addNonSourceRoot(DIST_DIR_PROP); - externalRootsRegistered = false; - ProjectManager.mutex().postWriteRequest(new Runnable() { - public void run() { - if (!externalRootsRegistered) { - sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); - externalRootsRegistered = true; - } - } - }); + sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); return sourcesHelper.createSources(); } diff --git a/j2ee.earproject/nbproject/project.xml b/j2ee.earproject/nbproject/project.xml --- a/j2ee.earproject/nbproject/project.xml +++ b/j2ee.earproject/nbproject/project.xml @@ -210,7 +210,7 @@ 1 - 1.30 + 1.31 diff --git a/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/EarProject.java b/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/EarProject.java --- a/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/EarProject.java +++ b/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/EarProject.java @@ -52,10 +52,8 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.Icon; -import javax.swing.ImageIcon; import org.netbeans.api.java.classpath.ClassPath; import org.netbeans.api.java.classpath.GlobalPathRegistry; -import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectInformation; import org.netbeans.api.project.ProjectManager; @@ -97,7 +95,6 @@ import org.netbeans.spi.project.support.ant.PropertyEvaluator; import org.netbeans.spi.project.support.ant.PropertyUtils; import org.netbeans.spi.project.support.ant.ReferenceHelper; -import org.netbeans.spi.project.support.ant.SourcesHelper; import org.netbeans.spi.project.ui.PrivilegedTemplates; import org.netbeans.spi.project.ui.ProjectOpenedHook; import org.netbeans.spi.project.ui.RecommendedTemplates; @@ -206,18 +203,6 @@ private Lookup createLookup(AuxiliaryConfiguration aux, ClassPathProviderImpl cpProvider) { SubprojectProvider spp = refHelper.createSubprojectProvider(); - - // XXX unnecessarily creates a SourcesHelper, which is then GC's - // as it is not hold. This is probably unneeded now that issue 63359 was fixed. - final SourcesHelper sourcesHelper = new SourcesHelper(helper, evaluator()); - String configFilesLabel = NbBundle.getMessage(EarProject.class, "LBL_Node_ConfigBase"); //NOI18N - - sourcesHelper.addPrincipalSourceRoot("${"+EarProjectProperties.META_INF+"}", configFilesLabel, /*XXX*/null, null); // NOI18N - ProjectManager.mutex().postWriteRequest(new Runnable() { - public void run() { - sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); - } - }); Lookup base = Lookups.fixed(new Object[] { new Info(), aux, @@ -232,7 +217,7 @@ LookupMergerSupport.createClassPathProviderMerger(cpProvider), new ProjectXmlSavedHookImpl(), UILookupMergerSupport.createProjectOpenHookMerger(new ProjectOpenedHookImpl()), - new EarSources(helper, evaluator()), + new EarSources(this, helper, evaluator()), new RecommendedTemplatesImpl(), helper.createSharabilityQuery(evaluator(), new String[] {"${"+EarProjectProperties.SOURCE_ROOT+"}"}, // NOI18N diff --git a/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/EarSources.java b/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/EarSources.java --- a/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/EarSources.java +++ b/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/EarSources.java @@ -51,6 +51,7 @@ import org.netbeans.api.project.SourceGroup; import org.netbeans.api.project.ProjectManager; import org.netbeans.api.project.FileOwnerQuery; +import org.netbeans.api.project.Project; import org.netbeans.spi.project.support.ant.SourcesHelper; import org.netbeans.spi.project.support.ant.AntProjectHelper; import org.netbeans.spi.project.support.ant.PropertyEvaluator; @@ -58,14 +59,15 @@ class EarSources implements Sources, PropertyChangeListener, ChangeListener { + private final Project project; private final AntProjectHelper helper; private final PropertyEvaluator evaluator; private Sources delegate; private final ChangeSupport changeSupport = new ChangeSupport(this); private SourcesHelper sourcesHelper; - private boolean externalRootsRegistered; - EarSources(AntProjectHelper helper, PropertyEvaluator evaluator) { + EarSources(Project project, AntProjectHelper helper, PropertyEvaluator evaluator) { + this.project = project; this.helper = helper; this.evaluator = evaluator; initSources(); // have to register external build roots eagerly @@ -85,19 +87,11 @@ } private Sources initSources() { - sourcesHelper = new SourcesHelper(helper, evaluator); + sourcesHelper = new SourcesHelper(project, helper, evaluator); String configFilesLabel = org.openide.util.NbBundle.getMessage(EarSources.class, "LBL_Node_ConfigBase"); //NOI18N sourcesHelper.addPrincipalSourceRoot("${"+EarProjectProperties.META_INF+"}", configFilesLabel, /*XXX*/null, null); // XXX add build dir too? - externalRootsRegistered = false; - ProjectManager.mutex().postWriteRequest(new Runnable() { - public void run() { - if (!externalRootsRegistered) { - sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); - externalRootsRegistered = true; - } - } - }); + sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); return sourcesHelper.createSources(); } diff --git a/j2ee.ejbjarproject/nbproject/project.xml b/j2ee.ejbjarproject/nbproject/project.xml --- a/j2ee.ejbjarproject/nbproject/project.xml +++ b/j2ee.ejbjarproject/nbproject/project.xml @@ -280,7 +280,7 @@ 1 - 1.30 + 1.31 diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarProject.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarProject.java --- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarProject.java +++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarProject.java @@ -62,13 +62,11 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.Icon; -import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.SwingUtilities; import org.netbeans.api.java.classpath.ClassPath; import org.netbeans.api.java.classpath.GlobalPathRegistry; import org.netbeans.api.java.project.JavaProjectConstants; -import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectManager; import org.netbeans.api.project.ant.AntArtifact; @@ -116,7 +114,6 @@ import org.netbeans.spi.project.ui.RecommendedTemplates; import org.netbeans.spi.project.support.ant.ReferenceHelper; import org.netbeans.spi.project.support.ant.PropertyEvaluator; -import org.netbeans.spi.project.support.ant.SourcesHelper; import org.netbeans.spi.project.ui.ProjectOpenedHook; import org.openide.filesystems.FileChangeListener; import org.openide.filesystems.FileObject; @@ -400,19 +397,6 @@ private Lookup createLookup(AuxiliaryConfiguration aux, ClassPathProviderImpl cpProvider) { SubprojectProvider spp = refHelper.createSubprojectProvider(); - - final SourcesHelper sourcesHelper = new SourcesHelper(helper, evaluator()); - String ejbModuleLabel = org.openide.util.NbBundle.getMessage(EjbJarLogicalViewProvider.class, "LBL_Node_EJBModule"); //NOI18N - String configFilesLabel = org.openide.util.NbBundle.getMessage(EjbJarLogicalViewProvider.class, "LBL_Node_DocBase"); //NOI18N - - sourcesHelper.addPrincipalSourceRoot("${"+EjbJarProjectProperties.SOURCE_ROOT+"}", ejbModuleLabel, /*XXX*/null, null); - sourcesHelper.addPrincipalSourceRoot("${"+EjbJarProjectProperties.META_INF+"}", configFilesLabel, /*XXX*/null, null); - - ProjectManager.mutex().postWriteRequest(new Runnable() { - public void run() { - sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); - } - }); FileEncodingQueryImplementation encodingQuery = QuerySupport.createFileEncodingQuery(evaluator(), EjbJarProjectProperties.SOURCE_ENCODING); Lookup base = Lookups.fixed(new Object[] { EjbJarProject.this, // never cast an externally obtained Project to EjbJarProject - use lookup instead @@ -437,7 +421,7 @@ UILookupMergerSupport.createProjectOpenHookMerger(new ProjectOpenedHookImpl()), QuerySupport.createUnitTestForSourceQuery(getSourceRoots(), getTestSourceRoots()), QuerySupport.createSourceLevelQuery(evaluator()), - new EjbJarSources (helper, evaluator(), getSourceRoots(), getTestSourceRoots()), + new EjbJarSources(this, helper, evaluator(), getSourceRoots(), getTestSourceRoots()), QuerySupport.createSharabilityQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots(), EjbJarProjectProperties.META_INF), QuerySupport.createFileBuiltQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()), diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarSources.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarSources.java --- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarSources.java +++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarSources.java @@ -53,6 +53,7 @@ import org.netbeans.api.project.ProjectManager; import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.java.project.JavaProjectConstants; +import org.netbeans.api.project.Project; import org.netbeans.modules.java.api.common.SourceRoots; import org.netbeans.modules.java.api.common.project.ProjectProperties; import org.netbeans.spi.project.support.ant.SourcesHelper; @@ -65,20 +66,18 @@ private static final String BUILD_DIR_PROP = "${" + EjbJarProjectProperties.BUILD_DIR + "}"; //NOI18N private static final String DIST_DIR_PROP = "${" + EjbJarProjectProperties.DIST_DIR + "}"; //NOI18N + private final Project project; private final AntProjectHelper helper; private final PropertyEvaluator evaluator; private final SourceRoots sourceRoots; private final SourceRoots testRoots; private Sources delegate; - /** - * Flag to forbid multiple invocation of {@link SourcesHelper#registerExternalRoots} - **/ - private boolean externalRootsRegistered; private final ChangeSupport changeSupport = new ChangeSupport(this); private SourcesHelper sourcesHelper; - EjbJarSources(AntProjectHelper helper, PropertyEvaluator evaluator, + EjbJarSources(Project project, AntProjectHelper helper, PropertyEvaluator evaluator, SourceRoots sourceRoots, SourceRoots testRoots) { + this.project = project; this.helper = helper; this.evaluator = evaluator; this.sourceRoots = sourceRoots; @@ -113,7 +112,7 @@ } private Sources initSources() { - sourcesHelper = new SourcesHelper(helper, evaluator); + sourcesHelper = new SourcesHelper(project, helper, evaluator); register(sourceRoots); register(testRoots); @@ -124,15 +123,7 @@ sourcesHelper.addNonSourceRoot(BUILD_DIR_PROP); sourcesHelper.addNonSourceRoot(DIST_DIR_PROP); - externalRootsRegistered = false; - ProjectManager.mutex().postWriteRequest(new Runnable() { - public void run() { - if (!externalRootsRegistered) { - sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); - externalRootsRegistered = true; - } - } - }); + sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); return sourcesHelper.createSources(); } diff --git a/java.j2seproject/nbproject/project.xml b/java.j2seproject/nbproject/project.xml --- a/java.j2seproject/nbproject/project.xml +++ b/java.j2seproject/nbproject/project.xml @@ -180,7 +180,7 @@ 1 - 1.28 + 1.31 diff --git a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java @@ -156,7 +156,7 @@ private final PropertyEvaluator eval; private final ReferenceHelper refHelper; private final GeneratedFilesHelper genFilesHelper; - private final Lookup lookup; + private Lookup lookup; private final UpdateHelper updateHelper; private MainClassUpdater mainClassUpdater; private SourceRoots sourceRoots; @@ -313,7 +313,7 @@ UILookupMergerSupport.createProjectOpenHookMerger(new ProjectOpenedHookImpl()), QuerySupport.createUnitTestForSourceQuery(getSourceRoots(), getTestSourceRoots()), QuerySupport.createSourceLevelQuery(evaluator()), - new J2SESources (this.helper, evaluator(), getSourceRoots(), getTestSourceRoots()), + new J2SESources(this, helper, evaluator(), getSourceRoots(), getTestSourceRoots()), QuerySupport.createSharabilityQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()), new CoSAwareFileBuiltQueryImpl(QuerySupport.createFileBuiltQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()), this), new RecommendedTemplatesImpl (this.updateHelper), @@ -335,6 +335,7 @@ LookupMergerSupport.createJFBLookupMerger(), QuerySupport.createBinaryForSourceQueryImplementation(this.sourceRoots, this.testRoots, this.helper, this.eval) //Does not use APH to get/put properties/cfgdata ); + lookup = base; // in case LookupProvider's call Project.getLookup return LookupProviderSupport.createCompositeLookup(base, "Projects/org-netbeans-modules-java-j2seproject/Lookup"); //NOI18N } diff --git a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SESources.java b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SESources.java --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SESources.java +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SESources.java @@ -53,6 +53,7 @@ import org.netbeans.api.project.ProjectManager; import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.java.project.JavaProjectConstants; +import org.netbeans.api.project.Project; import org.netbeans.modules.java.api.common.SourceRoots; import org.netbeans.modules.java.api.common.project.ProjectProperties; import org.netbeans.spi.project.support.GenericSources; @@ -72,20 +73,18 @@ private static final String BUILD_DIR_PROP = "${" + J2SEProjectProperties.BUILD_DIR + "}"; //NOI18N private static final String DIST_DIR_PROP = "${" + J2SEProjectProperties.DIST_DIR + "}"; //NOI18N + private final Project project; private final AntProjectHelper helper; private final PropertyEvaluator evaluator; private final SourceRoots sourceRoots; private final SourceRoots testRoots; private SourcesHelper sourcesHelper; private Sources delegate; - /** - * Flag to forbid multiple invocation of {@link SourcesHelper#registerExternalRoots} - **/ - private boolean externalRootsRegistered; private final ChangeSupport changeSupport = new ChangeSupport(this); - J2SESources(AntProjectHelper helper, PropertyEvaluator evaluator, + J2SESources(Project project, AntProjectHelper helper, PropertyEvaluator evaluator, SourceRoots sourceRoots, SourceRoots testRoots) { + this.project = project; this.helper = helper; this.evaluator = evaluator; this.sourceRoots = sourceRoots; @@ -152,20 +151,12 @@ } private Sources initSources() { - this.sourcesHelper = new SourcesHelper(helper, evaluator); //Safe to pass APH + this.sourcesHelper = new SourcesHelper(project, helper, evaluator); //Safe to pass APH register(sourceRoots); register(testRoots); this.sourcesHelper.addNonSourceRoot(BUILD_DIR_PROP); this.sourcesHelper.addNonSourceRoot(DIST_DIR_PROP); - externalRootsRegistered = false; - ProjectManager.mutex().postWriteRequest(new Runnable() { - public void run() { - if (!externalRootsRegistered) { - sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT, false); - externalRootsRegistered = true; - } - } - }); + sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT, false); return this.sourcesHelper.createSources(); } diff --git a/project.ant/apichanges.xml b/project.ant/apichanges.xml --- a/project.ant/apichanges.xml +++ b/project.ant/apichanges.xml @@ -104,6 +104,22 @@ + + + + Added SourcesHelper constructor accepting Project + + + + + +

+ The new constructor enables simplified control flow. +

+
+ + +
diff --git a/project.ant/manifest.mf b/project.ant/manifest.mf --- a/project.ant/manifest.mf +++ b/project.ant/manifest.mf @@ -1,6 +1,6 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.project.ant/1 -OpenIDE-Module-Specification-Version: 1.30 +OpenIDE-Module-Specification-Version: 1.31 OpenIDE-Module-Layer: org/netbeans/modules/project/ant/resources/mf-layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/project/ant/Bundle.properties OpenIDE-Module-Install: org/netbeans/modules/project/ant/AntProjectModule.class diff --git a/project.ant/src/org/netbeans/spi/project/support/ant/SourcesHelper.java b/project.ant/src/org/netbeans/spi/project/support/ant/SourcesHelper.java --- a/project.ant/src/org/netbeans/spi/project/support/ant/SourcesHelper.java +++ b/project.ant/src/org/netbeans/spi/project/support/ant/SourcesHelper.java @@ -74,6 +74,7 @@ import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.util.ChangeSupport; +import org.openide.util.Parameters; import org.openide.util.WeakListeners; // XXX should perhaps be legal to call add* methods at any time (should update things) @@ -98,7 +99,7 @@ if (val == null) { return null; } - return project.resolveFile(val); + return aph.resolveFile(val); } public Collection getIncludeRoots(boolean minimalSubfolders) { File loc = getActualLocation(); @@ -292,7 +293,8 @@ } } - private final AntProjectHelper project; + private final AntProjectHelper aph; + private final Project project; private final PropertyEvaluator evaluator; private final List principalSourceRoots = new ArrayList(); private final List nonSourceRoots = new ArrayList(); @@ -312,11 +314,29 @@ /** * Create the helper object, initially configured to recognize only sources * contained inside the project directory. - * @param project an Ant project helper + * @param aph an Ant project helper * @param evaluator a way to evaluate Ant properties used to define source locations + * @deprecated Rather use {@link #SourcesHelper(Project, AntProjectHelper, PropertyEvaluator)}. */ - public SourcesHelper(AntProjectHelper project, PropertyEvaluator evaluator) { + @Deprecated + public SourcesHelper(AntProjectHelper aph, PropertyEvaluator evaluator) { + this.project = null; + this.aph = aph; + this.evaluator = evaluator; + } + + /** + * Create the helper object, initially configured to recognize only sources + * contained inside the project directory. + * @param project the project object (need not yet be registered in {@link ProjectManager}) + * @param aph an Ant project helper + * @param evaluator a way to evaluate Ant properties used to define source locations + * @since org.netbeans.modules.project.ant/1 1.31 + */ + public SourcesHelper(Project project, AntProjectHelper aph, PropertyEvaluator evaluator) { + Parameters.notNull("project", project); this.project = project; + this.aph = aph; this.evaluator = evaluator; } @@ -470,7 +490,7 @@ } private Project getProject() { - return AntBasedProjectFactorySingleton.getProjectFor(project); + return project != null ? project : AntBasedProjectFactorySingleton.getProjectFor(aph); } /** @@ -504,11 +524,14 @@ * {@link FileOwnerQuery#EXTERNAL_ALGORITHM_TRANSIENT}. *

*

- * You may not call this method inside the project's constructor, as - * it requires the actual project to exist and be registered in {@link ProjectManager}. - * Typically you would use {@link org.openide.util.Mutex#postWriteRequest} to run it + * If you used the old constructor form + * {@link #SourcesHelper(AntProjectHelper, PropertyEvaluator)} + * then you may not call this method inside the project's constructor, as + * it requires the actual project to exist and be registered in {@link ProjectManager}; + * in this case you could still use {@link org.openide.util.Mutex#postWriteRequest} to run it * later, if you were creating the helper in your constructor, since the project construction * normally occurs in read access. + * Better to use {@link #SourcesHelper(Project, AntProjectHelper, PropertyEvaluator)}. *

* @param algorithm an external root registration algorithm as per * {@link FileOwnerQuery#markExternalOwner} @@ -584,7 +607,7 @@ allRoots.addAll(nonSourceRoots); allRoots.addAll(ownedFiles); Project p = getProject(); - FileObject pdir = project.getProjectDirectory(); + FileObject pdir = aph.getProjectDirectory(); // First time: register roots and add to lastRegisteredRoots. // Subsequent times: add to newRootsToRegister and maybe add them later. if (lastRegisteredRoots == null) { diff --git a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/SourcesHelperTest.java b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/SourcesHelperTest.java --- a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/SourcesHelperTest.java +++ b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/SourcesHelperTest.java @@ -85,7 +85,7 @@ private Project project2; private SourcesHelper sh2; - protected void setUp() throws Exception { + protected @Override void setUp() throws Exception { super.setUp(); MockLookup.setInstances(AntBasedTestUtil.testAntBasedProjectType()); scratch = TestUtil.makeScratchDir(this); @@ -120,7 +120,7 @@ p.setProperty("ext.file", "../../external/extFile"); h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, p); ProjectManager.getDefault().saveProject(project); - sh = new SourcesHelper(h, h.getStandardPropertyEvaluator()); + sh = new SourcesHelper(project, h, h.getStandardPropertyEvaluator()); sh.addPrincipalSourceRoot("${src1.dir}", "Sources #1", null, null); // inside proj dir sh.addPrincipalSourceRoot("${src2.dir}", "Sources #2", null, null); // outside (rel path) sh.addPrincipalSourceRoot("${src2a.dir}", "Sources #2a", null, null); // redundant @@ -147,7 +147,7 @@ h2 = ProjectGenerator.createProject(proj2dir, "test"); project2 = ProjectManager.getDefault().findProject(proj2dir); assertNotNull("have a project2", project2); - sh2 = new SourcesHelper(h2, h2.getStandardPropertyEvaluator()); + sh2 = new SourcesHelper(project2, h2, h2.getStandardPropertyEvaluator()); sh2.addPrincipalSourceRoot("src1", "Sources #1", null, null); sh2.addPrincipalSourceRoot("src2", "Sources #2", null, null); sh2.addNonSourceRoot("build"); @@ -420,7 +420,7 @@ // h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, p); ProjectManager.getDefault().saveProject(project); - sh = new SourcesHelper(h, h.getStandardPropertyEvaluator()); + sh = new SourcesHelper(project, h, h.getStandardPropertyEvaluator()); sh.addPrincipalSourceRoot("${src1.dir}", "${src1.includes}", "${src1.excludes}", "Sources #1", null, null); sh.addPrincipalSourceRoot("${src2.dir}", "${src2.includes}", "${src2.excludes}", "Sources #2", null, null); sh.addPrincipalSourceRoot("${src3.dir}", "${src3.includes}", null, "Sources #3", null, null); @@ -594,7 +594,7 @@ h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, p); ProjectManager.getDefault().saveProject(project); //minimalSubfolders = true - sh = new SourcesHelper(h, h.getStandardPropertyEvaluator()); + sh = new SourcesHelper(project, h, h.getStandardPropertyEvaluator()); sh.addPrincipalSourceRoot("${src1.dir}", "${src1.includes}", "${src1.excludes}", "Sources #1", null, null); sh.addTypedSourceRoot("${src1.dir}", "${src1.includes}", "${src1.excludes}", "java", "Packages #1", null, null); sh.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT, true); @@ -604,7 +604,7 @@ assertEquals("Packages #1", g1.getDisplayName()); assertNull(FileOwnerQuery.getOwner(src1dir)); //minimalSubfolders = false - sh = new SourcesHelper(h, h.getStandardPropertyEvaluator()); + sh = new SourcesHelper(project, h, h.getStandardPropertyEvaluator()); sh.addPrincipalSourceRoot("${src1.dir}", "${src1.includes}", "${src1.excludes}", "Sources #1", null, null); sh.addTypedSourceRoot("${src1.dir}", "${src1.includes}", "${src1.excludes}", "java", "Packages #1", null, null); sh.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT, false); diff --git a/projectapi/src/org/netbeans/modules/projectapi/AuxiliaryConfigBasedPreferencesProvider.java b/projectapi/src/org/netbeans/modules/projectapi/AuxiliaryConfigBasedPreferencesProvider.java --- a/projectapi/src/org/netbeans/modules/projectapi/AuxiliaryConfigBasedPreferencesProvider.java +++ b/projectapi/src/org/netbeans/modules/projectapi/AuxiliaryConfigBasedPreferencesProvider.java @@ -95,6 +95,7 @@ } AuxiliaryConfiguration ac = ProjectUtils.getAuxiliaryConfiguration(p); + assert p.getLookup() != null : p; AuxiliaryProperties ap = p.getLookup().lookup(AuxiliaryProperties.class); target.put(p, new WeakReference(prov = new AuxiliaryConfigBasedPreferencesProvider(p, ac, ap, shared))); diff --git a/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/ProjectOpenHookImpl.java b/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/ProjectOpenHookImpl.java --- a/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/ProjectOpenHookImpl.java +++ b/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/ProjectOpenHookImpl.java @@ -40,31 +40,17 @@ package org.netbeans.modules.projectimport.eclipse.core; import java.util.concurrent.ExecutionException; -import java.util.logging.Logger; -import org.netbeans.api.project.Project; import org.netbeans.api.project.ui.OpenProjects; import org.netbeans.spi.project.ui.ProjectOpenedHook; import org.openide.util.Exceptions; import org.openide.util.RequestProcessor; -/** - * - */ public class ProjectOpenHookImpl extends ProjectOpenedHook{ private static final RequestProcessor PROJ_OPEN_HOOK_RESYNCHRONIZER = new RequestProcessor("Eclipse.Resynchronizer"); // NOI18N private static RequestProcessor.Task currentTask; - private UpgradableProject upgradable; - private Project project; - - private static final Logger LOG = - Logger.getLogger(ProjectOpenHookImpl.class.getName()); - - public ProjectOpenHookImpl(Project project, UpgradableProject upgradable) { - this.upgradable = upgradable; - this.project = project; - } + public ProjectOpenHookImpl() {} @Override protected synchronized void projectOpened() { diff --git a/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/spi/UpgradableProjectLookupProvider.java b/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/spi/UpgradableProjectLookupProvider.java --- a/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/spi/UpgradableProjectLookupProvider.java +++ b/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/spi/UpgradableProjectLookupProvider.java @@ -40,22 +40,33 @@ package org.netbeans.modules.projectimport.eclipse.core.spi; import org.netbeans.api.project.Project; +import org.netbeans.api.project.ProjectUtils; import org.netbeans.modules.projectimport.eclipse.core.ProjectOpenHookImpl; import org.netbeans.modules.projectimport.eclipse.core.UpgradableProject; import org.netbeans.spi.project.LookupProvider; import org.openide.util.Lookup; import org.openide.util.lookup.Lookups; -// registered separately in j2se and web modules, but could use @LookupProvider.Registration +// registered separately in j2se and web modules, otherwise could use @LookupProvider.Registration final public class UpgradableProjectLookupProvider implements LookupProvider { public Lookup createAdditionalLookup(Lookup baseContext) { Project p = baseContext.lookup(Project.class); assert p != null; - UpgradableProject up = new UpgradableProject(p); + if (ProjectUtils.getPreferences(p, UpgradableProjectLookupProvider.class, true). + get("project", null) == null) { // NOI18N + // Shortcut, the normal case: + return Lookup.EMPTY; + } else { + // Keep as separate method to try to delay class initialization: + return upgradeLookup(p); + } + } + + private static Lookup upgradeLookup(Project p) { return Lookups.fixed( - up, - new ProjectOpenHookImpl(p, up)); + new UpgradableProject(p), + new ProjectOpenHookImpl()); } } diff --git a/projectimport.eclipse.core/test/unit/src/org/netbeans/modules/projectimport/eclipse/core/spi/ProjectFactorySupportTest.java b/projectimport.eclipse.core/test/unit/src/org/netbeans/modules/projectimport/eclipse/core/spi/ProjectFactorySupportTest.java --- a/projectimport.eclipse.core/test/unit/src/org/netbeans/modules/projectimport/eclipse/core/spi/ProjectFactorySupportTest.java +++ b/projectimport.eclipse.core/test/unit/src/org/netbeans/modules/projectimport/eclipse/core/spi/ProjectFactorySupportTest.java @@ -46,7 +46,6 @@ import java.util.Collections; import java.util.List; import org.netbeans.api.java.platform.JavaPlatform; -import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectManager; import org.netbeans.api.project.ProjectUtils; @@ -225,14 +224,6 @@ model.getEclipseTestSourceRootsAsFileArray(), null, null, null); J2SEProject p = (J2SEProject)ProjectManager.getDefault().findProject(helper.getProjectDirectory()); List importProblems = new ArrayList(); - - // - // NB-Core-Build #1293: "No project found to correspond to .../spcp/eclipse/src" from ProjectClassPathModifier.findExtensible - // - // Looks like J2SEProject registers its external source roots asynchronously and sometimes - // it is too late and above problem happens. Mark external source roots explicitly here: - FileOwnerQuery.markExternalOwner(model.getEclipseSourceRootsAsFileArray()[0].toURI(), p, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); - ProjectFactorySupport.updateProjectClassPath(helper, p.getReferenceHelper(), model, importProblems); EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); assertEquals( @@ -262,14 +253,6 @@ model.getEclipseTestSourceRootsAsFileArray(), null, null, null); J2SEProject p = (J2SEProject)ProjectManager.getDefault().findProject(helper.getProjectDirectory()); List importProblems = new ArrayList(); - - // - // NB-Core-Build #1293: "No project found to correspond to .../spcp/eclipse/src" from ProjectClassPathModifier.findExtensible - // - // Looks like J2SEProject registers its external source roots asynchronously and sometimes - // it is too late and above problem happens. Mark external source roots explicitly here: - FileOwnerQuery.markExternalOwner(model.getEclipseSourceRootsAsFileArray()[0].toURI(), p, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); - ProjectFactorySupport.updateProjectClassPath(helper, p.getReferenceHelper(), model, importProblems); EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); assertEquals( @@ -355,14 +338,6 @@ model.getEclipseTestSourceRootsAsFileArray(), null, null, null); J2SEProject p = (J2SEProject)ProjectManager.getDefault().findProject(helper.getProjectDirectory()); List importProblems = new ArrayList(); - - // - // NB-Core-Build #1293: "No project found to correspond to .../spcp/eclipse/src" from ProjectClassPathModifier.findExtensible - // - // Looks like J2SEProject registers its external source roots asynchronously and sometimes - // it is too late and above problem happens. Mark external source roots explicitly here: - FileOwnerQuery.markExternalOwner(model.getEclipseSourceRootsAsFileArray()[0].toURI(), p, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); - ProjectFactorySupport.updateProjectClassPath(helper, p.getReferenceHelper(), model, importProblems); EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); // required project "JavaLibrary1" is not available and therefore should not be @@ -411,14 +386,6 @@ mdl_d.getEclipseTestSourceRootsAsFileArray(), null, null, null); List problems = new ArrayList(); J2SEProject j2seprj_d = (J2SEProject) ProjectManager.getDefault().findProject(aph_d.getProjectDirectory()); - - // - // NB-Core-Build #1293: "No project found to correspond to .../spcp/eclipse/src" from ProjectClassPathModifier.findExtensible - // - // Looks like J2SEProject registers its external source roots asynchronously and sometimes - // it is too late and above problem happens. Mark external source roots explicitly here: - FileOwnerQuery.markExternalOwner(mdl_d.getEclipseSourceRootsAsFileArray()[0].toURI(), j2seprj_d, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); - ProjectFactorySupport.updateProjectClassPath(aph_d, j2seprj_d.getReferenceHelper(), mdl_d, problems); assertEquals(Collections.emptyList(), problems); assertEquals("${reference.c.jar}:${reference.b.jar}", aph_d.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH).get("javac.classpath")); diff --git a/web.project/src/org/netbeans/modules/web/project/WebProject.java b/web.project/src/org/netbeans/modules/web/project/WebProject.java --- a/web.project/src/org/netbeans/modules/web/project/WebProject.java +++ b/web.project/src/org/netbeans/modules/web/project/WebProject.java @@ -185,7 +185,7 @@ private final PropertyEvaluator eval; private final ReferenceHelper refHelper; private final GeneratedFilesHelper genFilesHelper; - private final Lookup lookup; + private Lookup lookup; private final ProjectWebModule webModule; private final CopyOnSaveSupport css; private final ArtifactCopyOnSaveSupport artifactSupport; @@ -528,6 +528,7 @@ LookupMergerSupport.createJFBLookupMerger(), QuerySupport.createBinaryForSourceQueryImplementation(sourceRoots, testRoots, helper, eval), }); + lookup = base; return LookupProviderSupport.createCompositeLookup(base, "Projects/org-netbeans-modules-web-project/Lookup"); //NOI18N }