[238550] Schema code completion causes stack error
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDescriptionBuilder.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDescriptionBuilder.java
index 49c9da1..f1cc690 100644
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDescriptionBuilder.java
+++ b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDescriptionBuilder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation and others.
+ * Copyright (c) 2002, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.wst.xml.core.internal.contentmodel.util;
+import java.util.Stack;
+
import org.eclipse.wst.xml.core.internal.contentmodel.CMAnyElement;
import org.eclipse.wst.xml.core.internal.contentmodel.CMContent;
import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
@@ -27,6 +29,7 @@
protected StringBuffer sb;
protected CMNode root;
protected boolean isRootVisited;
+ protected Stack visitedCMGroupStack = new Stack();
public String buildDescription(CMNode node)
{
@@ -59,6 +62,11 @@
public void visitCMGroup(CMGroup group)
{
+ // This is to prevent recursion.
+ if (visitedCMGroupStack.contains(group))
+ {
+ return;
+ }
int op = group.getOperator();
if (op == CMGroup.ALL)
{
@@ -73,7 +81,10 @@
{
separator = " | "; //$NON-NLS-1$
}
-
+
+ // Push the current group to check later to avoid potential recursion
+ visitedCMGroupStack.push(group);
+
CMNodeList nodeList = group.getChildNodes();
int size = nodeList.getLength();
for (int i = 0; i < size; i++)
@@ -84,6 +95,10 @@
sb.append(separator);
}
}
+
+ // Pop the current group
+ visitedCMGroupStack.pop();
+
sb.append(")"); //$NON-NLS-1$
addOccurenceSymbol(group);
}