use of org.eclipse.wst.jsdt.internal.core.JavaElement in project webtools.sourceediting by eclipse.
the class JFaceNodeAdapterForJs method getChildren.
public Object[] getChildren(Object object) {
if (object instanceof IJavaScriptElement) {
return getJavaElementProvider().getChildren(object);
}
if (object instanceof IJavaWebNode) {
JavaElement enclosedElement = (JavaElement) ((IJavaWebNode) object).getJavaElement();
if (enclosedElement != null) {
try {
IJavaScriptElement[] children = enclosedElement.getChildren();
if (children == null) {
return new IJavaScriptElement[0];
}
Object[] nodes = new Object[children.length];
Node parent = ((IJavaWebNode) object).getParentNode();
for (int i = 0; i < children.length; i++) {
// int htmllength = ((SourceRefElement) (children[i])).getSourceRange().getLength();
// int htmloffset = ((SourceRefElement) (children[i])).getSourceRange().getOffset();
IJavaScriptElement javaElement = children[i];
ISourceRange range = null;
if (javaElement instanceof Member) {
range = ((IMember) javaElement).getNameRange();
} else {
range = ((ISourceReference) javaElement).getSourceRange();
}
int htmllength = range.getLength();
int htmloffset = range.getOffset();
Position position = new Position(htmloffset, htmllength);
nodes[i] = getJsNode(parent, javaElement, position);
}
return nodes;
} catch (JavaScriptModelException ex) {
}
}
}
Node node = (Node) object;
if (isJSElementParent(node)) {
Object[] results = getJSElementsFromNode(node.getFirstChild(), true);
return filter(results);
}
return super.getChildren(object);
}
Aggregations