*******************************************************************************/
package net.sourceforge.phpdt.internal.core;
+import java.util.HashMap;
+
import net.sourceforge.phpdt.core.IBuffer;
import net.sourceforge.phpdt.core.ICompilationUnit;
import net.sourceforge.phpdt.core.IJavaElement;
import net.sourceforge.phpdt.core.IJavaProject;
+import net.sourceforge.phpdt.core.IMember;
import net.sourceforge.phpdt.core.IOpenable;
+import net.sourceforge.phpdt.core.ISourceManipulation;
import net.sourceforge.phpdt.core.ISourceRange;
import net.sourceforge.phpdt.core.ISourceReference;
import net.sourceforge.phpdt.core.JavaModelException;
+import net.sourceforge.phpdt.core.WorkingCopyOwner;
+import net.sourceforge.phpdt.internal.core.util.MementoTokenizer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
* Abstract class for Java elements which implement ISourceReference.
*/
/* package */ abstract class SourceRefElement extends JavaElement implements ISourceReference {
-protected SourceRefElement(int type, IJavaElement parent, String name) {
- super(type, parent, name);
+ protected SourceRefElement(JavaElement parent, String name) {
+ super(parent, name);
+ }
+/**
+ * This element is being closed. Do any necessary cleanup.
+ */
+protected void closing(Object info) throws JavaModelException {
+ // Do any necessary cleanup
+}
+/**
+ * Returns a new element info for this element.
+ */
+protected Object createElementInfo() {
+ return null; // not used for source ref elements
}
/**
* @see ISourceManipulation
*/
//public void copy(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException {
// if (container == null) {
-// throw new IllegalArgumentException(Util.bind("operation.nullContainer")); //$NON-NLS-1$
+// throw new IllegalArgumentException(ProjectPrefUtil.bind("operation.nullContainer")); //$NON-NLS-1$
// }
// IJavaElement[] elements= new IJavaElement[] {this};
// IJavaElement[] containers= new IJavaElement[] {container};
// IJavaElement[] elements = new IJavaElement[] {this};
// getJavaModel().delete(elements, force, monitor);
//}
+/*
+ * @see JavaElement#generateInfos
+ */
+protected void generateInfos(Object info, HashMap newElements, IProgressMonitor pm) throws JavaModelException {
+ Openable openableParent = (Openable)getOpenableParent();
+ if (openableParent == null) return;
+
+ JavaElementInfo openableParentInfo = (JavaElementInfo) JavaModelManager.getJavaModelManager().getInfo(openableParent);
+ if (openableParentInfo == null) {
+ openableParent.generateInfos(openableParent.createElementInfo(), newElements, pm);
+ }
+}
/**
* @see IMember
*/
if (!exists()) throw newNotPresentException();
return null;
}
+/*
+ * @see JavaElement
+ */
+public IJavaElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner workingCopyOwner) {
+ switch (token.charAt(0)) {
+ case JEM_COUNT:
+ return getHandleUpdatingCountFromMemento(memento, workingCopyOwner);
+ }
+ return this;
+}
/**
* Return the first instance of IOpenable in the hierarchy of this
* type (going up the hierarchy from this type);
}
return null;
}
+
/*
* @see IJavaElement
*/
if (offset == -1 || length == 0 ) {
return null;
}
- return buffer.getText(offset, length);
+ try {
+ return buffer.getText(offset, length);
+ // jsurfer insert start
+ } catch (ArrayIndexOutOfBoundsException e) {
+
+ }
+ return null;
+// jsurfer insert end
}
/**
* @see ISourceReference
*/
//public void move(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException {
// if (container == null) {
-// throw new IllegalArgumentException(Util.bind("operation.nullContainer")); //$NON-NLS-1$
+// throw new IllegalArgumentException(ProjectPrefUtil.bind("operation.nullContainer")); //$NON-NLS-1$
// }
// IJavaElement[] elements= new IJavaElement[] {this};
// IJavaElement[] containers= new IJavaElement[] {container};
*/
//public void rename(String name, boolean force, IProgressMonitor monitor) throws JavaModelException {
// if (name == null) {
-// throw new IllegalArgumentException(Util.bind("element.nullName")); //$NON-NLS-1$
+// throw new IllegalArgumentException(ProjectPrefUtil.bind("element.nullName")); //$NON-NLS-1$
// }
// IJavaElement[] elements= new IJavaElement[] {this};
// IJavaElement[] dests= new IJavaElement[] {this.getParent()};