1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-30 04:15:35 +02:00

2005-07-22 Chris Wiebe

Fix for PR 104725
	* model/org/eclipse/cdt/internal/core/model/BinaryElement.java
This commit is contained in:
Chris Wiebe 2005-07-21 20:42:55 +00:00
parent 4bcf2bce38
commit 459ee19699
2 changed files with 36 additions and 28 deletions

View file

@ -1,3 +1,7 @@
2005-07-22 Chris Wiebe
Fix for PR 104725
* model/org/eclipse/cdt/internal/core/model/BinaryElement.java
2005-07-16 Alain Magloire 2005-07-16 Alain Magloire
Fix for PR 102327: Fire deltas when contentType is changed. Fix for PR 102327: Fire deltas when contentType is changed.
* model/org/eclipse/cdt/core/model/ICElementDelta.java * model/org/eclipse/cdt/core/model/ICElementDelta.java

View file

@ -31,6 +31,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
IAddress addr; IAddress addr;
int fStartLine; int fStartLine;
int fEndLine; int fEndLine;
ITranslationUnit fSourceTU;
public BinaryElement(ICElement parent, String name, int type, IAddress a) { public BinaryElement(ICElement parent, String name, int type, IAddress a) {
super(parent, name, type); super(parent, name, type);
@ -103,40 +104,43 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
* @see org.eclipse.cdt.core.model.ISourceReference#getTranslationUnit() * @see org.eclipse.cdt.core.model.ISourceReference#getTranslationUnit()
*/ */
public ITranslationUnit getTranslationUnit() { public ITranslationUnit getTranslationUnit() {
ITranslationUnit tu = null; if (fSourceTU == null) {
CModelManager mgr = CModelManager.getDefault(); ITranslationUnit tu = null;
ICElement parent = getParent(); CModelManager mgr = CModelManager.getDefault();
if (parent != null) { ICElement parent = getParent();
IPath path = parent.getPath(); if (parent != null) {
if (path != null && path.isAbsolute()) { IPath path = parent.getPath();
IResource res = mgr.getCModel().getWorkspace().getRoot().getFileForLocation(path); if (path != null && path.isAbsolute()) {
if (res != null && res.exists() && res.getType() == IResource.FILE) { IResource res = mgr.getCModel().getWorkspace().getRoot().getFileForLocation(path);
ICElement e = CModelManager.getDefault().create(res, null); if (res != null && res.exists() && res.getType() == IResource.FILE) {
if (e instanceof ITranslationUnit) { ICElement e = CModelManager.getDefault().create(res, null);
tu = (ITranslationUnit)e; if (e instanceof ITranslationUnit) {
tu = (ITranslationUnit)e;
}
} }
// do not give up yet in C++ the methods may be inline in the headers
ICProject cproject = getCProject();
tu = mgr.createTranslationUnitFrom(cproject, path);
} else {
// TODO-model: handle non-absolute paths when finding source files
// ??? assert()
path = new Path(""); //$NON-NLS-1$
} }
// do not give up yet in C++ the methods may be inline in the headers // Fall back to the project sourcemapper.
ICProject cproject = getCProject(); if (tu == null) {
tu = mgr.createTranslationUnitFrom(cproject, path); ICProject cproject = getCProject();
} else { SourceMapper mapper = mgr.getSourceMapper(cproject);
// TODO-model: handle non-absolute paths when finding source files if (mapper != null) {
// ??? assert() String lastSegment = path.lastSegment();
path = new Path(""); //$NON-NLS-1$ if (lastSegment != null) {
} tu = mapper.findTranslationUnit(lastSegment);
// Fall back to the project sourcemapper. }
if (tu == null) {
ICProject cproject = getCProject();
SourceMapper mapper = mgr.getSourceMapper(cproject);
if (mapper != null) {
String lastSegment = path.lastSegment();
if (lastSegment != null) {
tu = mapper.findTranslationUnit(lastSegment);
} }
} }
} }
fSourceTU = tu;
} }
return tu; return fSourceTU;
} }
/* (non-Javadoc) /* (non-Javadoc)