[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Initial framework for the binary Parser
|
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/ChangeLog,v
retrieving revision 1.33
diff -u -r1.33 ChangeLog
--- ChangeLog 15 Nov 2002 14:40:11 -0000 1.33
+++ ChangeLog 18 Nov 2002 15:35:00 -0000
@@ -1,3 +1,49 @@
+2002-11-16 Alain Magloire
+
+ * src/.../model/IBinaryParser.java: New Interface for Binary parsers
+ extension-points.
+ * src/.../model/ICElement.java (getResource): New method added.
+ * src/.../internal/core/model/parser/BinaryContainerAdapter.java:
+ New file adapting an archive to a IContainer.
+ * src/.../internal/core/model/parser/BinaryFiledapter.java:
+ New file adapting a binary to a IFile.
+ * src/.../internal/core/model/parser/ElfBinaryArchive.java:
+ New file implements IBinaryArchive.
+ * src/.../internal/core/model/parser/ElfBinaryFile.java:
+ New file implements IBinaryObject etc ...
+ * src/.../internal/core/model/parser/ElfBinaryFile.java:
+ New file implements IBinaryParser.
+ * src/.../internal/core/model/Archive.java (isArchive): Removed.
+ (getResource): Added.
+ * src/.../internal/core/model/ArchiveContainer.java (getChildren):
+ Use new method CProject.setBinaryRunner().
+ * src/.../internal/core/model/ArchiveInfo.java:
+ rewritten to use IBinarParser interface.
+ * src/.../internal/core/model/BinaryContainer.java (getChildren):
+ Use new method CProject.setBinaryRunner().
+ * src/.../internal/core/model/BinaryInfo.java:
+ rewritten to use IBinarParser interface.
+ * src/.../internal/core/model/BinaryRunner.java: New File
+ replace the ElfRunner.java.
+ * src/.../internal/core/model/CProject.java: Rename the function
+ with *Elf* Binary.
+ * src/.../internal/core/model/ElfRunner.java: Rename to BinaryRunner.java
+ * src/.../internal/core/model/CElement.java: Use getResource() instead of
+ getCorrespondingResource().
+ * src/.../internal/core/model/CModelManager.java (ReleaseCElement):
+ Bug fix was not passing the key to hash.remove().
+ (isShared): Use IBinaryParser.
+ (isExecutable): Use IBinaryParser.
+ (isArchive): Use IBinaryParser.
+ * src/.../internal/core/model/Container.java: New file
+ * src/.../internal/core/model/Resource.java: New file
+ * src/.../internal/core/model/Marker.java: New file
+ * src/.../internal/core/model/SourceManipulation.java (getResource): New method.
+ * src/.../internal/core/model/Parent.java (getResource): New method.
+ * plugin.xml: Indentation.
+
+
+
2002-11-13 Alain Magloire
* src/.../internal/errorparsers/GCCErrorParser.java (processLine):
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/plugin.xml,v
retrieving revision 1.12
diff -u -r1.12 plugin.xml
--- plugin.xml 4 Nov 2002 19:28:32 -0000 1.12
+++ plugin.xml 18 Nov 2002 15:35:00 -0000
@@ -11,6 +11,7 @@
<export name="*"/>
</library>
</runtime>
+
<!-- ======================================================================= -->
<!-- The C Plugin -->
<!-- ======================================================================= -->
@@ -103,57 +104,23 @@
class="org.eclipse.cdt.internal.core.make.MakeBuilder">
</run>
</extension>
-<!-- Some well known C file extensions -->
- <extension
- point="org.eclipse.team.core.fileTypes">
- <fileTypes
- type="text"
- extension="c">
- </fileTypes>
- <fileTypes
- type="text"
- extension="cc">
- </fileTypes>
- <fileTypes
- type="text"
- extension="cpp">
- </fileTypes>
- <fileTypes
- type="text"
- extension="cxx">
- </fileTypes>
- <fileTypes
- type="text"
- extension="h">
- </fileTypes>
- <fileTypes
- type="text"
- extension="hh">
- </fileTypes>
- <fileTypes
- type="binary"
- extension="o">
- </fileTypes>
- <fileTypes
- type="binary"
- extension="a">
- </fileTypes>
- <fileTypes
- type="binary"
- extension="so">
- </fileTypes>
- <fileTypes
- type="binary"
- extension="dll">
- </fileTypes>
- <fileTypes
- type="binary"
- extension="exe">
- </fileTypes>
- <fileTypes
- type="binary"
- extension="com">
- </fileTypes>
+
+<!-- ================================================== -->
+<!-- Some well known C file extensions -->
+<!-- ================================================== -->
+ <extension point="org.eclipse.team.core.fileTypes">
+ <fileTypes extension="c" type="text"/>
+ <fileTypes extension="cc" type="text"/>
+ <fileTypes extension="cpp" type="text"/>
+ <fileTypes extension="cxx" type="text"/>
+ <fileTypes extension="h" type="text"/>
+ <fileTypes extension="hh" type="text"/>
+ <fileTypes extension="o" type="binary"/>
+ <fileTypes extension="a" type="binary"/>
+ <fileTypes extension="so" type="binary"/>
+ <fileTypes extension="dll" type="binary"/>
+ <fileTypes extension="exe" type="binary"/>
+ <fileTypes extension="com" type="binary"/>
</extension>
</plugin>
Index: model/org/eclipse/cdt/core/model/IBinaryParser.java
===================================================================
RCS file: model/org/eclipse/cdt/core/model/IBinaryParser.java
diff -N model/org/eclipse/cdt/core/model/IBinaryParser.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ model/org/eclipse/cdt/core/model/IBinaryParser.java 18 Nov 2002 15:35:09 -0000
@@ -0,0 +1,87 @@
+package org.eclipse.cdt.core.model;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ */
+public interface IBinaryParser {
+
+ /**
+ * Represents a binary file for example an ELF executable.
+ */
+ public interface IBinaryFile extends IAdaptable {
+ public int OBJECT = 0x1;
+ public int EXECUTABLE = 0x02;
+ public int SHARED = 0x04;
+ public int ARCHIVE = 0x08;
+
+ public IFile getFile();
+ public int getType();
+ public InputStream getContents();
+ }
+
+ /**
+ * Represents an archive.
+ */
+ public interface IBinaryArchive extends IBinaryFile {
+ public IBinaryObject[] getObjects();
+ }
+
+ /**
+ * Represents a binary, for example an ELF excutable.
+ */
+ public interface IBinaryObject extends IBinaryFile {
+
+ public boolean hasDebug();
+
+ public String getCPU();
+
+ public long getText();
+
+ public long getData();
+
+ public long getBSS();
+
+ public boolean isLittleEndian();
+
+ public ISymbol[] getSymbols();
+
+ public String getName();
+
+ }
+
+ /**
+ * An executable.
+ */
+ public interface IBinaryExecutable extends IBinaryObject {
+ public String[] getNeededSharedLibs();
+ }
+
+ /**
+ * A DLL.
+ */
+ public interface IBinaryShared extends IBinaryExecutable {
+ public String getSoName();
+ }
+
+ public interface ISymbol {
+ public int FUNCTION = 0x01;
+ public int VARIABLE = 0x02;
+
+ public String getName();
+ public int getLineNumber();
+ public String getFilename();
+ public int getType();
+ }
+
+ public IBinaryFile getBinary(IFile file) throws IOException;
+}
Index: model/org/eclipse/cdt/core/model/ICElement.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java,v
retrieving revision 1.2
diff -u -r1.2 ICElement.java
--- model/org/eclipse/cdt/core/model/ICElement.java 26 Jul 2002 19:15:13 -0000 1.2
+++ model/org/eclipse/cdt/core/model/ICElement.java 18 Nov 2002 15:35:10 -0000
@@ -250,6 +250,16 @@
IResource getUnderlyingResource() throws CModelException;
/**
+ * Returns the Corresponding resource for
+ * this element, or <code>null</code> if this element does not have
+ * a corresponding resource.
+ *
+ * @return the corresponding resource, or <code>null</code> if none
+ * @exception CModelException if this element does not exist or if an
+ * exception occurs while accessing its resource
+ */
+ IResource getResource() throws CModelException;
+ /**
* Returns whether this C element is read-only. An element is read-only
* if its structure cannot be modified by the C model.
*
Index: model/org/eclipse/cdt/internal/core/model/Archive.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Archive.java,v
retrieving revision 1.2
diff -u -r1.2 Archive.java
--- model/org/eclipse/cdt/internal/core/model/Archive.java 22 Jul 2002 23:46:59 -0000 1.2
+++ model/org/eclipse/cdt/internal/core/model/Archive.java 18 Nov 2002 15:35:04 -0000
@@ -5,15 +5,19 @@
* All Rights Reserved.
*/
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.resources.IFile;
-
-import org.eclipse.cdt.core.model.ICElement;
+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.internal.core.model.parser.BinaryContainerAdapter;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
public class Archive extends CFile implements IArchive {
+ IResource archive;
+
public Archive(ICElement parent, IFile file) {
super(parent, file);
}
@@ -21,13 +25,12 @@
public Archive(ICElement parent, IPath path) {
super (parent, path);
}
-
- public boolean isReadOnly() {
- return true;
- }
-
- public boolean isArchive() {
- return true;
+
+ public IResource getResource() throws CModelException {
+ if (archive == null) {
+ archive = new BinaryContainerAdapter(getArchiveInfo().getBinaryArchive());
+ }
+ return archive;
}
public IBinary[] getBinaries() {
Index: model/org/eclipse/cdt/internal/core/model/ArchiveContainer.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ArchiveContainer.java,v
retrieving revision 1.4
diff -u -r1.4 ArchiveContainer.java
--- model/org/eclipse/cdt/internal/core/model/ArchiveContainer.java 13 Oct 2002 21:30:28 -0000 1.4
+++ model/org/eclipse/cdt/internal/core/model/ArchiveContainer.java 18 Nov 2002 15:35:01 -0000
@@ -41,10 +41,10 @@
}
public ICElement [] getChildren(boolean sync) {
- if (!cProject.hasRunElf()) {
+ if (!cProject.hasStartBinaryRunner()) {
// It is vital to set this to true first, if not we are going to loop
- cProject.setRunElf(true);
- ElfRunner runner = new ElfRunner(cProject);
+ cProject.setStartBinaryRunner(true);
+ BinaryRunner runner = new BinaryRunner(cProject);
Thread thread = new Thread(runner, "Archive Runner");
// thread.setPriority(Thread.NORM_PRIORITY - 1);
thread.setDaemon(true);
Index: model/org/eclipse/cdt/internal/core/model/ArchiveInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ArchiveInfo.java,v
retrieving revision 1.1
diff -u -r1.1 ArchiveInfo.java
--- model/org/eclipse/cdt/internal/core/model/ArchiveInfo.java 26 Jun 2002 20:37:14 -0000 1.1
+++ model/org/eclipse/cdt/internal/core/model/ArchiveInfo.java 18 Nov 2002 15:35:01 -0000
@@ -4,17 +4,20 @@
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
-
-import java.io.IOException;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
+import java.io.IOException;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IBinaryParser;
import org.eclipse.cdt.core.model.ICElement;
-
-import org.eclipse.cdt.utils.elf.AR;
-import org.eclipse.cdt.utils.elf.ElfHelper;
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryArchive;
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile;
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject;
+import org.eclipse.cdt.internal.core.model.parser.BinaryFileAdapter;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
/**
* Info for ICProject.
@@ -22,56 +25,68 @@
class ArchiveInfo extends CFileInfo {
+ IBinaryArchive archive;
+
/**
*/
public ArchiveInfo(CElement element) {
super(element);
}
- public ICElement [] getChildren() {
- init();
- return super.getChildren();
- }
-
- public void init() {
+ public ICElement[] getChildren() {
if (hasChanged()) {
removeChildren();
- loadInfo();
+ IResource res = null;
+ try {
+ res = getElement().getResource();
+ } catch (CModelException e) {
+ }
+ if (res != null && res instanceof IContainer) {
+ IContainer container = (IContainer)res;
+ IBinaryArchive ar = getBinaryArchive();
+ IBinaryObject[] objects = ar.getObjects();
+ for (int i = 0; i < objects.length; i++) {
+ final IBinaryObject obj = objects[i];
+ IFile file = new BinaryFileAdapter(container, obj);
+ Binary binary = new Binary(getElement(), file) {
+ public CElementInfo createElementInfo() {
+ return new BinaryInfo(this) {
+ /**
+ * @see org.eclipse.cdt.internal.core.model.BinaryInfo#getBinaryObject()
+ */
+ IBinaryObject getBinaryObject() {
+ return obj;
+ }
+ };
+ }
+ };
+ addChild(binary);
+ }
+ }
}
+ return super.getChildren();
}
public boolean isArchive() {
return true;
}
- protected void loadInfo() {
- IPath location = ((CFile)getElement()).getLocation();
- IFile file = ((CFile)getElement()).getFile();
- try {
- AR ar = new AR(location.toOSString());
- AR.ARHeader[] header = ar.getHeaders();
- for (int i = 0; i < header.length; i++) {
- ElfHelper helper = new ElfHelper(header[i].getElf());
- //IPath path = new Path(header[i].getObjectName());
- // FIXME: We should create a special IResource for this files
- // but for now, just bypass.
- Binary binary = new Binary(getElement(), file, header[i].getObjectName()) {
- public IResource getCorrespondingResource() {
- return null;
+ IBinaryArchive getBinaryArchive() {
+ if (archive == null) {
+ IProject project = getElement().getCProject().getProject();
+ IBinaryParser parser = CModelManager.getBinaryParser(project);
+ if (parser != null) {
+ try {
+ IFile file = (IFile) getElement().getUnderlyingResource();
+ IBinaryFile bfile = parser.getBinary(file);
+ if (bfile instanceof IBinaryArchive) {
+ archive = (IBinaryArchive) bfile;
}
- };
- // Force the loading so we can dispose;
- ((BinaryInfo)(binary.getElementInfo())).elfHelper = helper;
- // Force the loading of the chidren right away so we can
- // dispose of the elf Elper.
- binary.getChildren();
- ((BinaryInfo)(binary.getElementInfo())).elfHelper = null;
- helper.dispose();
- addChild(binary);
+ } catch (CModelException e) {
+ } catch (IOException e) {
+ }
}
- ar.dispose();
- } catch (IOException e) {
- //e.printStackTrace();
}
+ return archive;
}
}
Index: model/org/eclipse/cdt/internal/core/model/Binary.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java,v
retrieving revision 1.2
diff -u -r1.2 Binary.java
--- model/org/eclipse/cdt/internal/core/model/Binary.java 25 Oct 2002 18:38:07 -0000 1.2
+++ model/org/eclipse/cdt/internal/core/model/Binary.java 18 Nov 2002 15:35:06 -0000
@@ -25,11 +25,6 @@
super(parent, file, name);
}
-
- public boolean isReadOnly () {
- return true;
- }
-
public boolean isBinary() {
return true;
}
Index: model/org/eclipse/cdt/internal/core/model/BinaryContainer.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryContainer.java,v
retrieving revision 1.4
diff -u -r1.4 BinaryContainer.java
--- model/org/eclipse/cdt/internal/core/model/BinaryContainer.java 13 Oct 2002 21:30:28 -0000 1.4
+++ model/org/eclipse/cdt/internal/core/model/BinaryContainer.java 18 Nov 2002 15:35:01 -0000
@@ -50,10 +50,10 @@
public ICElement [] getChildren(boolean sync) {
// The first time probe the entire project to discover binaries.
- if (!cProject.hasRunElf()) {
- cProject.setRunElf(true);
- ElfRunner runner = new ElfRunner(cProject);
- Thread thread = new Thread(runner, "Elf Runner");
+ if (!cProject.hasStartBinaryRunner()) {
+ cProject.setStartBinaryRunner(true);
+ BinaryRunner runner = new BinaryRunner(cProject);
+ Thread thread = new Thread(runner, "Binary Runner");
// thread.setPriority(Thread.NORM_PRIORITY - 1);
thread.setDaemon(true);
thread.start();
@@ -67,17 +67,9 @@
return super.getChildren();
}
- public IResource getCorrespondingResource() {
- return null;
- }
-
- //public IResource getUnderlyingResource() {
- // return null;
- //}
-
void addChildIfExec(CoreModel factory, IFile file) {
// Attempt to speed things up by rejecting up front
- // Things we know should not be Elf/Binary files.
+ // Things we know should not be Binary files.
if (!factory.isTranslationUnit(file)) {
ICElement celement = factory.create(file);
if (celement != null) {
Index: model/org/eclipse/cdt/internal/core/model/BinaryContainerAdapter.java
===================================================================
RCS file: model/org/eclipse/cdt/internal/core/model/BinaryContainerAdapter.java
diff -N model/org/eclipse/cdt/internal/core/model/BinaryContainerAdapter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ model/org/eclipse/cdt/internal/core/model/BinaryContainerAdapter.java 18 Nov 2002 15:35:07 -0000
@@ -0,0 +1,265 @@
+package org.eclipse.cdt.internal.core.model.parser;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryArchive;
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject;
+import org.eclipse.cdt.internal.core.model.Container;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.QualifiedName;
+
+/**
+ */
+public class BinaryContainerAdapter extends Container implements IFolder {
+
+ IBinaryArchive archive;
+ long timestamp;
+ ArrayList children;
+ ArrayList phantomResources;
+
+ public BinaryContainerAdapter (IBinaryArchive ar) {
+ archive = ar;
+ phantomResources = new ArrayList(0);
+ children = new ArrayList(5);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#refreshLocal(int, IProgressMonitor)
+ */
+ public void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException {
+ IFile file = archive.getFile();
+ if (file != null) {
+ file.refreshLocal(depth, monitor);
+ }
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getFullPath()
+ */
+ public IPath getFullPath() {
+ IFile file = archive.getFile();
+ if (file != null) {
+ return file.getFullPath();
+ }
+ return new Path("");
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getParent()
+ */
+ public IContainer getParent() {
+ IFile file = archive.getFile();
+ if (file != null) {
+ return file.getParent();
+ }
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getType()
+ */
+ public int getType() {
+ return IResource.FOLDER;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getModificationStamp()
+ */
+ public long getModificationStamp() {
+ IFile file = archive.getFile();
+ if (file != null) {
+ return file.getModificationStamp();
+ }
+ return 0;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFolder#delete(boolean, boolean, IProgressMonitor)
+ */
+ public void delete(boolean force, boolean keepHistory,
+ IProgressMonitor monitor) throws CoreException {
+ delete((keepHistory ? KEEP_HISTORY : IResource.NONE) | (force ? FORCE : IResource.NONE), monitor);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#delete(int, IProgressMonitor)
+ */
+ public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException {
+ IFile file = archive.getFile();
+ if (file != null) {
+ file.delete(updateFlags, monitor);
+ }
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#touch(IProgressMonitor)
+ */
+ public void touch(IProgressMonitor monitor) throws CoreException {
+ IFile file = archive.getFile();
+ if (file != null) {
+ file.touch(monitor);
+ }
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFolder#create(boolean, boolean, IProgressMonitor)
+ */
+ public void create(boolean force, boolean local, IProgressMonitor monitor)
+ throws CoreException {
+ create((force ? FORCE : IResource.NONE), local, monitor);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFolder#create(int, boolean, IProgressMonitor)
+ */
+ public void create(int updateFlags, boolean local,
+ IProgressMonitor monitor) throws CoreException {
+ // FIXME: Not implemented.
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFolder#getFile(String)
+ */
+ public IFile getFile(IPath path) {
+ IFile f = (IFile)findMember(path);
+ if (f == null) {
+ // Pass it to parent to create a fake/phantom if the object
+ // is not in the archive.
+ f = getParent().getFile(path);
+ // Add it to the list of phantoms
+ if (! phantomResources.contains(f)) {
+ phantomResources.add(f);
+ phantomResources.trimToSize();
+ }
+ }
+ return f;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFolder#move(IPath, boolean, boolean, IProgressMonitor)
+ */
+ public void move(IPath destination, boolean force, boolean keepHistory,
+ IProgressMonitor monitor) throws CoreException {
+ move(destination, (keepHistory ? KEEP_HISTORY : IResource.NONE) | (force ? FORCE : IResource.NONE), monitor);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IContainer#exists(IPath)
+ */
+ public boolean exists(IPath path) {
+ // Check if it is the archive.
+ if (getFullPath().equals(path)) {
+ IFile file = archive.getFile();
+ if (file != null) {
+ return file.exists();
+ }
+ return false;
+ }
+ return findMember(path) != null;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IContainer#getFolder(IPath)
+ */
+ public IFolder getFolder(IPath path) {
+ // Only Files in the archive pass this to the parent
+ // to create a phatom resource
+ IFolder f = getParent().getFolder(path);
+ if (!phantomResources.contains(f)) {
+ phantomResources.add(f);
+ phantomResources.trimToSize();
+ }
+ return f;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IContainer#members(int)
+ */
+ public IResource[] members(int memberFlags) throws CoreException {
+ final boolean includePhantoms = (memberFlags & IContainer.INCLUDE_PHANTOMS) != 0;
+ final boolean includeTeamPrivateMember =
+ (memberFlags & IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS) != 0;
+
+ ArrayList aList = new ArrayList();
+
+ if (hasChanged()) {
+ children.clear();
+ IBinaryObject[] objects = archive.getObjects();
+ for (int i = 0; i < objects.length; i++) {
+ children.add(new BinaryFileAdapter(this, objects[i]));
+ }
+ }
+
+ for (int i = 0; i < children.size(); i++) {
+ IResource child = (IResource)children.get(i);
+ if (includeTeamPrivateMember && child.isTeamPrivateMember() || !child.isTeamPrivateMember()) {
+ aList.add(child);
+ }
+ }
+
+ if (includePhantoms) {
+ aList.addAll(phantomResources);
+ }
+ return (IResource[])aList.toArray(new IResource[0]);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IContainer#findDeletedMembersWithHistory(int, IProgressMonitor)
+ */
+ public IFile[] findDeletedMembersWithHistory(int depth, IProgressMonitor monitor)
+ throws CoreException {
+ return new IFile[0];
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getPersistentProperty(QualifiedName)
+ */
+ public String getPersistentProperty(QualifiedName key) throws CoreException {
+ IFile file = archive.getFile();
+ if (file != null) {
+ return file.getPersistentProperty(key);
+ }
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#setPersistentProperty(QualifiedName, String)
+ */
+ public void setPersistentProperty(QualifiedName key, String value) throws CoreException {
+ IFile file = archive.getFile();
+ if (file != null) {
+ file.setPersistentProperty(key, value);
+ }
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#exists()
+ */
+ public boolean exists() {
+ IFile file = archive.getFile();
+ if (file != null) {
+ return file.exists();
+ }
+ return false;
+ }
+
+ boolean hasChanged() {
+ boolean changed;
+ long modif = getModificationStamp();
+ changed = modif != timestamp;
+ timestamp = modif;
+ return changed;
+ }
+}
Index: model/org/eclipse/cdt/internal/core/model/BinaryFileAdapter.java
===================================================================
RCS file: model/org/eclipse/cdt/internal/core/model/BinaryFileAdapter.java
diff -N model/org/eclipse/cdt/internal/core/model/BinaryFileAdapter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ model/org/eclipse/cdt/internal/core/model/BinaryFileAdapter.java 18 Nov 2002 15:35:08 -0000
@@ -0,0 +1,231 @@
+package org.eclipse.cdt.internal.core.model.parser;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.io.InputStream;
+
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject;
+import org.eclipse.cdt.internal.core.model.Resource;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFileState;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.QualifiedName;
+
+/**
+ */
+public class BinaryFileAdapter extends Resource implements IFile {
+
+ IBinaryObject object;
+ IContainer parent;
+
+ public BinaryFileAdapter(IContainer p, IBinaryObject o) {
+ object = o;
+ parent = p;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFile#appendContents(InputStream, boolean, boolean, IProgressMonitor)
+ */
+ public void appendContents(InputStream source, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException {
+ appendContents(source, (keepHistory ? KEEP_HISTORY : IResource.NONE) | (force ? FORCE : IResource.NONE), monitor);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFile#appendContents(InputStream, int, IProgressMonitor)
+ */
+ public void appendContents(InputStream source, int updateFlags, IProgressMonitor monitor)
+ throws CoreException {
+ // FIXME: Not implemented.
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFile#create(InputStream, boolean, IProgressMonitor)
+ */
+ public void create(InputStream source, boolean force,
+ IProgressMonitor monitor) throws CoreException {
+ create(source, (force ? FORCE : IResource.NONE), monitor);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFile#create(InputStream, int, IProgressMonitor)
+ */
+ public void create(InputStream source, int updateFlags,
+ IProgressMonitor monitor) throws CoreException {
+ // FIXME: Not implemented.
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IStorage#getContents()
+ */
+ public InputStream getContents() throws CoreException {
+ return getContents(false);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFile#getContents(boolean)
+ */
+ public InputStream getContents(boolean force) throws CoreException {
+ return object.getContents();
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFile#getEncoding()
+ */
+ public int getEncoding() throws CoreException {
+ return ENCODING_UNKNOWN;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFile#getHistory(IProgressMonitor)
+ */
+ public IFileState[] getHistory(IProgressMonitor monitor)
+ throws CoreException {
+ return new IFileState[0];
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFile#move(IPath, boolean, boolean, IProgressMonitor)
+ */
+ public void move(IPath destination, boolean force, boolean keepHistory, IProgressMonitor monitor)
+ throws CoreException {
+ move(destination, (keepHistory ? KEEP_HISTORY : IResource.NONE)
+ | (force ? FORCE : IResource.NONE), monitor);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFile#setContents(InputStream, boolean, boolean, IProgressMonitor)
+ */
+ public void setContents(InputStream source, boolean force, boolean keepHistory,
+ IProgressMonitor monitor) throws CoreException {
+ setContents(source, (keepHistory ? KEEP_HISTORY : IResource.NONE)
+ | (force ? FORCE : IResource.NONE), monitor);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFile#setContents(IFileState, boolean, boolean, IProgressMonitor)
+ */
+ public void setContents(IFileState source, boolean force, boolean keepHistory,
+ IProgressMonitor monitor) throws CoreException {
+ setContents(source, (keepHistory ? KEEP_HISTORY : IResource.NONE)
+ | (force ? FORCE : IResource.NONE), monitor);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFile#setContents(InputStream, int, IProgressMonitor)
+ */
+ public void setContents(InputStream source, int updateFlags, IProgressMonitor monitor)
+ throws CoreException {
+ // FIXME: Not implemented.
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFile#setContents(IFileState, int, IProgressMonitor)
+ */
+ public void setContents(IFileState source, int updateFlags, IProgressMonitor monitor)
+ throws CoreException {
+ // FIXME: Not implemented.
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IFile#delete(boolean, boolean, IProgressMonitor)
+ */
+ public void delete(boolean force, boolean keepHistory, IProgressMonitor monitor)
+ throws CoreException {
+ delete((keepHistory ? KEEP_HISTORY : IResource.NONE)
+ | (force ? FORCE : IResource.NONE), monitor);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#delete(int, IProgressMonitor)
+ */
+ public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException {
+ // FIXME: Not implemented.
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getFullPath()
+ */
+ public IPath getFullPath() {
+ IFile file = object.getFile();
+ if (file != null) {
+ return file.getFullPath().append(object.getName());
+ }
+ return new Path(object.getName());
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getModificationStamp()
+ */
+ public long getModificationStamp() {
+ IFile file = object.getFile();
+ if (file != null) {
+ return file.getModificationStamp();
+ }
+ return 0;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getParent()
+ */
+ public IContainer getParent() {
+ return parent;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getType()
+ */
+ public int getType() {
+ return IResource.FILE;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#refreshLocal(int, IProgressMonitor)
+ */
+ public void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException {
+ IFile file = object.getFile();
+ if (file != null) {
+ file.refreshLocal(depth, monitor);
+ }
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#touch(IProgressMonitor)
+ */
+ public void touch(IProgressMonitor monitor) throws CoreException {
+ IFile file = object.getFile();
+ if (file != null) {
+ file.touch(monitor);
+ }
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getPersistentProperty(QualifiedName)
+ */
+ public String getPersistentProperty(QualifiedName key)
+ throws CoreException {
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#setPersistentProperty(QualifiedName, String)
+ */
+ public void setPersistentProperty(QualifiedName key, String value)
+ throws CoreException {
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#exists()
+ */
+ public boolean exists() {
+ return parent.exists(new Path(getName()));
+ }
+
+}
Index: model/org/eclipse/cdt/internal/core/model/BinaryInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryInfo.java,v
retrieving revision 1.2
diff -u -r1.2 BinaryInfo.java
--- model/org/eclipse/cdt/internal/core/model/BinaryInfo.java 25 Oct 2002 18:38:13 -0000 1.2
+++ model/org/eclipse/cdt/internal/core/model/BinaryInfo.java 18 Nov 2002 15:35:07 -0000
@@ -6,257 +6,234 @@
*/
import java.io.IOException;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IBinaryParser;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryExecutable;
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile;
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject;
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryShared;
+import org.eclipse.cdt.core.model.IBinaryParser.ISymbol;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.cdt.core.model.ICElement;
-
-import org.eclipse.cdt.utils.elf.Elf;
-import org.eclipse.cdt.utils.elf.ElfHelper;
-
class BinaryInfo extends CFileInfo {
- String [] needed;
- ElfHelper.Sizes sizes;
- Elf.Attribute attribute;
- String soname;
+ IBinaryObject binary;
Map hash;
- ElfHelper elfHelper = null;
public BinaryInfo(CElement element) {
super(element);
- needed = new String[0];
- sizes = null;
- attribute = null;
- soname = "";
- hash = new HashMap();
}
public boolean isBinary() {
return true;
}
- public ICElement [] getChildren() {
- initChildren();
+ public ICElement[] getChildren() {
+ if (hasChanged()) {
+ if (hash == null) {
+ hash = new HashMap();
+ }
+ hash.clear();
+ removeChildren();
+ setIsStructureKnown(true);
+ IBinaryObject bin = getBinaryObject();
+ ISymbol[] symbols = bin.getSymbols();
+ for (int i = 0; i < symbols.length; i++) {
+ switch (symbols[i].getType()) {
+ case ISymbol.FUNCTION :
+ addFunction(symbols[i]);
+ break;
+
+ case ISymbol.VARIABLE :
+ addVariable(symbols[i]);
+ break;
+ }
+ }
+ }
return super.getChildren();
}
public String getCPU() {
- init();
- String cpu = null;
- if (attribute != null)
- cpu = attribute.getCPU();
- return (cpu == null) ? "" : cpu;
+ IBinaryObject bin = getBinaryObject();
+ if (bin != null) {
+ return bin.getCPU();
+ }
+ return "";
}
public boolean isSharedLib() {
- init();
- if (attribute != null)
- return attribute.getType() == attribute.ELF_TYPE_SHLIB;
+ IBinaryObject bin = getBinaryObject();
+ if (bin != null) {
+ return bin.getType() == IBinaryObject.SHARED;
+ }
return false;
}
public boolean isExecutable() {
- init();
- if (attribute != null)
- return attribute.getType() == attribute.ELF_TYPE_EXE;
+ IBinaryObject bin = getBinaryObject();
+ if (bin != null) {
+ return bin.getType() == IBinaryObject.EXECUTABLE;
+ }
return false;
}
public boolean isObject() {
- init();
- if (attribute != null)
- return attribute.getType() == attribute.ELF_TYPE_OBJ;
+ IBinaryObject bin = getBinaryObject();
+ if (bin != null) {
+ return bin.getType() == IBinaryObject.OBJECT;
+ }
return false;
}
- public boolean hasDebug () {
- init();
- if (attribute != null)
- return attribute.hasDebug();
+ public boolean hasDebug() {
+ IBinaryObject bin = getBinaryObject();
+ if (bin != null) {
+ return bin.hasDebug();
+ }
return false;
}
- public String [] getNeededSharedLibs() {
- init();
- return needed;
+ public String[] getNeededSharedLibs() {
+ if (isExecutable()) {
+ IBinaryExecutable exec = (IBinaryExecutable) getBinaryObject();
+ return exec.getNeededSharedLibs();
+ }
+ return new String[0];
}
public long getText() {
- init();
- if (sizes != null) {
- return sizes.text;
+ IBinaryObject bin = getBinaryObject();
+ if (bin != null) {
+ return bin.getText();
}
return 0;
}
public long getData() {
- init();
- if (sizes != null) {
- return sizes.data;
+ IBinaryObject bin = getBinaryObject();
+ if (bin != null) {
+ return bin.getData();
}
return 0;
}
public long getBSS() {
- init();
- if (sizes != null) {
- return sizes.bss;
+ IBinaryObject bin = getBinaryObject();
+ if (bin != null) {
+ return bin.getBSS();
}
return 0;
}
public String getSoname() {
- init();
- return soname;
+ if (isSharedLib()) {
+ IBinaryShared shared = (IBinaryShared) getBinaryObject();
+ return shared.getSoName();
+ }
+ return "";
}
public boolean isLittleEndian() {
- init();
- if (attribute != null) {
- return attribute.isLittleEndian();
+ IBinaryObject bin = getBinaryObject();
+ if (bin != null) {
+ return bin.isLittleEndian();
}
return false;
}
-
- private void addFunction(Elf.Symbol [] symbol, boolean external) {
- for (int i = 0; i < symbol.length; i++) {
- ICElement parent = getElement();
- String filename = null;
- try {
- filename = symbol[i].getFilename();
- } catch (IOException e) {
- //e.printStackTrace();
- }
- Function function = null;
- // Addr2line returns the funny "??" when it can find the file.
- if (filename != null && !filename.equals("??")) {
- TranslationUnit tu = null;
- IPath path = new Path(filename);
- if (hash.containsKey(path)) {
- tu = (TranslationUnit)hash.get(path);
- } else {
- tu = new TranslationUnit(parent, path);
- hash.put(path, tu);
- addChild(tu);
+ IBinaryObject getBinaryObject() {
+ if (binary == null) {
+ IProject project = getElement().getCProject().getProject();
+ IBinaryParser parser = CModelManager.getBinaryParser(project);
+ if (parser != null) {
+ try {
+ IFile file = (IFile) getElement().getUnderlyingResource();
+ IBinaryFile bfile = parser.getBinary(file);
+ if (bfile instanceof IBinaryObject) {
+ binary = (IBinaryObject) bfile;
+ }
+ } catch (CModelException e) {
+ } catch (IOException e) {
}
- function = new Function(tu, symbol[i].toString());
- tu.addChild(function);
- } else {
- function = new Function(parent, symbol[i].toString());
- addChild(function);
}
- if (function != null)
- if (!external)
- function.getFunctionInfo().setAccessControl(IConstants.AccStatic);
}
+ return binary;
}
- private void addVariable(Elf.Symbol[] symbol, boolean external) {
- for (int i = 0; i < symbol.length; i++) {
- String filename = null;
- try {
- filename = symbol[i].getFilename();
- } catch (IOException e) {
- //e.printStackTrace();
- }
- ICElement parent = getElement();
- Variable variable = null;
- // Addr2line returns the funny "??" when it can not find the file.
- if (filename != null && !filename.equals("??")) {
- TranslationUnit tu = null;
- IPath path = new Path(filename);
- if (hash.containsKey(path)) {
- tu = (TranslationUnit)hash.get(path);
- } else {
- tu = new TranslationUnit(parent, path);
- hash.put(path, tu);
- addChild(tu);
- }
- variable = new Variable(tu, symbol[i].toString());
- tu.addChild(variable);
+ private void addFunction(ISymbol symbol) {
+ ICElement parent = getElement();
+ String filename = filename = symbol.getFilename();
+ Function function = null;
+
+ // Addr2line returns the funny "??" when it can find the file.
+ if (filename != null && !filename.equals("??")) {
+ TranslationUnit tu = null;
+ IPath path = new Path(filename);
+ if (hash.containsKey(path)) {
+ tu = (TranslationUnit) hash.get(path);
} else {
- variable = new Variable(parent, symbol[i].toString());
- addChild(variable);
- }
- if (variable != null)
- if (!external)
- variable.getVariableInfo().setAccessControl(IConstants.AccStatic);
- }
- }
-
- protected void init() {
- if (hasChanged()) {
- loadInfo();
- }
- }
-
- protected void initChildren() {
- if (hasChanged() || !isStructureKnown()) {
- removeChildren();
- loadInfoChildren();
- }
- }
-
-
- protected ElfHelper getElfHelper() throws IOException {
- if (elfHelper != null) {
- return elfHelper;
- }
- CFile file = (CFile)getElement();
- if (file != null) {
- IPath path = ((CFile)getElement()).getLocation();
- if (path == null)
- path = new Path("");
- return new ElfHelper(path.toOSString());
- }
- throw new IOException("No file assiocated with Binary");
- }
-
- protected void loadInfo() {
- try {
- ElfHelper helper = this.getElfHelper();
- Elf.Dynamic[] sharedlibs = helper.getNeeded();
- needed = new String[sharedlibs.length];
- for (int i = 0; i < sharedlibs.length; i++) {
- needed[i] = sharedlibs[i].toString();
- }
-
- sizes = helper.getSizes();
- soname = helper.getSoname();
- attribute = helper.getElf().getAttributes();
- helper.dispose();
- } catch (IOException e) {
- //e.printStackTrace();
- }
+ // A special ITranslationUnit we do not want the file to be parse.
+ tu = new TranslationUnit(parent, path) {
+ ArrayList array = new ArrayList(5);
+ public void addChild(ICElement e) {
+ array.add(e);
+ array.trimToSize();
+ }
+
+ public ICElement [] getChildren() {
+ return (ICElement[])array.toArray(new ICElement[0]);
+ }
+ };
+ hash.put(path, tu);
+ addChild(tu);
+ }
+ function = new Function(tu, symbol.getName());
+ tu.addChild(function);
+ } else {
+ function = new Function(parent, symbol.getName());
+ addChild(function);
+ }
+ // if (function != null) {
+ // if (!external) {
+ // function.getFunctionInfo().setAccessControl(IConstants.AccStatic);
+ // }
+ // }
+ }
+
+ private void addVariable(ISymbol symbol) {
+ String filename = filename = symbol.getFilename();
+ ICElement parent = getElement();
+ Variable variable = null;
+ // Addr2line returns the funny "??" when it can not find the file.
+ if (filename != null && !filename.equals("??")) {
+ TranslationUnit tu = null;
+ IPath path = new Path(filename);
+ if (hash.containsKey(path)) {
+ tu = (TranslationUnit) hash.get(path);
+ } else {
+ tu = new TranslationUnit(parent, path);
+ hash.put(path, tu);
+ addChild(tu);
+ }
+ variable = new Variable(tu, symbol.getName());
+ tu.addChild(variable);
+ } else {
+ variable = new Variable(parent, symbol.getName());
+ addChild(variable);
+ }
+ //if (variable != null) {
+ // if (!external) {
+ // variable.getVariableInfo().setAccessControl(IConstants.AccStatic);
+ // }
+ //}
}
- protected void loadInfoChildren() {
- try {
- setIsStructureKnown(true);
- ElfHelper helper = this.getElfHelper();
- addFunction(helper.getExternalFunctions(), true);
- addFunction(helper.getLocalFunctions(), false);
- addVariable(helper.getExternalObjects(), true);
- addVariable(helper.getLocalObjects(), false);
-
- Elf.Dynamic[] sharedlibs = helper.getNeeded();
- needed = new String[sharedlibs.length];
- for (int i = 0; i < sharedlibs.length; i++) {
- needed[i] = sharedlibs[i].toString();
- }
-
- sizes = helper.getSizes();
- soname = helper.getSoname();
-
- attribute = helper.getElf().getAttributes();
- helper.dispose();
- } catch (IOException e) {
- //e.printStackTrace();
- }
- }
}
Index: model/org/eclipse/cdt/internal/core/model/BinaryRunner.java
===================================================================
RCS file: model/org/eclipse/cdt/internal/core/model/BinaryRunner.java
diff -N model/org/eclipse/cdt/internal/core/model/BinaryRunner.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ model/org/eclipse/cdt/internal/core/model/BinaryRunner.java 18 Nov 2002 15:35:01 -0000
@@ -0,0 +1,99 @@
+package org.eclipse.cdt.internal.core.model;
+
+/*
+ * (c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.cdt.core.model.CoreModel;
+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.ICRoot;
+
+public class BinaryRunner implements Runnable {
+ ArchiveContainer clib;
+ BinaryContainer cbin;
+ CProject cproject;
+
+ public BinaryRunner(CProject cprj) {
+ cproject = cprj;
+ cbin = (BinaryContainer)cprj.getBinaryContainer();
+ clib = (ArchiveContainer)cprj.getArchiveContainer();
+ }
+
+ public void run() {
+ cproject.setStartBinaryRunner(true);
+ clib.removeChildren();
+ cbin.removeChildren();
+ try {
+ cproject.getProject().accept(new Visitor(this));
+ } catch (CoreException e) {
+ //e.printStackTrace();
+ }
+ fireEvents(cbin);
+ fireEvents(clib);
+ }
+
+ public void fireEvents(Parent container) {
+ // Fired the event.
+ ICElement[] children = container.getChildren();
+ if (children.length > 0) {
+ CModelManager factory = CModelManager.getDefault();
+ ICElement root = (ICRoot)factory.getCRoot();
+ CElementDelta cdelta = new CElementDelta(root);
+ cdelta.added(cproject);
+ cdelta.added(container);
+ for (int i = 0; i < children.length; i++) {
+ cdelta.added(children[i]);
+ }
+ factory.registerCModelDelta(cdelta);
+ factory.fire();
+ }
+ }
+
+ void addChildIfBinary(CoreModel factory, IFile file) {
+ // Attempt to speed things up by rejecting up front
+ // Things we know should not be Binary files.
+ if (!factory.isTranslationUnit(file)) {
+ if (factory.isBinary(file)) {
+ ICElement celement = factory.create(file);
+ if (celement != null) {
+ if (celement instanceof IBinary) {
+ IBinary bin = (IBinary)celement;
+ if (bin.isExecutable() || bin.isSharedLib()) {
+ cbin.addChild(bin);
+ }
+ }
+ }
+ } else if (factory.isArchive(file)) {
+ ICElement celement = factory.create(file);
+ if (celement instanceof IArchive) {
+ clib.addChild(celement);
+ }
+ }
+ }
+ }
+
+ class Visitor implements IResourceVisitor {
+ CoreModel factory = CoreModel.getDefault();
+ BinaryRunner runner;
+
+ public Visitor (BinaryRunner r) {
+ runner = r;
+ }
+
+ public boolean visit(IResource res) throws CoreException {
+ if (res instanceof IFile) {
+ runner.addChildIfBinary(factory, (IFile)res);
+ return false;
+ }
+ return true;
+ }
+ }
+}
Index: model/org/eclipse/cdt/internal/core/model/CElement.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElement.java,v
retrieving revision 1.1
diff -u -r1.1 CElement.java
--- model/org/eclipse/cdt/internal/core/model/CElement.java 26 Jun 2002 20:37:14 -0000 1.1
+++ model/org/eclipse/cdt/internal/core/model/CElement.java 18 Nov 2002 15:35:04 -0000
@@ -81,7 +81,7 @@
public boolean exists() {
try {
- return getCorrespondingResource() != null;
+ return getResource() != null;
} catch (CModelException e) {
e.printStackTrace();
}
@@ -89,7 +89,7 @@
}
public boolean isReadOnly () {
- return true;
+ return getElementInfo().isReadOnly();
}
public boolean isStructureKnown() throws CModelException {
@@ -149,7 +149,7 @@
public abstract IResource getUnderlyingResource() throws CModelException;
- public abstract IResource getCorrespondingResource() throws CModelException;
+ public abstract IResource getResource() throws CModelException;
protected abstract CElementInfo createElementInfo();
@@ -184,8 +184,8 @@
if (o instanceof CElement) {
CElement other = (CElement) o;
try {
- IResource tres = getCorrespondingResource();
- IResource ores = other.getCorrespondingResource();
+ IResource tres = getResource();
+ IResource ores = other.getResource();
if (ores != null && tres != null) {
return tres.equals(ores);
}
Index: model/org/eclipse/cdt/internal/core/model/CElementInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java,v
retrieving revision 1.1
diff -u -r1.1 CElementInfo.java
--- model/org/eclipse/cdt/internal/core/model/CElementInfo.java 26 Jun 2002 20:37:14 -0000 1.1
+++ model/org/eclipse/cdt/internal/core/model/CElementInfo.java 18 Nov 2002 15:35:00 -0000
@@ -95,6 +95,20 @@
}
/**
+ * @see ICElement.isStructureKnown()
+ */
+ public boolean isReadOnly () {
+ try {
+ IResource r = getElement().getUnderlyingResource();
+ if (r != null) {
+ return r.isReadOnly();
+ }
+ } catch (CModelException e) {
+ }
+ return true;
+ }
+
+ /**
* Returns an array with all the same elements as the specified array except for
* the element to remove. Assumes that the deletion is contained in the array.
*/
Index: model/org/eclipse/cdt/internal/core/model/CModelManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java,v
retrieving revision 1.6
diff -u -r1.6 CModelManager.java
--- model/org/eclipse/cdt/internal/core/model/CModelManager.java 12 Nov 2002 13:51:55 -0000 1.6
+++ model/org/eclipse/cdt/internal/core/model/CModelManager.java 18 Nov 2002 15:35:06 -0000
@@ -16,6 +16,7 @@
import org.eclipse.cdt.core.model.ElementChangedEvent;
import org.eclipse.cdt.core.model.IArchive;
import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.IBinaryParser;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.ICFile;
@@ -24,8 +25,8 @@
import org.eclipse.cdt.core.model.ICResource;
import org.eclipse.cdt.core.model.ICRoot;
import org.eclipse.cdt.core.model.IElementChangedListener;
-import org.eclipse.cdt.utils.elf.AR;
-import org.eclipse.cdt.utils.elf.Elf;
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile;
+import org.eclipse.cdt.internal.core.model.parser.ElfParser;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -45,6 +46,8 @@
private HashMap fParsedResources = new HashMap();
+ private static IBinaryParser defaultBinaryParser = new ElfParser();
+
/**
* Used to convert <code>IResourceDelta</code>s into <code>IJavaElementDelta</code>s.
*/
@@ -303,7 +306,7 @@
container.removeChild(cfile);
} else if (cfile.isBinary()) {
if (! ((IBinary)celement).isObject()) {
-//System.out.println("RELEASE Binary " + cfile.getElementName());
+System.out.println("RELEASE Binary " + cfile.getElementName());
CProject cproj = (CProject)cfile.getCProject();
BinaryContainer container = (BinaryContainer)cproj.getBinaryContainer();
container.removeChild(cfile);
@@ -315,7 +318,11 @@
if (parent != null) {
parent.removeChild(celement);
}
- fParsedResources.remove(celement);
+ try {
+ IResource res = celement.getUnderlyingResource();
+ fParsedResources.remove(res);
+ } catch (CModelException e) {
+ }
}
public ICElement getCElement(IResource res) {
@@ -333,12 +340,17 @@
return null;
}
+ public static IBinaryParser getBinaryParser(IProject project) {
+ // For now the default is Elf.
+ // It is in the porperty of the project of the cdtproject
+ return defaultBinaryParser;
+ }
+
public static boolean isSharedLib(IFile file) {
try {
- Elf.Attribute attribute = Elf.getAttributes(file.getLocation().toOSString());
- if (attribute.getType() == Elf.Attribute.ELF_TYPE_SHLIB) {
- return true;
- }
+ IBinaryParser parser = getBinaryParser(file.getProject());
+ IBinaryFile bin = parser.getBinary(file);
+ return (bin.getType() == IBinaryFile.SHARED);
} catch (IOException e) {
//e.printStackTrace();
}
@@ -347,10 +359,9 @@
public static boolean isObject(IFile file) {
try {
- Elf.Attribute attribute = Elf.getAttributes(file.getLocation().toOSString());
- if (attribute.getType() == Elf.Attribute.ELF_TYPE_OBJ) {
- return true;
- }
+ IBinaryParser parser = getBinaryParser(file.getProject());
+ IBinaryFile bin = parser.getBinary(file);
+ return (bin.getType() == IBinaryFile.OBJECT);
} catch (IOException e) {
//e.printStackTrace();
}
@@ -359,10 +370,9 @@
public static boolean isExecutable(IFile file) {
try {
- Elf.Attribute attribute = Elf.getAttributes(file.getLocation().toOSString());
- if (attribute.getType() == Elf.Attribute.ELF_TYPE_EXE) {
- return true;
- }
+ IBinaryParser parser = getBinaryParser(file.getProject());
+ IBinaryFile bin = parser.getBinary(file);
+ return (bin.getType() == IBinaryFile.EXECUTABLE);
} catch (IOException e) {
//e.printStackTrace();
}
@@ -371,12 +381,11 @@
public static boolean isBinary(IFile file) {
try {
- Elf.Attribute attribute = Elf.getAttributes(file.getLocation().toOSString());
- if (attribute.getType() == Elf.Attribute.ELF_TYPE_EXE
- || attribute.getType() == Elf.Attribute.ELF_TYPE_OBJ
- || attribute.getType() == Elf.Attribute.ELF_TYPE_SHLIB) {
- return true;
- }
+ IBinaryParser parser = getBinaryParser(file.getProject());
+ IBinaryFile bin = parser.getBinary(file);
+ return (bin.getType() == IBinaryFile.EXECUTABLE
+ || bin.getType() == IBinaryFile.OBJECT
+ || bin.getType() == IBinaryFile.SHARED);
} catch (IOException e) {
//e.printStackTrace();
}
@@ -384,15 +393,12 @@
}
public static boolean isArchive(IFile file) {
- AR ar = null;
try {
- ar = new AR(file.getLocation().toOSString());
+ IBinaryParser parser = getBinaryParser(file.getProject());
+ IBinaryFile bin = parser.getBinary(file);
+ return (bin.getType() == IBinaryFile.ARCHIVE);
} catch (IOException e) {
//e.printStackTrace();
- }
- if (ar != null) {
- ar.dispose();
- return true;
}
return false;
}
Index: model/org/eclipse/cdt/internal/core/model/CProject.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java,v
retrieving revision 1.2
diff -u -r1.2 CProject.java
--- model/org/eclipse/cdt/internal/core/model/CProject.java 1 Nov 2002 20:11:21 -0000 1.2
+++ model/org/eclipse/cdt/internal/core/model/CProject.java 18 Nov 2002 15:35:02 -0000
@@ -17,7 +17,7 @@
public class CProject extends CResource implements ICProject {
- boolean elfDone = false;
+ boolean runner = false;
public CProject (ICElement parent, IProject project) {
super (parent, project, CElement.C_PROJECT);
@@ -62,12 +62,12 @@
return celem;
}
- synchronized protected boolean hasRunElf() {
- return elfDone;
+ synchronized protected boolean hasStartBinaryRunner() {
+ return runner;
}
- synchronized protected void setRunElf(boolean done) {
- elfDone = done;
+ synchronized protected void setStartBinaryRunner(boolean done) {
+ runner = done;
}
protected CProjectInfo getCProjectInfo() {
Index: model/org/eclipse/cdt/internal/core/model/CResource.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CResource.java,v
retrieving revision 1.2
diff -u -r1.2 CResource.java
--- model/org/eclipse/cdt/internal/core/model/CResource.java 26 Jul 2002 19:15:12 -0000 1.2
+++ model/org/eclipse/cdt/internal/core/model/CResource.java 18 Nov 2002 15:35:02 -0000
@@ -33,10 +33,6 @@
return resource;
}
- public IResource getCorrespondingResource() throws CModelException {
- return resource;
- }
-
public IResource getResource() throws CModelException {
return resource;
}
Index: model/org/eclipse/cdt/internal/core/model/Container.java
===================================================================
RCS file: model/org/eclipse/cdt/internal/core/model/Container.java
diff -N model/org/eclipse/cdt/internal/core/model/Container.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ model/org/eclipse/cdt/internal/core/model/Container.java 18 Nov 2002 15:35:06 -0000
@@ -0,0 +1,99 @@
+package org.eclipse.cdt.internal.core.model;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+public abstract class Container extends Resource implements IContainer {
+
+ /**
+ * @see IContainer#findMember(String)
+ */
+ public IResource findMember(String name) {
+ return findMember(name, false);
+ }
+
+ /**
+ * @see IContainer#findMember(String, boolean)
+ */
+ public IResource findMember(String name, boolean phantom) {
+ return findMember(new Path(name), phantom);
+ }
+
+ /**
+ * @see IContainer#findMember(IPath)
+ */
+ public IResource findMember(IPath path) {
+ return findMember(path, false);
+ }
+
+ /**
+ * @see IContainer#findMember(IPath)
+ */
+ public IResource findMember(IPath path, boolean phantom) {
+ path = getFullPath().append(path);
+ try {
+ IResource[] resources = members(phantom);
+ for (int i = 0; i < resources.length; i++) {
+ if (resources[i].getFullPath().equals(path)) {
+ return resources[i];
+ }
+ }
+ } catch (CoreException e) {
+ }
+ return null;
+ }
+
+ /**
+ * @see IContainer#getFile(String)
+ */
+ public IFile getFile(String name) {
+ return getFile(new Path(name));
+ }
+
+ /**
+ * @see IContainer#getFolder(String)
+ */
+ public IFolder getFolder(String name) {
+ return getFolder(new Path(name));
+ }
+
+ /**
+ * @see IContainer#members
+ */
+ public IResource[] members() throws CoreException {
+ return members(IResource.NONE);
+ }
+
+ /**
+ * @see IContainer#members(boolean)
+ */
+ public IResource[] members(boolean phantom) throws CoreException {
+ return members(phantom ? INCLUDE_PHANTOMS : IResource.NONE);
+ }
+
+ /*
+ * @see IContainer#members(int)
+ */
+ public abstract IResource[] members(int memberFlags) throws CoreException;
+
+ /**
+ * @see IContainer#exits(IPath)
+ */
+ public abstract boolean exists(IPath path);
+
+ /**
+ * @see IContainer#getFile(IPath)
+ */
+ public abstract IFile getFile(IPath path);
+
+ /**
+ * @see IContainer#getFolder(IPath)
+ */
+ public abstract IFolder getFolder(IPath path);
+
+}
Index: model/org/eclipse/cdt/internal/core/model/ElfBinaryArchive.java
===================================================================
RCS file: model/org/eclipse/cdt/internal/core/model/ElfBinaryArchive.java
diff -N model/org/eclipse/cdt/internal/core/model/ElfBinaryArchive.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ model/org/eclipse/cdt/internal/core/model/ElfBinaryArchive.java 18 Nov 2002 15:35:07 -0000
@@ -0,0 +1,94 @@
+package org.eclipse.cdt.internal.core.model.parser;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryArchive;
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile;
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject;
+import org.eclipse.cdt.utils.elf.AR;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.PlatformObject;
+
+/**
+ */
+public class ElfBinaryArchive extends PlatformObject implements IBinaryArchive {
+
+ IFile file;
+ ArrayList children;
+ long timestamp;
+
+ public ElfBinaryArchive(IFile f) {
+ file = f;
+ children = new ArrayList(5);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryArchive#getObjects()
+ */
+ public IBinaryObject[] getObjects() {
+ if (hasChanged()) {
+ children.clear();
+ IPath location = file.getLocation();
+ if (location != null) {
+ AR ar = null;
+ try {
+ ar = new AR(location.toOSString());
+ AR.ARHeader[] headers = ar.getHeaders();
+ for (int i = 0; i < headers.length; i++) {
+ IBinaryObject bin = new ElfBinaryFile(file, headers[i].getObjectName());
+ children.add(bin);
+ }
+ } catch (IOException e) {
+ //e.printStackTrace();
+ }
+ if (ar != null) {
+ ar.dispose();
+ }
+ }
+ children.trimToSize();
+ }
+ return (IBinaryObject[])children.toArray(new IBinaryObject[0]);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile#getFile()
+ */
+ public IFile getFile() {
+ return file;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile#getType()
+ */
+ public int getType() {
+ return IBinaryFile.ARCHIVE;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile#getContents()
+ */
+ public InputStream getContents() {
+ try {
+ return file.getContents();
+ } catch (CoreException e) {
+ }
+ return new ByteArrayInputStream(new byte[0]);
+ }
+
+ boolean hasChanged() {
+ long modif = file.getModificationStamp();
+ boolean changed = modif != timestamp;
+ timestamp = modif;
+ return changed;
+ }
+}
Index: model/org/eclipse/cdt/internal/core/model/ElfBinaryFile.java
===================================================================
RCS file: model/org/eclipse/cdt/internal/core/model/ElfBinaryFile.java
diff -N model/org/eclipse/cdt/internal/core/model/ElfBinaryFile.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ model/org/eclipse/cdt/internal/core/model/ElfBinaryFile.java 18 Nov 2002 15:35:09 -0000
@@ -0,0 +1,414 @@
+package org.eclipse.cdt.internal.core.model.parser;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryExecutable;
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile;
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject;
+import org.eclipse.cdt.core.model.IBinaryParser.IBinaryShared;
+import org.eclipse.cdt.core.model.IBinaryParser.ISymbol;
+import org.eclipse.cdt.utils.elf.AR;
+import org.eclipse.cdt.utils.elf.Elf;
+import org.eclipse.cdt.utils.elf.ElfHelper;
+import org.eclipse.cdt.utils.elf.Elf.Attribute;
+import org.eclipse.cdt.utils.elf.ElfHelper.Sizes;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.PlatformObject;
+
+/**
+ */
+public class ElfBinaryFile extends PlatformObject implements IBinaryFile,
+ IBinaryObject, IBinaryExecutable, IBinaryShared {
+
+ IFile file;
+ String objectName;
+ long timestamp;
+ String soname;
+ String[] needed;
+ Sizes sizes;
+ Attribute attribute;
+ ArrayList symbols;
+
+ public class ElfSymbol implements ISymbol {
+
+ String filename;
+ int lineno;
+ String name;
+ int type;
+
+ public ElfSymbol (Elf.Symbol symbol, int t) throws IOException {
+ filename = symbol.getFilename();
+ name = symbol.toString();
+ lineno = symbol.getFuncLineNumber();
+ type = t;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.ISymbol#getFilename()
+ */
+ public String getFilename() {
+ return filename;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.ISymbol#getLineNumber()
+ */
+ public int getLineNumber() {
+ return lineno;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.ISymbol#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.ISymbol#getType()
+ */
+ public int getType() {
+ return type;
+ }
+
+ }
+
+ public ElfBinaryFile(IFile f) throws IOException {
+ this(f, null, null);
+ }
+
+ public ElfBinaryFile(IFile f, String n) throws IOException {
+ this(f, n, null);
+ }
+
+ public ElfBinaryFile(IFile f, String n, Elf elf) throws IOException {
+ file = f;
+ objectName = n;
+ if (elf != null) {
+ loadAttributes(new ElfHelper(elf));
+ } else {
+ loadAttributes();
+ }
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile#getFile()
+ */
+ public IFile getFile() {
+ return file;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject#getBSS()
+ */
+ public long getBSS() {
+ Sizes sz = getSizes();
+ if (sz != null) {
+ return sizes.bss;
+ }
+ return 0;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject#getCPU()
+ */
+ public String getCPU() {
+ Attribute attr = getAttribute();
+ if (attr != null) {
+ return attribute.getCPU();
+ }
+ return "";
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject#getData()
+ */
+ public long getData() {
+ Sizes sz = getSizes();
+ if (sz != null) {
+ return sizes.data;
+ }
+ return 0;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject#getText()
+ */
+ public long getText() {
+ Sizes sz = getSizes();
+ if (sz != null) {
+ return sizes.text;
+ }
+ return 0;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryShared#getSoName()
+ */
+ public String getSoName() {
+ if (hasChanged()) {
+ try {
+ loadInformation();
+ } catch (IOException e) {
+ }
+ }
+ if (soname != null) {
+ return soname;
+ }
+ return "";
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject#hasDebug()
+ */
+ public boolean hasDebug() {
+ Attribute attr = getAttribute();
+ if (attr != null) {
+ return attribute.hasDebug();
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject#isLittleEndian()
+ */
+ public boolean isLittleEndian() {
+ Attribute attr = getAttribute();
+ if (attr != null) {
+ return attribute.isLittleEndian();
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryExecutable#getNeededSharedLibs()
+ */
+ public String[] getNeededSharedLibs() {
+ if (hasChanged()) {
+ try {
+ loadInformation();
+ } catch (IOException e) {
+ }
+ }
+ if (needed != null) {
+ return needed;
+ }
+ return new String[0];
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile#getType()
+ */
+ public int getType() {
+ int type = 0;
+ Attribute attr = getAttribute();
+ if (attr != null) {
+ switch (attribute.getType()) {
+ case Attribute.ELF_TYPE_EXE:
+ type = IBinaryFile.EXECUTABLE;
+ break;
+
+ case Attribute.ELF_TYPE_SHLIB:
+ type = IBinaryFile.SHARED;
+ break;
+
+ case Attribute.ELF_TYPE_OBJ:
+ type = IBinaryFile.OBJECT;
+ break;
+ }
+ }
+ return type;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject#getSymbols()
+ */
+ public ISymbol[] getSymbols() {
+ if (hasChanged() || symbols == null) {
+ if (symbols == null) {
+ symbols = new ArrayList(5);
+ }
+ try {
+ loadInformation();
+ } catch (IOException e) {
+ }
+ }
+ return (ISymbol[])symbols.toArray(new ISymbol[0]);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile#getContents()
+ */
+ public InputStream getContents() {
+ InputStream stream = null;
+ // Archive ?
+ if (file != null && objectName != null) {
+ IPath location = file.getLocation();
+ if (location != null) {
+ AR ar = null;
+ try {
+ ar = new AR(file.getLocation().toOSString());
+ AR.ARHeader[] headers = ar.getHeaders();
+ for (int i = 0; i < headers.length; i++) {
+ if (objectName.equals(headers[i].getObjectName())) {
+ stream = new ByteArrayInputStream(headers[i].getObjectData());
+ break;
+ }
+ }
+ } catch (IOException e) {
+ }
+ if (ar != null) {
+ ar.dispose();
+ }
+ }
+ } else if (file != null && file.exists()) {
+ try {
+ stream = file.getContents();
+ } catch (CoreException e) {
+ }
+ }
+ if (stream == null) {
+ stream = new ByteArrayInputStream(new byte[0]);
+ }
+ return stream;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject#getName()
+ */
+ public String getName() {
+ return objectName;
+ }
+
+ public String toString() {
+ return getName();
+ }
+
+ protected Attribute getAttribute() {
+ if (hasChanged()) {
+ try {
+ loadInformation();
+ } catch (IOException e) {
+ }
+ }
+ return attribute;
+ }
+
+ protected Sizes getSizes() {
+ if (hasChanged()) {
+ try {
+ loadInformation();
+ } catch (IOException e) {
+ }
+ }
+ return sizes;
+ }
+
+ boolean hasChanged() {
+ long modification = file.getModificationStamp();
+ boolean changed = modification != timestamp;
+ timestamp = modification;
+ return changed;
+ }
+
+ protected ElfHelper getElfHelper() throws IOException {
+ // Archive ?
+ if (file != null && file.exists() && objectName != null) {
+ ElfHelper helper = null;
+ AR ar = null;
+ try {
+ ar = new AR(file.getLocation().toOSString());
+ AR.ARHeader[] headers = ar.getHeaders();
+ for (int i = 0; i < headers.length; i++) {
+ if (objectName.equals(headers[i].getObjectName())) {
+ helper = new ElfHelper(headers[i].getElf());
+ break;
+ }
+ }
+ } finally {
+ if (ar != null) {
+ ar.dispose();
+ }
+ }
+ return helper;
+ } else if (file != null && file.exists()) {
+ IPath path = file.getLocation();
+ if (path == null) {
+ path = new Path("");
+ }
+ return new ElfHelper(path.toOSString());
+ }
+ throw new IOException("No file assiocated with Binary");
+ }
+
+ protected void loadInformation() throws IOException {
+ loadAttributes();
+ if (symbols != null) {
+ symbols.clear();
+ loadSymbols();
+ symbols.trimToSize();
+ }
+ }
+
+ protected void loadAttributes() throws IOException {
+ ElfHelper helper = getElfHelper();
+ loadAttributes(helper);
+ helper.dispose();
+ }
+
+ protected void loadAttributes(ElfHelper helper) throws IOException {
+ Elf.Dynamic[] sharedlibs = helper.getNeeded();
+ needed = new String[sharedlibs.length];
+ for (int i = 0; i < sharedlibs.length; i++) {
+ needed[i] = sharedlibs[i].toString();
+ }
+ sizes = helper.getSizes();
+ soname = helper.getSoname();
+ attribute = helper.getElf().getAttributes();
+ }
+
+ protected void loadSymbols() throws IOException {
+ ElfHelper helper = getElfHelper();
+ loadSymbols(helper);
+ helper.dispose();
+ }
+
+ protected void loadSymbols(ElfHelper helper) throws IOException {
+ Elf.Dynamic[] sharedlibs = helper.getNeeded();
+ needed = new String[sharedlibs.length];
+ for (int i = 0; i < sharedlibs.length; i++) {
+ needed[i] = sharedlibs[i].toString();
+ }
+ sizes = helper.getSizes();
+ soname = helper.getSoname();
+ attribute = helper.getElf().getAttributes();
+
+ addSymbols(helper.getExternalFunctions(), ISymbol.FUNCTION);
+ addSymbols(helper.getLocalFunctions(), ISymbol.FUNCTION);
+ addSymbols(helper.getExternalObjects(), ISymbol.VARIABLE);
+ addSymbols(helper.getLocalObjects(), ISymbol.VARIABLE);
+ symbols.trimToSize();
+ }
+
+ protected void addSymbols(Elf.Symbol[] array, int type) {
+ for (int i = 0; i < array.length; i++) {
+ try {
+ ISymbol sym = new ElfSymbol(array[i], type);
+ symbols.add(sym);
+ } catch (IOException e) {
+ }
+ }
+ }
+
+}
Index: model/org/eclipse/cdt/internal/core/model/ElfParser.java
===================================================================
RCS file: model/org/eclipse/cdt/internal/core/model/ElfParser.java
diff -N model/org/eclipse/cdt/internal/core/model/ElfParser.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ model/org/eclipse/cdt/internal/core/model/ElfParser.java 18 Nov 2002 15:35:08 -0000
@@ -0,0 +1,35 @@
+package org.eclipse.cdt.internal.core.model.parser;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.io.IOException;
+
+import org.eclipse.cdt.core.model.IBinaryParser;
+import org.eclipse.cdt.utils.elf.AR;
+import org.eclipse.cdt.utils.elf.Elf;
+import org.eclipse.core.resources.IFile;
+
+/**
+ */
+public class ElfParser implements IBinaryParser {
+
+ /**
+ * @see org.eclipse.cdt.core.model.IBinaryParser#getBinary(IPath)
+ */
+ public IBinaryFile getBinary(IFile file) throws IOException {
+ try {
+ Elf e = new Elf(file.getLocation().toOSString());
+ e.dispose();
+ return new ElfBinaryFile(file);
+ } catch (IOException e) {
+ }
+ // Is it an Archive.
+ AR ar = new AR(file.getLocation().toOSString());
+ ar.dispose();
+ return new ElfBinaryArchive(file);
+ }
+
+}
Index: model/org/eclipse/cdt/internal/core/model/ElfRunner.java
===================================================================
RCS file: model/org/eclipse/cdt/internal/core/model/ElfRunner.java
diff -N model/org/eclipse/cdt/internal/core/model/ElfRunner.java
--- model/org/eclipse/cdt/internal/core/model/ElfRunner.java 26 Jun 2002 20:37:14 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,99 +0,0 @@
-package org.eclipse.cdt.internal.core.model;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.cdt.core.model.CoreModel;
-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.ICRoot;
-
-public class ElfRunner implements Runnable {
- ArchiveContainer clib;
- BinaryContainer cbin;
- CProject cproject;
-
- public ElfRunner(CProject cprj) {
- cproject = cprj;
- cbin = (BinaryContainer)cprj.getBinaryContainer();
- clib = (ArchiveContainer)cprj.getArchiveContainer();
- }
-
- public void run() {
- cproject.setRunElf(true);
- clib.removeChildren();
- cbin.removeChildren();
- try {
- cproject.getProject().accept(new Visitor(this));
- } catch (CoreException e) {
- //e.printStackTrace();
- }
- fireEvents(cbin);
- fireEvents(clib);
- }
-
- public void fireEvents(Parent container) {
- // Fired the event.
- ICElement[] children = container.getChildren();
- if (children.length > 0) {
- CModelManager factory = CModelManager.getDefault();
- ICElement root = (ICRoot)factory.getCRoot();
- CElementDelta cdelta = new CElementDelta(root);
- cdelta.added(cproject);
- cdelta.added(container);
- for (int i = 0; i < children.length; i++) {
- cdelta.added(children[i]);
- }
- factory.registerCModelDelta(cdelta);
- factory.fire();
- }
- }
-
- void addChildIfElf(CoreModel factory, IFile file) {
- // Attempt to speed things up by rejecting up front
- // Things we know should not be Elf/Binary files.
- if (!factory.isTranslationUnit(file)) {
- if (factory.isBinary(file)) {
- ICElement celement = factory.create(file);
- if (celement != null) {
- if (celement instanceof IBinary) {
- IBinary bin = (IBinary)celement;
- if (bin.isExecutable() || bin.isSharedLib()) {
- cbin.addChild(bin);
- }
- }
- }
- } else if (factory.isArchive(file)) {
- ICElement celement = factory.create(file);
- if (celement instanceof IArchive) {
- clib.addChild(celement);
- }
- }
- }
- }
-
- class Visitor implements IResourceVisitor {
- CoreModel factory = CoreModel.getDefault();
- ElfRunner runner;
-
- public Visitor (ElfRunner r) {
- runner = r;
- }
-
- public boolean visit(IResource res) throws CoreException {
- if (res instanceof IFile) {
- runner.addChildIfElf(factory, (IFile)res);
- return false;
- }
- return true;
- }
- }
-}
Index: model/org/eclipse/cdt/internal/core/model/Marker.java
===================================================================
RCS file: model/org/eclipse/cdt/internal/core/model/Marker.java
diff -N model/org/eclipse/cdt/internal/core/model/Marker.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ model/org/eclipse/cdt/internal/core/model/Marker.java 18 Nov 2002 15:35:02 -0000
@@ -0,0 +1,125 @@
+package org.eclipse.cdt.internal.core.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.PlatformObject;
+
+public class Marker extends PlatformObject implements IMarker {
+ private long id;
+ private IResource resource;
+ private HashMap attributes;
+ private String type;
+
+ public Marker(IResource res, String t) {
+ resource = res;
+ type = t;
+ attributes = new HashMap();
+ id = System.currentTimeMillis();
+ }
+
+ public void delete() throws CoreException {
+ }
+
+ public boolean equals(Object object) {
+ return (this == object);
+ }
+
+ public boolean exists() {
+ return true;
+ }
+
+ public Object getAttribute(String attributeName) {
+ return attributes.get(attributeName);
+ }
+
+ public int getAttribute(String attributeName, int defaultValue) {
+ Integer loc = (Integer) getAttribute(attributeName);
+ if (loc != null) {
+ return loc.intValue();
+ }
+ return defaultValue;
+ }
+
+ public String getAttribute(String attributeName, String defaultValue) {
+ String result = (String) getAttribute(attributeName);
+ if (result != null) {
+ return result;
+ }
+ return defaultValue;
+ }
+
+ public boolean getAttribute(String attributeName, boolean defaultValue) {
+ Boolean result = (Boolean) getAttribute(attributeName);
+ if (result != null) {
+ return true;
+ }
+ return defaultValue;
+ }
+
+ public Map getAttributes() throws CoreException {
+ return attributes;
+ }
+
+ public Object[] getAttributes(String[] attributeNames) throws CoreException {
+ ArrayList results = new ArrayList();
+ for (int i = 0; i < attributeNames.length; i++) {
+ Object attribute = getAttribute(attributeNames[i]);
+ if (attribute != null) {
+ results.add(attribute);
+ }
+ }
+ return results.toArray();
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public IResource getResource() {
+ return resource;
+ }
+
+ public String getType() throws CoreException {
+ return type;
+ }
+
+ public boolean isSubtypeOf(String superType) throws CoreException {
+ return true;
+ }
+
+ public void setAttribute(String attributeName, Object value)
+ throws CoreException {
+ attributes.put(attributeName, value);
+ }
+
+ public void setAttribute(String attributeName, int value)
+ throws CoreException {
+ setAttribute(attributeName, new Integer(value));
+ }
+
+ public void setAttribute(String attributeName, boolean value)
+ throws CoreException {
+ setAttribute(attributeName, new Boolean(value));
+ }
+
+ public void setAttributes(String[] attributeNames, Object[] values)
+ throws CoreException {
+ for (int i = 0; i < attributeNames.length; i++) {
+ attributes.put(attributeNames[i], values[i]);
+ }
+ }
+
+ public void setAttributes(Map attributes) throws CoreException {
+ attributes = (HashMap) attributes;
+ }
+
+ public void setId(long i) {
+ id = i;
+ }
+
+}
Index: model/org/eclipse/cdt/internal/core/model/Parent.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Parent.java,v
retrieving revision 1.1
diff -u -r1.1 Parent.java
--- model/org/eclipse/cdt/internal/core/model/Parent.java 26 Jun 2002 20:37:14 -0000 1.1
+++ model/org/eclipse/cdt/internal/core/model/Parent.java 18 Nov 2002 15:35:01 -0000
@@ -82,7 +82,7 @@
return resource;
}
- public IResource getCorrespondingResource() throws CModelException {
+ public IResource getResource() throws CModelException {
return null;
}
Index: model/org/eclipse/cdt/internal/core/model/Resource.java
===================================================================
RCS file: model/org/eclipse/cdt/internal/core/model/Resource.java
diff -N model/org/eclipse/cdt/internal/core/model/Resource.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ model/org/eclipse/cdt/internal/core/model/Resource.java 18 Nov 2002 15:35:03 -0000
@@ -0,0 +1,503 @@
+package org.eclipse.cdt.internal.core.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.core.model.ICModelStatus;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+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.PlatformObject;
+import org.eclipse.core.runtime.QualifiedName;
+
+/**
+ */
+public abstract class Resource extends PlatformObject implements IResource {
+
+ ArrayList markers;
+ Map sessionProperties;
+ boolean readOnly;
+ boolean derived;
+ boolean teamPrivate;
+ long stamp;
+ boolean local;
+
+
+ /**
+ * @see org.eclipse.core.resources.IResource#accept(IResourceVisitor, int, boolean)
+ */
+ public void accept(IResourceVisitor visitor, int depth,
+ boolean includePhantoms) throws CoreException {
+ accept(visitor, depth, includePhantoms ? IContainer.INCLUDE_PHANTOMS : IResource.NONE);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#accept(IResourceVisitor)
+ */
+ public void accept(IResourceVisitor visitor) throws CoreException {
+ accept(visitor, IResource.NONE, IContainer.DEPTH_INFINITE);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#accept(IResourceVisitor, int, int)
+ */
+ public void accept(IResourceVisitor visitor, int depth, int memberFlags) throws CoreException {
+ final boolean includePhantoms = (memberFlags & IContainer.INCLUDE_PHANTOMS) != 0;
+ final boolean includeTeamPrivateMember =
+ (memberFlags & IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS) != 0;
+
+ // The INCLUDE_PHANTOMS flag is not specified and this resource does not exist.
+ if (!includePhantoms && !exists()) {
+ throw new CoreException(new CModelStatus(ICModelStatus.ERROR));
+ }
+
+ // The INCLUDE_PHANTOMS flag is not specified and this resource is
+ // a project that is not open.
+ if (!includePhantoms && !getProject().isOpen()) {
+ throw new CoreException(new CModelStatus(ICModelStatus.ERROR));
+ }
+
+ if ((!isPhantom() && !isTeamPrivateMember()) ||
+ (includePhantoms && isPhantom()) ||
+ (includeTeamPrivateMember && isTeamPrivateMember())) {
+ // If the visitor returns false, this resource's members are not visited.
+ if (!visitor.visit(this)) {
+ return;
+ }
+ }
+
+ // Full stop here.
+ if (depth == DEPTH_ZERO) {
+ return;
+ }
+
+ // Bail out here if not a container.
+ if (getType() == IResource.FILE) {
+ return;
+ }
+
+ // Advance.
+ if (depth == DEPTH_ONE) {
+ depth = DEPTH_ZERO;
+ }
+
+ IResource[] members = ((IContainer)this).members(memberFlags);
+ for (int i = 0; i < members.length; i++) {
+ members[i].accept(visitor, depth, memberFlags);
+ }
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#copy(IPath, boolean, IProgressMonitor)
+ */
+ public void copy(IPath destination, boolean force,
+ IProgressMonitor monitor) throws CoreException {
+ copy(destination, (force ? FORCE : IResource.NONE), monitor);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#copy(IProjectDescription, boolean, IProgressMonitor)
+ */
+ public void copy(IProjectDescription description, boolean force,
+ IProgressMonitor monitor) throws CoreException {
+ copy(description, (force ? FORCE : IResource.NONE), monitor);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#copy(IProjectDescription, int, IProgressMonitor)
+ */
+ public void copy(IProjectDescription description, int updateFlags,
+ IProgressMonitor monitor) throws CoreException {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject destProject = root.getProject(description.getName());
+ IPath destination = destProject.getFullPath();
+ copy(destination, updateFlags, monitor);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#copy(IPath, int, IProgressMonitor)
+ */
+ public void copy(IPath destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
+
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ int type = getType();
+ if (type == IResource.FILE) {
+ IFile oFile = (IFile)this;
+ IFile nFile = root.getFile(destination);
+ nFile.create(oFile.getContents(), updateFlags, monitor);
+ } else if (type == IResource.FOLDER) {
+ IFolder oFolder = (IFolder) this;
+ IFolder nFolder = root.getFolder(destination);
+ nFolder.create(updateFlags, true, monitor);
+ IResource[] children = oFolder.members(IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS);
+ for (int i = 0; i < children.length; i++) {
+ IResource child = children[i];
+ child.copy(destination.append(child.getName()), updateFlags, monitor);
+ }
+
+ }
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#delete(boolean, IProgressMonitor)
+ */
+ public void delete(boolean force, IProgressMonitor monitor) throws CoreException {
+ delete(force ? FORCE : IResource.NONE, monitor);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#move(IPath, boolean, IProgressMonitor)
+ */
+ public void move(IPath destination, boolean force, IProgressMonitor monitor)
+ throws CoreException {
+ move(destination, force ? FORCE : IResource.NONE, monitor);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#move(IProjectDescription, boolean, boolean, IProgressMonitor)
+ */
+ public void move(IProjectDescription description, boolean force, boolean keepHistory,
+ IProgressMonitor monitor) throws CoreException {
+ move(description, (keepHistory ? KEEP_HISTORY : IResource.NONE) | (force ? FORCE : IResource.NONE), monitor);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#move(IProjectDescription, int, IProgressMonitor)
+ */
+ public void move(IProjectDescription description, int updateFlags,
+ IProgressMonitor monitor) throws CoreException {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject destProject = root.getProject(description.getName());
+ IPath destination = destProject.getFullPath();
+ move(destination, updateFlags, monitor);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#move(IPath, int, IProgressMonitor)
+ */
+ public void move(IPath destination, int updateFlags, IProgressMonitor monitor)
+ throws CoreException {
+ // FIXME: this is not atomic.
+ copy(destination, updateFlags, monitor);
+ delete(updateFlags, monitor);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#createMarker(String)
+ */
+ public IMarker createMarker(String type) throws CoreException {
+ IMarker marker = new Marker(this, type);
+ if (markers == null) {
+ markers = new ArrayList();
+ }
+ markers.add(marker);
+ return marker;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#deleteMarkers(String, boolean, int)
+ */
+ public void deleteMarkers(String type, boolean includeSubtypes, int depth)
+ throws CoreException {
+ if (markers != null) {
+ markers.clear();
+ }
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#findMarker(long)
+ */
+ public IMarker findMarker(long id) throws CoreException {
+ if (markers != null) {
+ for (int i = 0; i < markers.size(); i++) {
+ IMarker marker = (IMarker)markers.get(i);
+ if (marker.getId() == id) {
+ return marker;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#findMarkers(String, boolean, int)
+ */
+ public IMarker[] findMarkers(String type, boolean includeSubtypes,
+ int depth) throws CoreException {
+ if (markers != null) {
+ ArrayList aList = new ArrayList();
+ for (int i = 0; i < markers.size(); i++) {
+ IMarker marker = (IMarker)markers.get(i);
+ if (marker.getType().equals(type)) {
+ aList.add(marker);
+ }
+ }
+
+ return (IMarker[]) aList.toArray(new IMarker[0]);
+ }
+ return new IMarker[0];
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getMarker(long)
+ */
+ public IMarker getMarker(long id) {
+ try {
+ IMarker marker = findMarker(id);
+ if (marker != null) {
+ return marker;
+ }
+ } catch (CoreException e) {
+ }
+ Marker marker = new Marker(this, "");
+ marker.setId(id);
+ return marker;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getSessionProperty(QualifiedName)
+ */
+ public Object getSessionProperty(QualifiedName key) throws CoreException {
+ if (sessionProperties != null) {
+ return sessionProperties.get(key);
+ }
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#setSessionProperty(QualifiedName, Object)
+ */
+ public void setSessionProperty(QualifiedName key, Object value)
+ throws CoreException {
+ if (sessionProperties == null) {
+ sessionProperties = new HashMap(5);
+ }
+ sessionProperties.put(key, value);
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getFileExtension()
+ */
+ public String getFileExtension() {
+ return getFullPath().getFileExtension();
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getLocation()
+ */
+ public IPath getLocation() {
+ return getProject().getLocation().append(getFullPath());
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getName()
+ */
+ public String getName() {
+ return getFullPath().lastSegment();
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getProject()
+ */
+ public IProject getProject() {
+ return getParent().getProject();
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getProjectRelativePath()
+ */
+ public IPath getProjectRelativePath() {
+ return getFullPath().removeFirstSegments(getProject().getFullPath().segmentCount());
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getWorkspace()
+ */
+ public IWorkspace getWorkspace() {
+ return getProject().getWorkspace();
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#clearHistory(IProgressMonitor)
+ */
+ public void clearHistory(IProgressMonitor monitor) throws CoreException {
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#isAccessible()
+ */
+ public boolean isAccessible() {
+ int type = getType();
+ if (type == IResource.FILE || type == IResource.FOLDER) {
+ return exists();
+ } else if (type == IResource.PROJECT) {
+ IProject project = (IProject)this;
+ return exists() && project.isOpen();
+ } else if (type == IResource.ROOT) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#isDerived()
+ */
+ public boolean isDerived() {
+ return derived;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#isLocal(int)
+ */
+ public boolean isLocal(int depth) {
+ return !isPhantom();
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#isPhantom()
+ */
+ public boolean isPhantom() {
+ return !exists();
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#isReadOnly()
+ */
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#isSynchronized(int)
+ */
+ public boolean isSynchronized(int depth) {
+ if (getType() == IResource.ROOT) {
+ if (depth == IResource.DEPTH_ZERO) {
+ return true;
+ }
+
+ if (depth == IResource.DEPTH_ONE) {
+ depth = IResource.DEPTH_ZERO;
+ }
+
+ IProject[] projects = ((IWorkspaceRoot)this).getProjects();
+ for (int i = 0; i < projects.length; i++) {
+ if (projects[i].isSynchronized(depth))
+ return false;
+ }
+ return true;
+
+ }
+ return exists();
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#isTeamPrivateMember()
+ */
+ public boolean isTeamPrivateMember() {
+ return teamPrivate;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#setDerived(boolean)
+ */
+ public void setDerived(boolean isDerived) throws CoreException {
+ derived = isDerived;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#setLocal(boolean, int, IProgressMonitor)
+ */
+ public void setLocal(boolean flag, int depth, IProgressMonitor monitor)
+ throws CoreException {
+ local = flag;
+ if (getType() == IResource.FILE || depth == IResource.DEPTH_ZERO) {
+ return;
+ }
+ if (depth == IResource.DEPTH_ONE)
+ depth = IResource.DEPTH_ZERO;
+ IResource[] children = ((IContainer) this).members();
+ for (int i = 0; i < children.length; i++) {
+ children[i].setLocal(flag, depth, monitor);
+ }
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#setReadOnly(boolean)
+ */
+ public void setReadOnly(boolean read) {
+ this.readOnly = read;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#setTeamPrivateMember(boolean)
+ */
+ public void setTeamPrivateMember(boolean isTeamPrivate)
+ throws CoreException {
+ teamPrivate = isTeamPrivate;
+ }
+
+ /**
+ * @see org.eclipse.core.resources.IResource#exists()
+ */
+ public abstract boolean exists();
+
+ /**
+ * @see org.eclipse.core.resources.IResource#refreshLocal(int, IProgressMonitor)
+ */
+ public abstract void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException;
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getFullPath()
+ */
+ public abstract IPath getFullPath();
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getParent()
+ */
+ public abstract IContainer getParent();
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getType()
+ */
+ public abstract int getType();
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getModificationStamp()
+ */
+ public abstract long getModificationStamp();
+
+ /**
+ * @see org.eclipse.core.resources.IResource#delete(int, IProgressMonitor)
+ */
+ public abstract void delete(int updateFlags, IProgressMonitor monitor) throws CoreException;
+
+ /**
+ * @see org.eclipse.core.resources.IResource#touch(IProgressMonitor)
+ */
+ public abstract void touch(IProgressMonitor monitor) throws CoreException;
+
+ /**
+ * @see org.eclipse.core.resources.IResource#setPersistentProperty(QualifiedName, String)
+ */
+ public abstract void setPersistentProperty(QualifiedName key, String value) throws CoreException;
+
+ /**
+ * @see org.eclipse.core.resources.IResource#getPersistentProperty(QualifiedName)
+ */
+ public abstract String getPersistentProperty(QualifiedName key) throws CoreException;
+
+
+}
Index: model/org/eclipse/cdt/internal/core/model/SourceManipulation.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceManipulation.java,v
retrieving revision 1.1
diff -u -r1.1 SourceManipulation.java
--- model/org/eclipse/cdt/internal/core/model/SourceManipulation.java 26 Jun 2002 20:37:14 -0000 1.1
+++ model/org/eclipse/cdt/internal/core/model/SourceManipulation.java 18 Nov 2002 15:35:02 -0000
@@ -126,6 +126,10 @@
return getParent().getUnderlyingResource();
}
+ public IResource getResource() throws CModelException {
+ return null;
+ }
+
protected CElementInfo createElementInfo () {
return new SourceManipulationInfo(this);
}
Index: model/org/eclipse/cdt/internal/core/model/TranslationUnitInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnitInfo.java,v
retrieving revision 1.1
diff -u -r1.1 TranslationUnitInfo.java
--- model/org/eclipse/cdt/internal/core/model/TranslationUnitInfo.java 26 Jun 2002 20:37:14 -0000 1.1
+++ model/org/eclipse/cdt/internal/core/model/TranslationUnitInfo.java 18 Nov 2002 15:35:06 -0000
@@ -20,17 +20,6 @@
class TranslationUnitInfo extends CFileInfo {
- /**
- * The length of this compilation unit's source code <code>String</code>
- */
- protected int fSourceLength;
-
- /**
- * Timestamp of original resource at the time this element
- * was opened or last updated.
- */
- protected long fTimestamp;
-
protected TranslationUnitInfo (CElement element) {
super(element);
}