Bug 540644 - IPackageFragmentRoot::getModuleDescription returns null for AutoModules
Summary: IPackageFragmentRoot::getModuleDescription returns null for AutoModules
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.10   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks: 539782
  Show dependency tree
 
Reported: 2018-10-31 05:09 EDT by Kalyan Prasad Tatavarthi CLA
Modified: 2022-12-27 15:49 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kalyan Prasad Tatavarthi CLA 2018-10-31 05:09:57 EDT
IPackageFragmentRoot::getModuleDescription returns null for AutoModules 

There is an API on IModuleDescription isAutoModule which specifies if it is an auto module or not.

So, IPackageFragmentRoot should return a non-null IModuleDescription.


This breaks the module related QuickAssists for Auto Modules.
Comment 1 Andrey Loskutov CLA 2018-10-31 05:15:58 EDT
Kalyan, are you on latest master? Do you see the fix for bug 539698 (I20181030-1800)?

How one can reproduce the issue?
Comment 2 Jay Arthanareeswaran CLA 2018-10-31 05:22:15 EDT
(In reply to Andrey Loskutov from comment #1)
> Kalyan, are you on latest master? Do you see the fix for bug 539698
> (I20181030-1800)?
> 
> How one can reproduce the issue?

Andrey, I have been following that bug. But it's not clear to me whether it will return non-null for automatic modules, which is what Kalyan is interested in.
Comment 3 Andrey Loskutov CLA 2018-10-31 05:28:09 EDT
(In reply to Jay Arthanareeswaran from comment #2)
> (In reply to Andrey Loskutov from comment #1)
> > Kalyan, are you on latest master? Do you see the fix for bug 539698
> > (I20181030-1800)?
> > 
> > How one can reproduce the issue?
> 
> Andrey, I have been following that bug. But it's not clear to me whether it
> will return non-null for automatic modules, which is what Kalyan is
> interested in.

This is not clear for me too, because AutoModule is not implementing IPackageFragmentRoot and I do not see where is the relationship between AutoModule and IPackageFragmentRoot::getModuleDescription.
Comment 4 Kalyan Prasad Tatavarthi CLA 2018-10-31 06:02:55 EDT
(In reply to Andrey Loskutov from comment #3)
> (In reply to Jay Arthanareeswaran from comment #2)
> > (In reply to Andrey Loskutov from comment #1)
> > > Kalyan, are you on latest master? Do you see the fix for bug 539698
> > > (I20181030-1800)?
> > > 
> > > How one can reproduce the issue?
> > 
> > Andrey, I have been following that bug. But it's not clear to me whether it
> > will return non-null for automatic modules, which is what Kalyan is
> > interested in.
> 
> This is not clear for me too, because AutoModule is not implementing
> IPackageFragmentRoot and I do not see where is the relationship between
> AutoModule and IPackageFragmentRoot::getModuleDescription.

The use case for this issue is the bug 239782.

While providing a quickfix for missing import on a type, if the type belongs to an Auto Module we will need to add "requires" statement in the module-info.java file.

The current procedure to get the module information for a type is to get the IPackageFragmentRoot in which the type is defined and get its IModuleDescription.

Currently this returns null for AutoModules.
Comment 5 Kalyan Prasad Tatavarthi CLA 2018-10-31 06:03:31 EDT
(In reply to Kalyan Prasad Tatavarthi from comment #4)
> (In reply to Andrey Loskutov from comment #3)
> > (In reply to Jay Arthanareeswaran from comment #2)
> > > (In reply to Andrey Loskutov from comment #1)
> > > > Kalyan, are you on latest master? Do you see the fix for bug 539698
> > > > (I20181030-1800)?
> > > > 
> > > > How one can reproduce the issue?
> > > 
> > > Andrey, I have been following that bug. But it's not clear to me whether it
> > > will return non-null for automatic modules, which is what Kalyan is
> > > interested in.
> > 
> > This is not clear for me too, because AutoModule is not implementing
> > IPackageFragmentRoot and I do not see where is the relationship between
> > AutoModule and IPackageFragmentRoot::getModuleDescription.
> 
> The use case for this issue is the bug 239782.
> 
> While providing a quickfix for missing import on a type, if the type belongs
> to an Auto Module we will need to add "requires" statement in the
> module-info.java file.
> 
> The current procedure to get the module information for a type is to get the
> IPackageFragmentRoot in which the type is defined and get its
> IModuleDescription.
> 
> Currently this returns null for AutoModules.

Its the bug 539782
Comment 6 Andrey Loskutov CLA 2018-10-31 06:07:13 EDT
Kalayan, van you please point me to the related code where you ask for the module description?
Comment 7 Stephan Herrmann CLA 2018-11-06 07:33:44 EST
Kalyan, I believe you need to call org.eclipse.jdt.core.provisional.JavaModelAccess.getAutomaticModuleDescription(IJavaElement) (see bug 525208).

IPackageFragmentRoot.getModuleDescription() has no provision to synthesize a module description for an auto module.

When you start using the method in JavaModelAccess please file a follow-up bug for migrating the provisional API to some permanent place.
Comment 8 Kalyan Prasad Tatavarthi CLA 2018-11-12 03:34:26 EST
(In reply to Stephan Herrmann from comment #7)
> Kalyan, I believe you need to call
> org.eclipse.jdt.core.provisional.JavaModelAccess.
> getAutomaticModuleDescription(IJavaElement) (see bug 525208).
> 
> IPackageFragmentRoot.getModuleDescription() has no provision to synthesize a
> module description for an auto module.
> 
> When you start using the method in JavaModelAccess please file a follow-up
> bug for migrating the provisional API to some permanent place.

Thanks Stephan, This API is helpful.

Once The changes go into JDT UI, I will create a bug requesting the migration of the provisonal API to some permanent place.
Comment 9 Eclipse Genie CLA 2020-11-02 05:06:07 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 10 Eclipse Genie CLA 2022-12-27 15:49:12 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.