summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpschonbac2008-01-25 12:07:10 (EST)
committerpschonbac2008-01-25 12:07:10 (EST)
commite35640a05bb1cd9b2a86b3b77a46fc0d5844dbb9 (patch)
tree61c9a86bb6b3e5c48df064dbad92eea1d9cbd91e
parent9311495329ac85d9840dcadf8b0321ade8d30c8e (diff)
downloadorg.eclipse.xpand-e35640a05bb1cd9b2a86b3b77a46fc0d5844dbb9.zip
org.eclipse.xpand-e35640a05bb1cd9b2a86b3b77a46fc0d5844dbb9.tar.gz
org.eclipse.xpand-e35640a05bb1cd9b2a86b3b77a46fc0d5844dbb9.tar.bz2
[Bug 206621] Stack overflow Exception
URL: https://bugs.eclipse.org/bugs/show_bug.cgi?id=206621 (on behalf of Karsten Thoms)
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/EmfToolsPlugin.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/EmfToolsPlugin.java b/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/EmfToolsPlugin.java
index bf825f5..f181f1c 100644
--- a/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/EmfToolsPlugin.java
+++ b/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/EmfToolsPlugin.java
@@ -178,6 +178,25 @@ public class EmfToolsPlugin extends AbstractUIPlugin {
* are accessible.
*/
public EPackage[] getMetamodelsForProject(IJavaProject project) {
+ Set<String> visited = new HashSet<String>();
+ return getMetamodelsForProjectInternal(project, visited);
+ }
+
+ /**
+ * Retrieves the list of EPackages that are accessible for the given
+ * project, i.e. that are in the project's classpath. The referenced projects are searched
+ * recursively, but loops are detected.
+ *
+ * @param project The project to retrieve the metamodels for. Must not be null.
+ * @param visited The names of the projects that have already been visited.
+ * @return The metamodels for the given project. An empty array if none
+ * are accessible.
+ */
+ private EPackage[] getMetamodelsForProjectInternal(IJavaProject project, Set<String> visited) {
+ if (visited.contains(project.getProject().getName()))
+ return new EPackage[0];
+ visited.add(project.getProject().getName());
+
ProjectAnalyzer projectAnalyzer = getProjectAnalyzer(project.getProject());
if (projectAnalyzer == null) {
return new EPackage[0];
@@ -197,7 +216,7 @@ public class EmfToolsPlugin extends AbstractUIPlugin {
try {
for (IProject p : project.getProject().getReferencedProjects()) {
IJavaProject jp = JavaCore.create(p);
- EPackage[] ps = getMetamodelsForProject(jp);
+ EPackage[] ps = getMetamodelsForProjectInternal(jp, visited);
for (EPackage package1 : ps) {
if (!packages.containsKey(package1.getNsURI())) {
packages.put(package1.getNsURI(), package1);
@@ -249,7 +268,7 @@ public class EmfToolsPlugin extends AbstractUIPlugin {
* @param visited All project names that where already visited during this recursion. This is to avoid loops when having
* circular dependencies.
*/
- private void collectReferencingExtXptProjects(IProject project, Map<String, IProject> referencingProjects, Set<String> visited) {
+ private void collectReferencingExtXptProjects(IProject project, Map<String, IProject> referencingProjects, Set<String> visited) {
if (visited.contains(project.getName()))
return;
visited.add(project.getName());