1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 08:46:02 +02:00

Initial commit of CDT code from QNX

This commit is contained in:
Sebastien Marineau 2002-06-26 20:39:58 +00:00
parent db3c6a4470
commit e0fe72f58c
206 changed files with 32324 additions and 0 deletions

View file

@ -0,0 +1 @@
bin

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.core</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,10 @@
################################################
#
# (c) Copyright QNX Software Systems Ltd. 2002.
# All Rights Reserved.
#
################################################
source.cdt.jar = builder,\
index,\
model,\
src

View file

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="org.eclipse.cdt.core" default="plugin.zip" basedir=".">
<target name="init">
<initTemplate/>
<property name="plugin" value="org.eclipse.cdt.core"/>
<property name="version" value="0.5.4"/>
</target>
<target name="plugin.zip" depends="init">
<property name="destroot" value="${basedir}/_temp___"/>
<delete dir="${destroot}"/>
<mkdir dir="${destroot}"/>
<antcall target="jar"/>
<antcall target="bin"/>
<zip zipfile="${plugin}_${version}.zip" basedir="${destroot}"/>
<delete dir="${destroot}"/>
</target>
<target name="cdt.jar" depends="init">
<property name="out" value="${basedir}/cdt.jar.bin"/>
<delete dir="${out}"/>
<mkdir dir="${out}"/>
<ant antfile="${template}" target="jar">
<property name="includes" value="CDTPlugin/"/>
<property name="excludes" value=""/>
<property name="compilePath" value="/export/WebSphere/eclipse/plugins/org.eclipse.core.boot/bin;/export/WebSphere/eclipse/plugins/org.eclipse.jdt.debug/jdimodel.jar;/export/WebSphere/eclipse/plugins/org.eclipse.ui/workbench.jar;/export/WebSphere/eclipse/plugins/org.eclipse.jdt.core/bin;/export/WebSphere/eclipse/plugins/org.eclipse.help/bin;/export/WebSphere/eclipse/plugins/org.eclipse.ui/bin;/export/WebSphere/eclipse/plugins/org.eclipse.debug.ui/dtui.jar;/export/WebSphere/eclipse/plugins/org.eclipse.jdt.launching/bin;/export/WebSphere/eclipse/plugins/org.apache.xerces/bin;/export/WebSphere/eclipse/plugins/org.eclipse.compare/bin;/export/WebSphere/eclipse/plugins/org.eclipse.swt/bin;/export/WebSphere/eclipse/plugins/org.eclipse.jdt.ui/bin;/export/WebSphere/eclipse/plugins/org.eclipse.jdt.core/jdtcore.jar;/export/WebSphere/eclipse/plugins/org.eclipse.debug.core/dtcore.jar;/export/WebSphere/eclipse/plugins/org.apache.xerces/xerces.jar;/export/WebSphere/eclipse/plugins/org.eclipse.jdt.debug/bin;/export/WebSphere/eclipse/plugins/org.eclipse.help/help.jar;/export/WebSphere/eclipse/plugins/org.eclipse.search/bin;/export/WebSphere/eclipse/plugins/org.eclipse.jdt.ui/jdt.jar;/export/WebSphere/eclipse/plugins/org.eclipse.swt/swt.jar;/export/WebSphere/eclipse/plugins/org.eclipse.core.runtime/runtime.jar;/export/WebSphere/eclipse/plugins/org.eclipse.core.resources/resources.jar;/export/WebSphere/eclipse/plugins/org.eclipse.core.runtime/bin;/export/WebSphere/eclipse/plugins/org.eclipse.jdt.debug/jdi.jar;/export/WebSphere/eclipse/plugins/org.eclipse.debug.core/bin;/export/WebSphere/eclipse/plugins/org.eclipse.jdt.launching/launching.jar;/export/WebSphere/eclipse/plugins/org.eclipse.core.boot/boot.jar;/export/WebSphere/eclipse/plugins/org.eclipse.search/search.jar;/export/WebSphere/eclipse/plugins/org.eclipse.debug.ui/bin;/export/WebSphere/eclipse/plugins/org.eclipse.compare/compare.jar;/export/WebSphere/eclipse/plugins/org.eclipse.core.resources/bin"/>
</ant>
<copy todir="${out}">
<fileset dir="CDTPlugin">
<include name="**"/>
<exclude name="**/*.java"/>
</fileset>
</copy>
<property name="dest" value="${destroot}/plugins/${plugin}_${version}"/>
<jar jarfile="cdt.jar" basedir="${out}"/>
<delete dir="${out}"/>
</target>
<target name="jar" depends="init,cdt.jar">
</target>
<target name="cdt.src" depends="init">
<property name="auto.includes" value="CDTPlugin/**/*.java"/>
<property name="auto.excludes" value=""/>
<ant antfile="${template}" target="src">
<property name="includes" value="${auto.includes}"/>
<property name="excludes" value="${auto.excludes}"/>
<property name="dest" value="${destroot}/plugins/${plugin}_${version}"/>
</ant>
</target>
<target name="src" depends="init,cdt.src">
</target>
<target name="bin" depends="init">
<property name="auto.includes" value="**"/>
<property name="auto.excludes" value="CDTPlugin/"/>
<ant antfile="${template}" target="bin">
<property name="includes" value="${auto.includes}"/>
<property name="excludes" value="${auto.excludes}"/>
<property name="dest" value="${destroot}/plugins/${plugin}_${version}"/>
</ant>
</target>
<target name="log" depends="init">
<ant antfile="${template}" target="log">
<property name="dest" value="${destroot}/plugins/${plugin}_${version}"/>
</ant>
</target>
<target name="clean" depends="init">
<ant antfile="${template}" target="clean">
<property name="jar" value="cdt.jar"/>
<property name="srczips" value="cdtsource.jar"/>
</ant>
<delete file="${plugin}_${version}.zip"/>
</target>
</project>

View file

@ -0,0 +1,113 @@
package org.eclipse.cdt.core.builder;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
public class BuilderModel {
private static BuilderModel buildModel = null;
public final static String PLUGIN_ID = "org.eclipse.cdt.core";
public final static String BUILDER_NAME = "cbuilder";
public final static String BUILDER_ID = PLUGIN_ID + "." + BUILDER_NAME;
public static String getBuilderName () {
return BUILDER_NAME;
}
public static String getBuilderId () {
return BUILDER_ID;
}
public IBuildPath getBuildPath(IProject project) {
return null;
}
public void setBuildPath(IProject project, IBuildPath bp) {
}
public void addBuildListener () {
}
public void removeBuildListener() {
}
public void build(IProject project, IPath workingDir, String[] args) {
}
/**
* Adds default C Builder.
*/
public void addCToBuildSpec(IProject project) throws CoreException {
addToBuildSpec(project, getBuilderId());
}
/**
* Adds a builder to the build spec for the given project.
*/
public void addToBuildSpec(IProject project, String builderID) throws CoreException {
IProjectDescription description = project.getDescription();
ICommand[] commands = description.getBuildSpec();
ICommand command = null;
for (int i = 0; i < commands.length; i++) {
if (commands[i].getBuilderName().equals(builderID)) {
command = commands[i];
break;
}
}
if (command == null) {
command = description.newCommand();
command.setBuilderName(builderID);
// Add a build spec before other builders (1FWJK7I)
ICommand[] newCommands = new ICommand[commands.length + 1];
System.arraycopy(commands, 0, newCommands, 1, commands.length);
newCommands[0] = command;
// Commit the spec change into the project
description.setBuildSpec(newCommands);
project.setDescription(description, null);
}
}
/**
* Removes the default C Builder.
*/
public void removeCFromBuildSpec(IProject project) throws CoreException {
removeFromBuildSpec(project, getBuilderId());
}
/**
* Removes the given builder from the build spec for the given project.
*/
public void removeFromBuildSpec(IProject project, String builderID) throws CoreException {
IProjectDescription description = project.getDescription();
ICommand[] commands = description.getBuildSpec();
for (int i = 0; i < commands.length; ++i) {
if (commands[i].getBuilderName().equals(builderID)) {
ICommand[] newCommands = new ICommand[commands.length - 1];
System.arraycopy(commands, 0, newCommands, 0, i);
System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1);
description.setBuildSpec(newCommands);
project.setDescription(description, null);
}
}
}
private BuilderModel() {
}
public static BuilderModel getDefault() {
if (buildModel == null) {
buildModel = new BuilderModel();
}
return buildModel;
}
}

View file

