mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-01 21:35:40 +02:00
Cosmetics.
This commit is contained in:
parent
fb9f6f5b59
commit
490035148e
3 changed files with 16 additions and 62 deletions
|
@ -29,7 +29,7 @@ class TranslationUnitInfo extends OpenableInfo {
|
||||||
|
|
||||||
/* Overide the SourceManipulation for the range. */
|
/* Overide the SourceManipulation for the range. */
|
||||||
protected ISourceRange getSourceRange() {
|
protected ISourceRange getSourceRange() {
|
||||||
IPath location = ((TranslationUnit)getElement()).getLocation();
|
IPath location = ((TranslationUnit) getElement()).getLocation();
|
||||||
return new SourceRange(0, (int)location.toFile().length());
|
return new SourceRange(0, (int)location.toFile().length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
* the timestamp of the resource it was created from.
|
* the timestamp of the resource it was created from.
|
||||||
*/
|
*/
|
||||||
public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If set, this is the factory that will be used to create the buffer.
|
* If set, this is the factory that will be used to create the buffer.
|
||||||
*/
|
*/
|
||||||
|
@ -71,9 +70,6 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
this.bufferFactory = bufferFactory == null ? getBufferManager() : bufferFactory;
|
this.bufferFactory = bufferFactory == null ? getBufferManager() : bufferFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.core.model.IWorkingCopy#commit(boolean, org.eclipse.core.runtime.IProgressMonitor)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void commit(boolean force, IProgressMonitor monitor) throws CModelException {
|
public void commit(boolean force, IProgressMonitor monitor) throws CModelException {
|
||||||
ITranslationUnit original = this.getOriginalElement();
|
ITranslationUnit original = this.getOriginalElement();
|
||||||
|
@ -112,9 +108,6 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.core.model.IWorkingCopy#destroy()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
if (--this.useCount > 0) {
|
if (--this.useCount > 0) {
|
||||||
|
@ -129,9 +122,6 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.core.model.ICElement#exists()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean exists() {
|
public boolean exists() {
|
||||||
// working copy always exists in the model until it is destroyed
|
// working copy always exists in the model until it is destroyed
|
||||||
|
@ -139,7 +129,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Answers custom buffer factory
|
* Returns custom buffer factory
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IBufferFactory getBufferFactory(){
|
public IBufferFactory getBufferFactory(){
|
||||||
|
@ -211,9 +201,6 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.core.model.IWorkingCopy#getOriginalElement()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public ITranslationUnit getOriginalElement() {
|
public ITranslationUnit getOriginalElement() {
|
||||||
IFile file= getFile();
|
IFile file= getFile();
|
||||||
|
@ -223,33 +210,21 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
return new ExternalTranslationUnit(getParent(), getLocationURI(), getContentTypeId());
|
return new ExternalTranslationUnit(getParent(), getLocationURI(), getContentTypeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#getSharedWorkingCopy(IProgressMonitor, IProblemRequestor)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IProblemRequestor requestor) {
|
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IProblemRequestor requestor) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#getWorkingCopy()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IWorkingCopy getWorkingCopy() {
|
public IWorkingCopy getWorkingCopy() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see IWorkingCopy
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IWorkingCopy getWorkingCopy(IProgressMonitor monitor){
|
public IWorkingCopy getWorkingCopy(IProgressMonitor monitor){
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see IWorkingCopy
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBasedOn(IResource resource) {
|
public boolean isBasedOn(IResource resource) {
|
||||||
if (resource.getType() != IResource.FILE) {
|
if (resource.getType() != IResource.FILE) {
|
||||||
|
@ -267,9 +242,6 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#isWorkingCopy()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWorkingCopy() {
|
public boolean isWorkingCopy() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -280,7 +252,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
* @see IWorkingCopy
|
* @see IWorkingCopy
|
||||||
*
|
*
|
||||||
* @exception CModelException attempting to open a read only element for
|
* @exception CModelException attempting to open a read only element for
|
||||||
* something other than navigation or if this is a working copy being
|
* something other than navigation, or if this is a working copy being
|
||||||
* opened after it has been destroyed.
|
* opened after it has been destroyed.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -297,26 +269,24 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.internal.core.model.TranslationUnit#openBuffer(org.eclipse.core.runtime.IProgressMonitor)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected IBuffer openBuffer(IProgressMonitor pm) throws CModelException {
|
protected IBuffer openBuffer(IProgressMonitor pm) throws CModelException {
|
||||||
if (this.useCount == 0) throw newNotPresentException();
|
if (this.useCount == 0)
|
||||||
|
throw newNotPresentException();
|
||||||
|
|
||||||
// create buffer - working copies may use custom buffer factory
|
// Create buffer - working copies may use custom buffer factory
|
||||||
IBuffer buffer = getBufferFactory().createBuffer(this);
|
IBuffer buffer = getBufferFactory().createBuffer(this);
|
||||||
if (buffer == null)
|
if (buffer == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// set the buffer source if needed
|
// Set the buffer source if needed
|
||||||
if (buffer.getContents() == null){
|
if (buffer.getContents() == null){
|
||||||
ITranslationUnit original= this.getOriginalElement();
|
ITranslationUnit original= this.getOriginalElement();
|
||||||
IBuffer originalBuffer = null;
|
IBuffer originalBuffer = null;
|
||||||
try {
|
try {
|
||||||
originalBuffer = original.getBuffer();
|
originalBuffer = original.getBuffer();
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
// original element does not exist: create an empty working copy
|
// Original element does not exist: create an empty working copy
|
||||||
if (!e.getCModelStatus().doesNotExist()) {
|
if (!e.getCModelStatus().doesNotExist()) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
@ -327,43 +297,35 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
buffer.setContents(originalContents.clone());
|
buffer.setContents(originalContents.clone());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// initialize buffer
|
// Initialize buffer
|
||||||
buffer.setContents(new char[0]);
|
buffer.setContents(new char[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add buffer to buffer cache
|
// Add buffer to buffer cache
|
||||||
this.getBufferManager().addBuffer(buffer);
|
this.getBufferManager().addBuffer(buffer);
|
||||||
|
|
||||||
// listen to buffer changes
|
// Listen to buffer changes
|
||||||
buffer.addBufferChangedListener(this);
|
buffer.addBufferChangedListener(this);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.core.model.IWorkingCopy#reconcile()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IMarker[] reconcile() throws CModelException {
|
public IMarker[] reconcile() throws CModelException {
|
||||||
reconcile(false, null);
|
reconcile(false, null);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.core.model.IWorkingCopy#reconcile(boolean, org.eclipse.core.runtime.IProgressMonitor)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void reconcile(boolean forceProblemDetection, IProgressMonitor monitor) throws CModelException {
|
public void reconcile(boolean forceProblemDetection, IProgressMonitor monitor) throws CModelException {
|
||||||
reconcile(false, forceProblemDetection, monitor);
|
reconcile(false, forceProblemDetection, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.core.model.IWorkingCopy#restore()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void restore() throws CModelException{
|
public void restore() throws CModelException{
|
||||||
if (this.useCount == 0) throw newNotPresentException(); //was destroyed
|
if (this.useCount == 0)
|
||||||
|
throw newNotPresentException(); // Was destroyed
|
||||||
|
|
||||||
TranslationUnit original = (TranslationUnit) getOriginalElement();
|
TranslationUnit original = (TranslationUnit) getOriginalElement();
|
||||||
IBuffer buffer = this.getBuffer();
|
IBuffer buffer = this.getBuffer();
|
||||||
|
@ -373,15 +335,12 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
makeConsistent(null);
|
makeConsistent(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ITranslationUnit#save(IProgressMonitor, boolean)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void save(IProgressMonitor pm, boolean force) throws CModelException {
|
public void save(IProgressMonitor pm, boolean force) throws CModelException {
|
||||||
if (isReadOnly()) {
|
if (isReadOnly()) {
|
||||||
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this));
|
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this));
|
||||||
}
|
}
|
||||||
// computes fine-grain deltas in case the working copy is being reconciled already
|
// Computes fine-grain deltas in case the working copy is being reconciled already
|
||||||
// (if not it would miss one iteration of deltas).
|
// (if not it would miss one iteration of deltas).
|
||||||
this.reconcile();
|
this.reconcile();
|
||||||
}
|
}
|
||||||
|
@ -391,17 +350,13 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
* @throws CModelException
|
* @throws CModelException
|
||||||
*/
|
*/
|
||||||
protected void updateTimeStamp(TranslationUnit original) throws CModelException {
|
protected void updateTimeStamp(TranslationUnit original) throws CModelException {
|
||||||
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(new CModelStatus(ICModelStatusConstants.INVALID_RESOURCE));
|
throw new CModelException(new CModelStatus(ICModelStatusConstants.INVALID_RESOURCE));
|
||||||
}
|
}
|
||||||
((TranslationUnitInfo) getElementInfo()).fTimestamp = timeStamp;
|
((TranslationUnitInfo) getElementInfo()).fTimestamp = timeStamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.model.IWorkingCopy#reconcile(boolean, boolean, org.eclipse.core.runtime.IProgressMonitor)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IASTTranslationUnit reconcile(boolean computeAST, boolean forceProblemDetection, IProgressMonitor monitor)
|
public IASTTranslationUnit reconcile(boolean computeAST, boolean forceProblemDetection, IProgressMonitor monitor)
|
||||||
throws CModelException {
|
throws CModelException {
|
||||||
|
|
|
@ -17,8 +17,7 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class WorkingCopyInfo extends TranslationUnitInfo {
|
public class WorkingCopyInfo extends TranslationUnitInfo {
|
||||||
|
|
||||||
public WorkingCopyInfo (CElement element) {
|
public WorkingCopyInfo(CElement element) {
|
||||||
super(element);
|
super(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue