X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaElement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaElement.java index bababc6..c45befb 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaElement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaElement.java @@ -10,8 +10,13 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.core; +import java.util.ArrayList; + +import net.sourceforge.phpdt.core.ICompilationUnit; import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.IJavaModel; +import net.sourceforge.phpdt.core.IJavaModelStatusConstants; +import net.sourceforge.phpdt.core.IJavaProject; import net.sourceforge.phpdt.core.IOpenable; import net.sourceforge.phpdt.core.JavaModelException; @@ -160,15 +165,15 @@ public abstract class JavaElement extends PlatformObject implements IJavaElement /** * @see IJavaElement */ -// public boolean exists() { -// -// try { -// getElementInfo(); -// return true; -// } catch (JavaModelException e) { -// } -// return false; -// } + public boolean exists() { + + try { + getElementInfo(); + return true; + } catch (JavaModelException e) { + } + return false; + } /** * Returns the IDOMNode that corresponds to this JavaElement @@ -249,39 +254,39 @@ public abstract class JavaElement extends PlatformObject implements IJavaElement /** * @see IParent */ -// public IJavaElement[] getChildren() throws JavaModelException { -// return ((JavaElementInfo)getElementInfo()).getChildren(); -// } + public IJavaElement[] getChildren() throws JavaModelException { + return ((JavaElementInfo)getElementInfo()).getChildren(); + } /** * Returns a collection of (immediate) children of this node of the * specified type. * * @param type - one of constants defined by IJavaLanguageElementTypes */ -// public ArrayList getChildrenOfType(int type) throws JavaModelException { -// IJavaElement[] children = getChildren(); -// int size = children.length; -// ArrayList list = new ArrayList(size); -// for (int i = 0; i < size; ++i) { -// JavaElement elt = (JavaElement)children[i]; -// if (elt.getElementType() == type) { -// list.add(elt); -// } -// } -// return list; -// } + public ArrayList getChildrenOfType(int type) throws JavaModelException { + IJavaElement[] children = getChildren(); + int size = children.length; + ArrayList list = new ArrayList(size); + for (int i = 0; i < size; ++i) { + JavaElement elt = (JavaElement)children[i]; + if (elt.getElementType() == type) { + list.add(elt); + } + } + return list; + } /** * @see IMember */ // public IClassFile getClassFile() { // return null; // } -// /** -// * @see IMember -// */ -// public ICompilationUnit getCompilationUnit() { -// return null; -// } + /** + * @see IMember + */ + public ICompilationUnit getCompilationUnit() { + return null; + } /** * Returns the info for this handle. * If this element is not already open, it and all of its parents are opened. @@ -289,10 +294,10 @@ public abstract class JavaElement extends PlatformObject implements IJavaElement * NOTE: BinaryType infos are NJOT rooted under JavaElementInfo. * @exception JavaModelException if the element is not present or not accessible */ -// public Object getElementInfo() throws JavaModelException { -// -// // workaround to ensure parent project resolved classpath is available to avoid triggering initializers -// // while the JavaModelManager lock is acquired (can cause deadlocks in clients) + public Object getElementInfo() throws JavaModelException { +return null; + // workaround to ensure parent project resolved classpath is available to avoid triggering initializers + // while the JavaModelManager lock is acquired (can cause deadlocks in clients) // IJavaProject project = getJavaProject(); // if (project != null && !project.isOpen()) { // // TODO: need to revisit, since deadlock could still occur if perProjectInfo is removed concurrent before entering the lock @@ -316,7 +321,7 @@ public abstract class JavaElement extends PlatformObject implements IJavaElement // } // return info; // } -// } + } /** * @see IAdaptable */ @@ -359,17 +364,17 @@ public abstract class JavaElement extends PlatformObject implements IJavaElement } while ((current = current.getParent()) != null); return null; } -// -// /** -// * @see IJavaElement -// */ -// public IJavaProject getJavaProject() { -// IJavaElement current = this; -// do { -// if (current instanceof IJavaProject) return (IJavaProject) current; -// } while ((current = current.getParent()) != null); -// return null; -// } + + /** + * @see IJavaElement + */ + public IJavaProject getJavaProject() { + IJavaElement current = this; + do { + if (current instanceof IJavaProject) return (IJavaProject) current; + } while ((current = current.getParent()) != null); + return null; + } /** * Returns the occurrence count of the handle. */ @@ -473,12 +478,12 @@ public abstract class JavaElement extends PlatformObject implements IJavaElement // public boolean isStructureKnown() throws JavaModelException { // return ((JavaElementInfo)getElementInfo()).isStructureKnown(); // } -// /** -// * Creates and returns and not present exception for this element. -// */ -// protected JavaModelException newNotPresentException() { -// return new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this)); -// } + /** + * Creates and returns and not present exception for this element. + */ + protected JavaModelException newNotPresentException() { + return new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this)); + } // /** // * Opens this element and all parents that are not already open. // * @@ -529,7 +534,7 @@ public abstract class JavaElement extends PlatformObject implements IJavaElement // /** // * Returns a copy of this element rooted at the given project. // */ -// public abstract IJavaElement rootedAt(IJavaProject project); + public abstract IJavaElement rootedAt(IJavaProject project); // /** // * Runs a Java Model Operation // */