mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
New class hierarchy for the binary and Archive:
IBinary IBinaryModule IBinaryFunction IBinaryVariable IBinaryElement
This commit is contained in:
parent
5c6b6cf09d
commit
aaad8cbc6b
13 changed files with 533 additions and 344 deletions
|
@ -62,14 +62,7 @@ public class Archive extends Openable implements IArchive {
|
||||||
IBinaryObject[] objects = ar.getObjects();
|
IBinaryObject[] objects = ar.getObjects();
|
||||||
for (int i = 0; i < objects.length; i++) {
|
for (int i = 0; i < objects.length; i++) {
|
||||||
final IBinaryObject obj = objects[i];
|
final IBinaryObject obj = objects[i];
|
||||||
Binary binary = new Binary(this, res.getLocation().append(obj.getName())) {
|
Binary binary = new Binary(this, res.getLocation().append(obj.getName()), obj);
|
||||||
protected IBinaryObject getBinaryObject(IResource res) {
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Force the loading of the children inf the Info by callin getElementInfo.
|
|
||||||
binary.getElementInfo();
|
|
||||||
info.addChild(binary);
|
info.addChild(binary);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -5,20 +5,18 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.IBinaryParser;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||||
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryShared;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.ISymbol;
|
import org.eclipse.cdt.core.IBinaryParser.ISymbol;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -26,67 +24,101 @@ import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
public class Binary extends Openable implements IBinary {
|
public class Binary extends Openable implements IBinary {
|
||||||
|
|
||||||
public Binary(ICElement parent, IFile file) {
|
IBinaryFile binaryFile;
|
||||||
this(parent, file.getLocation());
|
|
||||||
|
public Binary(ICElement parent, IFile file, IBinaryFile bin) {
|
||||||
|
super(parent, file, ICElement.C_BINARY);
|
||||||
|
binaryFile = bin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Binary(ICElement parent, IPath path) {
|
public Binary(ICElement parent, IPath path, IBinaryFile bin) {
|
||||||
super (parent, path, ICElement.C_BINARY);
|
super (parent, path, ICElement.C_BINARY);
|
||||||
|
binaryFile = bin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Binary(ICElement parent, IFile file, String name) {
|
|
||||||
super(parent, file, name, ICElement.C_BINARY);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasDebug () {
|
public boolean isSharedLib() {
|
||||||
return ((BinaryInfo)getElementInfo()).hasDebug();
|
if (binaryFile != null) {
|
||||||
|
return binaryFile.getType() == IBinaryObject.SHARED;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExecutable() {
|
public boolean isExecutable() {
|
||||||
return ((BinaryInfo)getElementInfo()).isExecutable();
|
if (binaryFile != null) {
|
||||||
|
return binaryFile.getType() == IBinaryObject.EXECUTABLE;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isObject() {
|
public boolean isObject() {
|
||||||
return ((BinaryInfo)getElementInfo()).isObject();
|
if (binaryFile != null) {
|
||||||
}
|
return binaryFile.getType() == IBinaryObject.OBJECT;
|
||||||
|
}
|
||||||
public boolean isSharedLib() {
|
return false;
|
||||||
return ((BinaryInfo)getElementInfo()).isSharedLib();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCore() {
|
public boolean isCore() {
|
||||||
return ((BinaryInfo)getElementInfo()).isCore();
|
if (binaryFile != null) {
|
||||||
|
return binaryFile.getType() == IBinaryObject.CORE;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String [] getNeededSharedLibs() {
|
public boolean hasDebug() {
|
||||||
return ((BinaryInfo)getElementInfo()).getNeededSharedLibs();
|
if (isObject() || isExecutable() || isSharedLib()) {
|
||||||
|
return ((IBinaryObject)binaryFile).hasDebug();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCPU() {
|
public String getCPU() {
|
||||||
return ((BinaryInfo)getElementInfo()).getCPU();
|
if (isObject() || isExecutable() || isSharedLib() || isCore()) {
|
||||||
|
return ((IBinaryObject)binaryFile).getCPU();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getNeededSharedLibs() {
|
||||||
|
if (isExecutable()) {
|
||||||
|
return ((IBinaryExecutable)binaryFile).getNeededSharedLibs();
|
||||||
|
}
|
||||||
|
return new String[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getText() {
|
public long getText() {
|
||||||
return ((BinaryInfo)getElementInfo()).getText();
|
if (isObject() || isExecutable() || isSharedLib()) {
|
||||||
|
return ((IBinaryObject)binaryFile).getText();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getData() {
|
public long getData() {
|
||||||
return ((BinaryInfo)getElementInfo()).getData();
|
if (isObject() || isExecutable() || isSharedLib()) {
|
||||||
|
return ((IBinaryObject)binaryFile).getData();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getBSS() {
|
public long getBSS() {
|
||||||
return ((BinaryInfo)getElementInfo()).getBSS();
|
if (isObject() || isExecutable() || isSharedLib()) {
|
||||||
|
return ((IBinaryObject)binaryFile).getBSS();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSoname() {
|
public String getSoname() {
|
||||||
return ((BinaryInfo)getElementInfo()).getSoname();
|
if (isSharedLib()) {
|
||||||
|
return ((IBinaryShared)binaryFile).getSoName();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.core.model.IBinary#isLittleEndian()
|
|
||||||
*/
|
|
||||||
public boolean isLittleEndian() {
|
public boolean isLittleEndian() {
|
||||||
return ((BinaryInfo)getElementInfo()).isLittleEndian();
|
if (isObject() || isExecutable() || isSharedLib() || isCore()) {
|
||||||
|
return ((IBinaryObject)binaryFile).isLittleEndian();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CElementInfo createElementInfo() {
|
public CElementInfo createElementInfo() {
|
||||||
|
@ -104,10 +136,9 @@ public class Binary extends Openable implements IBinary {
|
||||||
|
|
||||||
|
|
||||||
boolean computeChildren(OpenableInfo info, IResource res) {
|
boolean computeChildren(OpenableInfo info, IResource res) {
|
||||||
IBinaryObject bin = getBinaryObject(res);
|
if (isObject() || isExecutable() || isSharedLib()) {
|
||||||
if (bin != null) {
|
|
||||||
Map hash = new HashMap();
|
Map hash = new HashMap();
|
||||||
ISymbol[] symbols = bin.getSymbols();
|
ISymbol[] symbols = ((IBinaryObject)binaryFile).getSymbols();
|
||||||
for (int i = 0; i < symbols.length; i++) {
|
for (int i = 0; i < symbols.length; i++) {
|
||||||
switch (symbols[i].getType()) {
|
switch (symbols[i].getType()) {
|
||||||
case ISymbol.FUNCTION :
|
case ISymbol.FUNCTION :
|
||||||
|
@ -119,74 +150,37 @@ public class Binary extends Openable implements IBinary {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (info instanceof BinaryInfo) {
|
|
||||||
((BinaryInfo)info).loadInfo(bin);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IBinaryObject getBinaryObject(IResource res) {
|
|
||||||
IBinaryObject binary = null;
|
|
||||||
IBinaryParser parser = null;
|
|
||||||
IProject project = null;
|
|
||||||
if (res != null) {
|
|
||||||
project = res.getProject();
|
|
||||||
}
|
|
||||||
if (project != null) {
|
|
||||||
parser = CModelManager.getDefault().getBinaryParser(project);
|
|
||||||
}
|
|
||||||
if (parser != null) {
|
|
||||||
try {
|
|
||||||
IPath path = res.getLocation();
|
|
||||||
IBinaryFile bfile = parser.getBinary(path);
|
|
||||||
if (bfile instanceof IBinaryObject) {
|
|
||||||
binary = (IBinaryObject) bfile;
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return binary;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addFunction(OpenableInfo info, ISymbol symbol, Map hash) {
|
private void addFunction(OpenableInfo info, ISymbol symbol, Map hash) {
|
||||||
ICElement parent = this;
|
|
||||||
String filename = filename = symbol.getFilename();
|
String filename = filename = symbol.getFilename();
|
||||||
Function function = null;
|
BinaryFunction function = null;
|
||||||
|
|
||||||
// Addr2line returns the funny "??" when it can find the file.
|
// Addr2line returns the funny "??" when it can find the file.
|
||||||
if (filename != null && !filename.equals("??")) {
|
if (filename != null && !filename.equals("??")) {
|
||||||
TranslationUnit tu = null;
|
BinaryModule module = null;
|
||||||
IPath path = new Path(filename);
|
IPath path = new Path(filename);
|
||||||
if (hash.containsKey(path)) {
|
if (hash.containsKey(path)) {
|
||||||
tu = (TranslationUnit) hash.get(path);
|
module = (BinaryModule)hash.get(path);
|
||||||
} else {
|
} else {
|
||||||
// A special ITranslationUnit we do not want the file to be parse.
|
// A special container we do not want the file to be parse.
|
||||||
tu = new TranslationUnit(parent, path) {
|
module = new BinaryModule(this, path);
|
||||||
ArrayList array = new ArrayList(5);
|
hash.put(path, module);
|
||||||
public void addChild(ICElement e) {
|
info.addChild(module);
|
||||||
array.add(e);
|
|
||||||
array.trimToSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICElement [] getChildren() {
|
|
||||||
return (ICElement[])array.toArray(new ICElement[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean generateInfos(OpenableInfo info, IProgressMonitor pm,
|
|
||||||
Map newElements, IResource underlyingResource) throws CModelException {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
hash.put(path, tu);
|
|
||||||
info.addChild(tu);
|
|
||||||
}
|
}
|
||||||
function = new Function(tu, symbol.getName());
|
function = new BinaryFunction(module, symbol.getName());
|
||||||
tu.addChild(function);
|
function.setLines(symbol.getStartLine(), symbol.getEndLine());
|
||||||
|
function.setAddress(symbol.getAdress());
|
||||||
|
module.addChild(function);
|
||||||
} else {
|
} else {
|
||||||
function = new Function(parent, symbol.getName());
|
//function = new Function(parent, symbol.getName());
|
||||||
|
function = new BinaryFunction(this, symbol.getName());
|
||||||
|
function.setLines(symbol.getStartLine(), symbol.getEndLine());
|
||||||
|
function.setAddress(symbol.getAdress());
|
||||||
info.addChild(function);
|
info.addChild(function);
|
||||||
}
|
}
|
||||||
// if (function != null) {
|
// if (function != null) {
|
||||||
|
@ -198,40 +192,29 @@ public class Binary extends Openable implements IBinary {
|
||||||
|
|
||||||
private void addVariable(OpenableInfo info, ISymbol symbol, Map hash) {
|
private void addVariable(OpenableInfo info, ISymbol symbol, Map hash) {
|
||||||
String filename = filename = symbol.getFilename();
|
String filename = filename = symbol.getFilename();
|
||||||
ICElement parent = this;
|
BinaryVariable variable = null;
|
||||||
Variable variable = null;
|
|
||||||
// Addr2line returns the funny "??" when it can not find the file.
|
// Addr2line returns the funny "??" when it can not find the file.
|
||||||
if (filename != null && !filename.equals("??")) {
|
if (filename != null && !filename.equals("??")) {
|
||||||
TranslationUnit tu = null;
|
BinaryModule module = null;
|
||||||
IPath path = new Path(filename);
|
IPath path = new Path(filename);
|
||||||
if (hash.containsKey(path)) {
|
if (hash.containsKey(path)) {
|
||||||
tu = (TranslationUnit) hash.get(path);
|
module = (BinaryModule)hash.get(path);
|
||||||
} else {
|
} else {
|
||||||
tu = new TranslationUnit(parent, path) {
|
module = new BinaryModule(this, path);
|
||||||
ArrayList array = new ArrayList(5);
|
hash.put(path, module);
|
||||||
public void addChild(ICElement e) {
|
info.addChild(module);
|
||||||
array.add(e);
|
|
||||||
array.trimToSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICElement [] getChildren() {
|
|
||||||
return (ICElement[])array.toArray(new ICElement[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean generateInfos(OpenableInfo info, IProgressMonitor pm,
|
|
||||||
Map newElements, IResource underlyingResource) throws CModelException {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
hash.put(path, tu);
|
|
||||||
info.addChild(tu);
|
|
||||||
}
|
}
|
||||||
variable = new Variable(tu, symbol.getName());
|
variable = new BinaryVariable(module, symbol.getName());
|
||||||
tu.addChild(variable);
|
variable.setLines(symbol.getStartLine(), symbol.getEndLine());
|
||||||
|
variable.setAddress(symbol.getAdress());
|
||||||
|
module.addChild(variable);
|
||||||
} else {
|
} else {
|
||||||
variable = new Variable(parent, symbol.getName());
|
variable = new BinaryVariable(this, symbol.getName());
|
||||||
|
variable.setLines(symbol.getStartLine(), symbol.getEndLine());
|
||||||
|
variable.setAddress(symbol.getAdress());
|
||||||
info.addChild(variable);
|
info.addChild(variable);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (variable != null) {
|
//if (variable != null) {
|
||||||
// if (!external) {
|
// if (!external) {
|
||||||
// variable.getVariableInfo().setAccessControl(IConstants.AccStatic);
|
// variable.getVariableInfo().setAccessControl(IConstants.AccStatic);
|
||||||
|
|
|
@ -0,0 +1,140 @@
|
||||||
|
/*
|
||||||
|
* Created on Mar 30, 2003
|
||||||
|
*
|
||||||
|
* To change the template for this generated file go to
|
||||||
|
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
|
import org.eclipse.cdt.core.model.IBinaryElement;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.ICModelStatusConstants;
|
||||||
|
import org.eclipse.cdt.core.model.ISourceManipulation;
|
||||||
|
import org.eclipse.cdt.core.model.ISourceRange;
|
||||||
|
import org.eclipse.cdt.core.model.ISourceReference;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author alain
|
||||||
|
*
|
||||||
|
* To change the template for this generated type comment go to
|
||||||
|
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||||
|
*/
|
||||||
|
public class BinaryElement extends CElement implements IBinaryElement, ISourceManipulation, ISourceReference {
|
||||||
|
|
||||||
|
long addr;
|
||||||
|
|
||||||
|
public BinaryElement(ICElement parent, String name, int type) {
|
||||||
|
super(parent, name, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(long a) {
|
||||||
|
addr = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.ISourceManipulation#copy(org.eclipse.cdt.core.model.ICElement, org.eclipse.cdt.core.model.ICElement, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
|
*/
|
||||||
|
public void copy(
|
||||||
|
ICElement container,
|
||||||
|
ICElement sibling,
|
||||||
|
String rename,
|
||||||
|
boolean replace,
|
||||||
|
IProgressMonitor monitor)
|
||||||
|
throws CModelException {
|
||||||
|
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.ISourceManipulation#delete(boolean, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
|
*/
|
||||||
|
public void delete(boolean force, IProgressMonitor monitor)
|
||||||
|
throws CModelException {
|
||||||
|
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.ISourceManipulation#move(org.eclipse.cdt.core.model.ICElement, org.eclipse.cdt.core.model.ICElement, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
|
*/
|
||||||
|
public void move(
|
||||||
|
ICElement container,
|
||||||
|
ICElement sibling,
|
||||||
|
String rename,
|
||||||
|
boolean replace,
|
||||||
|
IProgressMonitor monitor)
|
||||||
|
throws CModelException {
|
||||||
|
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.ISourceManipulation#rename(java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
|
*/
|
||||||
|
public void rename(String name, boolean replace, IProgressMonitor monitor)
|
||||||
|
throws CModelException {
|
||||||
|
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.ISourceReference#getSource()
|
||||||
|
*/
|
||||||
|
public String getSource() throws CModelException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.ISourceReference#getSourceRange()
|
||||||
|
*/
|
||||||
|
public ISourceRange getSourceRange() throws CModelException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.ISourceReference#getTranslationUnit()
|
||||||
|
*/
|
||||||
|
public ITranslationUnit getTranslationUnit() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.model.CElement#createElementInfo()
|
||||||
|
*/
|
||||||
|
protected CElementInfo createElementInfo() {
|
||||||
|
return new CElementInfo(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.ICElement#getResource()
|
||||||
|
*/
|
||||||
|
public IResource getResource() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IBinaryElement#getAddress()
|
||||||
|
*/
|
||||||
|
public long getAddress() throws CModelException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IBinaryElement#getBinary()
|
||||||
|
*/
|
||||||
|
public IBinary getBinary() {
|
||||||
|
ICElement current = this;
|
||||||
|
do {
|
||||||
|
if (current instanceof IBinary) {
|
||||||
|
return (IBinary) current;
|
||||||
|
}
|
||||||
|
} while ((current = current.getParent()) != null);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
/*
|
||||||
|
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.IFunction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author alain
|
||||||
|
*
|
||||||
|
* To change the template for this generated type comment go to
|
||||||
|
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||||
|
*/
|
||||||
|
public class BinaryFunction extends BinaryElement implements IFunction {
|
||||||
|
|
||||||
|
public BinaryFunction(ICElement parent, String name) {
|
||||||
|
super(parent, name, ICElement.C_FUNCTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getExceptions()
|
||||||
|
*/
|
||||||
|
public String[] getExceptions() {
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getNumberOfParameters()
|
||||||
|
*/
|
||||||
|
public int getNumberOfParameters() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getParameterInitializer(int)
|
||||||
|
*/
|
||||||
|
public String getParameterInitializer(int pos) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return new String();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getParameterTypes()
|
||||||
|
*/
|
||||||
|
public String[] getParameterTypes() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getReturnType()
|
||||||
|
*/
|
||||||
|
public String getReturnType() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return new String();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getSignature()
|
||||||
|
*/
|
||||||
|
public String getSignature() {
|
||||||
|
return getElementName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IDeclaration#isStatic()
|
||||||
|
*/
|
||||||
|
public boolean isStatic() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IDeclaration#isConst()
|
||||||
|
*/
|
||||||
|
public boolean isConst() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IDeclaration#isVolatile()
|
||||||
|
*/
|
||||||
|
public boolean isVolatile() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IDeclaration#getAccessControl()
|
||||||
|
*/
|
||||||
|
public int getAccessControl() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,121 +5,11 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.IBinaryParser;
|
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
|
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryShared;
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
|
|
||||||
class BinaryInfo extends OpenableInfo {
|
class BinaryInfo extends OpenableInfo {
|
||||||
|
|
||||||
int type;
|
|
||||||
boolean debug;
|
|
||||||
String cpu = "";
|
|
||||||
String shared[] = new String[0];
|
|
||||||
long text;
|
|
||||||
long data;
|
|
||||||
long bss;
|
|
||||||
String soname = "";
|
|
||||||
boolean littleE;
|
|
||||||
|
|
||||||
public BinaryInfo(CElement element) {
|
public BinaryInfo(CElement element) {
|
||||||
super(element);
|
super(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCPU() {
|
|
||||||
return cpu;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSharedLib() {
|
|
||||||
return type == IBinaryObject.SHARED;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isExecutable() {
|
|
||||||
return type == IBinaryObject.EXECUTABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isObject() {
|
|
||||||
return type == IBinaryObject.OBJECT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCore() {
|
|
||||||
return type == IBinaryObject.CORE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasDebug() {
|
|
||||||
return debug;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getNeededSharedLibs() {
|
|
||||||
return shared;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getText() {
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getBSS() {
|
|
||||||
return bss;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSoname() {
|
|
||||||
return soname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLittleEndian() {
|
|
||||||
return littleE;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void loadInfo() {
|
|
||||||
loadInfo(getBinaryObject());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void loadInfo(IBinaryObject bin) {
|
|
||||||
if (bin != null) {
|
|
||||||
type = bin.getType();
|
|
||||||
cpu = bin.getCPU();
|
|
||||||
debug = bin.hasDebug();
|
|
||||||
if (isExecutable()) {
|
|
||||||
IBinaryExecutable exec = (IBinaryExecutable) bin;
|
|
||||||
shared = exec.getNeededSharedLibs();
|
|
||||||
}
|
|
||||||
text = bin.getText();
|
|
||||||
data = bin.getData();
|
|
||||||
bss = bin.getBSS();
|
|
||||||
if (isSharedLib()) {
|
|
||||||
IBinaryShared shared = (IBinaryShared) bin;
|
|
||||||
soname = shared.getSoName();
|
|
||||||
}
|
|
||||||
littleE = bin.isLittleEndian();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private IBinaryObject getBinaryObject() {
|
|
||||||
IBinaryObject binary = null;
|
|
||||||
IProject project = getElement().getCProject().getProject();
|
|
||||||
IBinaryParser parser = CModelManager.getDefault().getBinaryParser(project);
|
|
||||||
if (parser != null) {
|
|
||||||
try {
|
|
||||||
IPath path = getElement().getUnderlyingResource().getLocation();
|
|
||||||
IBinaryFile bfile = parser.getBinary(path);
|
|
||||||
if (bfile instanceof IBinaryObject) {
|
|
||||||
binary = (IBinaryObject) bfile;
|
|
||||||
}
|
|
||||||
} catch (CModelException e) {
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return binary;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*
|
||||||
|
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
|
import org.eclipse.cdt.core.model.IBinaryElement;
|
||||||
|
import org.eclipse.cdt.core.model.IBinaryModule;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public class BinaryModule extends Parent implements IBinaryModule {
|
||||||
|
|
||||||
|
IPath path;
|
||||||
|
|
||||||
|
public BinaryModule(Binary parent, IPath p) {
|
||||||
|
super(parent, p.lastSegment(), ICElement.C_VCONTAINER);
|
||||||
|
path = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IBinaryModule#getBinaryElements()
|
||||||
|
*/
|
||||||
|
public IBinaryElement[] getBinaryElements() {
|
||||||
|
ICElement[] e = getChildren();
|
||||||
|
IBinaryElement[] b = new IBinaryElement[e.length];
|
||||||
|
System.arraycopy(e, 0, b, 0, e.length);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IBinaryElement#getAddress()
|
||||||
|
*/
|
||||||
|
public long getAddress() throws CModelException {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IBinaryElement#getBinary()
|
||||||
|
*/
|
||||||
|
public IBinary getBinary() {
|
||||||
|
return (IBinary)getParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.ICElement#getResource()
|
||||||
|
*/
|
||||||
|
public IResource getResource() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.ICElement#isReadOnly()
|
||||||
|
*/
|
||||||
|
public boolean isReadOnly() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.model.CElement#createElementInfo()
|
||||||
|
*/
|
||||||
|
protected CElementInfo createElementInfo() {
|
||||||
|
return new CElementInfo(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.ICElement#getPath()
|
||||||
|
*/
|
||||||
|
public IPath getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.IVariable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class BinaryVariable extends BinaryElement implements IVariable {
|
||||||
|
|
||||||
|
public BinaryVariable(ICElement parent, String name) {
|
||||||
|
super(parent, name, ICElement.C_VARIABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IVariable#getInitializer()
|
||||||
|
*/
|
||||||
|
public String getInitializer() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IVariableDeclaration#getTypeName()
|
||||||
|
*/
|
||||||
|
public String getTypeName() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IVariableDeclaration#setTypeName(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setTypeName(String type) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IDeclaration#isStatic()
|
||||||
|
*/
|
||||||
|
public boolean isStatic() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IDeclaration#isConst()
|
||||||
|
*/
|
||||||
|
public boolean isConst() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IDeclaration#isVolatile()
|
||||||
|
*/
|
||||||
|
public boolean isVolatile() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IDeclaration#getAccessControl()
|
||||||
|
*/
|
||||||
|
public int getAccessControl() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -138,7 +138,7 @@ public class CContainer extends Openable implements ICContainer {
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
//System.out.println (e);
|
//System.out.println (e);
|
||||||
//CPlugin.log (e);
|
//CPlugin.log (e);
|
||||||
e.printStackTrace();
|
//e.printStackTrace();
|
||||||
}
|
}
|
||||||
ICElement[] children = new ICElement[vChildren.size()];
|
ICElement[] children = new ICElement[vChildren.size()];
|
||||||
vChildren.toArray(children);
|
vChildren.toArray(children);
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class CContainerInfo extends OpenableInfo {
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
//System.out.println (e);
|
//System.out.println (e);
|
||||||
//CPlugin.log (e);
|
//CPlugin.log (e);
|
||||||
e.printStackTrace();
|
//e.printStackTrace();
|
||||||
}
|
}
|
||||||
setNonCResources(notChildren.toArray());
|
setNonCResources(notChildren.toArray());
|
||||||
return nonCResources;
|
return nonCResources;
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.model.IParent;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
|
||||||
public abstract class CElement extends PlatformObject implements ICElement {
|
public abstract class CElement extends PlatformObject implements ICElement {
|
||||||
|
@ -75,7 +76,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return new Path(getElementName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean exists() {
|
public boolean exists() {
|
||||||
|
@ -155,8 +156,16 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
||||||
fEndLine = endLine;
|
fEndLine = endLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IResource getUnderlyingResource() throws CModelException {
|
||||||
public abstract IResource getUnderlyingResource() throws CModelException;
|
IResource res = getResource();
|
||||||
|
if (res == null) {
|
||||||
|
ICElement p = getParent();
|
||||||
|
if (p != null) {
|
||||||
|
res = p.getUnderlyingResource();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract IResource getResource() ;
|
public abstract IResource getResource() ;
|
||||||
|
|
||||||
|
@ -292,8 +301,10 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
||||||
* <p>Subclasses that are not IOpenable's must override this method.
|
* <p>Subclasses that are not IOpenable's must override this method.
|
||||||
*/
|
*/
|
||||||
public IOpenable getOpenableParent() {
|
public IOpenable getOpenableParent() {
|
||||||
|
if (fParent instanceof IOpenable) {
|
||||||
return (IOpenable)fParent;
|
return (IOpenable)fParent;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
import org.eclipse.cdt.core.model.ICModel;
|
import org.eclipse.cdt.core.model.ICModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IElementChangedListener;
|
import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||||
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -210,26 +211,11 @@ public class CModelManager implements IResourceChangeListener {
|
||||||
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
||||||
cfile = new Archive(parent, file);
|
cfile = new Archive(parent, file);
|
||||||
} else {
|
} else {
|
||||||
cfile = new Binary(parent, file);
|
cfile = new Binary(parent, file, bin);
|
||||||
}
|
}
|
||||||
} else if (isTranslationUnit(file)) {
|
} else if (isTranslationUnit(file)) {
|
||||||
cfile = new TranslationUnit(parent, file);
|
cfile = new TranslationUnit(parent, file);
|
||||||
}
|
}
|
||||||
//else {
|
|
||||||
// cfile = new CFile(parent, file);
|
|
||||||
//}
|
|
||||||
} else {
|
|
||||||
// Probably it was deleted, find it
|
|
||||||
if (parent instanceof CElement) {
|
|
||||||
ICElement[] children = ((CElement)parent).getElementInfo().getChildren();
|
|
||||||
for (int i = 0; i < children.length; i++) {
|
|
||||||
IResource res = children[i].getResource();
|
|
||||||
if (res != null && res.equals(file)) {
|
|
||||||
cfile = children[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Added also to the Containers
|
// Added also to the Containers
|
||||||
if (cfile != null && (cfile instanceof IBinary || cfile instanceof IArchive)) {
|
if (cfile != null && (cfile instanceof IBinary || cfile instanceof IArchive)) {
|
||||||
|
@ -305,26 +291,6 @@ public class CModelManager implements IResourceChangeListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void releaseCElement(IResource resource) {
|
|
||||||
ICElement celement = getCElement(resource);
|
|
||||||
if (celement == null) {
|
|
||||||
if (resource.exists()) {
|
|
||||||
celement = create(resource);
|
|
||||||
} else {
|
|
||||||
// Make sure they are not in the Containers.
|
|
||||||
CProject cproj = (CProject)create(resource.getProject());
|
|
||||||
if (cproj != null) {
|
|
||||||
Parent container = (Parent)cproj.getArchiveContainer();
|
|
||||||
removeChildrenContainer(container, resource);
|
|
||||||
container = (Parent)cproj.getBinaryContainer();
|
|
||||||
removeChildrenContainer(container, resource);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
releaseCElement(celement);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void releaseCElement(ICElement celement) {
|
public void releaseCElement(ICElement celement) {
|
||||||
|
|
||||||
// Guard.
|
// Guard.
|
||||||
|
@ -349,30 +315,25 @@ public class CModelManager implements IResourceChangeListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (celement instanceof IParent) {
|
||||||
|
CElementInfo info = ((CElement)celement).getElementInfo();
|
||||||
|
if (info != null) {
|
||||||
|
ICElement[] children = info.getChildren();
|
||||||
|
for (int i = 0; i < children.length; i++) {
|
||||||
|
releaseCElement(children[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove the child from the parent list.
|
// Remove the child from the parent list.
|
||||||
Parent parent = (Parent)celement.getParent();
|
Parent parent = (Parent)celement.getParent();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
parent.removeChild(celement);
|
parent.removeChild(celement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (celement instanceof CElement) {
|
|
||||||
CElementInfo info = ((CElement)celement).getElementInfo();
|
|
||||||
ICElement[] children = info.getChildren();
|
|
||||||
for (int i = 0; i < children.length; i++) {
|
|
||||||
releaseCElement(children[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
removeInfo(celement);
|
removeInfo(celement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICElement getCElement(IResource res) {
|
|
||||||
return create(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICElement getCElement(IPath path) {
|
|
||||||
return create(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IBinaryParser getBinaryParser(IProject project) {
|
public IBinaryParser getBinaryParser(IProject project) {
|
||||||
try {
|
try {
|
||||||
return CCorePlugin.getDefault().getBinaryParser(project);
|
return CCorePlugin.getDefault().getBinaryParser(project);
|
||||||
|
@ -396,12 +357,15 @@ public class CModelManager implements IResourceChangeListener {
|
||||||
*/
|
*/
|
||||||
public void resetBinaryParser(IProject project) {
|
public void resetBinaryParser(IProject project) {
|
||||||
if (project != null) {
|
if (project != null) {
|
||||||
releaseCElement(project);
|
ICElement celement = create(project);
|
||||||
// Fired and ICElementDelta.PARSER_CHANGED
|
if (celement != null) {
|
||||||
CElementDelta delta = new CElementDelta(getCModel());
|
releaseCElement(celement);
|
||||||
delta.binaryParserChanged(create(project));
|
// Fired and ICElementDelta.PARSER_CHANGED
|
||||||
registerCModelDelta(delta);
|
CElementDelta delta = new CElementDelta(getCModel());
|
||||||
fire();
|
delta.binaryParserChanged(celement);
|
||||||
|
registerCModelDelta(delta);
|
||||||
|
fire();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
public abstract class Openable extends Parent implements IOpenable, IBufferChangedListener {
|
public abstract class Openable extends Parent implements IOpenable, IBufferChangedListener {
|
||||||
|
|
||||||
|
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),
|
||||||
|
@ -34,27 +36,15 @@ public abstract class Openable extends Parent implements IOpenable, IBufferChang
|
||||||
this (parent, resource, resource.getName(), type);
|
this (parent, resource, resource.getName(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Openable (ICElement parent, IResource resource, String name, int type) {
|
public Openable (ICElement parent, IResource res, String name, int type) {
|
||||||
super (parent, resource, name, type);
|
super (parent, name, type);
|
||||||
}
|
resource = res;
|
||||||
|
|
||||||
public IResource getUnderlyingResource() throws CModelException {
|
|
||||||
IResource res = getResource();
|
|
||||||
if (res == null) {
|
|
||||||
ICElement p = getParent();
|
|
||||||
if (p != null) {
|
|
||||||
res = p.getUnderlyingResource();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IResource getResource() {
|
public IResource getResource() {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract CElementInfo createElementInfo ();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The buffer associated with this element has changed. Registers
|
* The buffer associated with this element has changed. Registers
|
||||||
* this element as being out of synch with its buffer's contents.
|
* this element as being out of synch with its buffer's contents.
|
||||||
|
|
|
@ -7,30 +7,13 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
|
|
||||||
public abstract class Parent extends CElement implements IParent {
|
public abstract class Parent extends CElement implements IParent {
|
||||||
|
|
||||||
protected IResource resource;
|
|
||||||
|
|
||||||
public Parent (ICElement parent, IPath path, int type) {
|
|
||||||
// Check if the file is under the workspace.
|
|
||||||
this (parent, ResourcesPlugin.getWorkspace().getRoot().getFileForLocation (path),
|
|
||||||
path.lastSegment(), type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Parent (ICElement parent, String name, int type) {
|
public Parent (ICElement parent, String name, int type) {
|
||||||
this (parent, null, name, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Parent (ICElement parent, IResource resource, String name, int type) {
|
|
||||||
super (parent, name, type);
|
super (parent, name, type);
|
||||||
this.resource = resource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// members
|
// members
|
||||||
|
@ -86,24 +69,6 @@ public abstract class Parent extends CElement implements IParent {
|
||||||
return getElementInfo().hasChildren();
|
return getElementInfo().hasChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUnderlyingResource(IResource res) {
|
|
||||||
resource = res;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IResource getUnderlyingResource() throws CModelException {
|
|
||||||
if (resource == null) {
|
|
||||||
ICElement p = getParent();
|
|
||||||
if (p != null) {
|
|
||||||
return p.getUnderlyingResource();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IResource getResource() {
|
|
||||||
return resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setChanged () {
|
protected void setChanged () {
|
||||||
getElementInfo().setChanged();
|
getElementInfo().setChanged();
|
||||||
}
|
}
|
||||||
|
@ -112,5 +77,4 @@ public abstract class Parent extends CElement implements IParent {
|
||||||
return getElementInfo().hasChanged();
|
return getElementInfo().hasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract CElementInfo createElementInfo ();
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue