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.
There are several copies on the J2SESources class spreading through java, j2ee, ruby, python, j2me clusters. There should be a common version covering all these use cases.
Can anyone expand on this? Is this copies of J2SESources or is this classes that implement Sources that are copy/paste copies of J2SESources?
(In reply to comment #1) > Is this copies of J2SESources or is this classes > that implement Sources that are copy/paste copies of J2SESources? The latter, I think. SourceRoots covers some of the infrastructure but I imagine more could be shared. Are you interested in working on it?
Yes, it's an implementation of Sources which delegates to SourcesHelper. The class solves adding and removing of source roots and was introduced in NB 4.1 when adding support for multiple source roots. Th problem is that the API will require SPI class (org.netbeans.modules.java.api.common.SourceRoots) which is a part of the java.common.api but the API should belong to project.ant as the copies are also in PHP, Ruby, Python which cannot depend on java.common.api. The API should look like something like: public class SourcesFactory { private SourcesFactory(){} p s Sources createSources(Project p, APH aph, PE eval, Collection<? extends SourceRootsLike> src, String... nonSourceRootProps){ return new J2SESources(....);} }
If it's good enough to solve just the "java" projects (no ruby or python) I can attach the API patch. J2SESources moved into j.c.a where the SourceRoots is available and factory method added into QuerySupport. I've fixed just a j2seproject to use it.
You know more about this so you should probably review any patches.
Created attachment 99603 [details] The diff file
I've added a factory method into the QuerySupport and fixed all usages in j2se, web, j2ee. I will also fix the j2me + card before commit. There is no nice solution how to remove the copy of *Sources as they are modified in projects and also have a custom method providing the SourceGroupModifierImplementaion. Rather than adding a special subtype of Sources with a new method getSourceGroupModifier as it was done, the factory method returns a Sources instance which also implements the SGMI. Not very nice but seems better than a new type. I've also had to create a supertype of SourceRoots as the web project and j2eeproject have typed source roots which are not based on SourceRoots (project.xml + properties). The supertype is nicer than adding List of String[] into the factory method.
It would be good if someone from web team can look to the rewritten parts of web (j2ee). Thanks
LibrarySourceGroup_DisplayName bundle key may need to be moved. Might need to add a change listener to sgmi & refire from SourcesImpl. Are you still listening to changes in J2SEProjectProperties.{BUILD,DIST}_DIR?
Consider also moving J2SESourcesTest and/or SourceRootsTest to java.api.common.
>LibrarySourceGroup_DisplayName bundle key may need to be moved. Fixed. >Might need to add a change listener to sgmi & refire from SourcesImpl. Sgmi does not support listening and has no listeners. >Are you still listening to changes in J2SEProjectProperties.{BUILD,DIST}_DIR? This is what I am not sure about it. I've removed it as I think it was not needed, the {BUILD,DIST}_DIR are registered to SourcesHelper by addNonSourcesRoot. The Sources created by SourcesHelper fire ChangeEvent which is delegated when property changed. I will add a test. >Consider also moving J2SESourcesTest and/or SourceRootsTest to java.api.common. I've added a new SourcesImplTest instead of moving the J2SESourcesTest as it's very j2seproject dependent. I will try to move the SourceRootsTest into java.api.common. Thanks for the review.
I am going to integrate it.
Fixed a81f706cef4e
Integrated into 'main-golden', will be available in build *201006040001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/a81f706cef4e User: Tomas Zezula <tzezula@netbeans.org> Log: #148320:Create API for common delegating Sources