*******************************************************************************/
package net.sourceforge.phpdt.internal.core;
+import java.util.ArrayList;
+import java.util.Map;
+
import net.sourceforge.phpdt.core.ICompilationUnit;
import net.sourceforge.phpdt.core.IJavaElement;
import net.sourceforge.phpdt.core.IJavaProject;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
* @see IPackageFragment
*/
protected PackageFragment(IPackageFragmentRoot root, String name) {
- super(PACKAGE_FRAGMENT, null, name);
+ super(PACKAGE_FRAGMENT, root, name);
}
/**
* Compute the children of this package fragment.
* <p>Package fragments which are in a jar only recognize .class files (
* @see JarPackageFragment).
*/
-//protected boolean computeChildren(OpenableElementInfo info, IResource resource) throws JavaModelException {
-// ArrayList vChildren = new ArrayList();
+protected boolean computeChildren(OpenableElementInfo info, IResource resource) throws JavaModelException {
+ ArrayList vChildren = new ArrayList();
// int kind = getKind();
-// String extType;
+ String extType;
// if (kind == IPackageFragmentRoot.K_SOURCE) {
-// extType = "java"; //$NON-NLS-1$
+ extType = "php"; //$NON-NLS-1$
// } else {
// extType = "class"; //$NON-NLS-1$
// }
-// try {
-// char[][] exclusionPatterns = ((PackageFragmentRoot)getPackageFragmentRoot()).fullExclusionPatternChars();
-// IResource[] members = ((IContainer) resource).members();
-// for (int i = 0, max = members.length; i < max; i++) {
-// IResource child = members[i];
-// if (child.getType() != IResource.FOLDER
-// && !Util.isExcluded(child, exclusionPatterns)) {
-// String extension = child.getProjectRelativePath().getFileExtension();
-// if (extension != null) {
-// if (extension.equalsIgnoreCase(extType)) {
-// IJavaElement childElement;
+ try {
+ char[][] exclusionPatterns = ((PackageFragmentRoot)getPackageFragmentRoot()).fullExclusionPatternChars();
+ IResource[] members = ((IContainer) resource).members();
+ for (int i = 0, max = members.length; i < max; i++) {
+ IResource child = members[i];
+ if (child.getType() != IResource.FOLDER
+ && !Util.isExcluded(child, exclusionPatterns)) {
+ String extension = child.getProjectRelativePath().getFileExtension();
+ if (extension != null) {
+ if (extension.equalsIgnoreCase(extType)) {
+ IJavaElement childElement;
// if (kind == IPackageFragmentRoot.K_SOURCE && Util.isValidCompilationUnitName(child.getName())) {
// childElement = getCompilationUnit(child.getName());
// vChildren.add(childElement);
// childElement = getClassFile(child.getName());
// vChildren.add(childElement);
// }
-// }
-// }
-// }
-// }
-// } catch (CoreException e) {
-// throw new JavaModelException(e);
-// }
-// IJavaElement[] children = new IJavaElement[vChildren.size()];
-// vChildren.toArray(children);
-// info.setChildren(children);
-// return true;
-//}
+ }
+ }
+ }
+ }
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
+ }
+ IJavaElement[] children = new IJavaElement[vChildren.size()];
+ vChildren.toArray(children);
+ info.setChildren(children);
+ return true;
+}
/**
* Returns true if this fragment contains at least one java resource.
* Returns false otherwise.
/**
* @see JavaElement
*/
-//protected OpenableElementInfo createElementInfo() {
-// return new PackageFragmentInfo();
-//}
+protected OpenableElementInfo createElementInfo() {
+ return new PackageFragmentInfo();
+}
/**
* @see ISourceManipulation
*/
/**
* @see Openable
*/
-//protected boolean generateInfos(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException {
-//
-// return computeChildren(info, underlyingResource);
-//}
+protected boolean generateInfos(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException {
+
+ return computeChildren(info, underlyingResource);
+}
///**
// * @see IPackageFragment#getClassFile(String)
// */
/**
* @see IPackageFragment#getCompilationUnits()
*/
-//public ICompilationUnit[] getCompilationUnits() throws JavaModelException {
-// if (getKind() == IPackageFragmentRoot.K_BINARY) {
-// return fgEmptyCompilationUnitList;
-// }
-//
-// ArrayList list = getChildrenOfType(COMPILATION_UNIT);
-// ICompilationUnit[] array= new ICompilationUnit[list.size()];
-// list.toArray(array);
-// return array;
-//}
+public ICompilationUnit[] getCompilationUnits() throws JavaModelException {
+ if (getKind() == IPackageFragmentRoot.K_BINARY) {
+ return fgEmptyCompilationUnitList;
+ }
+
+ ArrayList list = getChildrenOfType(COMPILATION_UNIT);
+ ICompilationUnit[] array= new ICompilationUnit[list.size()];
+ list.toArray(array);
+ return array;
+}
/**
* @see JavaElement#getHandleMementoDelimiter()
*/
/**
* @see IPackageFragment#getKind()
*/
-//public int getKind() throws JavaModelException {
-// return ((IPackageFragmentRoot)getParent()).getKind();
-//}
+public int getKind() throws JavaModelException {
+ return ((IPackageFragmentRoot)getParent()).getKind();
+}
/**
* Returns an array of non-java resources contained in the receiver.
*/
/**
* @see IJavaElement#getPath()
*/
-//public IPath getPath() {
-// PackageFragmentRoot root = this.getPackageFragmentRoot();
-// if (root.isArchive()) {
-// return root.getPath();
-// } else {
-// return root.getPath().append(this.getElementName().replace('.', '/'));
-// }
-//}
+public IPath getPath() {
+ PackageFragmentRoot root = this.getPackageFragmentRoot();
+ if (root.isArchive()) {
+ return root.getPath();
+ } else {
+ return root.getPath().append(this.getElementName().replace('.', '/'));
+ }
+}
/**
* @see IJavaElement#getResource()
*/