Java Code Examples for org.eclipse.jdt.core.IParent#getChildren()

The following examples show how to use org.eclipse.jdt.core.IParent#getChildren() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NLSSearchResult.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void collectMatches(Set<Match> matches, IJavaElement element) {
	//TODO: copied from JavaSearchResult:
	Match[] m= getMatches(element);
	if (m.length != 0) {
		for (int i= 0; i < m.length; i++) {
			matches.add(m[i]);
		}
	}
	if (element instanceof IParent) {
		IParent parent= (IParent) element;
		try {
			IJavaElement[] children= parent.getChildren();
			for (int i= 0; i < children.length; i++) {
				collectMatches(matches, children[i]);
			}
		} catch (JavaModelException e) {
			// we will not be tracking these results
		}
	}
}
 
Example 2
Source File: AbstractJavaSearchResult.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void collectMatches(Set<Match> matches, IJavaElement element) {
	Match[] m= getMatches(element);
	if (m.length != 0) {
		for (int i= 0; i < m.length; i++) {
			matches.add(m[i]);
		}
	}
	if (element instanceof IParent) {
		IParent parent= (IParent) element;
		try {
			IJavaElement[] children= parent.getChildren();
			for (int i= 0; i < children.length; i++) {
				collectMatches(matches, children[i]);
			}
		} catch (JavaModelException e) {
			// we will not be tracking these results
		}
	}
}
 
Example 3
Source File: JavaBrowsingContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private Object[] getChildren(IType type) throws JavaModelException{
	IParent parent;
	if (type.isBinary())
		parent= type.getClassFile();
	else {
		parent= type.getCompilationUnit();
	}
	if (type.getDeclaringType() != null)
		return type.getChildren();

	// Add import declarations
	IJavaElement[] members= parent.getChildren();
	ArrayList<IJavaElement> tempResult= new ArrayList<IJavaElement>(members.length);
	for (int i= 0; i < members.length; i++)
		if ((members[i] instanceof IImportContainer))
			tempResult.add(members[i]);
	tempResult.addAll(Arrays.asList(type.getChildren()));
	return tempResult.toArray();
}
 
Example 4
Source File: JdtUtils.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Traverses down the children tree of this parent and collect all child
 * anon. classes
 *
 * @param list
 * @param parent
 * @param allowNested
 *            true to search in IType child elements too
 * @throws JavaModelException
 */
private static void collectAllAnonymous(List<IType> list, IParent parent, boolean allowNested) throws JavaModelException {
    IJavaElement[] children = parent.getChildren();
    for (int i = 0; i < children.length; i++) {
        IJavaElement childElem = children[i];
        if (isAnonymousType(childElem)) {
            list.add((IType) childElem);
        }
        if (childElem instanceof IParent) {
            if (allowNested || !(childElem instanceof IType)) {
                collectAllAnonymous(list, (IParent) childElem, allowNested);
            }
        }
    }
}
 
Example 5
Source File: CopyElementsOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the anchor used for positioning in the destination for
 * the element being renamed. For renaming, if no anchor has
 * explicitly been provided, the element is anchored in the same position.
 */
private IJavaElement resolveRenameAnchor(IJavaElement element) throws JavaModelException {
	IParent parent = (IParent) element.getParent();
	IJavaElement[] children = parent.getChildren();
	for (int i = 0; i < children.length; i++) {
		IJavaElement child = children[i];
		if (child.equals(element)) {
			return child;
		}
	}
	return null;
}