Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2019-05-12 06:53:11 -0400
committerStephan Herrmann2019-05-12 06:53:11 -0400
commit467fcae66a2b2209658bc940708896e0bd80e606 (patch)
tree7acab7bcf20d5d6b9111918819507b5b1268f7b8
parent6b17b845d62c5069b21026c2cfe942c17aae6899 (diff)
downloadeclipse.jdt.core-467fcae66a2b2209658bc940708896e0bd80e606.tar.gz
eclipse.jdt.core-467fcae66a2b2209658bc940708896e0bd80e606.tar.xz
eclipse.jdt.core-467fcae66a2b2209658bc940708896e0bd80e606.zip
Bug 547197 - [9][model] API to get the kind of a IModuleDescription
Change-Id: I711c1322ade275a3ca0fff51e53588a02cef2935 Signed-off-by: Stephan Herrmann <stephan.herrmann@berlin.de>
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/provisional/JavaModelAccess.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/provisional/JavaModelAccess.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/provisional/JavaModelAccess.java
index 9e6ebc4b76..73e7644700 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/provisional/JavaModelAccess.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/provisional/JavaModelAccess.java
@@ -15,8 +15,10 @@ package org.eclipse.jdt.core.provisional;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IModuleDescription;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.core.JavaProject;
+import org.eclipse.jdt.internal.core.JrtPackageFragmentRoot;
import org.eclipse.jdt.internal.core.PackageFragmentRoot;
/**
@@ -61,4 +63,17 @@ public class JavaModelAccess {
throw new IllegalArgumentException("Illegal kind of java element: "+element.getElementType()); //$NON-NLS-1$
}
}
+
+ /**
+ * Answer whether the given module is a system module.
+ * <p><em>This provisional API may likely be changed into a direct method {@code IModuleDescription.isSystemModule()}.</em></p>
+ *
+ * @param module the module being queried about
+ * @return {@code true} iff the module is defined in the system library (also known as JRE).
+ * @since 3.18
+ */
+ public static boolean isSystemModule(IModuleDescription module) {
+ IPackageFragmentRoot pfr = (IPackageFragmentRoot) module.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
+ return pfr instanceof JrtPackageFragmentRoot;
+ }
}

Back to the top