Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2011-05-17 22:28:18 +0000
committerSergey Prigogin2011-05-17 22:28:18 +0000
commit9c930dfff34c4bda67fcc8bc686f3f7f078e6130 (patch)
tree562a6e8a50b344054e363c0bbac984312759d759
parent24d1fac0352caa18f31f419aab7c528b5483548c (diff)
downloadorg.eclipse.cdt-9c930dfff34c4bda67fcc8bc686f3f7f078e6130.tar.gz
org.eclipse.cdt-9c930dfff34c4bda67fcc8bc686f3f7f078e6130.tar.xz
org.eclipse.cdt-9c930dfff34c4bda67fcc8bc686f3f7f078e6130.zip
Cosmetics.
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java74
1 files changed, 36 insertions, 38 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java
index 08346c670b..7ffb7c117d 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java
@@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Rational Software - Initial API and implementation
- * Markus Schorn (Wind River Systems)
- * Anton Leherbauer (Wind River Systems)
+ * Rational Software - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
+ * Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.model;
@@ -59,6 +59,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
public WorkingCopy(ICElement parent, IFile file, String id, IBufferFactory bufferFactory) {
this(parent, file, id, bufferFactory, null);
}
+
public WorkingCopy(ICElement parent, IFile file, String id, IBufferFactory bufferFactory, IProblemRequestor requestor) {
super(parent, file, id);
this.bufferFactory =
@@ -79,45 +80,41 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
/**
* @see org.eclipse.cdt.core.model.IWorkingCopy#commit(boolean, org.eclipse.core.runtime.IProgressMonitor)
*/
- public void commit(boolean force, IProgressMonitor monitor)
- throws CModelException {
- ITranslationUnit original = this.getOriginalElement();
- if (original.exists()) {
- CommitWorkingCopyOperation op= new CommitWorkingCopyOperation(this, force);
- op.runOperation(monitor);
- } else {
- String contents = this.getSource();
- if (contents == null) return;
+ public void commit(boolean force, IProgressMonitor monitor) throws CModelException {
+ ITranslationUnit original = this.getOriginalElement();
+ if (original.exists()) {
+ CommitWorkingCopyOperation op= new CommitWorkingCopyOperation(this, force);
+ op.runOperation(monitor);
+ } else {
+ String contents = this.getSource();
+ if (contents == null) return;
+ try {
+ IFile originalRes = (IFile)original.getResource();
+ String encoding = null;
try {
- IFile originalRes = (IFile)original.getResource();
- String encoding = null;
- try {
- encoding = originalRes.getCharset();
- }
- catch (CoreException ce) {
- // use no encoding
- }
- byte[] bytes = encoding == null
- ? contents.getBytes()
- : contents.getBytes(encoding);
- ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
- if (originalRes.exists()) {
- originalRes.setContents(
+ encoding = originalRes.getCharset();
+ } catch (CoreException e) {
+ // use no encoding
+ }
+ byte[] bytes = encoding == null ? contents.getBytes() : contents.getBytes(encoding);
+ ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
+ if (originalRes.exists()) {
+ originalRes.setContents(
stream,
force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
- null);
- } else {
- originalRes.create(
+ null);
+ } else {
+ originalRes.create(
stream,
force,
monitor);
- }
- } catch (IOException e) {
- throw new CModelException(e, ICModelStatusConstants.IO_EXCEPTION);
- } catch (CoreException e) {
- throw new CModelException(e);
}
- }
+ } catch (IOException e) {
+ throw new CModelException(e, ICModelStatusConstants.IO_EXCEPTION);
+ } catch (CoreException e) {
+ throw new CModelException(e);
+ }
+ }
}
/**
@@ -271,6 +268,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
return false;
}
}
+
/**
* @see org.eclipse.cdt.core.model.ITranslationUnit#isWorkingCopy()
*/
@@ -394,8 +392,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
long timeStamp =
((IFile) original.getResource()).getModificationStamp();
if (timeStamp == IResource.NULL_STAMP) {
- throw new CModelException(
- new CModelStatus(ICModelStatusConstants.INVALID_RESOURCE));
+ throw new CModelException(new CModelStatus(ICModelStatusConstants.INVALID_RESOURCE));
}
((TranslationUnitInfo) getElementInfo()).fTimestamp = timeStamp;
}
@@ -405,7 +402,8 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
*/
public IASTTranslationUnit reconcile(boolean computeAST, boolean forceProblemDetection, IProgressMonitor monitor)
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);
op.runOperation(monitor);

Back to the top