@ -0,0 +1,91 @@
package org.eclipse.cdt.core.builder;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.core.runtime.IPath;
/**
* A BuildPath can contain the following:<ul>
* <li> EXTRA_INCVPATH: a list of path to look for include files
* <li> EXTRA_LIBVPATH: a list of path to search for libraries
* <li> EXTRA_SRCVPATH: a list of path to search for files
* <li> LIBS: a list of libraries to link
* <li> CPPFLAGS: C Preprocessor options
* <li> CPP: C Preprocessor cmd
* <li> CFLAGS: C options
* <li> CC: C cmd
* <li> CXXFLAGS: C++ Preprocessor options
* <li> CXX: C++ cmd
* <li> ARFLAGS: archive options
* <li> AR: archiver cmd
* <li> LDFLAGS: linker options
* <li> LD: linker cmd
* <li> ASFLAGS: assembly options
* <li> AS: assembly cmd
* </ul>
*/
public interface IBuildPath {
public String[] getCPPOpts();
public String[] getCPPFlags();
public void setCPP(IPath p);
public void setCPPOpts(String[] s);
public void setCPPFlags(String[] s);
public IPath getCXX();
public String[] getCXXOPT();
public String[] getCXXFlags();
public void setCXX(IPath p);
public void setCXXOpts(String[] s);
public void setCXXFlags(String[] s);
public IPath getCC();
public String[] getCFLAGS();
public String[] getCOpts();
public void setCFLAGS(String[] s);
public void setCOpts(String[] s);
public void setCC(IPath p);
public IPath getAS();
public String[] getASFlags();
public String[] getASOpts();
public void getAS(IPath p);
public void getASOpts(String[] s);
public void getASFlags(String[] s);
public IPath getLD();
public String[] getLDOpts();
public String[] getLDFlags();
public void setLD(IPath p);
public void setLDOpts(String[] s);
public void setLDFlags(String[] s);
public IPath getAR();
public String[] getARFlags();
public String[] getAROpts();
public void setAR(IPath p);
public void setAROpts(String[] s);
public void setARFlags(String[] s);
public IPath[] getIncVPath();
public void setIncVPath(IPath[] p);
public IPath[] getLibs();
public void setLibs(IPath[] p);
public IPath[] getLibVPath();
public void setLibVPath(IPath[] p);
public IPath[] getSRCVPath();
public void setSRCVPath(IPath[] p);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View file

@ -0,0 +1,78 @@
package org.eclipse.cdt.core.index;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.core.resources.IFile;
public interface ITagEntry {
/**
* Name of tag.
*/
public String getTagName();
/**
* Path of source file containing definition of tag.
*/
public String getFileName();
/**
* IFile of source file containing definition of tag.
*/
public IFile getIFile();
/**
* Address for locating tag in source file
* (may be null if not present).
*/
public String getPattern();
/**
* line number in source file of tag definition
* (may be zero if not known).
*/
public int getLineNumber();
/**
* Kind of tag.
*/
public int getKind();
/**
* Language of the file.
*/
public String getLanguage();
/**
* Is tag of file-limited scope?
*/
public boolean hasFileScope();
/**
* Return base classes.
*/
public String[] getInherits();
/**
* Access Control of structure/class/union members.
*/
public int getAccessControl();
// implementation:
public int getImplementation();
/**
* Class name of the tag if a member,
* null if not a member of a struct/class/union.
*/
public String getClassName();
/**
* Return the original tag line.
*/
public String getLine();
}

View file

@ -0,0 +1,62 @@
package org.eclipse.cdt.core.index;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.cdt.internal.core.index.IndexManager;
public class IndexModel {
static IndexModel indexModel = null;
static IndexManager manager = null;
/**
* Search Project for tag symbol.
*/
public ITagEntry[] query (IProject project, String tag) {
return manager.query(project, tag, true, false);
}
/**
* Search Project for tag symbol.
*/
public ITagEntry[] query (IProject project, String tag, boolean ignoreCase, boolean exactMatch) {
return manager.query(project, tag, ignoreCase, exactMatch);
}
/**
* Add a resource to be index. Containers(Folder, projects)
* resources are recusively search for C Files as define by
* CoreModel.isTranslationUnit().
*/
public void addResource(IResource resource) {
manager.addResource(resource);
}
/**
* Add all the C files recurively going to all projects
* identified as C Projects by CoreModel.
*/
public void addAll () {
manager.addAll();
}
/**
* Initialize default index Model.
*/
public static IndexModel getDefault() {
if (indexModel == null) {
indexModel = new IndexModel();
manager = IndexManager.getDefault();
}
return indexModel;
}
private IndexModel () {
}
}

View file

@ -0,0 +1,179 @@
package org.eclipse.cdt.core.index;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
public class TagFlags {
public final static int T_UNKNOWN = 0;
public final static int T_CLASS = 1;
public final static int T_MACRO = 2;
public final static int T_ENUMERATOR = 3;
public final static int T_FUNCTION = 4;
public final static int T_ENUM = 5;
public final static int T_MEMBER = 6;
public final static int T_NAMESPACE = 7;
public final static int T_PROTOTYPE = 8;
public final static int T_STRUCT = 9;
public final static int T_TYPEDEF = 10;
public final static int T_UNION = 11;
public final static int T_VARIABLE = 12;
public final static int T_EXTERNVAR = 13;
public final static int T_PRIVATE = 14;
public final static int T_PROTECTED = 15;
public final static int T_PUBLIC = 16;
public final static int T_FRIEND = 17;
public final static int T_VIRTUAL = 18;
public final static int T_ABSTRACT = 19;
private TagFlags() {
}
public static boolean isUnknown(int k) {
return k == T_UNKNOWN;
}
public static boolean isClass(int k) {
return k == T_CLASS;
}
public static boolean isMacro(int k) {
return k == T_MACRO;
}
public static boolean isEnumerator(int k) {
return k == T_ENUMERATOR;
}
public static boolean isFunction(int k) {
return k == T_FUNCTION;
}
public static boolean isEnum(int k) {
return k == T_ENUM;
}
public static boolean isMember(int k) {
return k == T_MEMBER;
}
public static boolean isNamespace(int k) {
return k == T_NAMESPACE;
}
public static boolean isPrototype(int k) {
return k == T_PROTOTYPE;
}
public static boolean isStruct(int k) {
return k == T_STRUCT;
}
public static boolean isTypedef(int k) {
return k == T_TYPEDEF;
}
public static boolean isUnion(int k) {
return k == T_UNION;
}
public static boolean isVariable(int k) {
return k == T_VARIABLE;
}
public static boolean isExternVar(int k) {
return k == T_EXTERNVAR;
}
public static int value(String flag) {
if (flag == null) {
return T_UNKNOWN;
} else if (flag.equals("class")) {
return T_CLASS;
} else if (flag.equals("macro")) {
return T_MACRO;
} else if (flag.equals("enumerator")) {
return T_ENUMERATOR;
} else if (flag.equals("function")) {
return T_FUNCTION;
} else if (flag.equals("enum")) {
return T_ENUM;
} else if (flag.equals("member")) {
return T_MEMBER;
} else if (flag.equals("namespace")) {
return T_NAMESPACE;
} else if (flag.equals("prototype")) {
return T_PROTOTYPE;
} else if (flag.equals("struct")) {
return T_STRUCT;
} else if (flag.equals("typedef")) {
return T_TYPEDEF;
} else if (flag.equals("union")) {
return T_UNION;
} else if (flag.equals("variable")) {
return T_VARIABLE;
} else if (flag.equals("externvar")) {
return T_EXTERNVAR;
} else if (flag.equals("public")) {
return T_PUBLIC;
} else if (flag.equals("private")) {
return T_PRIVATE;
} else if (flag.equals("protected")) {
return T_PROTECTED;
} else if (flag.equals("virtual")) {
return T_VIRTUAL;
} else if (flag.equals("abstract")) {
return T_ABSTRACT;
} else if (flag.equals("friend")) {
return T_FRIEND;
}
return T_UNKNOWN;
}
public static String value(int flag) {
if (flag == T_CLASS) {
return "class";
} else if (flag == T_MACRO) {
return "macro";
} else if (flag == T_ENUMERATOR) {
return "enumerator";
} else if (flag == T_FUNCTION) {
return "function";
} else if (flag == T_ENUM) {
return "enum";
} else if (flag == T_MEMBER) {
return "member";
} else if (flag == T_NAMESPACE) {
return "namespace";
} else if (flag == T_PROTOTYPE) {
return "prototype";
} else if (flag == T_STRUCT) {
return "struct";
} else if (flag == T_TYPEDEF) {
return "typedef";
} else if (flag == T_UNION) {
return "union";
} else if (flag == T_VARIABLE) {
return "variable";
} else if (flag == T_EXTERNVAR) {
return "externvar";
} else if (flag == T_PUBLIC) {
return "public";
} else if (flag == T_PRIVATE) {
return "private";
} else if (flag == T_PROTECTED) {
return "protected";
} else if (flag == T_VIRTUAL) {
return "virtual";
} else if (flag == T_ABSTRACT) {
return "abstract";
} else if (flag == T_FRIEND) {
return "friend";
}
return null;
}
}

View file

@ -0,0 +1,83 @@
package org.eclipse.cdt.internal.core.index;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.cdt.core.index.ITagEntry;
import org.eclipse.cdt.utils.spawner.ProcessFactory;
public class CTagsCmd {
public CTagsCmd() {
}
private void process(String filename, List list, IFile file) throws IOException {
BufferedReader stdout;
String[] args = {"ctags", "--excmd=pattern", "--format=2",
"--if0=yes", "--sort=no", "--extra=q",
"--fields=aiKlmnsz", "--line-directives=yes",
"--sort=no", "--kind-long", "--c-types=cdefgmnpstuvx",
"-f", "-", filename};
//Process ctags = Runtime.getRuntime().exec(args);
Process ctags = ProcessFactory.getFactory().exec(args);
//stdin = new BufferedWriter(new OutputStreamWriter(ctags.getOutputStream()));
stdout = new BufferedReader(new InputStreamReader(ctags.getInputStream()));
//System.out.println("Processing");
String line;
try {
while ((line = stdout.readLine()) != null) {
//System.out.println("ProcessingLine " + line);
CTagsEntry entry = new CTagsEntry(line, file);
list.add(entry);
}
} catch (IOException e) {
//e.printStackTrace();
}
// Force an explicit close even if
// we call destroy()
try {
stdout.close();
ctags.getOutputStream().close();
ctags.getErrorStream().close();
} catch (IOException e) {
}
ctags.destroy();
}
public ITagEntry[] getTagEntries(IFile file, String filename) throws IOException {
List list = new LinkedList();
process(filename, list, file);
return (ITagEntry[])list.toArray(new ITagEntry[0]);
}
public static void main(String[] args) {
try {
CTagsCmd cmd = new CTagsCmd();
ITagEntry[] entries = cmd.getTagEntries(null, args[0]);
for (int i = 0; i < entries.length; i++) {
if (entries[i] instanceof CTagsEntry) {
CTagsEntry entry = (CTagsEntry)entries[i];
System.out.println(entry.getLine() + "\n");
entry.print();
System.out.println("\n");
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,272 @@
package org.eclipse.cdt.internal.core.index;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;
import org.eclipse.core.resources.IFile;
import org.eclipse.cdt.core.index.ITagEntry;
import org.eclipse.cdt.core.index.TagFlags;
public class CTagsEntry implements ITagEntry {
final static String TAB_SEPARATOR = "\t";
final static String PATTERN_SEPARATOR = ";\"";
final static String LANGUAGE = "language";
final static String KIND = "kind";
final static String LINE = "line";
final static String FILE = "file";
final static String INHERITS = "inherits";
final static String ACCESS = "access";
final static String IMPLEMENTATION = "implementation";
final static String CLASS = "class";
final String[] NONE = new String[0];
String tagName;
/* Path of source file containing definition of tag. */
String fileName;
/* IFile of parsed file */
IFile file;
/* pattern for locating source line
* (may be NULL if not present) */
String pattern;
int lineNumber;
/* Miscellaneous extension fields */
HashMap tagExtensionField;
String line;
public CTagsEntry(String line, IFile file) {
this.line = line;
this.file = file;
tagName = "";
fileName ="";
pattern = null;
lineNumber = 0;
tagExtensionField = new HashMap();
parse();
}
void parse () {
String delim = TAB_SEPARATOR;
StringTokenizer st = new StringTokenizer(line, delim);
for (int state = 0; st.hasMoreTokens(); state++) {
String token = st.nextToken(delim);
switch (state) {
case 0: // TAG_NAME:
tagName = token;
break;
case 1: // FILE_NAME:
fileName = token;
delim = PATTERN_SEPARATOR;
break;
case 2: // PATTERN;
try {
String sub = token.substring(1);
if (Character.isDigit(sub.charAt(0))) {
lineNumber = Integer.parseInt(sub);
} else {
// Filter out the delimiters
int i = sub.indexOf("/^");
int j = sub.lastIndexOf("$/");
try {
if(i >= 0 && j >= 0 ) {
sub = sub.substring(i + 2, j);
} else if(i >= 0) {
sub = sub.substring(i + 2, sub.length()-1);
}
} catch (Exception e) {}
pattern = sub;
}
} catch (NumberFormatException e) {
//e.printStackTrace();
} catch (IndexOutOfBoundsException e) {
//e.printStackTrace();
}
delim = TAB_SEPARATOR;
break;
default: // EXTENSION_FIELDS:
int i = token.indexOf(':');
if (i != -1) {
String key = token.substring(0, i);
String value = token.substring(i + 1);
tagExtensionField.put(key, value);
}
break;
}
}
}
public String getTagName () {
return tagName;
}
public String getFileName() {
return fileName;
}
public IFile getIFile() {
return file;
}
public String getPattern() {
return pattern;
}
// line:
public int getLineNumber() {
try {
String sub = (String)tagExtensionField.get(LINE);
if (sub != null) {
lineNumber = Integer.parseInt(sub);
}
} catch (NumberFormatException e) {
//System.out.println(e);
}
return lineNumber;
}
// kind:
public int getKind() {
String kind = (String)tagExtensionField.get(KIND);
return TagFlags.value(kind);
}
// language:
public String getLanguage() {
return (String)tagExtensionField.get(LANGUAGE);
}
// Implementation:
public int getImplementation() {
String impl = (String)tagExtensionField.get(IMPLEMENTATION);
return TagFlags.value(impl);
}
// Class:
public String getClassName() {
return (String)tagExtensionField.get(CLASS);
}
// file:
public boolean hasFileScope() {
return (tagExtensionField.get(FILE) != null);
}
// inherits:
public String[] getInherits() {
String base = (String)tagExtensionField.get(INHERITS);
if (base != null) {
StringTokenizer st = new StringTokenizer(base, ",");
List list = new ArrayList();
while (st.hasMoreTokens()) {
list.add(st.nextToken());
}
return (String[])list.toArray(new String[0]);
}
return NONE;
}
// access:
public int getAccessControl() {
String access = (String)tagExtensionField.get(ACCESS);
return TagFlags.value(access);
}
public String getLine() {
return line;
}
public static String makeTagLine(ITagEntry tagEntry) {
StringBuffer buffer = new StringBuffer();
buffer.append(tagEntry.getTagName());
buffer.append("\t");
buffer.append(tagEntry.getFileName());
buffer.append("\t");
String pat = tagEntry.getPattern();
if (pat != null) {
buffer.append(pat);
} else {
buffer.append(tagEntry.getLineNumber());
}
buffer.append(";\"");
buffer.append("\t");
String kind = TagFlags.value(tagEntry.getKind());
if (kind != null) {
buffer.append(KIND + ":" + tagEntry.getKind());
buffer.append("\t");
}
String lang = tagEntry.getLanguage();
if (lang != null) {
buffer.append(LANGUAGE + ":" + tagEntry.getLanguage());
buffer.append("\t");
}
if (tagEntry.hasFileScope()) {
buffer.append(FILE + ":");
buffer.append("\t");
}
String[] inherits = tagEntry.getInherits();
for (int i = 0; i < inherits.length; i++) {
if (i == 0) {
buffer.append(INHERITS + ":");
} else {
buffer.append(",");
}
buffer.append(inherits[i]);
}
String access = TagFlags.value(tagEntry.getAccessControl());
if (access != null) {
buffer.append(ACCESS + ":" + access);
buffer.append("\t");
}
String impl = TagFlags.value(tagEntry.getImplementation());
if (impl != null) {
buffer.append(IMPLEMENTATION + ":" + impl);
buffer.append("\t");
}
String clazz = tagEntry.getClassName();
if (clazz != null) {
buffer.append(CLASS + ":" + clazz);
buffer.append("\t");
}
return buffer.toString().trim();
}
public void print() {
System.out.println("TagName " + getTagName());
System.out.println("FileName " + getFileName());
System.out.println("Pattern " + getPattern());
System.out.println("LineNumber " + getLineNumber());
System.out.println("Kind " + getKind());
System.out.println("Language " + getLanguage());
System.out.println("FileScope " + hasFileScope());
String[] inherits = getInherits();
for (int i = 0; i < inherits.length; i++) {
System.out.println("Inherit " + inherits[i]);
}
System.out.println("AccessControl " + getAccessControl());
System.out.println("Implementation " + getImplementation());
System.out.println("ClassName " + getClassName());
}
}

View file

@ -0,0 +1,62 @@
package org.eclipse.cdt.internal.core.index;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.cdt.core.index.ITagEntry;
public class CTagsFileReader {
String filename = null;
List list = null;
public CTagsFileReader(String name) {
filename = name;
}
private void parse(BufferedReader reader) throws IOException {
CTagsHeader header = new CTagsHeader();
// Skip the header.
header.parse(reader);
String s;
while ((s = reader.readLine()) != null) {
ITagEntry entry = new CTagsEntry(s, null);
list.add(entry);
// System.out.println (entry.getLine() + "\n\n");
// entry.print(); System.out.println();
}
}
public ITagEntry[] getTagEntries() throws IOException {
if (list == null) {
list = new LinkedList();
BufferedReader reader = new BufferedReader(new FileReader(filename));
parse(reader);
}
return (ITagEntry[])list.toArray(new ITagEntry[0]);
}
public static void main(String[] args) {
try {
CTagsFileReader tagfile = new CTagsFileReader(args[0]);
ITagEntry[] entries = tagfile.getTagEntries();
for (int i = 0; i < entries.length; i++) {
if (entries[i] instanceof CTagsEntry) {
CTagsEntry entry = (CTagsEntry)entries[i];
System.out.println(entry.getLine() + "\n\n");
entry.print();
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,61 @@
package org.eclipse.cdt.internal.core.index;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import org.eclipse.cdt.core.index.ITagEntry;
public class CTagsFileWriter {
BufferedWriter writer = null;
ITagEntry [] entries = null;
public CTagsFileWriter(String tagfile) throws IOException {
writer = new BufferedWriter(new FileWriter(tagfile));
}
public CTagsFileWriter(Writer outfile) {
writer = new BufferedWriter(outfile);
}
public void save(ITagEntry[] ent) throws IOException {
setTagEntries(ent);
save();
}
public void save() throws IOException {
if (entries != null) {
String header = CTagsHeader.header();
writer.write(header, 0, header.length());
for (int i = 0; i < entries.length; i++) {
String entry = entries[i].getLine();
writer.write(entry, 0, entry.length());
writer.newLine();
}
writer.flush();
entries = null;
}
}
public void setTagEntries(ITagEntry[] ent) {
entries = ent;
}
public static void main(String[] args) {
try {
CTagsFileReader inFile = new CTagsFileReader(args[0]);
ITagEntry[] entries = inFile.getTagEntries();
CTagsFileWriter outFile = new CTagsFileWriter(args[0] + ".back");
outFile.save(entries);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,96 @@
package org.eclipse.cdt.internal.core.index;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import java.io.IOException;
import java.io.BufferedReader;
/* This structure contains information about the tag file. */
public class CTagsHeader {
final static String TAG_FILE_FORMAT =
"!_TAG_FILE_FORMAT\t2\t/extended format; --format=1 will not append ;\" to lines/";
final static String TAG_FILE_SORTED =
"!_TAG_FILE_SORTED\t0\t/0=unsorted, 1=sorted/";
final static String TAG_PROGRAM_AUTHOR =
"!_TAG_PROGRAM_AUTHOR\tDarren Hiebert\t/dhiebert@users.sourceforge.net/";
final static String TAG_PROGRAM_NAME =
"!_TAG_PROGRAM_NAME\tExuberant Ctags\t//";
final static String TAG_PROGRAM_URL =
"!_TAG_PROGRAM_URL\thttp://ctags.sourceforge.net\t/official site/";
final static String TAG_PROGRAM_VERSION =
"!_TAG_PROGRAM_VERSION\t5.2.3\t//";
/* information about the structure of the tag file */
final String TAGS_PREFIX = "!_";
/* Format of tag file (1 = original, 2 = extended) */
String format;
/* Is the tag file sorted? (0 = unsorted, 1 = sorted) */
String sorted;
/* Information about the program which created this tag file */
/* Name of author of generating program (may be null) */
String author;
/* Name of program (may be null) */
String name;
/* URL of distribution (may be null) */
String url;
/* program version (may be null) */
String version;
void parse (BufferedReader in) throws IOException {
// !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
format = in.readLine();
if (format == null || !format.equals(TAG_FILE_FORMAT)) {
throw new IOException("Wrong Tag Format Header");
}
// !_TAG_FILE_SORTED 0 /0=unsorted, 1=sorted/
sorted = in.readLine();
if (sorted == null || !sorted.equals(TAG_FILE_SORTED)) {
throw new IOException("Wrong Tag Format Header");
}
// !_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
author = in.readLine();
if (author == null || !author.equals(TAG_PROGRAM_AUTHOR)) {
throw new IOException("Wrong Tag Format Header");
}
// !_TAG_PROGRAM_NAME Exuberant Ctags //
name = in.readLine();
if (name == null || !name.equals(TAG_PROGRAM_NAME)) {
throw new IOException("Wrong Tag Format Header");
}
// !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
url = in.readLine();
if (url == null || !url.equals(TAG_PROGRAM_URL)) {
throw new IOException("Wrong Tag Format Header");
}
// !_TAG_PROGRAM_VERSION 5.2.3 //
version = in.readLine();
if (version == null || !version.equals(TAG_PROGRAM_VERSION)) {
throw new IOException("Wrong Tag Format Header");
}
}
public static String header() {
return
TAG_FILE_FORMAT + "\n" + TAG_FILE_SORTED + "\n" +
TAG_PROGRAM_AUTHOR + "\n" + TAG_PROGRAM_NAME + "\n" +
TAG_PROGRAM_URL + "\n" + TAG_PROGRAM_VERSION + "\n";
}
}

View file

@ -0,0 +1,74 @@
package org.eclipse.cdt.internal.core.index;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.cdt.core.index.ITagEntry;
public class CTagsRunner extends Thread {
IndexManager manager;
public CTagsRunner(IndexManager indexManager) {
manager = indexManager;
setDaemon(true);
}
public void run () {
// It should be ok since we are being started on startup
// the delay should allow things to settle down.
manager.delay();
while (true) {
IResource resource = null;
RequestList requestList = manager.getRequestList();
try {
resource = requestList.removeItem();
} catch (Exception e) {
//e.printStackTrace();
}
if (resource != null) {
switch (resource.getType()) {
case IResource.FILE:
IProject project = resource.getProject();
Map projectsMap = manager.getProjectsMap();
Map filesMap = (Map)projectsMap.get(project.getLocation());
if (filesMap == null) {
Map m = Collections.synchronizedMap(new HashMap());
projectsMap.put(project.getLocation(), m);
// Kick Start;
manager.addContainer(project);
} else {
try {
CTagsCmd cmd = new CTagsCmd();
IFile file = (IFile)resource;
String location = file.getLocation().toOSString();
ITagEntry[] entries = cmd.getTagEntries(file, location);
filesMap.put(resource.getLocation(), entries);
} catch (IOException e) {
}
//System.out.println("indexing " + resource.getName());
}
break;
case IResource.FOLDER:
case IResource.PROJECT:
System.out.println("Can not index folders " + resource.getName());
break;
}
}
//System.out.println("Indexing " + filename);
}
}
}

View file

@ -0,0 +1,291 @@
package org.eclipse.cdt.internal.core.index;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.cdt.core.index.ITagEntry;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ElementChangedEvent;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.IElementChangedListener;
public class IndexManager implements IElementChangedListener {
RequestList requestList = null;
Thread thread = null;
Map projectsMap = null;
private static IndexManager indexManager = null;
private IndexManager() {
}
public ITagEntry[] query(IProject project, String pattern, boolean ignoreCase, boolean exactMatch) {
Map filesMap = (Map)projectsMap.get(project.getLocation());
// try to kick start.
if (filesMap == null) {
addContainer(project);
}
List result = new ArrayList();
filesMap = (Map)projectsMap.get(project.getLocation());
if (filesMap != null) {
if (pattern == null)
pattern = "*"; //FIXME: is this right null matching all?
// Compile the pattern
StringMatcher matcher = new StringMatcher(pattern, ignoreCase, exactMatch);
Iterator values = filesMap.values().iterator();
while (values.hasNext()) {
ITagEntry[] entries = (ITagEntry[])values.next();
for (int j = 0; j < entries.length; j++) {
String tagName = entries[j].getTagName();
if (tagName != null && matcher.match(tagName)) {
result.add(entries[j]);
}
//if (tagName != null && (pattern == null || tagName.equals(pattern))) {
// result.add(entries[j]);
//}
}
}
}
return (ITagEntry[])result.toArray(new ITagEntry[0]);
}
protected RequestList getRequestList() {
return requestList;
}
protected Map getProjectsMap() {
return projectsMap;
}
protected void init () {
requestList = new RequestList();
projectsMap = Collections.synchronizedMap(new HashMap());
CTagsRunner ctags = new CTagsRunner(this);
thread = new Thread(ctags, "C Tags indexer");
thread.setPriority (Thread.NORM_PRIORITY - 1);
thread.start();
addAll();
}
/**
* Before processing all jobs, need to ensure that the indexes are up to date.
*/
protected static void delay() {
try {
// wait 10 seconds so as not to interfere with plugin startup
Thread.currentThread().sleep(10000);
} catch (InterruptedException ie) {
}
}
/**
* About to delete a project.
*/
public void removeResource(IResource resource) {
Map filesMap = (Map)projectsMap.get(resource.getProject().getLocation());
if (filesMap == null)
return;
switch (resource.getType()) {
case IResource.ROOT:
// PROBLEM?
break;
case IResource.PROJECT:
projectsMap.remove(resource.getLocation());
break;
case IResource.FOLDER:
removeFolder((IFolder)resource);
break;
case IResource.FILE:
removeFile((IFile)resource);
break;
}
}
public void removeFolder(IFolder folder) {
Map filesMap = (Map)projectsMap.get(folder.getProject().getLocation());
if (filesMap == null)
return;
IPath folderPath = folder.getLocation();
if (filesMap != null) {
Iterator keys = filesMap.keySet().iterator();
while (keys.hasNext()) {
IPath p = (IPath)keys.next();
if (p != null && folderPath.isPrefixOf(p)) {
//System.out.println("Removing [" + folderPath + "] " + p);
filesMap.remove(p);
}
}
}
}
public void removeFile(IFile file) {
Map filesMap = (Map)projectsMap.get(file.getProject().getLocation());
if (filesMap != null) {
filesMap.remove(file.getLocation());
}
}
public void addResource(IResource resource) {
switch(resource.getType()) {
case IResource.ROOT:
case IResource.PROJECT:
case IResource.FOLDER:
addContainer((IContainer)resource);
break;
case IResource.FILE:
addFile((IFile)resource);
break;
}
}
/**
* Trigger addition of a resource to an index
* Note: the actual operation is performed in background
*/
public void addFile(IFile file) {
if (CoreModel.getDefault().isTranslationUnit(file)) {
requestList.addItem(file);
}
}
/**
* Trigger addition of the entire content of a project
* Note: the actual operation is performed in background
*/
public void addContainer(IContainer container) {
if (container != null && container.exists()) {
try {
IResource[] resources = container.members(false);
for (int i = 0; i < resources.length; i++) {
IResource res = resources[i];
switch(res.getType()) {
case IResource.ROOT:
break;
case IResource.PROJECT:
if (CoreModel.getDefault().hasCNature((IProject)res)) {
addContainer((IContainer)res);
}
break;
case IResource.FOLDER:
addContainer((IContainer)res);
break;
case IResource.FILE:
addFile((IFile)res);
break;
}
}
} catch (CoreException e) {
e.printStackTrace();
}
}
}
public void addAll() {
addResource(ResourcesPlugin.getWorkspace().getRoot());
}
public void saveIndexes() {
}
public void saveIndex(IProject project) {
}
public void shutdown() {
if (thread != null)
thread.interrupted();
CoreModel.getDefault().removeElementChangedListener(this);
}
public static IndexManager getDefault() {
if (indexManager == null) {
indexManager = new IndexManager();
indexManager.init();
// Register to the C Core Model for C specific changes.
CoreModel.getDefault().addElementChangedListener(indexManager);
}
return indexManager;
}
protected void processDelta(ICElementDelta delta) throws CModelException {
int kind= delta.getKind();
int flags= delta.getFlags();
ICElement element= delta.getElement();
//System.out.println("Index Processing Delta " + element);
// handle open and closing of a solution or project
if (((flags & ICElementDelta.F_CLOSED) != 0)
|| ((flags & ICElementDelta.F_OPENED) != 0)) {
}
if (kind == ICElementDelta.REMOVED) {
try {
IResource resource = ((ICElement)element).getCorrespondingResource();
removeResource(resource);
} catch (CModelException e) {
}
}
if (kind == ICElementDelta.ADDED) {
try {
IResource resource = ((ICElement)element).getCorrespondingResource();
addResource(resource);
} catch (CModelException e) {
}
}
if (element instanceof ITranslationUnit) {
if (kind == ICElementDelta.CHANGED) {
IResource resource = ((ICElement)element).getCorrespondingResource();
addResource(resource);
return;
}
}
ICElementDelta[] affectedChildren= delta.getAffectedChildren();
for (int i= 0; i < affectedChildren.length; i++) {
processDelta(affectedChildren[i]);
}
}
/* (non-Cdoc)
* Method declared on IElementChangedListener.
*/
public void elementChanged(final ElementChangedEvent event) {
try {
processDelta(event.getDelta());
} catch(CModelException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,57 @@
package org.eclipse.cdt.internal.core.index;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import java.util.*;
import org.eclipse.core.resources.*;
public class RequestList {
private List list;
public RequestList() {
list = Collections.synchronizedList(new LinkedList());
}
public IResource removeItem() throws InterruptedException {
//print("in removeItem() - entering");
synchronized (list) {
while (list.isEmpty()) {
//print("in removeItem() - about to wait()");
list.wait();
//print("in removeItem() - done with wait()");
}
// extract the new first item
IResource item = (IResource)list.remove(0);
//print("in removeItem() - leaving");
return item;
}
}
public void addItem(IResource item) {
//print("in addItem() - entering");
synchronized (list) {
// There will always be room to add to this List
// because it expands as needed.
list.add(item);
//print("in addItem - just added: '" + item + "'");
// After adding, notify any and all waiting
// threads that the list has changed.
list.notifyAll();
//print("in addItem() - just notified");
}
//print("in addItem() - leaving");
}
private static void print(String msg) {
String name = Thread.currentThread().getName();
System.out.println(name + ": " + msg);
}
}

View file

@ -0,0 +1,389 @@
package org.eclipse.cdt.internal.core.index;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import java.util.Vector;
public class StringMatcher {
protected String fPattern;
protected int fLength; // pattern length
protected boolean fIgnoreWildCards;
protected boolean fIgnoreCase;
protected boolean fHasLeadingStar;
protected boolean fHasTrailingStar;
protected String fSegments[]; //the given pattern is split into * separated segments
/* boundary value beyond which we don't need to search in the text */
protected int fBound= 0;
protected static final char fSingleWildCard= '\u0000';
public static class Position {
int start; //inclusive
int end; //exclusive
public Position(int start, int end) {
this.start= start;
this.end= end;
}
public int getStart() {
return start;
}
public int getEnd() {
return end;
}
}
/**
* Find the first occurrence of the pattern between <code>start</code)(inclusive)
* and <code>end</code>(exclusive).
* @param <code>text</code>, the String object to search in
* @param <code>start</code>, the starting index of the search range, inclusive
* @param <code>end</code>, the ending index of the search range, exclusive
* @return an <code>StringMatcher.Position</code> object that keeps the starting
* (inclusive) and ending positions (exclusive) of the first occurrence of the
* pattern in the specified range of the text; return null if not found or subtext
* is empty (start==end). A pair of zeros is returned if pattern is empty string
* Note that for pattern like "*abc*" with leading and trailing stars, position of "abc"
* is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned
*/
public StringMatcher.Position find(String text, int start, int end) {
if (fPattern == null || text == null)
throw new IllegalArgumentException();
int tlen= text.length();
if (start < 0)
start= 0;
if (end > tlen)
end= tlen;
if (end < 0 || start >= end)
return null;
if (fLength == 0)
return new Position(start, start);
if (fIgnoreWildCards) {
int x= posIn(text, start, end);
if (x < 0)
return null;
return new Position(x, x + fLength);
}
int segCount= fSegments.length;
if (segCount == 0) //pattern contains only '*'(s)
return new Position(start, end);
int curPos= start;
int matchStart= -1;
for (int i= 0; i < segCount && curPos < end; ++i) {
String current= fSegments[i];
int nextMatch= regExpPosIn(text, curPos, end, current);
if (nextMatch < 0)
return null;
if (i == 0)
matchStart= nextMatch;
curPos= nextMatch + current.length();
}
return new Position(matchStart, curPos);
}
/**
* StringMatcher constructor takes in a String object that is a simple
* pattern which may contain *  for 0 and many characters and
* ?  for exactly one character. Also takes as parameter a boolean object
* specifying if case should be ignored
* @deprecated Use StringMatcher(pattern, ignoreCase, ignoreWildCards).
*/
public StringMatcher(String aPattern, boolean ignoreCase) {
this(aPattern, ignoreCase, false);
}
/**
* StringMatcher constructor takes in a String object that is a simple
* pattern which may contain *  for 0 and many characters and
* ?  for exactly one character.
*
* Literal '*' and '?' characters must be escaped in the pattern
* e.g., "\*" means literal "*", etc.
*
* Escaping any other character (including the escape character itself),
* just results in that character in the pattern.
* e.g., "\a" means "a" and "\\" means "\"
*
* If invoking the StringMatcher with string literals in Java, don't forget
* escape characters are represented by "\\".
*
* @param aPattern the pattern to match text against
* @param ignoreCase if true, case is ignored
* @param ignoreWildCards if true, wild cards and their escape sequences are ignored
* (everything is taken literally).
*/
public StringMatcher(String aPattern, boolean ignoreCase, boolean ignoreWildCards) {
fIgnoreCase= ignoreCase;
fIgnoreWildCards= ignoreWildCards;
fLength= aPattern.length();
/* convert case */
if (fIgnoreCase) {
fPattern= aPattern.toUpperCase();
} else {
fPattern= aPattern;
}
if (fIgnoreWildCards) {
parseNoWildCards();
} else {
parseWildCards();
}
}
/**
* Given the starting (inclusive) and the ending (exclusive) poisitions in the
* <code>text</code>, determine if the given substring matches with aPattern
* @return true if the specified portion of the text matches the pattern
* @param String <code>text</code>, a String object that contains the substring to match
* @param int <code>start<code> marks the starting position (inclusive) of the substring
* @param int <code>end<code> marks the ending index (exclusive) of the substring
*/
public boolean match(String text, int start, int end) {
if (null == fPattern || null == text)
throw new IllegalArgumentException();
if (start > end)
return false;
if (fIgnoreWildCards)
return fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength);
int segCount= fSegments.length;
if (segCount == 0) //pattern contains only '*'(s) or empty pattern
return true;
if (start == end)
return fLength == 0;
if (fLength == 0)
return start == end;
int tlen= text.length();
if (start < 0)
start= 0;
if (end > tlen)
end= tlen;
int tCurPos= start;
int bound= end - fBound;
if (bound < 0)
return false;
int i= 0;
String current= fSegments[i];
int segLength= current.length();
/* process first segment */
if (!fHasLeadingStar) {
if (!regExpRegionMatches(text, start, current, 0, segLength)) {
return false;
} else {
++i;
tCurPos= tCurPos + segLength;
}
}
/* process middle segments */
for (; i < segCount && tCurPos <= bound; ++i) {
current= fSegments[i];
int currentMatch;
int k= current.indexOf(fSingleWildCard);
if (k < 0) {
currentMatch= textPosIn(text, tCurPos, end, current);
if (currentMatch < 0)
return false;
} else {
currentMatch= regExpPosIn(text, tCurPos, end, current);
if (currentMatch < 0)
return false;
}
tCurPos= currentMatch + current.length();
}
/* process final segment */
if (!fHasTrailingStar && tCurPos != end) {
int clen= current.length();
return regExpRegionMatches(text, end - clen, current, 0, clen);
}
return i == segCount;
}
/**
* match the given <code>text</code> with the pattern
* @return true if matched eitherwise false
* @param <code>text</code>, a String object
*/
public boolean match(String text) {
return match(text, 0, text.length());
}
/**
* This method parses the given pattern into segments seperated by wildcard '*' characters.
* Since wildcards are not being used in this case, the pattern consists of a single segment.
*/
private void parseNoWildCards() {
fSegments= new String[1];
fSegments[0]= fPattern;
fBound= fLength;
}
/**
* This method parses the given pattern into segments seperated by wildcard '*' characters.
* @param p, a String object that is a simple regular expression with *  and/or ? 
*/
private void parseWildCards() {
if (fPattern.startsWith("*")) //$NON-NLS-1$
fHasLeadingStar= true;
if (fPattern.endsWith("*")) { //$NON-NLS-1$
/* make sure it's not an escaped wildcard */
if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') {
fHasTrailingStar= true;
}
}
Vector temp= new Vector();
int pos= 0;
StringBuffer buf= new StringBuffer();
while (pos < fLength) {
char c= fPattern.charAt(pos++);
switch (c) {
case '\\' :
if (pos >= fLength) {
buf.append(c);
} else {
char next= fPattern.charAt(pos++);
/* if it's an escape sequence */
if (next == '*' || next == '?' || next == '\\') {
buf.append(next);
} else {
/* not an escape sequence, just insert literally */
buf.append(c);
buf.append(next);
}
}
break;
case '*' :
if (buf.length() > 0) {
/* new segment */
temp.addElement(buf.toString());
fBound += buf.length();
buf.setLength(0);
}
break;
case '?' :
/* append special character representing single match wildcard */
buf.append(fSingleWildCard);
break;
default :
buf.append(c);
}
}
/* add last buffer to segment list */
if (buf.length() > 0) {
temp.addElement(buf.toString());
fBound += buf.length();
}
fSegments= new String[temp.size()];
temp.copyInto(fSegments);
}
/**
* @param <code>text</code>, a string which contains no wildcard
* @param <code>start</code>, the starting index in the text for search, inclusive
* @param <code>end</code>, the stopping point of search, exclusive
* @return the starting index in the text of the pattern , or -1 if not found
*/
protected int posIn(String text, int start, int end) { //no wild card in pattern
int max= end - fLength;
if (!fIgnoreCase) {
int i= text.indexOf(fPattern, start);
if (i == -1 || i > max)
return -1;
return i;
}
for (int i= start; i <= max; ++i) {
if (text.regionMatches(true, i, fPattern, 0, fLength))
return i;
}
return -1;
}
/**
* @param <code>text</code>, a simple regular expression that may only contain '?'(s)
* @param <code>start</code>, the starting index in the text for search, inclusive
* @param <code>end</code>, the stopping point of search, exclusive
* @param <code>p</code>, a simple regular expression that may contains '?'
* @param <code>caseIgnored</code>, wether the pattern is not casesensitive
* @return the starting index in the text of the pattern , or -1 if not found
*/
protected int regExpPosIn(String text, int start, int end, String p) {
int plen= p.length();
int max= end - plen;
for (int i= start; i <= max; ++i) {
if (regExpRegionMatches(text, i, p, 0, plen))
return i;
}
return -1;
}
/**
*
* @return boolean
* @param <code>text</code>, a String to match
* @param <code>start</code>, int that indicates the starting index of match, inclusive
* @param <code>end</code> int that indicates the ending index of match, exclusive
* @param <code>p</code>, String, String, a simple regular expression that may contain '?'
* @param <code>ignoreCase</code>, boolean indicating wether code>p</code> is case sensitive
*/
protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen) {
while (plen-- > 0) {
char tchar= text.charAt(tStart++);
char pchar= p.charAt(pStart++);
/* process wild cards */
if (!fIgnoreWildCards) {
/* skip single wild cards */
if (pchar == fSingleWildCard) {
continue;
}
}
if (pchar == tchar)
continue;
if (fIgnoreCase) {
char tc= Character.toUpperCase(tchar);
if (tc == pchar)
continue;
}
return false;
}
return true;
}
/**
* @param <code>text</code>, the string to match
* @param <code>start</code>, the starting index in the text for search, inclusive
* @param <code>end</code>, the stopping point of search, exclusive
* @param code>p</code>, a string that has no wildcard
* @param <code>ignoreCase</code>, boolean indicating wether code>p</code> is case sensitive
* @return the starting index in the text of the pattern , or -1 if not found
*/
protected int textPosIn(String text, int start, int end, String p) {
int plen= p.length();
int max= end - plen;
if (!fIgnoreCase) {
int i= text.indexOf(p, start);
if (i == -1 || i > max)
return -1;
return i;
}
for (int i= 0; i <= max; ++i) {
if (text.regionMatches(true, i, p, 0, plen))
return i;
}
return -1;
}
}

View file

@ -0,0 +1,117 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.core.runtime.CoreException;
import org.eclipse.cdt.internal.core.model.CModelStatus;
/**
* A checked exception representing a failure in the C model.
* C model exceptions contain a C-specific status object describing the
* cause of the exception.
*
* @see ICModelStatus
* @see ICModelStatusConstants
*/
public class CModelException extends CoreException {
/**
* Creates a C model exception that wrappers the given <code>Throwable</code>.
* The exception contains a C-specific status object with severity
* <code>IStatus.ERROR</code> and the given status code.
*
* @param exception the <code>Throwable</code>
* @param code one of the C-specific status codes declared in
* <code>ICModelStatusConstants</code>
* @return the new C model exception
* @see ICModelStatusConstants
* @see org.eclipse.core.runtime.IStatus#ERROR
*/
public CModelException(Throwable e, int code) {
this(new CModelStatus(code, e));
}
/**
* Creates a C model exception for the given <code>CoreException</code>.
* Equivalent to
* <code>CModelException(exception,ICModelStatusConstants.CORE_EXCEPTION</code>.
*
* @param exception the <code>CoreException</code>
* @return the new C model exception
*/
public CModelException(CoreException exception) {
this(new CModelStatus(exception));
}
/**
* Creates a C model exception for the given C-specific status object.
*
* @param status the C-specific status object
* @return the new C model exception
*/
public CModelException(ICModelStatus status) {
super(status);
}
/**
* Returns the underlying <code>Throwable</code> that caused the failure.
*
* @return the wrappered <code>Throwable</code>, or <code>null</code> if the
* direct case of the failure was at the C model layer
*/
public Throwable getException() {
return getStatus().getException();
}
/**
* Returns the C model status object for this exception.
* Equivalent to <code>(ICModelStatus) getStatus()</code>.
*
* @return a status object
*/
public ICModelStatus getCModelStatus() {
return (ICModelStatus) getStatus();
}
/**
* Returns whether this exception indicates that a C model element does not
* exist. Such exceptions have a status with a code of
* <code>ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST</code>.
* This is a convenience method.
*
* @return <code>true</code> if this exception indicates that a C model
* element does not exist
* @see ICModelStatus#doesNotExist
* @see ICModelStatusConstants#ELEMENT_DOES_NOT_EXIST
*/
public boolean doesNotExist() {
ICModelStatus cModelStatus = getCModelStatus();
return cModelStatus != null && cModelStatus.doesNotExist();
}
/**
* Returns a printable representation of this exception suitable for debugging
* purposes only.
*/
public String toString() {
StringBuffer buffer= new StringBuffer();
buffer.append("C Model Exception: "); //$NON-NLS-1$
if (getException() != null) {
if (getException() instanceof CoreException) {
CoreException c= (CoreException)getException();
buffer.append("Core Exception [code "); //$NON-NLS-1$
buffer.append(c.getStatus().getCode());
buffer.append("] "); //$NON-NLS-1$
buffer.append(c.getStatus().getMessage());
} else {
buffer.append(getException().toString());
}
} else {
buffer.append(getStatus().toString());
}
return buffer.toString();
}
}

View file

@ -0,0 +1,252 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
//import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.core.model.CModelManager;
// This should be done in the Plugin.
public class CoreModel {
private static CoreModel cmodel = null;
private static CModelManager manager = null;
/**
* Plugin string id.
*/
public final static String PLUGIN_ID = "org.eclipse.cdt.core";
/**
* C nature string name, "cnature".
*/
public final static String C_NATURE_NAME = "cnature";
/**
* C nature string id, PLUGIN_ID + C_NATURE_NAME
*/
public final static String C_NATURE_ID = PLUGIN_ID + "." + C_NATURE_NAME;
/**
* C++ nature string name, "ccnature"
*/
public final static String CC_NATURE_NAME = "ccnature";
/**
* C++ nature string id, PLUGIN_ID + CC_NATURE_NAME
*/
public final static String CC_NATURE_ID = PLUGIN_ID + "." + CC_NATURE_NAME;
/**
* Returns the plugin id.
*/
public static String getPluginId() {
return PLUGIN_ID;
}
/**
* Returns the C nature Name.
*/
public static String getCNatureName () {
return C_NATURE_NAME;
}
/**
* Returns the C++ nature name.
*/
public static String getCCNatureName () {
return CC_NATURE_NAME;
}
/**
* Returns the C nature Id.
*/
public static String getCNatureId () {
return C_NATURE_ID;
}
/**
* Returns the C++ nature Id.
*/
public static String getCCNatureId () {
return CC_NATURE_ID;
}
/**
* Creates an ICElement form and IPath.
* Returns null if not found.
*/
public ICElement create(IPath path) {
return manager.create(path);
}
/**
* Creates an ICElement form and IFile.
* Returns null if not found.
*/
public ICElement create(IFile file) {
return manager.create(file);
}
/**
* Creates an ICElement form and IFolder.
* Returns null if not found.
*/
public ICElement create(IFolder folder) {
return manager.create(folder);
}
/**
* Creates an ICElement form and IProject.
* Returns null if not found.
*/
public ICElement create(IProject project) {
return manager.create(project);
}
/**
* Creates an ICElement form and IWorkspaceRoot.
* Returns null if not found.
*/
public ICElement create(IWorkspaceRoot root) {
return manager.create(root);
}
/**
* Creates an ICElement form and IResource.
* Returns null if not found.
*/
public ICElement create(IResource resource) {
return manager.create(resource);
}
/**
* Returns the default ICRoot.
*/
public ICElement getCRoot() {
return manager.getCRoot();
}
/**
* Return true if IFile is a shared library, i.e. libxx.so
*/
public static boolean isSharedLib(IFile file) {
return manager.isSharedLib(file);
}
/**
* Return true if IFile is a an object(ELF), i.e. *.o
*/
public static boolean isObject(IFile file) {
return manager.isObject(file);
}
/**
* Return true if IFile is an ELF executable
*/
public static boolean isExecutable(IFile file) {
return manager.isExecutable(file);
}
/**
* Return true if IFile is an ELF.
*/
public static boolean isBinary(IFile file) {
return manager.isBinary(file);
}
/**
* Return true if IFile is an Achive, *.a
*/
public static boolean isArchive(IFile file) {
return manager.isArchive(file);
}
/**
* Return true if IFile is a TranslationUnit.
*/
public static boolean isTranslationUnit(IFile file) {
return manager.isTranslationUnit(file);
}
/**
* Return true if name is a valid name for a translation unit.
*/
public static boolean isValidTranslationUnitName(String name){
return manager.isValidTranslationUnitName(name);
}
/**
* Return true if project has C nature.
*/
public static boolean hasCNature(IProject project){
return manager.hasCNature(project);
}
public static boolean hasCCNature(IProject project){
return manager.hasCCNature(project);
}
public static void addCNature(IProject project, IProgressMonitor monitor) throws CModelException {
manager.addCNature(project, monitor);
}
public static void addCCNature(IProject project, IProgressMonitor monitor) throws CModelException {
manager.addCCNature(project, monitor);
}
public static void removeCNature(IProject project, IProgressMonitor monitor) throws CModelException {
manager.removeCNature(project, monitor);
}
public static void removeCCNature(IProject project, IProgressMonitor monitor) throws CModelException {
manager.removeCCNature(project, monitor);
}
public static void addNature(IProject project, String natureId, IProgressMonitor monitor)
throws CModelException {
manager.addNature(project, natureId, monitor);
}
public static void removeNature(IProject project, String natureId, IProgressMonitor monitor)
throws CModelException {
manager.removeNature(project, natureId, monitor);
}
/**
* Return the singleton.
*/
public static CoreModel getDefault() {
if (cmodel == null) {
cmodel = new CoreModel();
manager = CModelManager.getDefault();
}
return cmodel;
}
public static void addElementChangedListener(IElementChangedListener listener) {
manager.addElementChangedListener(listener);
}
/**
* Removes the given element changed listener.
* Has no affect if an identical listener is not registered.
*
* @param listener the listener
*/
public static void removeElementChangedListener(IElementChangedListener listener) {
manager.removeElementChangedListener(listener);
}
private CoreModel() {
}
}

View file

@ -0,0 +1,33 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import java.util.EventObject;
/**
* An element changed event describes a change to the structure or contents
* of a tree of C elements. The changes to the elements are described by
* the associated delta object carried by this event.
*
* @see IElementChangedListener
* @see ICElementDelta
*/
public class ElementChangedEvent extends EventObject {
/**
* Creates an new element changed event (based on a <code>ICElementDelta</code>).
*
* @param delta the C element delta.
*/
public ElementChangedEvent(ICElementDelta delta) {
super(delta);
}
/**
* Returns the delta describing the change.
*
*/
public ICElementDelta getDelta() {
return (ICElementDelta) source;
}
}

View file

@ -0,0 +1,188 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import org.eclipse.cdt.internal.core.model.IConstants;
/**
* Utility class for decoding modifier flags in C elements.
* <p>
* This class provides static methods only; it is not intended to be
* instantiated or subclassed by clients.
* </p>
*
*/
public final class Flags {
/**
* Not instantiable.
*/
private Flags() {}
/**
* Returns whether the given integer includes the <code>abstract</code> modifier.
*
* @param flags the flags
* @return <code>true</code> if the <code>abstract</code> modifier is included
*/
public static boolean isAbstract(int flags) {
return (flags & IConstants.AccAbstract) != 0;
}
/**
*
* Return whether the give integer include the keyword <code>export</code> modifier.
* @param flags the flags
* @return <code>true</code> if the element is <code>export</code>
*/
public static boolean isExport(int flags) {
return (flags & IConstants.AccExport) != 0;
}
/**
* Returns whether the given integer includes the <code>inline</code> modifier.
*
* @param flags the flags
* @return <code>true</code> if the <code>inline</code> modifier is included
*/
public static boolean isInline(int flags) {
return (flags & IConstants.AccInline) != 0;
}
/**
* Returns whether the given integer includes the <code>explicit</code> modifier.
*
* @param flags the flags
* @return <code>true</code> if <code>explicit</code> modifier is included
*/
public static boolean isExplicit(int flags) {
return (flags & IConstants.AccExplicit) != 0;
}
/**
* Returns whether the given integer includes the <code>private</code> modifier.
*
* @param flags the flags
* @return <code>true</code> if the <code>private</code> modifier is included
*/
public static boolean isPrivate(int flags) {
return (flags & IConstants.AccPrivate) != 0;
}
/**
* Returns whether the given integer includes the <code>protected</code> modifier.
*
* @param flags the flags
* @return <code>true</code> if the <code>protected</code> modifier is included
*/
public static boolean isProtected(int flags) {
return (flags & IConstants.AccProtected) != 0;
}
/**
* Returns whether the given integer includes the <code>public</code> modifier.
*
* @param flags the flags
* @return <code>true</code> if the <code>public</code> modifier is included
*/
public static boolean isPublic(int flags) {
return (flags & IConstants.AccPublic) != 0;
}
/**
* Returns whether the given integer includes the <code>static</code> modifier.
*
* @param flags the flags
* @return <code>true</code> if the <code>static</code> modifier is included
*/
public static boolean isStatic(int flags) {
return (flags & IConstants.AccStatic) != 0;
}
/**
* Returns whether the given integer includes the <code>extern</code> modifier.
*
* @param flags the flags
* @return <code>true</code> if the <code>extern</code> modifier is included
*/
public static boolean isExtern(int flags) {
return (flags & IConstants.AccExtern) != 0;
}
/**
* Returns whether the given integer includes the <code>mutable</code> modifier.
*
* @param flags the flags
* @return <code>true</code> if the <code>mutable</code> modifier is included
*/
public static boolean isMutable(int flags) {
return (flags & IConstants.AccMutable) != 0;
}
/**
* Returns whether the given integer includes the indication that the
* element is a register storage specifier.
*
* @param flags the flags
* @return <code>true</code> if the element is marked register storage specifier
*/
public static boolean isRegister(int flags) {
return (flags & IConstants.AccRegister) != 0;
}
/**
* Returns whether the given integer includes the <code>virtual</code> modifier.
*
* @param flags the flags
* @return <code>true</code> if the <code>virtual</code> modifier is included
*/
public static boolean isVirtual(int flags) {
return (flags & IConstants.AccVirtual) != 0;
}
/**
* Returns whether the given integer includes the <code>volatile</code> modifier.
*
* @param flags the flags
* @return <code>true</code> if the <code>volatile</code> modifier is included
*/
public static boolean isVolatile(int flags) {
return (flags & IConstants.AccVolatile) != 0;
}
/**
* Returns a standard string describing the given modifier flags.
* Only modifier flags are included in the output; the deprecated and
* synthetic flags are ignored if set.
* <p>
* Examples results:
* <pre>
* <code>"public static"</code>
* <code>"private"</code>
* </pre>
* </p>
*
* @param flags the flags
* @return the standard string representation of the given flags
*/
public static String toString(int flags) {
StringBuffer sb = new StringBuffer();
if (isPublic(flags)) sb.append("public "); //$NON-NLS-1$
if (isProtected(flags)) sb.append("protected "); //$NON-NLS-1$
if (isPrivate(flags)) sb.append("private "); //$NON-NLS-1$
if (isStatic(flags)) sb.append("static "); //$NON-NLS-1$
if (isAbstract(flags)) sb.append("abstract "); //$NON-NLS-1$
if (isVirtual(flags)) sb.append("virtual "); //$NON-NLS-1$
if (isInline(flags)) sb.append("inline "); //$NON-NLS-1$
if (isExtern(flags)) sb.append("extern "); //$NON-NLS-1$
if (isExport(flags)) sb.append("export "); //$NON-NLS-1$
if (isVolatile(flags)) sb.append("volatile "); //$NON-NLS-1$
if (isExplicit(flags)) sb.append("explicit "); //$NON-NLS-1$
int len = sb.length();
if (len == 0) return ""; //$NON-NLS-1$
sb.setLength(len-1);
return sb.toString();
}
}

View file

@ -0,0 +1,18 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
* An IArchive represents a group of files combined into a
* single file(the Archive), for example libxx.a.
*/
public interface IArchive extends ICFile {
/**
* Return the binaries contain in the archive.
* It does not actually extract the files.
*/
public IBinary[] getBinaries();
}

View file

@ -0,0 +1,14 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
* Represents a container of all the IArchive's found in the project
* while inspecting the project.
*/
public interface IArchiveContainer extends IParent, ICElement {
public IArchive[] getArchives();
}

View file

@ -0,0 +1,35 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
* Represents a Binary file, for example an ELF excutable.
* An ELF parser will inspect the binary.
*/
public interface IBinary extends ICFile {
/**
* Return whether the file was compiling with debug symbols.
*/
public boolean hasDebug();
public boolean isExecutable();
public boolean isObject();
public boolean isSharedLib();
public String [] getNeededSharedLibs();
public String getSoname();
public String getCPU();
public long getText();
public long getData();
public long getBSS();
}

View file

@ -0,0 +1,15 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
* Represents a container of all the IBinary's found in the project
* while inspecting the project.
*/
public interface IBinaryContainer extends IParent, ICElement {
public IBinary[] getBinaries();
}

View file

@ -0,0 +1,289 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IAdaptable;
/**
* Common protocol for all elements provided by the C model.
*/
public interface ICElement extends IAdaptable {
/**
* IResource from 10-20
*/
/**
* Constant representing a C Root workspace (IWorkspaceRoot object).
* A C element with this type can be safely cast to <code>ICRoot</code>.
*/
public static final int C_ROOT = 10;
/**
* Constant representing a C project(IProject object).
* A C element with this type can be safely cast to <code>ICProject</code>.
*/
public static final int C_PROJECT = 11;
/**
* Constant representing a folder(ICFolder object).
* A C element with this type can be safely cast to <code>ICFolder</code>.
*/
public static final int C_FOLDER = 12;
/**
* Constant representing a file(ICFile object).
* A C element with this type can be safely cast to <code>ICFile</code>.
*/
public static final int C_FILE = 13;
/**
* Virtual container serving as a place holder.
*/
public static final int C_CONTAINER = 30;
/**
* Constant representing a C/C++ children of a Translation Unit
*/
public static final int C_UNIT = 60;
/**
* Namespace.
*/
public static final int C_NAMESPACE = 61;
/**
* Using.
*/
public static final int C_USING = 62;
/**
* Enumeration.
*/
public static final int C_ENUMERATION = 63;
/**
* Constant representing a class structure.
*/
public static final int C_CLASS = 64;
/**
* Constant representing a struct structure.
*/
public static final int C_STRUCT = 65;
/**
* Constant representing a union structure.
*/
public static final int C_UNION = 66;
/**
* A method definition part of a structure(class, struct, union).
*/
public static final int C_METHOD = 67;
/**
* A method declaration part of a structure(class, struct, union).
*/
public static final int C_METHOD_DECLARATION = 68;
/**
* A Field definition part of a structure(class, struct, union).
*/
public static final int C_FIELD = 69;
/**
* a C/C++ function prototype.
*/
public static final int C_FUNCTION_DECLARATION = 70;
/**
* a C/C++ function.
*/
public static final int C_FUNCTION = 71;
/**
* Preprocessor #include directive.
*/
public static final int C_INCLUDE = 72;
/**
* C++ template class.
*/
public static final int C_TEMPLATE = 73;
/**
* Global variable.
*/
public static final int C_VARIABLE = 74;
/**
* variable Declaration.
*/
public static final int C_VARIABLE_DECLARATION = 75;
/**
* Local Variable.
*/
public static final int C_VARIABLE_LOCAL = 76;
/**
* A preprocessor macro.
*/
public static final int C_MACRO = 77;
/**
* a Typedef.
*/
public static final int C_TYPEDEF = 78;
/**
* Modifier indicating a class constructor
*/
public static final int C_CLASS_CTOR = 0x100;
/**
* Modifier indicating a class destructor
*/
public static final int C_CLASS_DTOR = 0x200;
/**
* Modifier indicating a static storage attribute
*/
public static final int C_STORAGE_STATIC = 0x400;
/**
* Modifier indicating an extern storage attribute
*/
public static final int C_STORAGE_EXTERN = 0x800;
/**
* Modifier indicating a private class
*/
public static final int CPP_PRIVATE = 0x1000;
/**
* Modifier indicating a public class
*/
public static final int CPP_PUBLIC = 0x2000;
/**
* Modifier indicating a friend class
*/
public static final int CPP_FRIEND = 0x4000;
/**
* Returns whether this C element exists in the model.
*
* @return <code>true</code> if this element exists in the C model
*/
boolean exists();
/**
* Returns the resource that corresponds directly to this element,
* or <code>null</code> if there is no resource that corresponds to
* this element.
* <p>
* For example, the corresponding resource for an <code>ATranslationUnit</code>
* is its underlying <code>IFile</code>.
*
* @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 corresponding resource
*/
IResource getCorrespondingResource() throws CModelException;
/**
* Returns the name of this element.
*
* @return the element name
*/
String getElementName();
/**
* Returns this element's kind encoded as an integer.
* This is a handle-only method.
*
* @return the kind of element; one of the constants declared in
* <code>ICElement</code>
* @see ICElement
*/
public int getElementType();
/**
* Returns the C model.
*
* @return the C model
*/
ICRoot getCRoot();
/**
* Returns the C project this element is contained in,
* or <code>null</code> if this element is not contained in any C project
*
* @return the containing C project, or <code>null</code> if this element is
* not contained in a C project
*/
ICProject getCProject();
/**
* Returns the element directly containing this element,
* or <code>null</code> if this element has no parent.
*
* @return the parent element, or <code>null</code> if this element has no parent
*/
ICElement getParent();
/**
* Returns the path to the innermost resource enclosing this element.
* If this element is not included in an external archive,
* the path returned is the full, absolute path to the underlying resource,
* relative to the workbench.
* If this element is included in an external archive,
* the path returned is the absolute path to the archive in the file system.
* This is a handle-only method.
*
*/
IPath getPath();
/**
* Returns the underlying resource that contains
* this element, or <code>null</code> if this element is not contained
* in a resource.
*
* @return the underlying resource, or <code>null</code> if none
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its underlying resource
*/
IResource getUnderlyingResource() 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.
*
* @return <code>true</code> if this element is read-only
*/
boolean isReadOnly();
/**
* Returns whether the structure of this element is known. For example, for a
* translation unit that could not be parsed, <code>false</code> is returned.
* If the structure of an element is unknown, navigations will return reasonable
* defaults. For example, <code>getChildren</code> will return an empty collection.
* <p>
* Note: This does not imply anything about consistency with the
* underlying resource/buffer contents.
* </p>
*
* @return <code>true</code> if the structure of this element is known
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
*/
boolean isStructureKnown() throws CModelException;
}

View file

@ -0,0 +1,187 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import org.eclipse.core.resources.IResourceDelta;
/**
* A C element delta describes changes in C element between two discrete
* points in time. Given a delta, clients can access the element that has
* changed, and any children that have changed.
* <p>
* Deltas have a different status depending on the kind of change they represent.
* The list below summarizes each status (as returned by <code>getKind</code>)
* and its meaning:
* <ul>
* <li><code>ADDED</code> - The element described by the delta
* has been added.
* <li><code>REMOVED</code> - The element described by the delta
* has been removed.
* <li><code>CHANGED</code> - The element described by the delta
* has been changed in some way.
* </li>
* </ul>
* <p>
* Move operations are indicated by other change flags, layered on top
* of the change flags described above. If element A is moved to become B,
* the delta for the change in A will have status <code>REMOVED</code>,
* with change flag <code>F_MOVED_TO</code>. In this case,
* <code>getMovedToElement</code> on delta A will return the handle for B.
* The delta for B will have status <code>ADDED</code>, with change flag
* <code>F_MOVED_FROM</code>, and <code>getMovedFromElement</code> on delta
* B will return the handle for A. (Note, the handle to A in this case represents
* an element that no longer exists).
* </p>
* <p>
* Note that the move change flags only describe the changes to a single element, they
* do not imply anything about the parent or children of the element.
*/
public interface ICElementDelta {
/**
* Status constant indicating that the element has been added.
*/
public int ADDED = 1;
/**
* Status constant indicating that the element has been removed.
*/
public int REMOVED = 2;
/**
* Status constant indicating that the element has been changed,
* as described by the change flags.
*/
public int CHANGED = 4;
/**
* Change flag indicating that the content of the element has changed.
*/
public int F_CONTENT = 0x0001;
/**
* Change flag indicating that the modifiers of the element have changed.
*/
public int F_MODIFIERS = 0x0002;
/**
* Change flag indicating that there are changes to the children of the element.
*/
public int F_CHILDREN = 0x0008;
/**
* Change flag indicating that the element was moved from another location.
* The location of the old element can be retrieved using <code>getMovedFromElement</code>.
*/
public int F_MOVED_FROM = 0x0010;
/**
* Change flag indicating that the element was moved to another location.
* The location of the new element can be retrieved using <code>getMovedToElement</code>.
*/
public int F_MOVED_TO = 0x0020;
/**
* Change flag indicating that the underlying <code>IProject</code> has been
* opened.
*/
public int F_OPENED = 0x0200;
/**
* Change flag indicating that the underlying <code>IProject</code> has been
* closed.
*/
public int F_CLOSED = 0x0400;
//public int F_ADDED_TO_CLASSPATH = 0x0040;
//public int F_REMOVED_FROM_CLASSPATH = 0x0080;
//public int F_CLASSPATH_REORDER = 0x0100;
//public int F_SUPER_TYPES = 0x0800;
/**
* Change flag indicating that a source jar has been attached to a binary jar.
*/
public int F_SOURCEATTACHED = 0x1000;
/**
* Change flag indicating that a source jar has been detached to a binary jar.
*/
public int F_SOURCEDETACHED = 0x2000;
/**
* Change flag indicating that this is a fine-grained delta, i.e. an analysis down
* to the members level was done to determine if there were structural changes to
* members.
*/
public int F_FINE_GRAINED = 0x4000;
/**
* Returns deltas for the children that have been added.
*/
public ICElementDelta[] getAddedChildren();
/**
* Returns deltas for the affected (added, removed, or changed) children.
*/
public ICElementDelta[] getAffectedChildren();
/**
* Returns deltas for the children which have changed.
*/
public ICElementDelta[] getChangedChildren();
/**
* Returns the element that this delta describes a change to.
*/
public ICElement getElement();
/**
* Returns flags that describe how an element has changed.
*
* @see ICElementDelta#F_CHILDREN
* @see ICElementDelta#F_CONTENT
* @see ICElementDelta#F_MODIFIERS
* @see ICElementDelta#F_MOVED_FROM
* @see ICElementDelta#F_MOVED_TO
*/
public int getFlags();
/**
* Returns the kind of this delta - one of <code>ADDED</code>, <code>REMOVED</code>,
* or <code>CHANGED</code>.
*/
public int getKind();
/**
* Returns an element describing this element before it was moved
* to its current location, or <code>null</code> if the
* <code>F_MOVED_FROM</code> change flag is not set.
*/
public ICElement getMovedFromElement();
/**
* Returns an element describing this element in its new location,
* or <code>null</code> if the <code>F_MOVED_TO</code> change
* flag is not set.
*/
public ICElement getMovedToElement();
/**
* Returns deltas for the children which have been removed.
*/
public ICElementDelta[] getRemovedChildren();
/**
* Returns the collection of resource deltas.
* <p>
* Note that resource deltas, like C element deltas, are generally only valid
* for the dynamic scope of an event notification. Clients must not hang on to
* these objects.
* </p>
*
* @return the underlying resource deltas, or <code>null</code> if none
*/
public IResourceDelta[] getResourceDeltas();
}

View file

@ -0,0 +1,22 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.core.resources.IFile;
/**
* A C File Resource.
*/
public interface ICFile extends IParent, ICElement {
public boolean isBinary();
public boolean isArchive();
public boolean isTranslationUnit();
public IFile getFile();
}

View file

@ -0,0 +1,16 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.core.resources.IFolder;
/**
* A C Folder Resource.
*/
public interface ICFolder extends IParent, ICElement {
public IFolder getFolder();
}

View file

@ -0,0 +1,35 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.cdt.internal.CCorePlugin;
/**
* Markers used by the C model.
* <p>
* This interface declares constants only; it is not intended to be implemented
* or extended.
* </p>
*/
public interface ICModelMarker {
/**
* C model problem marker type (value <code>"org.eclipse.cdt.core.problem"</code>).
* This can be used to recognize those markers in the workspace that flag problems
* detected by the C ompilers.
*/
public static final String C_MODEL_PROBLEM_MARKER = CCorePlugin.PLUGIN_ID + ".problem"; //$NON-NLS-1$
/**
* C model extension to the marker problem markers which may hold a hint on
* the variable name that caused the error. Used by the ui to highlight the variable
* itself if it can be found.
*/
public static final String C_MODEL_MARKER_VARIABLE = "problem.variable"; //$NON-NLS-1$
}

View file

@ -0,0 +1,79 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
/**
* Represents the outcome of an C model operation. Status objects are
* used inside <code>CModelException</code> objects to indicate what went
* wrong.
* <p>
* C model status object are distinguished by their plug-in id:
* <code>getPlugin</code> returns <code>"org.eclipse.cdt.core"</code>.
* <code>getCode</code> returns one of the status codes declared in
* <code>ICModelStatusConstants</code>.
* </p>
* <p>
* A C model status may also carry additional information (that is, in
* addition to the information defined in <code>IStatus</code>):
* <ul>
* <li>elements - optional handles to C elements associated with the failure</li>
* <li>string - optional string associated with the failure</li>
* </ul>
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*
* @see org.eclipse.core.runtime.IStatus
* @see ICModelStatusConstants
*/
public interface ICModelStatus extends IStatus {
/**
* Returns any C elements associated with the failure (see specification
* of the status code), or an empty array if no elements are related to this
* particular status code.
*
* @return the list of C element culprits
* @see ICModelStatusConstants
*/
ICElement[] getElements();
/**
* Returns the path associated with the failure (see specification
* of the status code), or <code>null</code> if the failure is not
* one of <code>DEVICE_PATH</code>, <code>INVALID_PATH</code>,
* <code>PATH_OUTSIDE_PROJECT</code>, or <code>RELATIVE_PATH</code>.
*
* @return the path that caused the failure, or <code>null</code> if none
* @see ICModelStatusConstants#DEVICE_PATH
* @see ICModelStatusConstants#INVALID_PATH
* @see ICModelStatusConstants#PATH_OUTSIDE_PROJECT
* @see ICModelStatusConstants#RELATIVE_PATH
*/
IPath getPath();
/**
* Returns the string associated with the failure (see specification
* of the status code), or <code>null</code> if no string is related to this
* particular status code.
*
* @return the string culprit, or <code>null</code> if none
* @see ICModelStatusConstants
*/
String getString();
/**
* Returns whether this status indicates that a C model element does not exist.
* This convenience method is equivalent to
* <code>getCode() == ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST</code>.
*
* @return <code>true</code> if the status code indicates that a C model
* element does not exist
* @see ICModelStatusConstants#ELEMENT_DOES_NOT_EXIST
*/
boolean doesNotExist();
}

View file

@ -0,0 +1,224 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
* Status codes used with C model status objects.
* <p>
* This interface declares constants only; it is not intended to be implemented
* or extended.
* </p>
*
* @see ICModelStatus
* @see org.eclipse.core.runtime.IStatus#getCode
*/
public interface ICModelStatusConstants {
/**
* Status constant indicating that a variable path was not resolvable
* indicating either the referred variable is undefined, unbound or the resolved
* variable path does not correspond to an existing file or folder.
*/
public static final int CP_VARIABLE_PATH_UNBOUND = 965;
/**
* Status constant indicating a core exception occurred.
* Use <code>getException</code> to retrieve a <code>CoreException</code>.
*/
public static final int CORE_EXCEPTION = 966;
/**
* Status constant indicating one or more of the elements
* supplied are not of a valid type for the operation to
* process.
* The element(s) can be retrieved using <code>getElements</code> on the status object.
*/
public static final int INVALID_ELEMENT_TYPES = 967;
/**
* Status constant indicating that no elements were
* provided to the operation for processing.
*/
public static final int NO_ELEMENTS_TO_PROCESS = 968;
/**
* Status constant indicating that one or more elements
* supplied do not exist.
* The element(s) can be retrieved using <code>getElements</code> on the status object.
*
* @see ICModelStatus#isDoesNotExist
*/
public static final int ELEMENT_DOES_NOT_EXIST = 969;
/**
* Status constant indicating that a <code>null</code> path was
* supplied to the operation.
*/
public static final int NULL_PATH = 970;
/**
* Status constant indicating that a path outside of the
* project was supplied to the operation. The path can be retrieved using
* <code>getPath</code> on the status object.
*/
public static final int PATH_OUTSIDE_PROJECT = 971;
/**
* Status constant indicating that a relative path
* was supplied to the operation when an absolute path is
* required. The path can be retrieved using <code>getPath</code> on the
* status object.
*/
public static final int RELATIVE_PATH = 972;
/**
* Status constant indicating that a path specifying a device
* was supplied to the operation when a path with no device is
* required. The path can be retrieved using <code>getPath</code> on the
* status object.
*/
public static final int DEVICE_PATH = 973;
/**
* Status constant indicating that a string
* was supplied to the operation that was <code>null</code>.
*/
public static final int NULL_STRING = 974;
/**
* Status constant indicating that the operation encountered
* a read-only element.
* The element(s) can be retrieved using <code>getElements</code> on the status object.
*/
public static final int READ_ONLY = 976;
/**
* Status constant indicating that a naming collision would occur
* if the operation proceeded.
*/
public static final int NAME_COLLISION = 977;
/**
* Status constant indicating that a destination provided for a copy/move/rename operation
* is invalid.
* The destination element can be retrieved using <code>getElements</code> on the status object.
*/
public static final int INVALID_DESTINATION = 978;
/**
* Status constant indicating that a path provided to an operation
* is invalid. The path can be retrieved using <code>getPath</code> on the
* status object.
*/
public static final int INVALID_PATH = 979;
/**
* Status constant indicating the given source position is out of bounds.
*/
public static final int INDEX_OUT_OF_BOUNDS = 980;
/**
* Status constant indicating there is an update conflict
* for a working copy. The translation unit on which the
* working copy is based has changed since the working copy
* was created.
*/
public static final int UPDATE_CONFLICT = 981;
/**
* Status constant indicating that <code>null</code> was specified
* as a name argument.
*/
public static final int NULL_NAME = 982;
/**
* Status constant indicating that a name provided is not syntactically correct.
* The name can be retrieved from <code>getString</code>.
*/
public static final int INVALID_NAME = 983;
/**
* Status constant indicating that the specified contents
* are not valid.
*/
public static final int INVALID_CONTENTS = 984;
/**
* Status constant indicating that an <code>java.io.IOException</code>
* occurred.
*/
public static final int IO_EXCEPTION = 985;
/**
* Status constant indicating that a <code>DOMException</code>
* occurred.
*/
public static final int DOM_EXCEPTION = 986;
/**
* Status constant indicating that a <code>TargetException</code>
* occurred.
*/
public static final int TARGET_EXCEPTION = 987;
/**
* Status constant indicating that the C builder
* could not be initialized.
*/
public static final int BUILDER_INITIALIZATION_ERROR = 990;
/**
* Status constant indicating that the C builder's last built state
* could not be serialized or deserialized.
*/
public static final int BUILDER_SERIALIZATION_ERROR = 991;
/**
* Status constant indicating that an error was encountered while
* trying to evaluate a code snippet, or other item.
*/
public static final int EVALUATION_ERROR = 992;
/**
* Status constant indicating that a sibling specified is not valid.
*/
public static final int INVALID_SIBLING = 993;
/**
* Status indicating that a C element could not be created because
* the underlying resource is invalid.
* @see CCore
*/
public static final int INVALID_RESOURCE = 995;
/**
* Status indicating that a C element could not be created because
* the underlying resource is not of an appropriate type.
* @see CCore
*/
public static final int INVALID_RESOURCE_TYPE = 996;
/**
* Status indicating that a C element could not be created because
* the project owning underlying resource does not have the C nature.
* @see CCore
*/
public static final int INVALID_PROJECT = 997;
//public static final int INVALID_NAMESPACE = 998;
/**
* Status indicating that the corresponding resource has no local contents yet.
* This might happen when attempting to use a resource before its contents
* has been made locally available.
*/
public static final int NO_LOCAL_CONTENTS = 999;
///**
//* Status constant indicating that a classpath entry was invalid
//*/
//public static final int INVALID_CLASSPATH = 964;
}

View file

@ -0,0 +1,43 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
/**
* A C project represents a view of a project resource in terms of C
* elements such as ICFile, ICFolder ....
* <code>CCore.create(project)</code>.
* </p>
*
* @see CCore#create(org.eclipse.core.resources.IProject)
* @see IBuildEntry
*/
public interface ICProject extends IParent, ICElement {
/**
* Returns the <code>ICElement</code> corresponding to the given
* path, or <code>null</code> if no such
* <code>ICElement</code> is found.
*
* @exception CModelException if the given path is <code>null</code>
* or absolute
*/
ICElement findElement(IPath path) throws CModelException;
/**
* Return the ArchiveContainer of this Project.
*/
IArchiveContainer getArchiveContainer();
/**
* Return the BinaryContainer of this Project.
*/
IBinaryContainer getBinaryContainer();
IProject getProject();
}

View file

@ -0,0 +1,179 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* Represent the root C element corresponding to the workspace.
* Since there is only one such root element, it is commonly referred to as
* <em>the</em> C model element.
* The C model element needs to be opened before it can be navigated or manipulated.
* The C model element has no parent (it is the root of the C element
* hierarchy). Its children are <code>ICProject</code>s.
* <p>
* This interface provides methods for performing copy, move, rename, and
* delete operations on multiple C elements.
* </p>
*
* @see CCore#create(org.eclipse.core.resources.IWorkspaceRoot)
*/
public interface ICRoot extends ICElement, IParent {
/**
* Copies the given elements to the specified container(s).
* If one container is specified, all elements are copied to that
* container. If more than one container is specified, the number of
* elements and containers must match, and each element is copied to
* its associated container.
* <p>
* Optionally, each copy can positioned before a sibling
* element. If <code>null</code> is specified for a given sibling, the copy
* is inserted as the last child of its associated container.
* </p>
* <p>
* Optionally, each copy can be renamed. If
* <code>null</code> is specified for the new name, the copy
* is not renamed.
* </p>
* <p>
* Optionally, any existing child in the destination container with
* the same name can be replaced by specifying <code>true</code> for
* force. Otherwise an exception is thrown in the event that a name
* collision occurs.
* </p>
*
* @param elements the elements to copy
* @param containers the container, or list of containers
* @param siblings the list of siblings element any of which may be
* <code>null</code>; or <code>null</code>
* @param renamings the list of new names any of which may be
* <code>null</code>; or <code>null</code>
* @param replace <code>true</code> if any existing child in a target container
* with the target name should be replaced, and <code>false</code> to throw an
* exception in the event of a name collision
* @param monitor a progress monitor
* @exception CModelException if an element could not be copied. Reasons include:
* <ul>
* <li> A specified element, container, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> A <code>CoreException</code> occurred while updating an underlying resource
* <li> A container is of an incompatible type (<code>INVALID_DESTINATION</code>)
* <li> A sibling is not a child of it associated container (<code>INVALID_SIBLING</code>)
* <li> A new name is invalid (<code>INVALID_NAME</code>)
* <li> A child in its associated container already exists with the same
* name and <code>replace</code> has been specified as <code>false</code> (<code>NAME_COLLISION</code>)
* <li> A container or element is read-only (<code>READ_ONLY</code>)
* </ul>
*/
void copy(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException;
/**
* Deletes the given elements, forcing the operation if necessary and specified.
*
* @param elements the elements to delete
* @param force a flag controlling whether underlying resources that are not
* in sync with the local file system will be tolerated
* @param monitor a progress monitor
* @exception CModelException if an element could not be deleted. Reasons include:
* <ul>
* <li> A specified element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> A <code>CoreException</code> occurred while updating an underlying resource
* <li> An element is read-only (<code>READ_ONLY</code>)
* </ul>
*/
void delete(ICElement[] elements, boolean force, IProgressMonitor monitor) throws CModelException;
/**
* Moves the given elements to the specified container(s).
* If one container is specified, all elements are moved to that
* container. If more than one container is specified, the number of
* elements and containers must match, and each element is moved to
* its associated container.
* <p>
* Optionally, each element can positioned before a sibling
* element. If <code>null</code> is specified for sibling, the element
* is inserted as the last child of its associated container.
* </p>
* <p>
* Optionally, each element can be renamed. If
* <code>null</code> is specified for the new name, the element
* is not renamed.
* </p>
* <p>
* Optionally, any existing child in the destination container with
* the same name can be replaced by specifying <code>true</code> for
* force. Otherwise an exception is thrown in the event that a name
* collision occurs.
* </p>
*
* @param elements the elements to move
* @param containers the container, or list of containers
* @param siblings the list of siblings element any of which may be
* <code>null</code>; or <code>null</code>
* @param renamings the list of new names any of which may be
* <code>null</code>; or <code>null</code>
* @param replace <code>true</code> if any existing child in a target container
* with the target name should be replaced, and <code>false</code> to throw an
* exception in the event of a name collision
* @param monitor a progress monitor
* @exception CModelException if an element could not be moved. Reasons include:
* <ul>
* <li> A specified element, container, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> A <code>CoreException</code> occurred while updating an underlying resource
* <li> A container is of an incompatible type (<code>INVALID_DESTINATION</code>)
* <li> A sibling is not a child of it associated container (<code>INVALID_SIBLING</code>)
* <li> A new name is invalid (<code>INVALID_NAME</code>)
* <li> A child in its associated container already exists with the same
* name and <code>replace</code> has been specified as <code>false</code> (<code>NAME_COLLISION</code>)
* <li> A container or element is read-only (<code>READ_ONLY</code>)
* </ul>
*
* @exception IllegalArgumentException any element or container is <code>null</code>
*/
void move(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException;
/**
* Renames the given elements as specified.
* If one container is specified, all elements are renamed within that
* container. If more than one container is specified, the number of
* elements and containers must match, and each element is renamed within
* its associated container.
*
* @param elements the elements to rename
* @param destinations the container, or list of containers
* @param names the list of new names
* @param replace <code>true</code> if an existing child in a target container
* with the target name should be replaced, and <code>false</code> to throw an
* exception in the event of a name collision
* @param monitor a progress monitor
* @exception CModelException if an element could not be renamed. Reasons include:
* <ul>
* <li> A specified element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> A <code>CoreException</code> occurred while updating an underlying resource
* <li> A new name is invalid (<code>INVALID_NAME</code>)
* <li> A child already exists with the same name and <code>replace</code> has been specified as <code>false</code> (<code>NAME_COLLISION</code>)
* <li> An element is read-only (<code>READ_ONLY</code>)
* </ul>
*/
void rename(ICElement[] elements, ICElement[] destinations, String[] names, boolean replace, IProgressMonitor monitor) throws CModelException;
/**
* Returns the C project with the given name. This is a handle-only method.
* The project may or may not exist.
*/
ICProject getCProject(String name);
/**
* Returns the C projects.
*/
ICProject[] getCProjects();
/**
* Returns the workspace associated with this C model.
*/
IWorkspace getWorkspace();
IWorkspaceRoot getRoot();
}

View file

@ -0,0 +1,20 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
/**
* An element changed listener receives notification of changes to C elements
* maintained by the C model.
*/
public interface IElementChangedListener {
/**
* Notifies that one or more attributes of one or more C elements have changed.
* The specific details of the change are described by the given event.
*
* @param event the change event
*/
public void elementChanged(ElementChangedEvent event);
}

View file

@ -0,0 +1,12 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
/**
* An Enumeration type.
*/
public interface IEnumeration extends IVariable {
}

View file

@ -0,0 +1,20 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
/**
* Represents a field(variable) declared in an IStructure(struct, class, union).
*/
public interface IField extends IMember, IVariable {
/**
* Returns whether this storage specifier is mutable for the member.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
public boolean isMutable() throws CModelException;
}

View file

@ -0,0 +1,78 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
* Represents a function.
*/
public interface IFunction extends ICElement, ISourceReference, ISourceManipulation {
/**
* Returns the exceptions this method throws, in the order declared in the source.
* or an empty array if this method throws no exceptions.
*
* <p>For example, a source method declaring <code>"void f(int a) throw (x2, x3);"</code>,
* would return the array <code>{"x2", "x3"}</code>.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*
*/
public String[] getExceptions() throws CModelException;
/**
* Returns the number of parameters of this method.
*/
public int getNumberOfParameters();
/**
* Returns the initializer of parameters pos for this method.
* Returns an empty string if this argument has no initializer.
*
* <p>For example, a method declared as <code>void foo(String text, int length=9)</code>
* would return the array <code>{"9"}</code>.
*
* @exception CModelException if this argument does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
public String getParameterInitializer(int pos);
/**
* Returns the type signatures for the parameters of this method.
* Returns an empty array if this method has no parameters.
* This is a handle-only method.
*
* <p>For example, a source method declared as <code>void foo(string text, int length)</code>
* would return the array <code>{"string","int"}</code>.
*
* @see Signature
*/
public String[] getParameterTypes();
/**
* Returns the type signature of the return value of this method.
* For constructors, this returns the signature for void.
*
* <p>For example, a source method declared as <code>int getName()</code>
* would return <code>"int"</code>.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*
* @see Signature
*/
public String getReturnType() throws CModelException;
/**
* Returns the access Control of the member. The value can be
* can be examined using class <code>Flags</code>.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
* @see Flags
*/
public int getAccessControl() throws CModelException;
}

View file

@ -0,0 +1,80 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
* Represents a function
*/
public interface IFunctionDeclaration extends ICElement, ISourceReference, ISourceManipulation {
/**
* Returns the type signatures of the exceptions this method throws,
* in the order declared in the source. Returns an empty array
* if this method throws no exceptions.
*
* <p>For example, a source method declaring <code>"void f(int a) throw (x1, x2);"</code>,
* would return the array <code>{"x1", "x2"}</code>.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*
* @see Signature
*/
String[] getExceptions() throws CModelException;
/**
* Returns the number of parameters of this method.
*/
int getNumberOfParameters();
/**
* Returns the initializer of parameters position for this method.
* Returns an empty string if this argument has no initializer.
*
* <p>For example, a method declared as <code>public void foo(String text, int length=9)</code>
* would return the array <code>{"9"}</code>.
*
* @exception CModelException if this argument does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
String getParameterInitializer(int pos);
/**
* Returns the type signatures for the parameters of this method.
* Returns an empty array if this method has no parameters.
* This is a handle-only method.
*
* <p>For example, a source method declared as <code>void foo(string text, int length)</code>
* would return the array <code>{"string","int"}</code>.
*
* @see Signature
*/
String[] getParameterTypes();
/**
* Returns the type signature of the return value of this method.
* For constructors, this returns the signature for void.
*
* <p>For example, a source method declared as <code>public String getName()</code>
* would return <code>"String"</code>.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*
* @see Signature
*/
String getReturnType() throws CModelException;
/**
* Returns the access Control of the member. The access qualifier
* can be examine using the AccessControl class.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
* @see IAccessControl
*/
int getAccessControl() throws CModelException;
}

View file

@ -0,0 +1,25 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
* Represents an include declaration in a C translation unit.
*/
public interface IInclude extends ICElement, ISourceReference, ISourceManipulation {
/**
* Returns the name that of the included file.
* For example, for the statement <code>"#include <stdio.h></code>,
* this returns <code>"stdio.h"</code>.
*/
String getIncludeName();
/**
* Returns whether the included was search on "standard places" like /usr/include first .
* An include is standard if it starts with <code>"\<"</code>.
* For example, <code>"#include \<stdio.h\>"</code> returns true and
* <code>"#include "foobar.h"</code> returns false.
*/
boolean isStandard();
}

View file

@ -0,0 +1,21 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
* Place holder of the inherited class from struct or class(IStructure).
*/
public interface IInheritance {
/**
* Return the inherited structures.
*/
public IStructure [] getBaseTypes() throws CModelException;
/**
* Return the access control for each inherited structure.
*/
public int getAccessControl(int pos) throws CModelException;
}

View file

@ -0,0 +1,11 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
*/
public interface ILibraryReference extends IParent, ICElement {
}

View file

@ -0,0 +1,14 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
/**
* Represents a field declared in a type.
*/
public interface IMacro extends ICElement, ISourceManipulation, ISourceReference {
String getIdentifierList();
String getTokenSequence();
}

View file

@ -0,0 +1,48 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
/**
* Common protocol for C elements that can be members of types.
* This set consists of <code>IType</code>, <code>IMethod</code>,
* <code>IField</code>.
*/
public interface IMember extends ICElement, ISourceReference, ISourceManipulation {
///**
//* Returns the structure in which this member is declared, or <code>null</code>
//* if this member is not declared in a type (for example, a top-level type).
//*/
//IStructure belongsTo() throws CModelException;
/**
* Returns true if the member as class scope.
* For example static methods in C++ have class scope
*
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
public boolean hasClassScope() throws CModelException;
/**
* Returns whether this method/field is declared constant.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
public boolean isConst() throws CModelException;
/**
* Returns the access Control of the member. The access qualifier
* can be examine using the AccessControl class.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
* @see IAccessControl
*/
public int getAccessControl() throws CModelException;
}

View file

@ -0,0 +1,117 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
* Represents the definition method of a class.
*/
public interface IMethod extends IMember {
/**
* Returns the type signatures of the exceptions this method throws,
* in the order declared in the source. Returns an empty array
* if this method throws no exceptions.
*
* <p>For example, a source method declaring <code>"throws IOException"</code>,
* would return the array <code>{"QIOException;"}</code>.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*
* @see Signature
*/
String[] getExceptions() throws CModelException;
/**
* Returns the number of parameters of this method.
*/
int getNumberOfParameters();
/**
* Returns the initializer of parameters pos for this method.
* Returns an empty string if this argument has no initializer.
*
* <p>For example, a method declared as <code>public void foo(String text, int length=9)</code>
* would return the array <code>{"9"}</code>.
*
* @exception CModelException if this argument does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
String getParameterInitializer(int pos);
/**
* Returns the type signatures for the parameters of this method.
* Returns an empty array if this method has no parameters.
* This is a handle-only method.
*
* <p>For example, a source method declared as <code>void foo(String text, int length)</code>
* would return the array <code>{"String","int"}</code>.
*
* @see Signature
*/
String[] getParameterTypes();
/**
* Returns the type signature of the return value of this method.
* For constructors, this returns the signature for void.
*
* <p>For example, a source method declared as <code>public String getName()</code>
* would return <code>"String"</code>.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*
* @see Signature
*/
String getReturnType() throws CModelException;
/**
* Returns whether this method is a constructor.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
boolean isConstructor() throws CModelException;
/**
* Returns whether this method is a destructor.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
boolean isDestructor() throws CModelException;
/**
* Returns whether this method is an operator method.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
boolean isOperator() throws CModelException;
/**
* Returns whether this method is declared pure virtual.
*
* <p>For example, a source method declared as <code>virtual void m() = 0;</code>.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
boolean isAbstract() throws CModelException;
/**
* Returns whether this method is declared virtual.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
boolean isVirtual() throws CModelException;
/**
* return true if the member is a friend.
*/
public boolean isFriend() throws CModelException;
}

View file

@ -0,0 +1,117 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
* Represents the declaration method of a class
*/
public interface IMethodDeclaration extends IMember {
/**
* Returns the type signatures of the exceptions this method throws,
* in the order declared in the source. Returns an empty array
* if this method throws no exceptions.
*
* <p>For example, a source method declaring <code>"throws IOException"</code>,
* would return the array <code>{"QIOException;"}</code>.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*
* @see Signature
*/
String[] getExceptions() throws CModelException;
/**
* Returns the number of parameters of this method.
*/
int getNumberOfParameters();
/**
* Returns the initializer of parameters pos for this method.
* Returns an empty string if this argument has no initializer.
*
* <p>For example, a method declared as <code>public void foo(String text, int length=9)</code>
* would return the array <code>{"9"}</code>.
*
* @exception CModelException if this argument does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
String getParameterInitializer(int pos);
/**
* Returns the type signatures for the parameters of this method.
* Returns an empty array if this method has no parameters.
* This is a handle-only method.
*
* <p>For example, a source method declared as <code>void foo(String text, int length)</code>
* would return the array <code>{"String","int"}</code>.
*
* @see Signature
*/
String[] getParameterTypes();
/**
* Returns the type signature of the return value of this method.
* For constructors, this returns the signature for void.
*
* <p>For example, a source method declared as <code>public String getName()</code>
* would return <code>"String"</code>.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*
* @see Signature
*/
String getReturnType() throws CModelException;
/**
* Returns whether this method is a constructor.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
boolean isConstructor() throws CModelException;
/**
* Returns whether this method is a destructor.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
boolean isDestructor() throws CModelException;
/**
* Returns whether this method is an operator method.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
boolean isOperator() throws CModelException;
/**
* Returns whether this method is declared pure virtual.
*
* <p>For example, a source method declared as <code>virtual void m() = 0;</code>.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
boolean isAbstract() throws CModelException;
/**
* Returns whether this method is declared virtual.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
boolean isVirtual() throws CModelException;
/**
* return true if the member is a friend.
*/
public boolean isFriend() throws CModelException;
}

View file

@ -0,0 +1,16 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
/**
* Represents a package declaration in a C translation unit.
*/
public interface INamespace extends ICElement, ISourceManipulation, ISourceReference {
/**
* Returns the name of the package the statement refers to.
* This is a handle-only method.
*/
String getElementName();
}

View file

@ -0,0 +1,31 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
* Common protocol for C elements that contain other C elements.
*/
public interface IParent {
/**
* Returns the immediate children of this element.
* The children are in no particular order.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
*/
ICElement[] getChildren(); //throws CModelException;
/**
* Returns whether this element has one or more immediate children.
* This is a convenience method, and may be more efficient than
* testing whether <code>getChildren</code> is an empty array.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
*/
boolean hasChildren(); //throws CModelException;
}

View file

@ -0,0 +1,109 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.core.runtime.IProgressMonitor;
/**
* Common protocol for C elements that support source code manipulations such
* as copy, move, rename, and delete.
*/
public interface ISourceManipulation {
/**
* Copies this element to the given container.
*
* @param container the container
* @param sibling the sibling element before which the copy should be inserted,
* or <code>null</code> if the copy should be inserted as the last child of
* the container
* @param rename the new name for the element, or <code>null</code> if the copy
* retains the name of this element
* @param replace <code>true</code> if any existing child in the container with
* the target name should be replaced, and <code>false</code> to throw an
* exception in the event of a name collision
* @param monitor a progress monitor
* @exception CModelException if this element could not be copied. Reasons include:
* <ul>
* <li> This C element, container element, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> A <code>CoreException</code> occurred while updating an underlying resource
* <li> The container is of an incompatible type (INVALID_DESTINATION)
* <li> The sibling is not a child of the given container (INVALID_SIBLING)
* <li> The new name is invalid (INVALID_NAME)
* <li> A child in the container already exists with the same name (NAME_COLLISION)
* and <code>replace</code> has been specified as <code>false</code>
* <li> The container or this element is read-only (READ_ONLY)
* </ul>
*
* @exception IllegalArgumentException if container is <code>null</code>
*/
void copy(ICElement container, ICElement sibling, String rename, boolean replace, IProgressMonitor monitor) throws CModelException;
/**
* Deletes this element, forcing if specified and necessary.
*
* @param force a flag controlling whether underlying resources that are not
* in sync with the local file system will be tolerated (same as the force flag
* in IResource operations).
* @param monitor a progress monitor
* @exception CModelException if this element could not be deleted. Reasons include:
* <ul>
* <li> This C element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> A <code>CoreException</code> occurred while updating an underlying resource (CORE_EXCEPTION)</li>
* <li> This element is read-only (READ_ONLY)</li>
* </ul>
*/
void delete(boolean force, IProgressMonitor monitor) throws CModelException;
/**
* Moves this element to the given container.
*
* @param container the container
* @param sibling the sibling element before which the element should be inserted,
* or <code>null</code> if the element should be inserted as the last child of
* the container
* @param rename the new name for the element, or <code>null</code> if the
* element retains its name
* @param replace <code>true</code> if any existing child in the container with
* the target name should be replaced, and <code>false</code> to throw an
* exception in the event of a name collision
* @param monitor a progress monitor
* @exception CModelException if this element could not be moved. Reasons include:
* <ul>
* <li> This C element, container element, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> A <code>CoreException</code> occurred while updating an underlying resource
* <li> The container is of an incompatible type (INVALID_DESTINATION)
* <li> The sibling is not a child of the given container (INVALID_SIBLING)
* <li> The new name is invalid (INVALID_NAME)
* <li> A child in the container already exists with the same name (NAME_COLLISION)
* and <code>replace</code> has been specified as <code>false</code>
* <li> The container or this element is read-only (READ_ONLY)
* </ul>
*
* @exception IllegalArgumentException if container is <code>null</code>
*/
void move(ICElement container, ICElement sibling, String rename, boolean replace, IProgressMonitor monitor) throws CModelException;
/**
* Renames this element to the given name.
*
* @param name the new name for the element
* @param replace <code>true</code> if any existing element with the target name
* should be replaced, and <code>false</code> to throw an exception in the
* event of a name collision
* @param monitor a progress monitor
* @exception CModelException if this element could not be renamed. Reasons include:
* <ul>
* <li> This C element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> A <code>CoreException</code> occurred while updating an underlying resource
* <li> The new name is invalid (INVALID_NAME)
* <li> A child in the container already exists with the same name (NAME_COLLISION)
* and <code>replace</code> has been specified as <code>false</code>
* <li> This element is read-only (READ_ONLY)
* </ul>
*/
void rename(String name, boolean replace, IProgressMonitor monitor) throws CModelException;
}

View file

@ -0,0 +1,42 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
* A source range defines an element's source coordinates
*/
public interface ISourceRange {
/**
* Returns the 0-based starting position of this element.
*/
public int getStartPos();
/**
* Returns the number of characters of the source code for this element.
*/
public int getLength();
/**
* Returns the Id starting position of this element.
*/
public int getIdStartPos();
/**
* Returns the number of characters of the Id for this element.
*/
public int getIdLength();
/**
* Returns the 1-based starting line of this element.
*/
public int getStartLine();
/**
* Returns the 1-based ending line of this element.
*/
public int getEndLine();
}

View file

@ -0,0 +1,51 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
* Common protocol for C elements that have associated source code.
* <p>
* Note: For <code>IBinary</code>, <code>IArchive</code> and other members
* derived from a binary type, the implementation returns source iff the
* element has attached source code and debuging information.
*
*/
public interface ISourceReference {
/**
* Returns the source code associated with this element.
* <p>
* For binary files, this returns the source of the entire translation unit
* associated with the binary file (if there is one).
* </p>
*
* @return the source code, or <code>null</code> if this element has no
* associated source code
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
*/
String getSource() throws CModelException;
/**
* Returns the source range associated with this element.
* <p>
* For binary files, this returns the range of the entire translation unit
* associated with the binary file (if there is one).
* </p>
*
* @return the source range, or <code>null</code> if if this element has no
* associated source code
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
*/
ISourceRange getSourceRange() throws CModelException;
/**
* Returns the translation unit in which this member is declared, or <code>null</code>
* if this member is not declared in a translation unit (for example, a binary type).
*/
ITranslationUnit getTranslationUnit();
}

View file

@ -0,0 +1,27 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
* Represent struct(ure), class or union.
*/
public interface IStructure extends IInheritance, IParent, ICElement, IVariable {
//public String instantiatesTemplate();
public IField getField(String name);
public IField[] getFields();
public IMethod getMethod(String name);
public IMethod [] getMethods();
public boolean isUnion();
public boolean isClass();
public boolean isStruct();
public boolean isAbstract();
}

View file

@ -0,0 +1,120 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import org.eclipse.core.runtime.IProgressMonitor;
/**
* Represents an entire C translation unit (<code>.c</code> source file).
* The children are of type <code>IStructureElement</code>,
* <code>IInclude</code>, etc..
* and appear in the order in which they are declared in the source.
* If a <code>.c</code> file cannot be parsed, its structure remains unknown.
* Use <code>ICElement.isStructureKnown</code> to determine whether this is
* the case.
*/
public interface ITranslationUnit extends ICFile , ISourceReference, ISourceManipulation {
/**
* Creates and returns an include declaration in this translation unit
* with the given name.
* <p>
* Optionally, the new element can be positioned before the specified
* sibling. If no sibling is specified, the element will be inserted
* as the last import declaration in this translation unit.
* <p>
* If the translation unit already includes the specified include declaration,
* the import is not generated (it does not generate duplicates).
*
* @param name the name of the include declaration to add (For example: <code>"stdio.h"</code> or
* <code>"sys/types.h"</code>)
* @param sibling the existing element which the include declaration will be inserted immediately before (if
* <code> null </code>, then this include will be inserted as the last include declaration.
* @param monitor the progress monitor to notify
* @return the newly inserted include declaration (or the previously existing one in case attempting to create a duplicate)
*
* @exception CModelException if the element could not be created. Reasons include:
* <ul>
* <li> This C element does not exist or the specified sibling does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> A <code>CoreException</code> occurred while updating an underlying resource
* <li> The specified sibling is not a child of this translation unit (INVALID_SIBLING)
* <li> The name is not a valid import name (INVALID_NAME)
* </ul>
*/
IInclude createInclude(String name, ICElement sibling, IProgressMonitor monitor) throws CModelException;
/**
* Creates and returns a namesapce declaration in this translation unit
* with the given package name.
*
* <p>If the translation unit already includes the specified package declaration,
* it is not generated (it does not generate duplicates).
*
* @param name the name of the namespace declaration to add (For example, <code>"std"</code>)
* @param monitor the progress monitor to notify
* @return the newly inserted namespace declaration (or the previously existing one in case attempting to create a duplicate)
*
* @exception CModelException if the element could not be created. Reasons include:
* <ul>
* <li>This C element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> A <code>CoreException</code> occurred while updating an underlying resource
* <li> The name is not a valid package name (INVALID_NAME)
* </ul>
*/
IUsing createUsing (String name, IProgressMonitor monitor) throws CModelException;
/**
* Returns the smallest element within this translation unit that
* includes the given source position (that is, a method, field, etc.), or
* <code>null</code> if there is no element other than the translation
* unit itself at the given position, or if the given position is not
* within the source range of this translation unit.
*
* @param position a source position inside the translation unit
* @return the innermost C element enclosing a given source position or <code>null</code>
* if none (excluding the translation unit).
* @exception CModelException if the translation unit does not exist or if an
* exception occurs while accessing its corresponding resource
*/
ICElement getElementAtLine(int line) throws CModelException;
ICElement getElement(String name) throws CModelException;
/**
* Returns the include declaration in this translation unit with the given name.
*
* @param the name of the include to find (For example: <code>"stdio.h"</code>
* or <code>"sys/types.h"</code>)
* @return a handle onto the corresponding include declaration. The include declaration may or may not exist.
*/
IInclude getInclude(String name) ;
/**
* Returns the include declarations in this translation unit
* in the order in which they appear in the source.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
*/
IInclude[] getIncludes() throws CModelException;
/**
* Returns the first namespace declaration in this translation unit with the given package name
* This is a handle-only method. The namespace declaration may or may not exist.
*
* @param name the name of the namespace declaration (For example, <code>"std"</code>)
*/
IUsing getUsing(String name);
/**
* Returns the namespace declarations in this translation unit
* in the order in which they appear in the source.
*
* @return an array of namespace declaration (normally of size one)
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
*/
IUsing[] getUsings() throws CModelException;
}

View file

@ -0,0 +1,16 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
/**
* Represents a field declared in a type.
*/
public interface ITypeDef extends ICElement, ISourceManipulation, ISourceReference {
/**
* Return the type beeing alias.
*/
String getType() throws CModelException;
}

View file

@ -0,0 +1,16 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
/**
* Represents a "using" declaration in C translation unit.
*/
public interface IUsing extends ICElement, ISourceManipulation, ISourceReference {
/**
* Returns the name of the package the statement refers to.
* This is a handle-only method.
*/
String getElementName();
}

View file

@ -0,0 +1,15 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
/**
* Represents a global variable.
*/
public interface IVariable extends ICElement , ISourceManipulation, ISourceReference {
public String getType();
public String getInitializer();
public int getAccessControl() throws CModelException;
}

View file

@ -0,0 +1,15 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
/**
* Represents the declaration of a variable.
*/
public interface IVariableDeclaration extends ICElement, ISourceManipulation, ISourceReference {
public String getType ();
public int getAccesControl();
}

View file

@ -0,0 +1,12 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
/**
* Represents a static variable.
*/
public interface IVariableLocal extends IVariable {
}

View file

@ -0,0 +1,44 @@
package org.eclipse.cdt.internal.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* 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.IArchive;
import org.eclipse.cdt.core.model.IBinary;
public class Archive extends CFile implements IArchive {
public Archive(ICElement parent, IFile file) {
super(parent, file);
}
public Archive(ICElement parent, IPath path) {
super (parent, path);
}
public boolean isReadOnly() {
return true;
}
public boolean isArchive() {
return true;
}
public IBinary[] getBinaries() {
return (IBinary[])getChildren();
}
public CElementInfo createElementInfo() {
return new ArchiveInfo(this);
}
protected ArchiveInfo getArchiveInfo() {
return (ArchiveInfo)getElementInfo();
}
}

View file

@ -0,0 +1,87 @@
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.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.cdt.core.model.IArchive;
import org.eclipse.cdt.core.model.IArchiveContainer;
import org.eclipse.cdt.core.model.ICElement;
public class ArchiveContainer extends Parent implements IArchiveContainer {
CProject cProject;
private long modificationStamp;
public ArchiveContainer (CProject cProject) {
super (cProject, null, "lib", CElement.C_CONTAINER);
this.cProject = cProject;
IProject project = cProject.getProject();
IFolder folder = project.getFolder("Virtual.lib");
setUnderlyingResource(folder);
}
public IArchive[] getArchives() {
ICElement[] e = getChildren(false);
IArchive[] a = new IArchive[e.length];
System.arraycopy(e, 0, a, 0, e.length);
return a;
}
public boolean hasChildren() {
return (getChildren().length > 0);
}
public ICElement [] getChildren() {
return getChildren(true);
}
public ICElement [] getChildren(boolean sync) {
if (!cProject.hasRunElf()) {
// It is vital to set this to true first, if not we are going to loop
cProject.setRunElf(true);
ElfRunner runner = new ElfRunner(cProject);
Thread thread = new Thread(runner, "Archive Runner");
// thread.setPriority(Thread.NORM_PRIORITY - 1);
thread.setDaemon(true);
thread.start();
if (sync) {
try {
thread.join();
} catch (InterruptedException e) {
}
}
}
return super.getChildren();
}
//public IResource getUnderlyingResource() {
// return null;
//}
public IResource getCorrespondingResource() {
return null;
}
void addChildIfLib(IFile file) {
CModelManager factory = CModelManager.getDefault();
if (factory.isArchive(file)) {
ICElement celement = factory.create(file);
if (celement != null) {
if (celement instanceof IArchive) {
addChild (celement);
}
}
}
}
public CElementInfo createElementInfo() {
return new CElementInfo(this);
}
}

View file

@ -0,0 +1,77 @@
package org.eclipse.cdt.internal.core.model;
/*
* (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 org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.utils.elf.AR;
import org.eclipse.cdt.utils.elf.ElfHelper;
/**
* Info for ICProject.
*/
class ArchiveInfo extends CFileInfo {
/**
*/
public ArchiveInfo(CElement element) {
super(element);
}
public ICElement [] getChildren() {
init();
return super.getChildren();
}
public void init() {
if (hasChanged()) {
removeChildren();
loadInfo();
}
}
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;
}
};
// 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);
}
ar.dispose();
} catch (IOException e) {
//e.printStackTrace();
}
}
}

View file

@ -0,0 +1,80 @@
package org.eclipse.cdt.internal.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* 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.IBinary;
public class Binary extends CFile implements IBinary {
public Binary(ICElement parent, IFile file) {
super(parent, file);
}
public Binary(ICElement parent, IPath path) {
super (parent, path);
}
public Binary(ICElement parent, IFile file, String name) {
super(parent, file, name);
}
public boolean isReadOnly () {
return true;
}
public boolean isBinary() {
return true;
}
public boolean hasDebug () {
return ((BinaryInfo)getElementInfo()).hasDebug();
}
public boolean isExecutable() {
return ((BinaryInfo)getElementInfo()).isExecutable();
}
public boolean isObject() {
return ((BinaryInfo)getElementInfo()).isObject();
}
public boolean isSharedLib() {
return ((BinaryInfo)getElementInfo()).isSharedLib();
}
public String [] getNeededSharedLibs() {
return ((BinaryInfo)getElementInfo()).getNeededSharedLibs();
}
public String getCPU() {
return ((BinaryInfo)getElementInfo()).getCPU();
}
public long getText() {
return ((BinaryInfo)getElementInfo()).getText();
}
public long getData() {
return ((BinaryInfo)getElementInfo()).getData();
}
public long getBSS() {
return ((BinaryInfo)getElementInfo()).getBSS();
}
public String getSoname() {
return ((BinaryInfo)getElementInfo()).getSoname();
}
public CElementInfo createElementInfo() {
return new BinaryInfo(this);
}
}

View file

@ -0,0 +1,147 @@
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.IFolder;
import org.eclipse.core.resources.IProject;
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.IBinary;
import org.eclipse.cdt.core.model.IBinaryContainer;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICRoot;
public class BinaryContainer extends Parent implements IBinaryContainer {
CProject cProject;
private long modificationStamp;
public BinaryContainer (CProject cProject) {
this (cProject, "bin");
}
public BinaryContainer (CProject cProject, String name) {
super (cProject, null, name, CElement.C_CONTAINER);
this.cProject = cProject;
IProject project = cProject.getProject();
IFolder folder = project.getFolder("Virtual.bin");
setUnderlyingResource(folder);
}
public IBinary[] getBinaries() {
ICElement[] e = getChildren(false);
IBinary[] b = new IBinary[e.length];
System.arraycopy(e, 0, b, 0, e.length);
return b;
}
public boolean hasChildren() {
return (getChildren().length > 0);
}
public ICElement [] getChildren() {
return getChildren(true);
}
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");
// thread.setPriority(Thread.NORM_PRIORITY - 1);
thread.setDaemon(true);
thread.start();
if (sync) {
try {
thread.join();
} catch (InterruptedException e) {
}
}
}
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.
if (!factory.isTranslationUnit(file)) {
ICElement celement = factory.create(file);
if (celement != null) {
if (celement instanceof IBinary) {
IBinary bin = (IBinary)celement;
if (bin.isExecutable() || bin.isSharedLib()) {
addChild (bin);
}
}
}
}
}
public CElementInfo createElementInfo() {
return new CElementInfo(this);
}
class Visitor implements IResourceVisitor {
CoreModel factory = CoreModel.getDefault();
BinaryContainer cbin;
public Visitor (BinaryContainer element) {
cbin = element;
}
public boolean visit(IResource res) throws CoreException {
if (res instanceof IFile) {
cbin.addChildIfExec(factory, (IFile)res);
return false;
}
return true;
}
}
class BinaryRunnable implements Runnable {
BinaryContainer cbin;
public BinaryRunnable(BinaryContainer element) {
cbin = element;
}
public void run() {
try {
((IProject)cbin.getCProject().getUnderlyingResource()).accept(new Visitor(cbin));
} catch (CoreException e) {
//e.printStackTrace();
}
// Fired the event.
ICElement[] children = cbin.getChildren();
if (children.length > 0) {
CModelManager factory = CModelManager.getDefault();
ICElement root = (ICRoot)factory.getCRoot();
CElementDelta cdelta = new CElementDelta(root);
cdelta.added(cbin.getCProject());
cdelta.added(cbin);
for (int i = 0; i < children.length; i++) {
ICElement child = children[i];
cdelta.added(child);
}
factory.registerCModelDelta(cdelta);
factory.fire();
}
}
}
}

Some files were not shown because too many files have changed in this diff Show more