mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
ICModel and ICProject no longer extends ICContainer
This commit is contained in:
parent
f980b3161f
commit
7de97b8a11
12 changed files with 211 additions and 140 deletions
|
@ -1,3 +1,22 @@
|
|||
2004-03-21 Alain Magloire
|
||||
|
||||
The methods CoreModel.create() are now handle operation.
|
||||
Meaning it will generate a ICElement even if the file does
|
||||
not exists. ICModel and ICProject no longer implements
|
||||
ICContainer.
|
||||
|
||||
* model/org/eclipse/cdt/core/model/ICModel.java
|
||||
* model/org/eclipse/cdt/core/model/ICProject.java
|
||||
|
||||
* model/eclipse/cdt/internal/core/model/CContainer.java
|
||||
* model/eclipse/cdt/internal/core/model/CContainerInfo.java
|
||||
* model/eclipse/cdt/internal/core/model/CModel.java
|
||||
* model/eclipse/cdt/internal/core/model/CModelInfo.java
|
||||
* model/eclipse/cdt/internal/core/model/CModelManager.java
|
||||
* model/eclipse/cdt/internal/core/model/CProject.java
|
||||
* model/eclipse/cdt/internal/core/model/CCProjectInfo.java
|
||||
* model/eclipse/cdt/internal/core/model/DeltaProcessor.java
|
||||
|
||||
2004-03-19 David Inglis
|
||||
|
||||
* model/org/eclipse/cdt/core/model/CoreModel.java
|
||||
|
|
|
@ -161,11 +161,14 @@ public interface ICModel extends ICElement, IParent, IOpenable {
|
|||
/**
|
||||
* Returns the C project with the given name. This is a handle-only method.
|
||||
* The project may or may not exist.
|
||||
*
|
||||
* @param name of the Project
|
||||
*/
|
||||
ICProject getCProject(String name);
|
||||
|
||||
/**
|
||||
* Returns the C projects.
|
||||
*
|
||||
*/
|
||||
ICProject[] getCProjects();
|
||||
|
||||
|
|
|
@ -45,11 +45,25 @@ public interface ICProject extends IParent, IOpenable, ICElement {
|
|||
|
||||
/**
|
||||
* Returns the source root folders of the project.
|
||||
*
|
||||
* <p>NOTE: This is equivalent to <code>getChildren()</code>.
|
||||
*
|
||||
* @return ISourceRoot - root folders
|
||||
* @exception CModelException
|
||||
*/
|
||||
ISourceRoot[] getSourceRoots() throws CModelException;
|
||||
|
||||
/**
|
||||
* Returns all of the existing source roots that exist
|
||||
* on the pathentry, in the order they are defined by the ".cdtproject".
|
||||
*
|
||||
* @return all of the existing package fragment roots that exist
|
||||
* on the classpath
|
||||
* @exception JavaModelException if this element does not exist or if an
|
||||
* exception occurs while accessing its corresponding resource
|
||||
*/
|
||||
ISourceRoot[] getAllSourceRoots() throws CModelException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param entry
|
||||
|
|
|
@ -117,6 +117,18 @@ public class CContainer extends Openable implements ICContainer {
|
|||
return new TranslationUnit(this, file);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.model.ICContainer#getCContainers()
|
||||
*/
|
||||
public ICContainer[] getCContainers() throws CModelException {
|
||||
List list = getChildrenOfType(C_CCONTAINER);
|
||||
ICContainer[] array = new ICContainer[list.size()];
|
||||
list.toArray(array);
|
||||
return array;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -239,13 +251,4 @@ public class CContainer extends Openable implements ICContainer {
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.model.ICContainer#getCContainers()
|
||||
*/
|
||||
public ICContainer[] getCContainers() throws CModelException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,11 +21,6 @@ import org.eclipse.core.runtime.CoreException;
|
|||
*/
|
||||
public class CContainerInfo extends OpenableInfo {
|
||||
|
||||
/**
|
||||
* Shared empty collection used for efficiency.
|
||||
*/
|
||||
static Object[] NO_NON_C_RESOURCES = new Object[] {};
|
||||
|
||||
Object[] nonCResources = null;
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,6 +16,11 @@ import org.eclipse.core.resources.IResource;
|
|||
*/
|
||||
class CElementInfo {
|
||||
|
||||
/**
|
||||
* Shared empty collection used for efficiency.
|
||||
*/
|
||||
static Object[] NO_NON_C_RESOURCES = new Object[] {};
|
||||
|
||||
protected CElement element;
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,9 +31,11 @@ public class CModel extends Openable implements ICModel {
|
|||
super (null, root, ICElement.C_MODEL);
|
||||
}
|
||||
|
||||
public ICProject getCProject(String name) {
|
||||
IProject project = getWorkspace().getRoot().getProject(name);
|
||||
return CModelManager.getDefault().create(project);
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof CModel)) {
|
||||
return false;
|
||||
}
|
||||
return super.equals(o);
|
||||
}
|
||||
|
||||
public ICProject[] getCProjects() {
|
||||
|
@ -43,6 +45,14 @@ public class CModel extends Openable implements ICModel {
|
|||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* ICModel#getCProject(String)
|
||||
*/
|
||||
public ICProject getCProject(String name) {
|
||||
IProject project = ((IWorkspaceRoot)getResource()).getProject(name);
|
||||
return CModelManager.getDefault().create(project);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the active C project associated with the specified
|
||||
* resource, or <code>null</code> if no C project yet exists
|
||||
|
|
|
@ -11,7 +11,9 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
|||
/**
|
||||
* @see ICModel
|
||||
*/
|
||||
public class CModelInfo extends CContainerInfo {
|
||||
public class CModelInfo extends OpenableInfo {
|
||||
|
||||
Object[] nonCResources = null;
|
||||
|
||||
/**
|
||||
* Constructs a new C Model Info
|
||||
|
@ -57,4 +59,11 @@ public class CModelInfo extends CContainerInfo {
|
|||
return nonCResources;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public void setNonCResources(Object[] resources) {
|
||||
nonCResources = resources;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.eclipse.cdt.core.model.IParent;
|
|||
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -53,7 +52,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
public class CModelManager implements IResourceChangeListener, ICDescriptorListener {
|
||||
|
||||
|
@ -188,9 +186,6 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
return null;
|
||||
}
|
||||
|
||||
if (cproject == null) {
|
||||
cproject = create(resource.getProject());
|
||||
}
|
||||
int type = resource.getType();
|
||||
switch (type) {
|
||||
case IResource.PROJECT :
|
||||
|
@ -200,7 +195,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
case IResource.FOLDER :
|
||||
return create((IFolder)resource, cproject);
|
||||
case IResource.ROOT :
|
||||
return create((IWorkspaceRoot)resource);
|
||||
return getCModel((IWorkspaceRoot)resource);
|
||||
default :
|
||||
return null;
|
||||
}
|
||||
|
@ -213,10 +208,6 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
return cModel.getCProject(project);
|
||||
}
|
||||
|
||||
public ICModel create(IWorkspaceRoot root) {
|
||||
return getCModel();
|
||||
}
|
||||
|
||||
public ICContainer create(IFolder folder, ICProject cproject) {
|
||||
if (folder == null) {
|
||||
return null;
|
||||
|
@ -227,7 +218,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
ICContainer celement = null;
|
||||
IPath resourcePath = folder.getFullPath();
|
||||
try {
|
||||
ISourceRoot[] roots = cproject.getSourceRoots();
|
||||
ISourceRoot[] roots = cproject.getAllSourceRoots();
|
||||
for (int i = 0; i < roots.length; ++i) {
|
||||
ISourceRoot root = roots[i];
|
||||
IPath rootPath = root.getPath();
|
||||
|
@ -239,21 +230,9 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
String[] segments = path.segments();
|
||||
ICContainer cfolder = root;
|
||||
for (int j = 0; j < segments.length; j++) {
|
||||
IResource res = cfolder.getResource();
|
||||
if (res instanceof IContainer) {
|
||||
IContainer container = (IContainer)res;
|
||||
res = container.findMember(new Path(segments[j]));
|
||||
if (res instanceof IFolder) {
|
||||
cfolder = cfolder.getCContainer(segments[j]);
|
||||
} else {
|
||||
cfolder = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cfolder != null) {
|
||||
celement = cfolder;
|
||||
cfolder = cfolder.getCContainer(segments[j]);
|
||||
}
|
||||
celement = cfolder;
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
|
@ -271,43 +250,36 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
}
|
||||
ICElement celement = null;
|
||||
try {
|
||||
ISourceRoot[] roots = cproject.getSourceRoots();
|
||||
ISourceRoot[] roots = cproject.getAllSourceRoots();
|
||||
for (int i = 0; i < roots.length; ++i) {
|
||||
ISourceRoot root = roots[i];
|
||||
IPath rootPath = root.getPath();
|
||||
if (root.isOnSourceEntry(file)) {
|
||||
IPath resourcePath = file.getFullPath();
|
||||
IPath path = resourcePath.removeFirstSegments(rootPath.segmentCount());
|
||||
String fileName = path.lastSegment();
|
||||
path = path.removeLastSegments(1);
|
||||
String[] segments = path.segments();
|
||||
ICContainer cfolder = root;
|
||||
for (int j = 0; j < segments.length; j++) {
|
||||
IResource res = cfolder.getResource();
|
||||
if (res instanceof IContainer) {
|
||||
IContainer container = (IContainer)res;
|
||||
res = container.findMember(new Path(segments[j]));
|
||||
if (res instanceof IFolder) {
|
||||
cfolder = cfolder.getCContainer(segments[j]);
|
||||
} else if (res instanceof IFile) {
|
||||
IFile f = (IFile)res;
|
||||
if (isTranslationUnit(f)) {
|
||||
celement = new TranslationUnit(cfolder, f);
|
||||
} else if (cproject.isOnOutputEntry(f)) {
|
||||
IBinaryFile bin = createBinaryFile(f);
|
||||
if (bin != null) {
|
||||
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
||||
celement = new Archive(cfolder, f, (IBinaryArchive)bin);
|
||||
ArchiveContainer vlib = (ArchiveContainer)cproject.getArchiveContainer();
|
||||
vlib.addChild(celement);
|
||||
} else {
|
||||
celement = new Binary(cfolder, f, (IBinaryObject)bin);
|
||||
if (bin.getType() == IBinaryFile.EXECUTABLE || bin.getType() == IBinaryFile.SHARED) {
|
||||
BinaryContainer vbin = (BinaryContainer)cproject.getBinaryContainer();
|
||||
vbin.addChild(celement);
|
||||
}
|
||||
}
|
||||
}
|
||||
cfolder = cfolder.getCContainer(segments[j]);
|
||||
}
|
||||
|
||||
if (isValidTranslationUnitName(fileName)) {
|
||||
celement = cfolder.getTranslationUnit(fileName);
|
||||
} else if (cproject.isOnOutputEntry(file)) {
|
||||
IBinaryFile bin = createBinaryFile(file);
|
||||
if (bin != null) {
|
||||
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
||||
celement = new Archive(cfolder, file, (IBinaryArchive)bin);
|
||||
ArchiveContainer vlib = (ArchiveContainer)cproject.getArchiveContainer();
|
||||
vlib.addChild(celement);
|
||||
} else {
|
||||
celement = new Binary(cfolder, file, (IBinaryObject)bin);
|
||||
if (bin.getType() == IBinaryFile.EXECUTABLE || bin.getType() == IBinaryFile.SHARED) {
|
||||
BinaryContainer vbin = (BinaryContainer)cproject.getBinaryContainer();
|
||||
vbin.addChild(celement);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -336,45 +308,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
}
|
||||
return celement;
|
||||
}
|
||||
/*
|
||||
public synchronized ICElement create(ICElement parent, IFile file, IBinaryFile bin) {
|
||||
ICElement cfile = null;
|
||||
|
||||
if (isTranslationUnit(file)) {
|
||||
cfile = new TranslationUnit(parent, file);
|
||||
} else if (file.exists()) {
|
||||
// Try to create the binaryFile first.
|
||||
if (bin == null) {
|
||||
bin = createBinaryFile(file);
|
||||
}
|
||||
if (bin != null) {
|
||||
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
||||
cfile = new Archive(parent, file, (IBinaryArchive)bin);
|
||||
} else {
|
||||
cfile = new Binary(parent, file, bin);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Added also to the Containers
|
||||
if (cfile != null && (cfile instanceof IBinary || cfile instanceof IArchive)) {
|
||||
if (bin == null) {
|
||||
bin = createBinaryFile(file);
|
||||
}
|
||||
if (bin != null) {
|
||||
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
||||
CProject cproj = (CProject)cfile.getCProject();
|
||||
ArchiveContainer container = (ArchiveContainer)cproj.getArchiveContainer();
|
||||
container.addChild(cfile);
|
||||
} else if (bin.getType() == IBinaryFile.EXECUTABLE || bin.getType() == IBinaryFile.SHARED) {
|
||||
CProject cproj = (CProject)cfile.getCProject();
|
||||
BinaryContainer container = (BinaryContainer)cproj.getBinaryContainer();
|
||||
container.addChild(cfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
return cfile;
|
||||
}
|
||||
*/
|
||||
public void releaseCElement(ICElement celement) {
|
||||
|
||||
// Guard.
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.HashSet;
|
|||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.CCProjectNature;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.IBinaryParser;
|
||||
|
@ -40,7 +41,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
import org.eclipse.core.runtime.Preferences;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
|
||||
public class CProject extends CContainer implements ICProject {
|
||||
public class CProject extends Openable implements ICProject {
|
||||
|
||||
private static final String CUSTOM_DEFAULT_OPTION_VALUE = "#\r\n\r#custom-non-empty-default-value#\r\n\r#"; //$NON-NLS-1$
|
||||
|
||||
|
@ -87,6 +88,39 @@ public class CProject extends CContainer implements ICProject {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean hasCCNature(IProject p) {
|
||||
try {
|
||||
return p.hasNature(CCProjectNature.CC_NATURE_ID);
|
||||
} catch (CoreException e) {
|
||||
//throws exception if the project is not open.
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isCProject() {
|
||||
return hasCNature(getProject()) || hasCCNature(getProject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this handle represents the same C project
|
||||
* as the given handle. Two handles represent the same
|
||||
* project if they are identical or if they represent a project with
|
||||
* the same underlying resource and occurrence counts.
|
||||
*
|
||||
* @see CElement#equals(Object)
|
||||
*/
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (this == o)
|
||||
return true;
|
||||
|
||||
if (!(o instanceof CProject))
|
||||
return false;
|
||||
|
||||
CProject other = (CProject) o;
|
||||
return getProject().equals(other.getProject());
|
||||
}
|
||||
|
||||
protected CElementInfo createElementInfo() {
|
||||
return new CProjectInfo(this);
|
||||
}
|
||||
|
@ -255,6 +289,9 @@ public class CProject extends CContainer implements ICProject {
|
|||
* Project preferences may include custom encoding.
|
||||
*/
|
||||
private Preferences getPreferences() {
|
||||
if (!(isCProject())) {
|
||||
return null;
|
||||
}
|
||||
Preferences preferences = new Preferences();
|
||||
Iterator iter = CModelManager.OptionNames.iterator();
|
||||
|
||||
|
@ -281,6 +318,9 @@ public class CProject extends CContainer implements ICProject {
|
|||
private void savePreferences(Preferences preferences) {
|
||||
if (preferences == null)
|
||||
return;
|
||||
if (!isCProject()) {
|
||||
return; // ignore
|
||||
}
|
||||
Iterator iter = CModelManager.OptionNames.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
|
@ -305,6 +345,9 @@ public class CProject extends CContainer implements ICProject {
|
|||
* Set cached preferences, no preferences are saved, only info is updated
|
||||
*/
|
||||
private void setPreferences(Preferences preferences) {
|
||||
if (!isCProject()) {
|
||||
return; // ignore
|
||||
}
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
@ -355,9 +398,31 @@ public class CProject extends CContainer implements ICProject {
|
|||
* @see org.eclipse.cdt.core.model.ICProject#getSourceRoots()
|
||||
*/
|
||||
public ISourceRoot[] getSourceRoots() throws CModelException {
|
||||
Object[] children;
|
||||
int length;
|
||||
|
||||
children = getChildren();
|
||||
length = children.length;
|
||||
ISourceRoot[] roots = new ISourceRoot[length];
|
||||
System.arraycopy(children, 0, roots, 0, length);
|
||||
|
||||
return roots;
|
||||
|
||||
//return computeSourceRoots();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws CModelException
|
||||
*/
|
||||
public ISourceRoot[] getAllSourceRoots() throws CModelException {
|
||||
return computeSourceRoots();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public IOutputEntry[] getOutputEntries() throws CModelException {
|
||||
IPathEntry[] entries = getResolvedPathEntries();
|
||||
ArrayList list = new ArrayList(entries.length);
|
||||
|
@ -371,6 +436,9 @@ public class CProject extends CContainer implements ICProject {
|
|||
return outputs;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public boolean isOnOutputEntry(IResource resource) {
|
||||
IPath path = resource.getFullPath();
|
||||
|
||||
|
@ -394,8 +462,7 @@ public class CProject extends CContainer implements ICProject {
|
|||
}
|
||||
|
||||
private boolean isOnOutputEntry(IOutputEntry entry, IPath path) {
|
||||
if (entry.getPath().isPrefixOf(path)
|
||||
&& !Util.isExcluded(path, entry.fullExclusionPatternChars())) {
|
||||
if (entry.getPath().isPrefixOf(path) && !Util.isExcluded(path, entry.fullExclusionPatternChars())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -484,4 +551,20 @@ public class CProject extends CContainer implements ICProject {
|
|||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICElement#exists()
|
||||
*/
|
||||
public boolean exists() {
|
||||
if (!isCProject()) {
|
||||
return false;
|
||||
}
|
||||
return super.exists();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICProject#getNonCResources()
|
||||
*/
|
||||
public Object[] getNonCResources() throws CModelException {
|
||||
return ((CProjectInfo) getElementInfo()).getNonCResources(getResource());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,11 @@ import org.eclipse.core.runtime.IPath;
|
|||
* Info for ICProject.
|
||||
*/
|
||||
|
||||
class CProjectInfo extends CContainerInfo {
|
||||
class CProjectInfo extends OpenableInfo {
|
||||
|
||||
BinaryContainer vBin;
|
||||
ArchiveContainer vLib;
|
||||
Object[] nonCResources = null;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -54,7 +55,8 @@ class CProjectInfo extends CContainerInfo {
|
|||
if (nonCResources != null)
|
||||
return nonCResources;
|
||||
|
||||
// determine if src == project and/or if bin == project
|
||||
CProject cproject = (CProject)getElement();
|
||||
// determine if src == project
|
||||
IPath projectPath = res.getProject().getFullPath();
|
||||
ISourceRoot root = null;
|
||||
ICElement[] elements = getChildren();
|
||||
|
@ -108,4 +110,11 @@ class CProjectInfo extends CContainerInfo {
|
|||
return nonCResources;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param container
|
||||
* @return
|
||||
*/
|
||||
public void setNonCResources(Object[] resources) {
|
||||
nonCResources = resources;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.eclipse.cdt.core.model.CModelException;
|
|||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||
import org.eclipse.cdt.core.model.IBinaryContainer;
|
||||
import org.eclipse.cdt.core.model.ICContainer;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||
import org.eclipse.cdt.core.model.ICModel;
|
||||
|
@ -18,7 +17,6 @@ import org.eclipse.cdt.core.model.IParent;
|
|||
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceDelta;
|
||||
|
@ -70,7 +68,7 @@ public class DeltaProcessor {
|
|||
ICProject cpj = manager.create((IProject)resParent);
|
||||
if (cpj != null) {
|
||||
try {
|
||||
ISourceRoot[] roots = cpj.getSourceRoots();
|
||||
ISourceRoot[] roots = cpj.getAllSourceRoots();
|
||||
for (int i = 0; i < roots.length; i++) {
|
||||
if (roots[i].isOnSourceEntry(resource)) {
|
||||
parent = roots[i];
|
||||
|
@ -139,22 +137,6 @@ public class DeltaProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
// return an handler
|
||||
if (celement == null) {
|
||||
IResource resParent = resource.getParent();
|
||||
ICElement parent = manager.create(resParent, null);
|
||||
if (parent instanceof ICContainer) {
|
||||
String name = resource.getName();
|
||||
if (resource instanceof IFile) {
|
||||
if (manager.isValidTranslationUnitName(name)) {
|
||||
celement = ((ICContainer)parent).getTranslationUnit(name);
|
||||
}
|
||||
} else if (resource instanceof IFolder) {
|
||||
celement = ((ICContainer)parent).getCContainer(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return celement;
|
||||
}
|
||||
|
||||
|
@ -440,13 +422,18 @@ public class DeltaProcessor {
|
|||
} else {
|
||||
elementDelta.addResourceDelta(delta);
|
||||
}
|
||||
if (parent instanceof CContainer) {
|
||||
// if info not created yet no need to null NonCResources...
|
||||
if (CModelManager.getDefault().peekAtInfo(parent) != null) {
|
||||
CElementInfo info = ((CContainer)parent).getElementInfo();
|
||||
if (info instanceof CContainerInfo) {
|
||||
((CContainerInfo)info).setNonCResources(null);
|
||||
}
|
||||
if (parent instanceof Openable && ((Openable)parent).isOpen()) {
|
||||
CElementInfo info = ((Openable)parent).getElementInfo();
|
||||
switch (parent.getElementType()) {
|
||||
case ICElement.C_MODEL:
|
||||
((CModelInfo)info).setNonCResources(null);
|
||||
break;
|
||||
case ICElement.C_PROJECT:
|
||||
((CProjectInfo)info).setNonCResources(null);
|
||||
break;
|
||||
case ICElement.C_CCONTAINER:
|
||||
((CContainerInfo)info).setNonCResources(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue