import net.sourceforge.phpdt.core.IBuffer;
import net.sourceforge.phpdt.core.IBufferFactory;
+import net.sourceforge.phpdt.core.ICodeAssist;
+import net.sourceforge.phpdt.core.ICodeCompletionRequestor;
import net.sourceforge.phpdt.core.ICompilationUnit;
+import net.sourceforge.phpdt.core.IImportContainer;
import net.sourceforge.phpdt.core.IImportDeclaration;
import net.sourceforge.phpdt.core.IJavaElement;
import net.sourceforge.phpdt.core.IJavaModelStatusConstants;
import net.sourceforge.phpdt.internal.compiler.SourceElementParser;
import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblemFactory;
+import net.sourceforge.phpdt.internal.core.util.MementoTokenizer;
import net.sourceforge.phpdt.internal.core.util.Util;
import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
public class CompilationUnit extends Openable implements ICompilationUnit,
net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit {
public WorkingCopyOwner owner;
-
/**
* Constructs a handle to a compilation unit with the given name in the specified package for the specified owner
*
// update timestamp (might be IResource.NULL_STAMP if original does not exist)
unitInfo.timestamp = ((IFile) underlyingResource).getModificationStamp();
-
// compute other problems if needed
CompilationUnitDeclaration compilationUnitDeclaration = null;
try {
// if (info instanceof ASTHolderCUInfo) {
// int astLevel = ((ASTHolderCUInfo) info).astLevel;
- // org.eclipse.jdt.core.dom.CompilationUnit cu = AST.convertCompilationUnit(astLevel, unit, contents, options, pm);
+ // net.sourceforge.phpdt.core.dom.CompilationUnit cu = AST.convertCompilationUnit(astLevel, unit, contents, options, pm);
// ((ASTHolderCUInfo) info).ast = cu;
// }
} finally {
// * @see ICodeAssist#codeComplete(int, ICompletionRequestor)
// */
//public void codeComplete(int offset, ICompletionRequestor requestor) throws JavaModelException {
- // codeComplete(this, isWorkingCopy() ? (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) getOriginalElement() : this,
+ // codeComplete(this, isWorkingCopy() ? (net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit) getOriginalElement() : this,
// offset, requestor);
//}
/**
// String source = ""; //$NON-NLS-1$
// if (pkg.getElementName().length() > 0) {
// //not the default package...add the package declaration
- // source = "package " + pkg.getElementName() + ";" + org.eclipse.jdt.internal.compiler.util.ProjectPrefUtil.LINE_SEPARATOR +
- // org.eclipse.jdt.internal.compiler.util.ProjectPrefUtil.LINE_SEPARATOR; //$NON-NLS-1$ //$NON-NLS-2$
+ // source = "package " + pkg.getElementName() + ";" + net.sourceforge.phpdt.internal.compiler.util.ProjectPrefUtil.LINE_SEPARATOR +
+ // net.sourceforge.phpdt.internal.compiler.util.ProjectPrefUtil.LINE_SEPARATOR; //$NON-NLS-1$ //$NON-NLS-2$
// }
// CreateCompilationUnitOperation op = new CreateCompilationUnitOperation(pkg, fName, source, force);
// runOperation(op, monitor);
}
/**
- * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getContents()
+ * @see net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit#getContents()
*/
public char[] getContents() {
try {
public char[] getFileName() {
return getElementName().toCharArray();
}
+ /*
+ * @see JavaElement
+ */
+ public IJavaElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner workingCopyOwner) {
+ switch (token.charAt(0)) {
+ case JEM_COUNT:
+ return getHandleUpdatingCountFromMemento(memento, workingCopyOwner);
+ case JEM_IMPORTDECLARATION:
+ JavaElement container = (JavaElement)getImportContainer();
+ return container.getHandleFromMemento(token, memento, workingCopyOwner);
+ case JEM_PACKAGEDECLARATION:
+ String pkgName = memento.nextToken();
+ JavaElement pkgDecl = (JavaElement)getPackageDeclaration(pkgName);
+ return pkgDecl.getHandleFromMemento(memento, workingCopyOwner);
+ case JEM_TYPE:
+ String typeName = memento.nextToken();
+ JavaElement type = (JavaElement)getType(typeName);
+ return type.getHandleFromMemento(memento, workingCopyOwner);
+ }
+ return null;
+ }
/**
* @see JavaElement#getHandleMementoDelimiter()
*/
protected char getHandleMementoDelimiter() {
- return JavaElement.JEM_COMPILATIONUNIT;
+ return JavaElement.JEM_COMPILATIONUNIT;
}
-
/**
* @see ICompilationUnit#getImport(String)
*/
public IImportDeclaration getImport(String importName) {
- return new ImportDeclaration((ImportContainer) getImportContainer(), importName);
+ return new ImportDeclaration((ImportContainer)getImportContainer(), importName);
}
-
/**
* @see ICompilationUnit#getImportContainer()
*/
- public ImportContainer getImportContainer() {
- return new ImportContainer(this);
+ public IImportContainer getImportContainer() {
+ return new ImportContainer(this);
}
+
/**
* @see ICompilationUnit#getImports()
*/
- //public IImportDeclaration[] getImports() throws JavaModelException {
- // IImportContainer container= getImportContainer();
- // if (container.exists()) {
- // IJavaElement[] elements= container.getChildren();
- // IImportDeclaration[] imprts= new IImportDeclaration[elements.length];
- // System.arraycopy(elements, 0, imprts, 0, elements.length);
- // return imprts;
- // } else if (!exists()) {
- // throw newNotPresentException();
- // } else {
- // return new IImportDeclaration[0];
- // }
- //
- //}
+ public IImportDeclaration[] getImports() throws JavaModelException {
+ IImportContainer container= getImportContainer();
+ if (container.exists()) {
+ IJavaElement[] elements= container.getChildren();
+ IImportDeclaration[] imprts= new IImportDeclaration[elements.length];
+ System.arraycopy(elements, 0, imprts, 0, elements.length);
+ return imprts;
+ } else if (!exists()) {
+ throw newNotPresentException();
+ } else {
+ return new IImportDeclaration[0];
+ }
+
+ }
+
/**
- * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getMainTypeName()
+ * @see net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit#getMainTypeName()
*/
public char[] getMainTypeName() {
String name = getElementName();
}
/**
- * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getPackageName()
+ * @see net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit#getPackageName()
*/
public char[][] getPackageName() {
return null;
// ASTHolderCUInfo info = new ASTHolderCUInfo();
// info.astLevel = astLevel;
// openWhenClosed(info, monitor);
- // org.eclipse.jdt.core.dom.CompilationUnit result = info.ast;
+ // net.sourceforge.phpdt.core.dom.CompilationUnit result = info.ast;
// info.ast = null;
// return result;
// } else {
* @see ICompilationUnit#reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor)
* @since 3.0
*/
- //public org.eclipse.jdt.core.dom.CompilationUnit reconcile(
+ //public net.sourceforge.phpdt.core.dom.CompilationUnit reconcile(
public Object reconcile(int astLevel, boolean forceProblemDetection, WorkingCopyOwner workingCopyOwner, IProgressMonitor monitor)
throws JavaModelException {