1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2011-05-17 22:28:18 +00:00
parent 24d1fac035
commit 9c930dfff3

View file

@ -59,6 +59,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
public WorkingCopy(ICElement parent, IFile file, String id, IBufferFactory bufferFactory) { public WorkingCopy(ICElement parent, IFile file, String id, IBufferFactory bufferFactory) {
this(parent, file, id, bufferFactory, null); this(parent, file, id, bufferFactory, null);
} }
public WorkingCopy(ICElement parent, IFile file, String id, IBufferFactory bufferFactory, IProblemRequestor requestor) { public WorkingCopy(ICElement parent, IFile file, String id, IBufferFactory bufferFactory, IProblemRequestor requestor) {
super(parent, file, id); super(parent, file, id);
this.bufferFactory = this.bufferFactory =
@ -79,8 +80,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
/** /**
* @see org.eclipse.cdt.core.model.IWorkingCopy#commit(boolean, org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.cdt.core.model.IWorkingCopy#commit(boolean, org.eclipse.core.runtime.IProgressMonitor)
*/ */
public void commit(boolean force, IProgressMonitor monitor) public void commit(boolean force, IProgressMonitor monitor) throws CModelException {
throws CModelException {
ITranslationUnit original = this.getOriginalElement(); ITranslationUnit original = this.getOriginalElement();
if (original.exists()) { if (original.exists()) {
CommitWorkingCopyOperation op= new CommitWorkingCopyOperation(this, force); CommitWorkingCopyOperation op= new CommitWorkingCopyOperation(this, force);
@ -93,13 +93,10 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
String encoding = null; String encoding = null;
try { try {
encoding = originalRes.getCharset(); encoding = originalRes.getCharset();
} } catch (CoreException e) {
catch (CoreException ce) {
// use no encoding // use no encoding
} }
byte[] bytes = encoding == null byte[] bytes = encoding == null ? contents.getBytes() : contents.getBytes(encoding);
? contents.getBytes()
: contents.getBytes(encoding);
ByteArrayInputStream stream = new ByteArrayInputStream(bytes); ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
if (originalRes.exists()) { if (originalRes.exists()) {
originalRes.setContents( originalRes.setContents(
@ -271,6 +268,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
return false; return false;
} }
} }
/** /**
* @see org.eclipse.cdt.core.model.ITranslationUnit#isWorkingCopy() * @see org.eclipse.cdt.core.model.ITranslationUnit#isWorkingCopy()
*/ */
@ -394,8 +392,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
long timeStamp = long timeStamp =
((IFile) original.getResource()).getModificationStamp(); ((IFile) original.getResource()).getModificationStamp();
if (timeStamp == IResource.NULL_STAMP) { if (timeStamp == IResource.NULL_STAMP) {
throw new CModelException( throw new CModelException(new CModelStatus(ICModelStatusConstants.INVALID_RESOURCE));
new CModelStatus(ICModelStatusConstants.INVALID_RESOURCE));
} }
((TranslationUnitInfo) getElementInfo()).fTimestamp = timeStamp; ((TranslationUnitInfo) getElementInfo()).fTimestamp = timeStamp;
} }
@ -405,7 +402,8 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
*/ */
public IASTTranslationUnit reconcile(boolean computeAST, boolean forceProblemDetection, IProgressMonitor monitor) public IASTTranslationUnit reconcile(boolean computeAST, boolean forceProblemDetection, IProgressMonitor monitor)
throws CModelException { throws CModelException {
if (this.useCount == 0) throw newNotPresentException(); // was destroyed if (this.useCount == 0)
throw newNotPresentException(); // was destroyed
ReconcileWorkingCopyOperation op = new ReconcileWorkingCopyOperation(this, computeAST, forceProblemDetection); ReconcileWorkingCopyOperation op = new ReconcileWorkingCopyOperation(this, computeAST, forceProblemDetection);
op.runOperation(monitor); op.runOperation(monitor);