Community
Participate
Working Groups
Build id: M20071023-1652 It would be nice if there were an option to tell Organize Imports to add comments saying which eclipse project a particular import came from. (We have close on 100 projects, and sometimes it's not obvious which one needs to be opened/imported in order to fix a "Cannot be resolved to a type" compile problem.)
I'm sorry but we won't add this. > sometimes it's not obvious which one needs to be opened/imported Quickly use Open Type to see the project or do a Java search.
Ah, and if you really need this, you could create your own plug-in with an action that simply appends the project name (or full path) behind each import or even groups them per project.
(In reply to comment #1) > > sometimes it's not obvious which [project] needs to be opened/imported > Quickly use Open Type to see the project or do a Java search. That works, if the project in which the import lives is open. But if the project isn't open, then Eclipse (of course) won't find it. That said, I agree that commenting the imports is a kludge. (In reply to comment #2) > Ah, and if you really need this, you could create your own plug-in with an > action that simply appends the project name (or full path) behind each import > or even groups them per project. That sounds like it might be the way to go. Thanks, Ben
>That works, if the project in which the import lives is open. >But if the project isn't open, then Eclipse (of course) won't find it. Right, because the reason for having a closed project is to reduce memory footprint. If we'd go and open this to add some comment we'd violate that principle. Ben, if you plan to add your own plug-in you might do better than commenting or searching: you could contribute a quick fix that would for example open the needed project and add it to the build path if not yet there. And if you're using 3.4 then it's even simpler: take a look at the org.eclipse.jdt.ui.classpathFixProcessors extension point.
(In reply to comment #4) > Right, because the reason for having a closed project is to reduce memory > footprint. If we'd go and open this to add some comment we'd violate that > principle. Not sure I follow this. To have the information needed to add a comment both projects already need to be open, no? Suppose Project_A contains Class_A. And Class_A #imports Class_B which is in Project_B. What I was thinking was that it might be nice to comment the import statement in Class_A with some indication that Class_B is in Project_B. The benefit being that later, if someone tries to build Class_A with Project_B closed, there is a comment that tells them where to look. I wasn't planning on having comments added to Class_B saying what its 'consumers' are. Or have I completely missed what you're saying? > Ben, if you plan to add your own plug-in you might do better than commenting or > searching: you could contribute a quick fix that would for example open the > needed project and add it to the build path if not yet there. And if you're > using 3.4 then it's even simpler: take a look at the > org.eclipse.jdt.ui.classpathFixProcessors extension point. Yes, that would be nice. You might still want some record somewhere so that you know whether to open Project_B1 or Project_B2. I guess that could be an in-line comment, or something in the .project file. Which raises a question for me. I know there is some tracking of inter-project dependency, is there a reasons that it doesn't already cover this situation?
>Not sure I follow this. To have the information needed to add a comment both >projects already need to be open, no? From your previous comments I assumed that some of the needed projects might be closed even when trying to make a comment. Since that is not the case then I don't see your problem. Normally you either have the dependent projects on the Java build path and/or they are listed in the manifest.mf. In that case you should see an error on the project or on the manifest.mf telling you what's missing.
No, when the initial import is done, everything is open. Later, when someone else comes along and opens the importing project, they can get an error if the imported project isn't open. I admit, I'm not sure why this happens - as per my previous comment, I know there is some degree of linkage between projects, but it doesn't seem to be complete. Sometimes, when opening a project, Eclipse offers to also open the projects that project depends on, but sometimes, I find I have an open project that has errors because some imports are from projects that seemingly didn't get opened. It could be user error somewhere, I just don't know.
PS. (Also in reply to comment #6) > Normally you either have the dependent projects on the > Java build path and/or they are listed in the manifest.mf. In that case you > should see an error on the project or on the manifest.mf telling you what's > missing. You'd think so. I must have missed something, somewhere. I'll keep an eye out and see if it happens again.