mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 12:55:40 +02:00
Cosmetics.
This commit is contained in:
parent
ef4a520f87
commit
66e0db829f
1 changed files with 24 additions and 29 deletions
|
@ -9,7 +9,6 @@
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -28,26 +27,25 @@ import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
public abstract class Openable extends Parent implements IOpenable {
|
public abstract class Openable extends Parent implements IOpenable {
|
||||||
|
|
||||||
protected IResource resource;
|
protected IResource resource;
|
||||||
|
|
||||||
public Openable (ICElement parent, IPath path, int type) {
|
public Openable(ICElement parent, IPath path, int type) {
|
||||||
// Check if the file is under the workspace.
|
// Check if the file is under the workspace.
|
||||||
this (parent, ResourcesPlugin.getWorkspace().getRoot().getFileForLocation (path),
|
this(parent, ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path),
|
||||||
path.lastSegment(), type);
|
path.lastSegment(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Openable (ICElement parent, IResource resource, int type) {
|
public Openable(ICElement parent, IResource resource, int type) {
|
||||||
this (parent, resource, resource.getName(), type);
|
this(parent, resource, resource.getName(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Openable (ICElement parent, IResource res, String name, int type) {
|
public Openable(ICElement parent, IResource res, String name, int type) {
|
||||||
super (parent, name, type);
|
super(parent, name, type);
|
||||||
resource = res;
|
resource = res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IResource getResource() {
|
public IResource getResource() {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +76,8 @@ public abstract class Openable extends Parent implements IOpenable {
|
||||||
* if successful, or false if an error is encountered while determining
|
* if successful, or false if an error is encountered while determining
|
||||||
* the structure of this element.
|
* the structure of this element.
|
||||||
*/
|
*/
|
||||||
protected abstract boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map<ICElement, CElementInfo> newElements, IResource underlyingResource) throws CModelException;
|
protected abstract boolean buildStructure(OpenableInfo info, IProgressMonitor pm,
|
||||||
|
Map<ICElement, CElementInfo> newElements, IResource underlyingResource) throws CModelException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the buffer associated with this element, if any.
|
* Close the buffer associated with this element, if any.
|
||||||
|
@ -145,7 +144,6 @@ public abstract class Openable extends Parent implements IOpenable {
|
||||||
* @see org.eclipse.cdt.core.model.IOpenable#hasUnsavedChanges()
|
* @see org.eclipse.cdt.core.model.IOpenable#hasUnsavedChanges()
|
||||||
*/
|
*/
|
||||||
public boolean hasUnsavedChanges() throws CModelException{
|
public boolean hasUnsavedChanges() throws CModelException{
|
||||||
|
|
||||||
if (isReadOnly() || !isOpen()) {
|
if (isReadOnly() || !isOpen()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -155,13 +153,12 @@ public abstract class Openable extends Parent implements IOpenable {
|
||||||
}
|
}
|
||||||
// for roots and projects must check open buffers
|
// for roots and projects must check open buffers
|
||||||
// to see if they have an child with unsaved changes
|
// to see if they have an child with unsaved changes
|
||||||
if (fType == C_MODEL ||
|
if (fType == C_MODEL || fType == C_PROJECT) {
|
||||||
fType == C_PROJECT) {
|
|
||||||
Enumeration<IBuffer> openBuffers= getBufferManager().getOpenBuffers();
|
Enumeration<IBuffer> openBuffers= getBufferManager().getOpenBuffers();
|
||||||
while (openBuffers.hasMoreElements()) {
|
while (openBuffers.hasMoreElements()) {
|
||||||
IBuffer buffer= openBuffers.nextElement();
|
IBuffer buffer= openBuffers.nextElement();
|
||||||
if (buffer.hasUnsavedChanges()) {
|
if (buffer.hasUnsavedChanges()) {
|
||||||
ICElement owner= (ICElement)buffer.getOwner();
|
ICElement owner= (ICElement) buffer.getOwner();
|
||||||
if (isAncestorOf(owner)) {
|
if (isAncestorOf(owner)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -171,6 +168,7 @@ public abstract class Openable extends Parent implements IOpenable {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclasses must override as required.
|
* Subclasses must override as required.
|
||||||
*
|
*
|
||||||
|
@ -234,30 +232,28 @@ public abstract class Openable extends Parent implements IOpenable {
|
||||||
/**
|
/**
|
||||||
* Open the parent element if necessary.
|
* Open the parent element if necessary.
|
||||||
*/
|
*/
|
||||||
protected void openParent(CElementInfo childInfo, Map<ICElement, CElementInfo> newElements, IProgressMonitor pm) throws CModelException {
|
protected void openParent(CElementInfo childInfo, Map<ICElement, CElementInfo> newElements,
|
||||||
|
IProgressMonitor pm) throws CModelException {
|
||||||
Openable openableParent = (Openable)getOpenableParent();
|
Openable openableParent = (Openable) getOpenableParent();
|
||||||
if (openableParent != null && !openableParent.isOpen()){
|
if (openableParent != null && !openableParent.isOpen()){
|
||||||
openableParent.generateInfos(openableParent.createElementInfo(), newElements, pm);
|
openableParent.generateInfos(openableParent.createElementInfo(), newElements, pm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.model.CElement#generateInfos(java.lang.Object, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
|
|
||||||
*/
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.model.CElement#generateInfos(java.lang.Object, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.cdt.internal.core.model.CElement#generateInfos(java.lang.Object, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void generateInfos(CElementInfo info, Map<ICElement, CElementInfo> newElements, IProgressMonitor monitor) throws CModelException {
|
protected void generateInfos(CElementInfo info, Map<ICElement, CElementInfo> newElements,
|
||||||
|
IProgressMonitor monitor) throws CModelException {
|
||||||
if (CModelManager.VERBOSE){
|
if (CModelManager.VERBOSE){
|
||||||
System.out.println("OPENING Element ("+ Thread.currentThread()+"): " + this); //$NON-NLS-1$//$NON-NLS-2$
|
System.out.println("OPENING Element ("+ Thread.currentThread()+"): " + this); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
// open the parent if necessary
|
// open the parent if necessary
|
||||||
openParent(info, newElements, monitor);
|
openParent(info, newElements, monitor);
|
||||||
if (monitor != null && monitor.isCanceled()) return;
|
if (monitor != null && monitor.isCanceled())
|
||||||
|
return;
|
||||||
|
|
||||||
// puts the info before building the structure so that questions to the handle behave as if the element existed
|
// puts the info before building the structure so that questions to the handle behave as if the element existed
|
||||||
// (case of compilation units becoming working copies)
|
// (case of compilation units becoming working copies)
|
||||||
|
@ -265,7 +261,7 @@ public abstract class Openable extends Parent implements IOpenable {
|
||||||
|
|
||||||
// build the structure of the openable (this will open the buffer if needed)
|
// build the structure of the openable (this will open the buffer if needed)
|
||||||
try {
|
try {
|
||||||
OpenableInfo openableInfo = (OpenableInfo)info;
|
OpenableInfo openableInfo = (OpenableInfo) info;
|
||||||
boolean isStructureKnown = buildStructure(openableInfo, monitor, newElements, getResource());
|
boolean isStructureKnown = buildStructure(openableInfo, monitor, newElements, getResource());
|
||||||
openableInfo.setIsStructureKnown(isStructureKnown);
|
openableInfo.setIsStructureKnown(isStructureKnown);
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
|
@ -275,7 +271,6 @@ public abstract class Openable extends Parent implements IOpenable {
|
||||||
|
|
||||||
// remove out of sync buffer for this element
|
// remove out of sync buffer for this element
|
||||||
CModelManager.getDefault().getElementsOutOfSynchWithBuffers().remove(this);
|
CModelManager.getDefault().getElementsOutOfSynchWithBuffers().remove(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -306,10 +301,10 @@ public abstract class Openable extends Parent implements IOpenable {
|
||||||
public SourceRoot getSourceRoot() {
|
public SourceRoot getSourceRoot() {
|
||||||
ICElement current = this;
|
ICElement current = this;
|
||||||
do {
|
do {
|
||||||
if (current instanceof SourceRoot) return (SourceRoot)current;
|
if (current instanceof SourceRoot)
|
||||||
|
return (SourceRoot) current;
|
||||||
current = current.getParent();
|
current = current.getParent();
|
||||||
} while(current != null);
|
} while (current != null);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue