diff options
author | Jonah Graham | 2018-11-20 16:20:42 +0000 |
---|---|---|
committer | Jonah Graham | 2018-11-22 21:47:02 +0000 |
commit | 170e654b4796bad1453ae85a427b97317d67a69a (patch) | |
tree | 6ca9b8a8fedd5fd25f97eb79c408312e256ff981 /core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CommitWorkingCopyOperation.java | |
parent | 35996a5c5ca5c254959ba48241eaada6dbf8628d (diff) | |
download | org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.gz org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.xz org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.zip |
Bug 540373: Cleanup: Format & Remove trailing whitespace
This was done by selecting all projects in Eclipse then
Source -> Clean Up... -> choosing:
- Format source code
- Remove trailing white spaces on all lines
and completing the wizard
Change-Id: I63685372c6bcc67719bcf145123bcb72e5b00394
Diffstat (limited to 'core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CommitWorkingCopyOperation.java')
-rw-r--r-- | core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CommitWorkingCopyOperation.java | 164 |
1 files changed, 81 insertions, 83 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CommitWorkingCopyOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CommitWorkingCopyOperation.java index c2bc08c8c5f..0ce31ccca04 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CommitWorkingCopyOperation.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CommitWorkingCopyOperation.java @@ -15,7 +15,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.model; - import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.IBuffer; import org.eclipse.cdt.core.model.ICElement; @@ -39,7 +38,7 @@ import org.eclipse.core.runtime.jobs.ISchedulingRule; * original resource have changed since the working copy was created, * in which case there is an update conflict. This operation allows * for two settings to resolve conflict set by the <code>fForce</code> flag:<ul> - * <li>force flag is <code>false</code> - in this case a <code>CModelException</code> + * <li>force flag is <code>false</code> - in this case a <code>CModelException</code> * is thrown</li> * <li>force flag is <code>true</code> - in this case the contents of * the working copy are applied to the underlying resource even though @@ -51,7 +50,7 @@ import org.eclipse.core.runtime.jobs.ISchedulingRule; * * A CModelOperation exception is thrown either if the commit could not be * performed. - * + * * This class is similar to the JDT CommitWorkingCopyOperation class. */ @@ -62,9 +61,9 @@ public class CommitWorkingCopyOperation extends CModelOperation { */ public CommitWorkingCopyOperation(ITranslationUnit element, boolean force) { - super(new ICElement[] {element}, force); + super(new ICElement[] { element }, force); } - + @Override public ISchedulingRule getSchedulingRule() { IResource resource = getElementToProcess().getResource(); @@ -74,7 +73,7 @@ public class CommitWorkingCopyOperation extends CModelOperation { } return workspace.getRuleFactory().createRule(resource); } - + /** * @see org.eclipse.cdt.internal.core.model.CModelOperation#executeOperation() */ @@ -82,86 +81,85 @@ public class CommitWorkingCopyOperation extends CModelOperation { protected void executeOperation() throws CModelException { try { beginTask(CoreModelMessages.getString("workingCopy.commit"), 2); //$NON-NLS-1$ - WorkingCopy wc = (WorkingCopy)getElementToProcess(); + WorkingCopy wc = (WorkingCopy) getElementToProcess(); ITranslationUnit tu = wc.getOriginalElement(); - - - // creates the delta builder (this remembers the content of the cu) + + // creates the delta builder (this remembers the content of the cu) if (!tu.isOpen()) { // force opening so that the delta builder can get the old info tu.open(null); } CElementDeltaBuilder deltaBuilder = new CElementDeltaBuilder(tu); - + // save the translation unit - boolean hasSaved = false; - IBuffer tuBuffer = tu.getBuffer(); - IBuffer wcBuffer = wc.getBuffer(); - if (wcBuffer == null || tuBuffer == null) { - return; - } - ITextFileBuffer tuFileBuffer= null; - ITextFileBuffer wcFileBuffer= null; - if (tuBuffer instanceof IAdaptable) { - tuFileBuffer= ((IAdaptable) tuBuffer).getAdapter(ITextFileBuffer.class); - } - if (wcBuffer instanceof IAdaptable) { - wcFileBuffer= ((IAdaptable) wcBuffer).getAdapter(ITextFileBuffer.class); - } - - if (wcFileBuffer != null) { - if (wcFileBuffer.equals(tuFileBuffer)) { - // working on the same buffer, saving the translation unit does the trick. - tu.save(fMonitor, fForce); - hasSaved= true; - } - else { - if (wcFileBuffer.getLocation().equals(tu.getPath())) { - char[] originalContents = tuBuffer.getCharacters(); - try { - // save the file buffer of the working copy. - wcFileBuffer.commit(fMonitor, fForce); - // change the buffer of the translation unit. - tuBuffer.setContents(wcBuffer.getCharacters()); - tu.makeConsistent(null); - hasSaved= true; - } catch (CoreException e) { - tuBuffer.setContents(originalContents); - throw new CModelException(e); - } - } - } - } - - if (!hasSaved) { - char[] originalContents = tuBuffer.getCharacters(); - try { - tuBuffer.setContents(wcBuffer.getCharacters()); - tu.save(fMonitor, fForce); - } catch (CModelException e) { - tuBuffer.setContents(originalContents); - throw e; - } - } - this.hasModifiedResource = true; - // make sure working copy is in sync - wc.updateTimeStamp((TranslationUnit)tu); - wc.makeConsistent(this); - - worked(1); - - // build the deltas - deltaBuilder.buildDeltas(); - - // add the deltas to the list of deltas created during this operation - if (deltaBuilder.delta != null) { - addDelta(deltaBuilder.delta); - } - worked(1); - } finally { - done(); - } + boolean hasSaved = false; + IBuffer tuBuffer = tu.getBuffer(); + IBuffer wcBuffer = wc.getBuffer(); + if (wcBuffer == null || tuBuffer == null) { + return; + } + ITextFileBuffer tuFileBuffer = null; + ITextFileBuffer wcFileBuffer = null; + if (tuBuffer instanceof IAdaptable) { + tuFileBuffer = ((IAdaptable) tuBuffer).getAdapter(ITextFileBuffer.class); + } + if (wcBuffer instanceof IAdaptable) { + wcFileBuffer = ((IAdaptable) wcBuffer).getAdapter(ITextFileBuffer.class); + } + + if (wcFileBuffer != null) { + if (wcFileBuffer.equals(tuFileBuffer)) { + // working on the same buffer, saving the translation unit does the trick. + tu.save(fMonitor, fForce); + hasSaved = true; + } else { + if (wcFileBuffer.getLocation().equals(tu.getPath())) { + char[] originalContents = tuBuffer.getCharacters(); + try { + // save the file buffer of the working copy. + wcFileBuffer.commit(fMonitor, fForce); + // change the buffer of the translation unit. + tuBuffer.setContents(wcBuffer.getCharacters()); + tu.makeConsistent(null); + hasSaved = true; + } catch (CoreException e) { + tuBuffer.setContents(originalContents); + throw new CModelException(e); + } + } + } + } + + if (!hasSaved) { + char[] originalContents = tuBuffer.getCharacters(); + try { + tuBuffer.setContents(wcBuffer.getCharacters()); + tu.save(fMonitor, fForce); + } catch (CModelException e) { + tuBuffer.setContents(originalContents); + throw e; + } + } + this.hasModifiedResource = true; + // make sure working copy is in sync + wc.updateTimeStamp((TranslationUnit) tu); + wc.makeConsistent(this); + + worked(1); + + // build the deltas + deltaBuilder.buildDeltas(); + + // add the deltas to the list of deltas created during this operation + if (deltaBuilder.delta != null) { + addDelta(deltaBuilder.delta); + } + worked(1); + } finally { + done(); + } } + /** * Possible failures: <ul> * <li>INVALID_ELEMENT_TYPES - the Translation unit supplied to this @@ -175,22 +173,22 @@ public class CommitWorkingCopyOperation extends CModelOperation { @Override public ICModelStatus verify() { - + IWorkingCopy wc = (IWorkingCopy) getElementToProcess(); if (!wc.isWorkingCopy()) { return new CModelStatus(ICModelStatusConstants.INVALID_ELEMENT_TYPES, wc); } - - ITranslationUnit original= wc.getOriginalElement(); + + ITranslationUnit original = wc.getOriginalElement(); IResource resource = original.getResource(); if (!wc.isBasedOn(resource) && !fForce) { return new CModelStatus(ICModelStatusConstants.UPDATE_CONFLICT); } // no read-only check, since some repository adapters can change the flag on save - // operation. + // operation. return CModelStatus.VERIFIED_OK; - + } } |