Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2019-10-19 14:15:55 -0400
committerStephan Herrmann2019-10-19 14:16:10 -0400
commit9ef03eee1438718368e8d3a7fe69a47ee6a51ef0 (patch)
tree45d483bc6f0303be009dbd123482b870bb810cc0
parent084f94ac85d1f661580309ab1a2d301071ee80dd (diff)
downloadeclipse.jdt.core-9ef03eee1438718368e8d3a7fe69a47ee6a51ef0.tar.gz
eclipse.jdt.core-9ef03eee1438718368e8d3a7fe69a47ee6a51ef0.tar.xz
eclipse.jdt.core-9ef03eee1438718368e8d3a7fe69a47ee6a51ef0.zip
Bug 552247 - [9][model] API to get a project's module disregardingI20191023-1810I20191022-1800I20191022-0405I20191020-1800I20191019-1800
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java20
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java6
2 files changed, 24 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java
index f095b8f82b..0938c2f4ce 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java
@@ -610,7 +610,7 @@ public interface IJavaProject extends IParent, IJavaElement, IOpenable {
IProject getProject();
/**
- * Returns the <code>IModuleDescription</code> this project represents or
+ * Returns the {@link IModuleDescription} this project represents or
* null if the Java project doesn't represent any named module. A Java
* project is said to represent a module if any of its source package
* fragment roots (see {@link IPackageFragmentRoot#K_SOURCE}) contains a
@@ -620,7 +620,7 @@ public interface IJavaProject extends IParent, IJavaElement, IOpenable {
* In the latter case the corresponding module description of the
* location referenced by that classpath entry is returned.
*
- * @return the <code>IModule</code> this project represents.
+ * @return the {@link IModuleDescription} this project represents.
* @exception JavaModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
* @since 3.14
@@ -628,6 +628,22 @@ public interface IJavaProject extends IParent, IJavaElement, IOpenable {
IModuleDescription getModuleDescription() throws JavaModelException;
/**
+ * Returns the <code>IModuleDescription</code> owned by this project or
+ * null if the Java project doesn't own a valid Java module descriptor.
+ * This method considers only module descriptions contained in any of the
+ * project's source package fragment roots (see {@link IPackageFragmentRoot#K_SOURCE}).
+ * In particular any {@link IClasspathAttribute#PATCH_MODULE} attribute
+ * is not considered.
+ *
+ * @return the {@link IModuleDescription} this project owns.
+ * @exception JavaModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource
+ * @throws JavaModelException
+ * @since 3.20
+ */
+ IModuleDescription getOwnModuleDescription() throws JavaModelException;
+
+ /**
* Returns the raw classpath for the project, as a list of classpath
* entries. This corresponds to the exact set of entries which were assigned
* using <code>setRawClasspath</code>, in particular such a classpath may
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
index e2cf1bfbc6..d91f25149a 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
@@ -3831,6 +3831,12 @@ public class JavaProject
return null;
}
+ @Override
+ public IModuleDescription getOwnModuleDescription() throws JavaModelException {
+ JavaProjectElementInfo info = (JavaProjectElementInfo) getElementInfo();
+ return info.getModule();
+ }
+
public List<String> getPatchedModules(IClasspathEntry cpEntry) {
String patchModules = ClasspathEntry.getExtraAttribute(cpEntry, IClasspathAttribute.PATCH_MODULE);
if (patchModules != null) {

Back to the top