A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / core / SourceRefElement.java
index 6f89844..9e11af5 100644 (file)
@@ -29,191 +29,224 @@ import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 
-
 /**
  * Abstract class for Java elements which implement ISourceReference.
  */
-/* package */ abstract class SourceRefElement extends JavaElement implements ISourceReference {
+/* package */abstract class SourceRefElement extends JavaElement implements
+               ISourceReference {
        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(ProjectPrefUtil.bind("operation.nullContainer")); //$NON-NLS-1$
-//     }
-//     IJavaElement[] elements= new IJavaElement[] {this};
-//     IJavaElement[] containers= new IJavaElement[] {container};
-//     IJavaElement[] siblings= null;
-//     if (sibling != null) {
-//             siblings= new IJavaElement[] {sibling};
-//     }
-//     String[] renamings= null;
-//     if (rename != null) {
-//             renamings= new String[] {rename};
-//     }
-//     getJavaModel().copy(elements, containers, siblings, renamings, force, monitor);
-//}
-/**
- * @see ISourceManipulation
- */
-//public void delete(boolean force, IProgressMonitor monitor) throws JavaModelException {
-//     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);
+       /**
+        * This element is being closed. Do any necessary cleanup.
+        */
+       protected void closing(Object info) throws JavaModelException {
+               // Do any necessary cleanup
        }
-}
-/**
- * @see IMember
- */
-public ICompilationUnit getCompilationUnit() {
-       return ((JavaElement)getParent()).getCompilationUnit();
-}
-/**
- * Elements within compilation units and class files have no
- * corresponding resource.
- *
- * @see IJavaElement
- */
-public IResource getCorrespondingResource() throws JavaModelException {
-       if (!exists()) throw newNotPresentException();
-       return null;
-}
-/*
- * @see JavaElement
- */
-public IJavaElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner workingCopyOwner) {
-       switch (token.charAt(0)) {
+
+       /**
+        * 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(ProjectPrefUtil.bind("operation.nullContainer"));
+       // //$NON-NLS-1$
+       // }
+       // IJavaElement[] elements= new IJavaElement[] {this};
+       // IJavaElement[] containers= new IJavaElement[] {container};
+       // IJavaElement[] siblings= null;
+       // if (sibling != null) {
+       // siblings= new IJavaElement[] {sibling};
+       // }
+       // String[] renamings= null;
+       // if (rename != null) {
+       // renamings= new String[] {rename};
+       // }
+       // getJavaModel().copy(elements, containers, siblings, renamings, force,
+       // monitor);
+       // }
+       /**
+        * @see ISourceManipulation
+        */
+       // public void delete(boolean force, IProgressMonitor monitor) throws
+       // JavaModelException {
+       // 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
+        */
+       public ICompilationUnit getCompilationUnit() {
+               return ((JavaElement) getParent()).getCompilationUnit();
+       }
+
+       /**
+        * Elements within compilation units and class files have no corresponding
+        * resource.
+        * 
+        * @see IJavaElement
+        */
+       public IResource getCorrespondingResource() throws JavaModelException {
+               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);
- */
-public IOpenable getOpenableParent() {
-       IJavaElement current = getParent();
-       while (current != null){
-               if (current instanceof IOpenable){
-                       return (IOpenable) current;
                }
-               current = current.getParent();
+               return this;
        }
-       return null;
-}
 
-/*
- * @see IJavaElement
- */
-public IPath getPath() {
-       return this.getParent().getPath();
-}
-/*
- * @see IJavaElement
- */
-public IResource getResource() {
-       return this.getParent().getResource();
-}
-/**
- * @see ISourceReference
- */
-public String getSource() throws JavaModelException {
-       IOpenable openable = getOpenableParent();
-       IBuffer buffer = openable.getBuffer();
-       if (buffer == null) {
+       /**
+        * Return the first instance of IOpenable in the hierarchy of this type
+        * (going up the hierarchy from this type);
+        */
+       public IOpenable getOpenableParent() {
+               IJavaElement current = getParent();
+               while (current != null) {
+                       if (current instanceof IOpenable) {
+                               return (IOpenable) current;
+                       }
+                       current = current.getParent();
+               }
                return null;
        }
-       ISourceRange range = getSourceRange();
-       int offset = range.getOffset();
-       int length = range.getLength();
-       if (offset == -1 || length == 0 ) {
+
+       /*
+        * @see IJavaElement
+        */
+       public IPath getPath() {
+               return this.getParent().getPath();
+       }
+
+       /*
+        * @see IJavaElement
+        */
+       public IResource getResource() {
+               return this.getParent().getResource();
+       }
+
+       /**
+        * @see ISourceReference
+        */
+       public String getSource() throws JavaModelException {
+               IOpenable openable = getOpenableParent();
+               IBuffer buffer = openable.getBuffer();
+               if (buffer == null) {
+                       return null;
+               }
+               ISourceRange range = getSourceRange();
+               int offset = range.getOffset();
+               int length = range.getLength();
+               if (offset == -1 || length == 0) {
+                       return null;
+               }
+               try {
+                       return buffer.getText(offset, length);
+                       // jsurfer insert start
+               } catch (ArrayIndexOutOfBoundsException e) {
+
+               }
                return null;
+               // jsurfer insert end
+       }
+
+       /**
+        * @see ISourceReference
+        */
+       public ISourceRange getSourceRange() throws JavaModelException {
+               SourceRefElementInfo info = (SourceRefElementInfo) getElementInfo();
+               return info.getSourceRange();
        }
-       try {
-         return buffer.getText(offset, length);
-         // jsurfer insert start
-       } catch (ArrayIndexOutOfBoundsException e) {
-               
+
+       /**
+        * @see IJavaElement
+        */
+       public IResource getUnderlyingResource() throws JavaModelException {
+               if (!exists())
+                       throw newNotPresentException();
+               return getParent().getUnderlyingResource();
+       }
+
+       /**
+        * @see ISourceManipulation
+        */
+       // public void move(IJavaElement container, IJavaElement sibling, String
+       // rename, boolean force, IProgressMonitor monitor) throws
+       // JavaModelException {
+       // if (container == null) {
+       // throw new
+       // IllegalArgumentException(ProjectPrefUtil.bind("operation.nullContainer"));
+       // //$NON-NLS-1$
+       // }
+       // IJavaElement[] elements= new IJavaElement[] {this};
+       // IJavaElement[] containers= new IJavaElement[] {container};
+       // IJavaElement[] siblings= null;
+       // if (sibling != null) {
+       // siblings= new IJavaElement[] {sibling};
+       // }
+       // String[] renamings= null;
+       // if (rename != null) {
+       // renamings= new String[] {rename};
+       // }
+       // getJavaModel().move(elements, containers, siblings, renamings, force,
+       // monitor);
+       // }
+       /**
+        * @see ISourceManipulation
+        */
+       // public void rename(String name, boolean force, IProgressMonitor monitor)
+       // throws JavaModelException {
+       // if (name == null) {
+       // throw new
+       // IllegalArgumentException(ProjectPrefUtil.bind("element.nullName"));
+       // //$NON-NLS-1$
+       // }
+       // IJavaElement[] elements= new IJavaElement[] {this};
+       // IJavaElement[] dests= new IJavaElement[] {this.getParent()};
+       // String[] renamings= new String[] {name};
+       // getJavaModel().rename(elements, dests, renamings, force, monitor);
+       // }
+       /*
+        * @see JavaElement#rootedAt(IJavaProject)
+        */
+       public IJavaElement rootedAt(IJavaProject project) {
+               // not needed
+               return null;
        }
-       return null;
-//      jsurfer insert end
-}
-/**
- * @see ISourceReference
- */
-public ISourceRange getSourceRange() throws JavaModelException {
-       SourceRefElementInfo info = (SourceRefElementInfo) getElementInfo();
-       return info.getSourceRange();
-}
-/**
- * @see IJavaElement
- */
-public IResource getUnderlyingResource() throws JavaModelException {
-       if (!exists()) throw newNotPresentException();
-       return getParent().getUnderlyingResource();
-}
-/**
- * @see ISourceManipulation
- */
-//public void move(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException {
-//     if (container == null) {
-//             throw new IllegalArgumentException(ProjectPrefUtil.bind("operation.nullContainer")); //$NON-NLS-1$
-//     }
-//     IJavaElement[] elements= new IJavaElement[] {this};
-//     IJavaElement[] containers= new IJavaElement[] {container};
-//     IJavaElement[] siblings= null;
-//     if (sibling != null) {
-//             siblings= new IJavaElement[] {sibling};
-//     }
-//     String[] renamings= null;
-//     if (rename != null) {
-//             renamings= new String[] {rename};
-//     }
-//     getJavaModel().move(elements, containers, siblings, renamings, force, monitor);
-//}
-/**
- * @see ISourceManipulation
- */
-//public void rename(String name, boolean force, IProgressMonitor monitor) throws JavaModelException {
-//     if (name == null) {
-//             throw new IllegalArgumentException(ProjectPrefUtil.bind("element.nullName")); //$NON-NLS-1$
-//     }
-//     IJavaElement[] elements= new IJavaElement[] {this};
-//     IJavaElement[] dests= new IJavaElement[] {this.getParent()};
-//     String[] renamings= new String[] {name};
-//     getJavaModel().rename(elements, dests, renamings, force, monitor);
-//}
-/*
- * @see JavaElement#rootedAt(IJavaProject)
- */
-public IJavaElement rootedAt(IJavaProject project) {
-       // not needed
-       return null;
-}
 }