mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
More support for external headers
and cleanup of the CElement.close() method
This commit is contained in:
parent
70aaf923d3
commit
ceefe291d8
9 changed files with 306 additions and 98 deletions
|
@ -1,3 +1,17 @@
|
|||
2004-04-04 Alain Magloire
|
||||
|
||||
More support for external headers.
|
||||
Cleanup of the CElement.close() calls.
|
||||
|
||||
* model/org/eclipse/cdt/internal/core/model/Archive.java
|
||||
* model/org/eclipse/cdt/internal/core/model/Binary.java
|
||||
* model/org/eclipse/cdt/internal/core/model/CElement.java
|
||||
* model/org/eclipse/cdt/internal/core/model/CModelManager.java
|
||||
* model/org/eclipse/cdt/internal/core/model/CProject.java
|
||||
* model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
|
||||
* model/org/eclipse/cdt/internal/core/model/ExternaltranslationUnit.java
|
||||
* model/org/eclipse/cdt/internal/core/model/IncludeReference.java
|
||||
|
||||
2004-04-03 Alain Magloire
|
||||
|
||||
Draft work on LibraryReferences and IncludeReferences.
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.eclipse.cdt.core.model.CModelException;
|
|||
import org.eclipse.cdt.core.model.IArchive;
|
||||
import org.eclipse.cdt.core.model.IBinary;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
@ -87,4 +88,16 @@ public class Archive extends Openable implements IArchive {
|
|||
public boolean exists() {
|
||||
return getResource() != null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.model.CElement#closing(java.lang.Object)
|
||||
*/
|
||||
protected void closing(Object info) throws CModelException {
|
||||
ICProject cproject = getCProject();
|
||||
CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(cproject);
|
||||
if (pinfo != null && pinfo.vLib != null) {
|
||||
pinfo.vLib.removeChild(this);
|
||||
}
|
||||
super.closing(info);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.core.model.CModelException;
|
|||
import org.eclipse.cdt.core.model.IBinary;
|
||||
import org.eclipse.cdt.core.model.IBuffer;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
@ -357,4 +358,15 @@ public class Binary extends Openable implements IBinary {
|
|||
public boolean exists() {
|
||||
return getResource() != null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.model.CElement#closing(java.lang.Object)
|
||||
*/
|
||||
protected void closing(Object info) throws CModelException {
|
||||
ICProject cproject = getCProject();
|
||||
CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(cproject);
|
||||
if (pinfo != null && pinfo.vBin != null) {
|
||||
pinfo.vBin.removeChild(this);
|
||||
}
|
||||
super.closing(info);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -302,19 +302,21 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
* @throws CModelException
|
||||
*/
|
||||
public void close() throws CModelException {
|
||||
Object info = CModelManager.getDefault().peekAtInfo(this);
|
||||
if (info != null) {
|
||||
if (this instanceof IParent) {
|
||||
ICElement[] children = ((CElementInfo) info).getChildren();
|
||||
for (int i = 0, size = children.length; i < size; ++i) {
|
||||
CElement child = (CElement) children[i];
|
||||
child.close();
|
||||
}
|
||||
}
|
||||
closing(info);
|
||||
CModelManager.getDefault().removeInfo(this);
|
||||
}
|
||||
//Object info = CModelManager.getDefault().peekAtInfo(this);
|
||||
//if (info != null) {
|
||||
// if (this instanceof IParent) {
|
||||
// ICElement[] children = ((CElementInfo) info).getChildren();
|
||||
// for (int i = 0, size = children.length; i < size; ++i) {
|
||||
// CElement child = (CElement) children[i];
|
||||
// child.close();
|
||||
// }
|
||||
// }
|
||||
// closing(info);
|
||||
// CModelManager.getDefault().removeInfo(this);
|
||||
//}
|
||||
CModelManager.getDefault().releaseCElement(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* This element is being closed. Do any necessary cleanup.
|
||||
*/
|
||||
|
|
|
@ -288,17 +288,18 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
}
|
||||
|
||||
// try in the outputEntry and save in the container
|
||||
// But do not create an ICElement since they are not in the Model per say
|
||||
if (celement == null && !checkIfBinary && cproject.isOnOutputEntry(file)) {
|
||||
IBinaryFile bin = createBinaryFile(file);
|
||||
if (bin != null) {
|
||||
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
||||
ArchiveContainer vlib = (ArchiveContainer)cproject.getArchiveContainer();
|
||||
ICElement archive = new Archive(vlib, file, (IBinaryArchive)bin);
|
||||
vlib.addChild(archive);
|
||||
celement = new Archive(vlib, file, (IBinaryArchive)bin);
|
||||
vlib.addChild(celement);
|
||||
} else {
|
||||
BinaryContainer vbin = (BinaryContainer)cproject.getBinaryContainer();
|
||||
IBinary binary = new Binary(vbin, file, (IBinaryObject)bin);
|
||||
vbin.addChild(binary);
|
||||
celement = new Binary(vbin, file, (IBinaryObject)bin);
|
||||
vbin.addChild(celement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -349,15 +350,16 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
}
|
||||
|
||||
// try in the outputEntry and save in the container
|
||||
// But do not create a ICElement since they are not in the Model per say
|
||||
if (celement == null) {
|
||||
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
||||
ArchiveContainer vlib = (ArchiveContainer)cproject.getArchiveContainer();
|
||||
ICElement archive = new Archive(vlib, file, (IBinaryArchive)bin);
|
||||
vlib.addChild(archive);
|
||||
celement = new Archive(vlib, file, (IBinaryArchive)bin);
|
||||
vlib.addChild(celement);
|
||||
} else {
|
||||
BinaryContainer vbin = (BinaryContainer)cproject.getBinaryContainer();
|
||||
IBinary binary = new Binary(vbin, file, (IBinaryObject)bin);
|
||||
vbin.addChild(binary);
|
||||
celement = new Binary(vbin, file, (IBinaryObject)bin);
|
||||
vbin.addChild(celement);
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
|
@ -375,87 +377,65 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
//System.out.println("RELEASE " + celement.getElementName());
|
||||
|
||||
// Remove from the containers.
|
||||
int type = celement.getElementType();
|
||||
if (type == ICElement.C_ARCHIVE) {
|
||||
//System.out.println("RELEASE Archive " + cfile.getElementName());
|
||||
CProject cproj = (CProject)celement.getCProject();
|
||||
ArchiveContainer container = (ArchiveContainer)cproj.getArchiveContainer();
|
||||
container.removeChild(celement);
|
||||
CElementDelta delta = new CElementDelta(getCModel());
|
||||
delta.changed(container, ICElementDelta.CHANGED);
|
||||
registerCModelDelta(delta);
|
||||
} else if (type == ICElement.C_BINARY) {
|
||||
//System.out.println("RELEASE Binary " + celement.getElementName());
|
||||
CProject cproj = (CProject)celement.getCProject();
|
||||
BinaryContainer container = (BinaryContainer)cproj.getBinaryContainer();
|
||||
container.removeChild(celement);
|
||||
CElementDelta delta = new CElementDelta(getCModel());
|
||||
delta.changed(container, ICElementDelta.CHANGED);
|
||||
registerCModelDelta(delta);
|
||||
}
|
||||
|
||||
if (celement instanceof IParent) {
|
||||
if (peekAtInfo(celement) != null) {
|
||||
CElementInfo info = ((CElement)celement).getElementInfo();
|
||||
if (info != null) {
|
||||
ICElement[] children = info.getChildren();
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
releaseCElement(children[i]);
|
||||
}
|
||||
// Make sure we destroy the BinaryContainer and ArchiveContainer
|
||||
// Since they are not part of the children.
|
||||
if (info instanceof CProjectInfo) {
|
||||
CProjectInfo pinfo = (CProjectInfo) info;
|
||||
if (pinfo.vBin != null) {
|
||||
releaseCElement(pinfo.vBin);
|
||||
}
|
||||
if (pinfo.vLib != null) {
|
||||
releaseCElement(pinfo.vLib);
|
||||
}
|
||||
pinfo.resetCaches();
|
||||
IProject project = celement.getCProject().getProject();
|
||||
removeBinaryRunner(project);
|
||||
CElementInfo info = (CElementInfo)peekAtInfo(celement);
|
||||
if (info != null) {
|
||||
ICElement[] children = info.getChildren();
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
releaseCElement(children[i]);
|
||||
}
|
||||
// Make sure any object specifics not part of the children be destroy
|
||||
// For example the CProject needs to destroy the BinaryContainer and ArchiveContainer
|
||||
if (celement instanceof CElement) {
|
||||
try {
|
||||
((CElement)celement).closing(info);
|
||||
} catch (CModelException e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If an entire folder was deleted we need to update the
|
||||
// BinaryContainer/ArchiveContainer also.
|
||||
}
|
||||
|
||||
// If an entire folder was deleted we need to update the
|
||||
// BinaryContainer/ArchiveContainer also.
|
||||
if (celement.getElementType() == ICElement.C_CCONTAINER) {
|
||||
ICProject cproject = celement.getCProject();
|
||||
CProjectInfo info = (CProjectInfo)peekAtInfo(cproject);
|
||||
if (info != null && info.vBin != null) {
|
||||
if (peekAtInfo(info.vBin) != null) {
|
||||
ICElement[] bins = info.vBin.getChildren();
|
||||
CProjectInfo pinfo = (CProjectInfo)peekAtInfo(cproject);
|
||||
ArrayList list = new ArrayList(5);
|
||||
if (pinfo != null && pinfo.vBin != null) {
|
||||
if (peekAtInfo(pinfo.vBin) != null) {
|
||||
ICElement[] bins = pinfo.vBin.getChildren();
|
||||
for (int i = 0; i < bins.length; i++) {
|
||||
if (celement.getPath().isPrefixOf(bins[i].getPath())) {
|
||||
CElementDelta delta = new CElementDelta(getCModel());
|
||||
delta.changed(info.vBin, ICElementDelta.CHANGED);
|
||||
registerCModelDelta(delta);
|
||||
info.vBin.removeChild(bins[i]);
|
||||
//pinfo.vBin.removeChild(bins[i]);
|
||||
list.add(bins[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (info != null && info.vLib != null) {
|
||||
if (peekAtInfo(info.vLib) != null) {
|
||||
ICElement[] ars = info.vLib.getChildren();
|
||||
if (pinfo != null && pinfo.vLib != null) {
|
||||
if (peekAtInfo(pinfo.vLib) != null) {
|
||||
ICElement[] ars = pinfo.vLib.getChildren();
|
||||
for (int i = 0; i < ars.length; i++) {
|
||||
if (celement.getPath().isPrefixOf(ars[i].getPath())) {
|
||||
CElementDelta delta = new CElementDelta(getCModel());
|
||||
delta.changed(info.vLib, ICElementDelta.CHANGED);
|
||||
registerCModelDelta(delta);
|
||||
info.vLib.removeChild(ars[i]);
|
||||
//pinfo.vLib.removeChild(ars[i]);
|
||||
list.add(ars[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// release any binary/archive that was in the path
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ICElement b = (ICElement)list.get(i);
|
||||
releaseCElement(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the child from the parent list.
|
||||
Parent parent = (Parent)celement.getParent();
|
||||
if (parent != null && peekAtInfo(parent) != null) {
|
||||
parent.removeChild(celement);
|
||||
}
|
||||
//Parent parent = (Parent)celement.getParent();
|
||||
//if (parent != null && peekAtInfo(parent) != null) {
|
||||
// parent.removeChild(celement);
|
||||
//}
|
||||
|
||||
removeInfo(celement);
|
||||
}
|
||||
|
|
|
@ -585,6 +585,7 @@ public class CProject extends Openable implements ICProject {
|
|||
public Object[] getNonCResources() throws CModelException {
|
||||
return ((CProjectInfo) getElementInfo()).getNonCResources(getResource());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.model.CElement#closing(java.lang.Object)
|
||||
*/
|
||||
|
|
|
@ -125,24 +125,16 @@ public class DeltaProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
// It is not a C resource if the parent is a Binary/ArchiveContainer
|
||||
if (celement != null && resource.getType() == IResource.FILE) {
|
||||
ICElement parent = celement.getParent();
|
||||
if (parent instanceof IArchiveContainer || parent instanceof IBinaryContainer) {
|
||||
celement = null;
|
||||
}
|
||||
}
|
||||
return celement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the create corresponding to this resource.
|
||||
* Returns null if none was found.
|
||||
*/
|
||||
protected ICElement createElement(IPath path) {
|
||||
return CModelManager.getDefault().create(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the Element and cleaning.
|
||||
*/
|
||||
protected void releaseCElement(ICElement celement) {
|
||||
CModelManager.getDefault().releaseCElement(celement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given child handle to its parent's cache of children.
|
||||
*/
|
||||
|
@ -154,6 +146,73 @@ public class DeltaProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the given element from its parents cache of children. If the
|
||||
* element does not have a parent, or the parent is not currently open,
|
||||
* this has no effect.
|
||||
*/
|
||||
private void removeFromParentInfo(ICElement child) {
|
||||
CModelManager factory = CModelManager.getDefault();
|
||||
|
||||
// Remove the child from the parent list.
|
||||
ICElement parent = child.getParent();
|
||||
if (parent != null && parent instanceof Parent && factory.peekAtInfo(parent) != null) {
|
||||
((Parent)parent).removeChild(child);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the Element and cleaning.
|
||||
*/
|
||||
protected void releaseCElement(ICElement celement) {
|
||||
CModelManager factory = CModelManager.getDefault();
|
||||
int type = celement.getElementType();
|
||||
if (type == ICElement.C_ARCHIVE) {
|
||||
ICProject cproject = celement.getCProject();
|
||||
IArchiveContainer container = cproject.getArchiveContainer();
|
||||
fCurrentDelta.changed(container, ICElementDelta.CHANGED);
|
||||
} else if (type == ICElement.C_BINARY) {
|
||||
ICProject cproject = celement.getCProject();
|
||||
IBinaryContainer container = cproject.getBinaryContainer();
|
||||
fCurrentDelta.changed(container, ICElementDelta.CHANGED);
|
||||
} else {
|
||||
// If an entire folder was deleted we need to update the
|
||||
// BinaryContainer/ArchiveContainer also.
|
||||
ICProject cproject = celement.getCProject();
|
||||
CProjectInfo pinfo = (CProjectInfo)factory.peekAtInfo(cproject);
|
||||
if (pinfo != null && pinfo.vBin != null) {
|
||||
if (factory.peekAtInfo(pinfo.vBin) != null) {
|
||||
ICElement[] bins = pinfo.vBin.getChildren();
|
||||
for (int i = 0; i < bins.length; i++) {
|
||||
if (celement.getPath().isPrefixOf(bins[i].getPath())) {
|
||||
fCurrentDelta.changed(pinfo.vBin, ICElementDelta.CHANGED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pinfo != null && pinfo.vLib != null) {
|
||||
if (factory.peekAtInfo(pinfo.vLib) != null) {
|
||||
ICElement[] ars = pinfo.vLib.getChildren();
|
||||
for (int i = 0; i < ars.length; i++) {
|
||||
if (celement.getPath().isPrefixOf(ars[i].getPath())) {
|
||||
fCurrentDelta.changed(pinfo.vBin, ICElementDelta.CHANGED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
removeFromParentInfo(celement);
|
||||
factory.releaseCElement(celement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the create corresponding to this resource.
|
||||
* Returns null if none was found.
|
||||
*/
|
||||
protected ICElement createElement(IPath path) {
|
||||
return CModelManager.getDefault().create(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processing for an element that has been added:<ul>
|
||||
* <li>If the element is a project, do nothing, and do not process
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003,2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
***********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.IBuffer;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
/**
|
||||
* ExternalTranslationUnit
|
||||
*/
|
||||
public class ExternalTranslationUnit extends TranslationUnit {
|
||||
|
||||
IPath fPath;
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param path
|
||||
*/
|
||||
public ExternalTranslationUnit(ICElement parent, IPath path) {
|
||||
super(parent, path);
|
||||
fPath = path;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.model.Openable#openBuffer(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
protected IBuffer openBuffer(IProgressMonitor pm) throws CModelException {
|
||||
|
||||
// create buffer - translation units only use default buffer factory
|
||||
BufferManager bufManager = getBufferManager();
|
||||
IBuffer buffer = getBufferFactory().createBuffer(this);
|
||||
if (buffer == null)
|
||||
return null;
|
||||
|
||||
// set the buffer source
|
||||
if (buffer.getCharacters() == null){
|
||||
IPath path = this.getPath();
|
||||
File file = path.toFile();
|
||||
if (file != null && file.isFile()) {
|
||||
try {
|
||||
InputStream stream = new FileInputStream(file);
|
||||
buffer.setContents(Util.getInputStreamAsCharArray(stream, (int)file.length(), null));
|
||||
} catch (IOException e) {
|
||||
buffer.setContents(new char[0]);
|
||||
}
|
||||
} else {
|
||||
buffer.setContents(new char[0]);
|
||||
}
|
||||
}
|
||||
|
||||
// add buffer to buffer cache
|
||||
bufManager.addBuffer(buffer);
|
||||
|
||||
// listen to buffer changes
|
||||
buffer.addBufferChangedListener(this);
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICElement#getPath()
|
||||
*/
|
||||
public IPath getPath() {
|
||||
return fPath;
|
||||
}
|
||||
}
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
|
@ -21,6 +23,7 @@ import org.eclipse.cdt.core.model.IIncludeReference;
|
|||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
* IncludeReference
|
||||
|
@ -28,6 +31,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
public class IncludeReference extends Openable implements IIncludeReference {
|
||||
|
||||
IIncludeEntry fIncludeEntry;
|
||||
IPath fPath;
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
|
@ -35,8 +39,13 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
|||
* @param type
|
||||
*/
|
||||
public IncludeReference(ICProject cproject, IIncludeEntry entry) {
|
||||
super(cproject, null, entry.getIncludePath().toString(), ICElement.C_VCONTAINER);
|
||||
this(cproject, entry, entry.getIncludePath());
|
||||
}
|
||||
|
||||
public IncludeReference(ICElement celement, IIncludeEntry entry, IPath path) {
|
||||
super(celement, null, path.toString(), ICElement.C_VCONTAINER);
|
||||
fIncludeEntry = entry;
|
||||
fPath = path;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -64,7 +73,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
|||
* @see org.eclipse.cdt.internal.core.model.Openable#generateInfos(org.eclipse.cdt.internal.core.model.OpenableInfo, org.eclipse.core.runtime.IProgressMonitor, java.util.Map, org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
protected boolean generateInfos(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws CModelException {
|
||||
return false;
|
||||
return computeChildren(info, underlyingResource);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -73,4 +82,38 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
|||
public IPath getAffectedPath() {
|
||||
return fIncludeEntry.getPath();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.model.CContainer#computeChildren(org.eclipse.cdt.internal.core.model.OpenableInfo, org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
|
||||
ArrayList vChildren = new ArrayList();
|
||||
final CModelManager factory = CModelManager.getDefault();
|
||||
File file = fIncludeEntry.getIncludePath().toFile();
|
||||
String[] names = null;
|
||||
if (file != null && file.isDirectory()) {
|
||||
names = file.list();
|
||||
}
|
||||
|
||||
if (names != null) {
|
||||
IPath path = new Path(file.getAbsolutePath());
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
File child = new File(file, names[i]);
|
||||
ICElement celement = null;
|
||||
if (child.isDirectory()) {
|
||||
celement = new IncludeReference(this, fIncludeEntry, new Path(child.getAbsolutePath()));
|
||||
} else if (child.isFile()) {
|
||||
celement = new ExternalTranslationUnit(this, path.append(names[i]));
|
||||
}
|
||||
if (celement != null) {
|
||||
vChildren.add(celement);
|
||||
}
|
||||
}
|
||||
}
|
||||
ICElement[] children = new ICElement[vChildren.size()];
|
||||
vChildren.toArray(children);
|
||||
info.setChildren(children);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue