import net.sourceforge.phpdt.core.IBuffer;
import net.sourceforge.phpdt.core.IBufferFactory;
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.problem.DefaultProblemFactory;
import net.sourceforge.phpdt.internal.core.util.Util;
import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
-import net.sourceforge.phpdt.core.*;
+
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
* @see IWorkingCopy#commit(boolean, IProgressMonitor)
*/
public void commit(boolean force, IProgressMonitor monitor) throws JavaModelException {
- throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this));
+ commitWorkingCopy(force, monitor);
+// throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this));
}
/**
* @see ICompilationUnit#commitWorkingCopy(boolean, IProgressMonitor)
}
}
}
-protected boolean generateInfos(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException {
-
-// if (getParent() instanceof JarPackageFragment) {
-// // ignore .java files in jar
-// throw newNotPresentException();
-// } else {
- // put the info now, because getting the contents requires it
- JavaModelManager.getJavaModelManager().putInfo(this, info);
- CompilationUnitElementInfo unitInfo = (CompilationUnitElementInfo) info;
-
- // generate structure
- CompilationUnitStructureRequestor requestor = new CompilationUnitStructureRequestor(this, unitInfo, newElements);
- IProblemFactory factory = new DefaultProblemFactory();
- SourceElementParser parser = new SourceElementParser(requestor, factory, new CompilerOptions(getJavaProject().getOptions(true)));
-// SourceElementParser parser = new SourceElementParser(requestor, factory);
- requestor.parser = parser;
- parser.parseCompilationUnit(this, false);
- if (isWorkingCopy()) {
- CompilationUnit original = (CompilationUnit) getOriginalElement();
- // might be IResource.NULL_STAMP if original does not exist
- unitInfo.timestamp = ((IFile) original.getResource()).getModificationStamp();
- }
- return unitInfo.isStructureKnown();
-// }
-}
+//protected boolean generateInfos(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException {
+//
+//// if (getParent() instanceof JarPackageFragment) {
+//// // ignore .java files in jar
+//// throw newNotPresentException();
+//// } else {
+// // put the info now, because getting the contents requires it
+// JavaModelManager.getJavaModelManager().putInfo(this, info);
+// CompilationUnitElementInfo unitInfo = (CompilationUnitElementInfo) info;
+//
+// // generate structure
+// CompilationUnitStructureRequestor requestor = new CompilationUnitStructureRequestor(this, unitInfo, newElements);
+// IProblemFactory factory = new DefaultProblemFactory();
+// SourceElementParser parser = new SourceElementParser(requestor, factory, new CompilerOptions(getJavaProject().getOptions(true)));
+//// SourceElementParser parser = new SourceElementParser(requestor, factory);
+// requestor.parser = parser;
+// parser.parseCompilationUnit(this, false);
+// if (isWorkingCopy()) {
+// CompilationUnit original = (CompilationUnit) getOriginalElement();
+// // might be IResource.NULL_STAMP if original does not exist
+// unitInfo.timestamp = ((IFile) original.getResource()).getModificationStamp();
+// }
+// return unitInfo.isStructureKnown();
+//// }
+//}
/**
* @see ICompilationUnit#getAllTypes()
*/
/**
* @see ICompilationUnit#getImportContainer()
*/
-public IImportContainer getImportContainer() {
+public ImportContainer getImportContainer() {
return new ImportContainer(this);
}
// }
ReconcileWorkingCopyOperation op = new ReconcileWorkingCopyOperation(this, createAST, astLevel, forceProblemDetection, workingCopyOwner);
op.runOperation(monitor);
-// return op.ast;
+// return op.ast;
return null;
}
String[] renamings= new String[] {name};
getJavaModel().rename(elements, dests, renamings, force, monitor);
}
-/**
- * Does nothing - this is not a working copy.
- *
- * @see IWorkingCopy#restore()
+
+/*
+ * @see ICompilationUnit
*/
public void restore () throws JavaModelException {
+
+ if (!isWorkingCopy()) return;
+
+ CompilationUnit original = (CompilationUnit) getOriginalElement();
+ IBuffer buffer = this.getBuffer();
+ if (buffer == null) return;
+ buffer.setContents(original.getContents());
+ updateTimeStamp(original);
+ makeConsistent(null);
}
/**
* @see ICodeAssist#codeComplete(int, ICodeCompletionRequestor)
// (IPackageFragment)((JavaElement)parent).rootedAt(project),
// name);
//}
+
/*
* Assume that this is a working copy
*/