Initial commit
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/.classpath b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/.classpath
new file mode 100644
index 0000000..065ac06
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/.cvsignore b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/.cvsignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/.project b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/.project
new file mode 100644
index 0000000..7368702
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.wtp.releng.tools.component.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>
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/apiagent/apiagent.c b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/apiagent/apiagent.c
new file mode 100644
index 0000000..cd09e2c
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/apiagent/apiagent.c
@@ -0,0 +1,193 @@
+#include <jvmpi.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static JVMPI_Interface *jvmpi_interface;
+static struct methodref *mrefs;
+static int msize = 0;
+static struct classref *crefs;
+static int csize = 0;
+static FILE *outputFile;
+static char *include;
+static char *exclude;
+
+int memSize;
+int i;
+int j;
+
+struct methodref
+{
+ jmethodID id;
+ char *name;
+ char *signature;
+ int classid;
+};
+
+struct classref
+{
+ char *name;
+};
+
+void addClassref(char *classname)
+{
+ memSize = sizeof(struct classref);
+ if (csize == 0)
+ crefs = (struct classref *)malloc(memSize);
+ else
+ crefs = (struct classref *)realloc(crefs, memSize * (csize + 1));
+ (crefs + csize)->name = (char *)malloc(strlen(classname) + 1);
+ strcpy((crefs + csize)->name, classname);
+ csize++;
+}
+
+void addMethodref(jmethodID id, char *name, char *signature, int classid)
+{
+ memSize = sizeof(struct methodref);
+ if (msize == 0)
+ mrefs = (struct methodref *)malloc(memSize);
+ else
+ mrefs = (struct methodref *)realloc(mrefs, memSize * (msize + 1));
+
+ for (j = 0; j < msize; j++)
+ {
+ if ((mrefs + j)->id > id)
+ {
+ break;
+ }
+ }
+ if (j != msize)
+ {
+ memmove((mrefs + j + 1), (mrefs + j), memSize * (msize - j));
+ }
+ (mrefs + j)->name = (char *)malloc(strlen(name) + 1);
+ (mrefs + j)->signature = (char *)malloc(strlen(signature) + 1);
+ (mrefs + j)->id = id;
+ strcpy((mrefs + j)->name, name);
+ strcpy((mrefs + j)->signature, signature);
+ (mrefs + j)->classid = classid;
+ msize++;
+ /*
+ (mrefs + msize)->name = (char *)malloc(strlen(name) + 1);
+ (mrefs + msize)->signature = (char *)malloc(strlen(signature) + 1);
+ (mrefs + msize)->id = id;
+ strcpy((mrefs + msize)->name, name);
+ strcpy((mrefs + msize)->signature, signature);
+ (mrefs + msize)->classid = classid;
+ msize++;
+ */
+}
+
+int lower;
+int upper;
+int middle;
+jmethodID lowerid;
+jmethodID upperid;
+jmethodID middleid;
+
+void addMethodID(jmethodID id)
+{
+ if (msize < 1)
+ return;
+ lower = 0;
+ upper = msize - 1;
+ lowerid = (mrefs + lower)->id;
+ upperid = (mrefs + upper)->id;
+ while (lowerid < id && id < upperid && (upper - lower) > 1)
+ {
+ middle = ((upper - lower) / 2) + lower;
+ middleid = (mrefs + middle)->id;
+ if (middleid > id)
+ {
+ upper = middle;
+ upperid = middleid;
+ }
+ else if (middleid < id)
+ {
+ lower = middle;
+ lowerid = middleid;
+ }
+ else
+ {
+ upper = middle;
+ upperid = middleid;
+ break;
+ }
+ }
+ if (lowerid == id)
+ middle = lower;
+ else if (upperid == id)
+ middle = upper;
+ else
+ middle = -1;
+ if (middle != -1)
+ {
+ fputs((crefs + (mrefs + middle)->classid)->name, outputFile);
+ fputs("#", outputFile);
+ fputs((mrefs + middle)->name, outputFile);
+ fputs("#", outputFile);
+ fputs((mrefs + middle)->signature, outputFile);
+ fputs(" ", outputFile);
+ if (middle != (msize - 1))
+ memmove((mrefs + middle), (mrefs + middle + 1), sizeof(struct methodref) * (msize - (middle + 1)));
+ msize--;
+ return;
+ }
+ /*
+ for (i = 0; i < msize; i++)
+ {
+ if ((mrefs + i)->id == id)
+ {
+ fputs((crefs + (mrefs + i)->classid)->name, outputFile);
+ fputs("#", outputFile);
+ fputs((mrefs + i)->name, outputFile);
+ fputs("#", outputFile);
+ fputs((mrefs + i)->signature, outputFile);
+ fputs(" ", outputFile);
+ memmove((mrefs + i), (mrefs + i + 1), sizeof(struct methodref) * (msize - (i + 1)));
+ msize--;
+ return;
+ }
+ }
+ */
+}
+
+void notifyEvent(JVMPI_Event *event)
+{
+ switch(event->event_type)
+ {
+ case JVMPI_EVENT_CLASS_LOAD:
+ if (strstr(event->u.class_load.class_name, include) != NULL && (exclude == NULL || strstr(event->u.class_load.class_name, exclude) == NULL))
+ {
+ addClassref((char *)event->u.class_load.class_name);
+ for (i = 0; i < event->u.class_load.num_methods; i++)
+ {
+ addMethodref(event->u.class_load.methods[i].method_id, (char *)event->u.class_load.methods[i].method_name, (char *)event->u.class_load.methods[i].method_signature, csize - 1);
+ }
+ }
+ break;
+ case JVMPI_EVENT_METHOD_ENTRY:
+ addMethodID(event->u.method.method_id);
+ break;
+ case JVMPI_EVENT_JVM_SHUT_DOWN:
+ fclose(outputFile);
+ break;
+ }
+}
+
+JNIEXPORT jint JNICALL
+JVM_OnLoad(JavaVM *jvm, char *options, void *reserved)
+{
+ if ((*jvm)->GetEnv(jvm, (void **)&jvmpi_interface, JVMPI_VERSION_1) < 0)
+ return JNI_ERR;
+ outputFile = fopen(getenv("apiagent_output"), "a");
+ include = getenv("apiagent_include");
+ exclude = getenv("apiagent_exclude");
+ if (outputFile != NULL && include != NULL)
+ {
+ jvmpi_interface->NotifyEvent = notifyEvent;
+ jvmpi_interface->EnableEvent(JVMPI_EVENT_CLASS_LOAD, NULL);
+ jvmpi_interface->EnableEvent(JVMPI_EVENT_METHOD_ENTRY, NULL);
+ jvmpi_interface->EnableEvent(JVMPI_EVENT_JVM_SHUT_DOWN, NULL);
+ }
+ return JNI_OK;
+}
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/apiagent/build.sh b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/apiagent/build.sh
new file mode 100644
index 0000000..8b8cced
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/apiagent/build.sh
@@ -0,0 +1,3 @@
+export LD_LIBRARY_PATH=$JAVA_HOME/jre/bin/java:$JAVA_HOME/jre/bin:$PWD
+gcc -c -I$JAVA_HOME/include -I$JAVA_HOME/include/linux apiagent.c
+ld -shared apiagent.o -o libapiagent.so
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/apiagent/libpiAgent.so b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/apiagent/libpiAgent.so
new file mode 100644
index 0000000..2b8779c
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/apiagent/libpiAgent.so
Binary files differ
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/apiagent/piagent_options.txt b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/apiagent/piagent_options.txt
new file mode 100644
index 0000000..6db935d
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/apiagent/piagent_options.txt
@@ -0,0 +1,14 @@
+MONITOR_MODE=none
+FILTERS=false
+TRACK_GC_EVENT_TYPES=none
+* ID_STYLE=static
+OPTIONS=false
+TIMESTAMPS=false
+OBJ_ALLOC_IS_ARRAY=false
+STACK_INFORMATION=normal
+* BOUNDARY_DEPTH=0
+TICKET=false
+TRACE_MODE=noObjectCorrelation
+TRACE_ID_REFS=true
+METHOD_COUNTS=true
+METHOD_COUNTS_ONLY=true
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/build.properties b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/build.properties
new file mode 100644
index 0000000..99cf29d
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/build.properties
@@ -0,0 +1,12 @@
+bin.includes = plugin.xml,\
+ componentcore.jar,\
+ data/,\
+ xsl/
+jars.compile.order = componentcore.jar
+source.componentcore.jar = src/
+output.componentcore.jar = bin/
+src.includes = xsl/,\
+ data/,\
+ src/,\
+ plugin.xml,\
+ build.properties
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/data/eclipse.properties b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/data/eclipse.properties
new file mode 100644
index 0000000..e151875
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/data/eclipse.properties
@@ -0,0 +1,98 @@
+Ant=org.eclipse.ant.core \
+ org.eclipse.ant.ui
+
+Cheatsheets=org.eclipse.ui.cheatsheets
+
+Compare=org.eclipse.compare
+
+Console=org.eclipse.ui.console
+
+Core_Expressions=org.eclipse.core.expressions
+
+Core_Filebuffers=org.eclipse.core.filebuffers
+
+Core_Variables=org.eclipse.core.variables
+
+CVS=org.eclipse.team.cvs.ssh \
+ org.eclipse.team.cvs.ssh2 \
+ org.eclipse.team.cvs.ui \
+ org.eclipse.team.cvs.core
+
+Help=org.eclipse.help \
+ org.eclipse.help.base \
+ org.eclipse.help.ui \
+ org.eclipse.help.webapp \
+ org.eclipse.help.appserver \
+ org.eclipse.help.ide
+
+JFace=org.eclipse.jface \
+ org.eclipse.jface.text
+
+Platform_Debug_Core=org.eclipse.debug.core
+
+Platform_Debug_UI=org.eclipse.debug.ui
+
+Platform_Resources=org.eclipse.core.resources \
+ org.eclipse.core.resources.win32 \
+ org.eclipse.core.resources.linux \
+ org.eclipse.core.resources.hpux \
+ org.eclipse.core.resources.macosx \
+ org.eclipse.core.resources.qnx
+
+Platform_Runtime=org.eclipse.core.runtime \
+ org.eclipse.core.boot
+
+Platform_Text=org.eclipse.text \
+ org.eclipse.ui.workbench.texteditor \
+ org.eclipse.ui.editors
+
+Platform_UI_IDE=org.eclipse.ui.ide \
+ org.eclipse.ui.workbench.compatibility
+
+Platform_UI_RCP=org.eclipse.ui \
+ org.eclipse.ui.workbench \
+ org.eclipse.ui.win32 \
+ org.eclipse.ui.workbench.texteditor \
+ org.eclipse.ui.editors \
+ org.eclipse.ui.externaltools \
+ org.eclipse.ui.presentations.r21 \
+ org.eclipse.ui.views
+
+Search=org.eclipse.search
+
+SWT=org.eclipse.swt \
+ org.eclipse.swt.win32
+
+Team=org.eclipse.team.core \
+ org.eclipse.team.ui
+
+UI_Forms=org.eclipse.ui.forms
+
+UI_Intro=org.eclipse.ui.intro
+
+Update=org.eclipse.update.core \
+ org.eclipse.update.core.win32 \
+ org.eclipse.update.configurator \
+ org.eclipse.update.scheduler \
+ org.eclipse.update.ui
+
+JDT_Core=org.eclipse.jdt.core
+
+JDT_Debug=org.eclipse.jdt.debug \
+ org.eclipse.jdt.debug.ui \
+ org.eclipse.jdt.launching
+
+JDT_UI=org.eclipse.jdt.ui \
+ org.eclipse.jdt.junit
+
+LTK_Core=org.eclipse.ltk.core.refactoring
+
+LTK_UI=org.eclipse.ltk.ui.refactoring
+
+PDE=org.eclipse.pde.core \
+ org.eclipse.pde.ui \
+ org.eclipse.pde.build
+
+OSGI=org.eclipse.osgi \
+ org.eclipse.osgi.util \
+ org.eclipse.osgi.services
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/data/emf.properties b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/data/emf.properties
new file mode 100644
index 0000000..882b584
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/data/emf.properties
@@ -0,0 +1,39 @@
+emf=org.eclipse.emf.codegen.ecore.ui \
+ org.eclipse.emf.codegen.ecore \
+ org.eclipse.emf.codegen.ui \
+ org.eclipse.emf.codegen \
+ org.eclipse.emf.common.ui \
+ org.eclipse.emf.common \
+ org.eclipse.emf.ecore.change.edit \
+ org.eclipse.emf.ecore.change \
+ org.eclipse.emf.ecore.edit \
+ org.eclipse.emf.ecore.editor \
+ org.eclipse.emf.ecore.xmi \
+ org.eclipse.emf.ecore \
+ org.eclipse.emf.edit.ui \
+ org.eclipse.emf.edit \
+ org.eclipse.emf.mapping.ecore2ecore.editor \
+ org.eclipse.emf.mapping.ecore2ecore \
+ org.eclipse.emf.mapping.ui \
+ org.eclipse.emf.mapping.xsd2ecore.editor \
+ org.eclipse.emf.mapping.xsd2ecore \
+ org.eclipse.emf.mapping \
+ org.eclipse.emf
+
+sdo=org.eclipse.emf.commonj.sdo \
+ org.eclipse.emf.ecore.sdo.edit \
+ org.eclipse.emf.ecore.sdo.editor \
+ org.eclipse.emf.ecore.sdo \
+
+xsd=org.eclipse.xsd.edit \
+ org.eclipse.xsd.editor \
+ org.eclipse.xsd
+
+jem=com.ibm.etools.emf.event \
+ com.ibm.wtp.common.util \
+ com.ibm.wtp.emf.workbench \
+ org.eclipse.jem.beaninfo \
+ org.eclipse.jem.proxy \
+ org.eclipse.jem.ui \
+ org.eclipse.jem.workbench \
+ org.eclipse.jem
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/data/gef.properties b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/data/gef.properties
new file mode 100644
index 0000000..557a324
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/data/gef.properties
@@ -0,0 +1,2 @@
+gef=org.eclipse.gef \
+ org.eclipse.draw2d
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/data/ve.properties b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/data/ve.properties
new file mode 100644
index 0000000..d7a64ab
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/data/ve.properties
@@ -0,0 +1,8 @@
+jem=com.ibm.etools.emf.event \
+ com.ibm.wtp.common.util \
+ com.ibm.wtp.emf.workbench \
+ org.eclipse.jem.beaninfo \
+ org.eclipse.jem.proxy \
+ org.eclipse.jem.ui \
+ org.eclipse.jem.workbench \
+ org.eclipse.jem
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/data/wtp.properties b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/data/wtp.properties
new file mode 100644
index 0000000..84cc52e
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/data/wtp.properties
@@ -0,0 +1,140 @@
+wst.command=org.eclipse.wst.command.env \
+ org.eclipse.wst.command.env.core \
+ org.eclipse.wst.command.env.ui
+
+wst.common=org.eclipse.wst.common.contentmodel \
+ org.eclipse.wst.common.emf \
+ org.eclipse.wst.common.emfworkbench.integration \
+ org.eclipse.wst.common.encoding \
+ org.eclipse.wst.common.frameworks \
+ org.eclipse.wst.common.frameworks.ui \
+ org.eclipse.wst.common.migration \
+ org.eclipse.wst.common.migration.ui \
+ org.eclipse.wst.common.navigator \
+ org.eclipse.wst.common.navigator.views \
+ org.eclipse.wst.common.navigator.workbench \
+ org.eclipse.wst.common.ui \
+ org.eclipse.wst.common.ui.properties \
+ org.eclipse.wst.common.uriresolver
+
+wst.css=org.eclipse.wst.css.core \
+ org.eclipse.wst.css.ui
+
+wst.dtd=org.eclipse.wst.dtd \
+ org.eclipse.wst.dtd.contentmodel \
+ org.eclipse.wst.dtd.core \
+ org.eclipse.wst.dtd.parser \
+ org.eclipse.wst.dtd.ui \
+ org.eclipse.wst.dtd.validation
+
+wst.html=org.eclipse.wst.html.core \
+ org.eclipse.wst.html.ui
+
+wst.internet=org.eclipse.wst.internet.monitor.core \
+ org.eclipse.wst.internet.monitor.ui \
+ org.eclipse.wst.internet.proxy \
+ org.eclipse.wst.internet.webbrowser
+
+wst.javascript=org.eclipse.wst.javascript.common.ui \
+ org.eclipse.wst.javascript.core \
+ org.eclipse.wst.javascript.ui
+
+wst.rdb=org.eclipse.wst.rdb.connection.ui \
+ org.eclipse.wst.rdb.core \
+ org.eclipse.wst.rdb.core.ui \
+ org.eclipse.wst.rdb.dbdefinition.db2.cloudscape \
+ org.eclipse.wst.rdb.dbdefinition.db2.iseries \
+ org.eclipse.wst.rdb.dbdefinition.db2.luw \
+ org.eclipse.wst.rdb.dbdefinition.db2.zseries \
+ org.eclipse.wst.rdb.dbdefinition.informix \
+ org.eclipse.wst.rdb.dbdefinition.oracle \
+ org.eclipse.wst.rdb.dbdefinition.sqlserver \
+ org.eclipse.wst.rdb.dbdefinition.sybase \
+ org.eclipse.wst.rdb.models.dbdefinition \
+ org.eclipse.wst.rdb.models.sql \
+ org.eclipse.wst.rdb.outputview \
+ org.eclipse.wst.rdb.server.ui \
+ org.eclipse.wst.rdb.sqlscrapbook
+
+wst.server=org.eclipse.wst.server.core \
+ org.eclipse.wst.server.ui \
+ org.eclipse.wst.server.util
+
+wst.sse=org.eclipse.wst.sse.core \
+ org.eclipse.wst.sse.snippets \
+ org.eclipse.wst.sse.ui
+
+wst.validation=org.eclipse.wst.validation \
+ org.eclipse.wst.validation.ui
+
+wst.web=org.eclipse.wst.web \
+ org.eclipse.wst.web.ui
+
+wst.ws=org.eclipse.wst.ws.parser
+
+wst.wsdl=org.eclipse.wst.wsdl \
+ org.eclipse.wst.wsdl.ui \
+ org.eclipse.wst.wsdl.validation
+
+wst.wsi=org.eclipse.wst.wsi.core \
+ org.eclipse.wst.wsi.ui \
+ org.eclipse.wst.wsi.validation
+
+wst.xml=org.eclipse.wst.xml.core \
+ org.eclipse.wst.xml.ui \
+ org.eclipse.wst.xml.uriresolver \
+ org.eclipse.wst.xml.uriresolver.ui \
+ org.eclipse.wst.xml.validation
+
+wst.xsd=org.eclipse.wst.xsd.contentmodel \
+ org.eclipse.wst.xsd.ui \
+ org.eclipse.wst.xsd.validation
+
+jst.common=org.eclipse.jst.common.annotations.controller \
+ org.eclipse.jst.common.annotations.core \
+ org.eclipse.jst.common.annotations.ui \
+ org.eclipse.jst.common.frameworks \
+ org.eclipse.jst.common.frameworks.ui \
+ org.eclipse.jst.common.launcher.ant \
+ org.eclipse.jst.common.navigator.java \
+ org.eclipse.jst.sample.web.project
+
+jst.ejb=org.eclipse.jst.ejb.ui
+
+jst.j2ee=org.eclipse.jst.j2ee \
+ org.eclipse.jst.j2ee.core \
+ org.eclipse.jst.j2ee.ejb \
+ org.eclipse.jst.j2ee.jca \
+ org.eclipse.jst.j2ee.jca.ui \
+ org.eclipse.jst.j2ee.navigator.ui \
+ org.eclipse.jst.j2ee.ui \
+ org.eclipse.jst.j2ee.web \
+ org.eclipse.jst.j2ee.webservice
+
+jst.jsp=org.eclipse.jst.jsp.core \
+ org.eclipse.jst.jsp.ui
+
+jst.server=org.eclipse.jst.server.core \
+ org.eclipse.jst.server.generic.core \
+ org.eclipse.jst.server.generic.modules \
+ org.eclipse.jst.server.generic.ui \
+ org.eclipse.jst.server.jboss.core \
+ org.eclipse.jst.server.jboss.ui \
+ org.eclipse.jst.server.tomcat.core \
+ org.eclipse.jst.server.tomcat.ui \
+ org.eclipse.jst.server.ui
+
+jst.servlet=org.eclipse.jst.servlet.ui
+
+jst.ws=org.eclipse.jst.ws \
+ org.eclipse.jst.ws.axis \
+ org.eclipse.jst.ws.axis.ant \
+ org.eclipse.jst.ws.axis.consumption.core \
+ org.eclipse.jst.ws.axis.consumption.ui \
+ org.eclipse.jst.ws.axis.creation.ui \
+ org.eclipse.jst.ws.consumption \
+ org.eclipse.jst.ws.consumption.ui \
+ org.eclipse.jst.ws.creation.ejb.ui \
+ org.eclipse.jst.ws.creation.ui \
+ org.eclipse.jst.ws.uddiregistry \
+ org.eclipse.jst.ws.ui
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/plugin.xml b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/plugin.xml
new file mode 100644
index 0000000..b8dc9cd
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/plugin.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin
+ id="org.eclipse.wtp.releng.tools.component.core"
+ name="Component Core"
+ version="1.0.0">
+ <runtime>
+ <library name="componentcore.jar">
+ <export name="*"/>
+ </library>
+ </runtime>
+ <requires>
+ <import plugin="org.eclipse.jdt.core"/>
+ <import plugin="org.eclipse.core.runtime"/>
+ </requires>
+ <extension
+ id="JavadocCoverageEmitter"
+ point="org.eclipse.core.runtime.applications">
+ <application>
+ <run
+ class="org.eclipse.wtp.releng.tools.component.javadoc.JavadocCoverageEmitter">
+ </run>
+ </application>
+ </extension>
+</plugin>
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/IClazz.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/IClazz.java
new file mode 100644
index 0000000..dee53cf
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/IClazz.java
@@ -0,0 +1,49 @@
+/**********************************************************************
+ * Copyright (c) 2002, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component;
+
+import java.util.List;
+import java.util.Set;
+import org.eclipse.jdt.core.util.IConstantPoolEntry;
+import org.eclipse.jdt.core.util.IFieldInfo;
+import org.eclipse.jdt.core.util.IMethodInfo;
+
+public interface IClazz
+{
+ public Set getReferencedTypes();
+
+ public List getMethodRefs(List includes, List excludes, boolean genLineInfo);
+
+ public void resetMethodRefs();
+
+ public List getFieldRefs(List includes, List excludes, boolean genLineInfo);
+
+ public void resetFieldRefs();
+
+ public String getName();
+
+ public String getSuperClass();
+
+ public String[] getInterfaces();
+
+ public IFieldInfo[] getFieldInfo();
+
+ public IMethodInfo[] getMethodInfo();
+
+ public IConstantPoolEntry[] getConstantPoolEntries(int kind);
+
+ public boolean isInterface();
+
+ public int getAccessFlags();
+
+ public void resetClazz();
+}
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/IClazzVisitor.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/IClazzVisitor.java
new file mode 100644
index 0000000..fc9b292
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/IClazzVisitor.java
@@ -0,0 +1,17 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component;
+
+public interface IClazzVisitor
+{
+ public boolean visit(IClazz clazz);
+}
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/IFileLocation.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/IFileLocation.java
new file mode 100644
index 0000000..307f165
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/IFileLocation.java
@@ -0,0 +1,19 @@
+/**********************************************************************
+ * Copyright (c) 2002, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component;
+
+import java.io.File;
+
+public interface IFileLocation extends ILocation
+{
+ public File getFile();
+}
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/IFragmentXML.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/IFragmentXML.java
new file mode 100644
index 0000000..3b65670
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/IFragmentXML.java
@@ -0,0 +1,42 @@
+/**********************************************************************
+ * Copyright (c) 2002, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component;
+
+import org.eclipse.wtp.releng.tools.component.internal.PluginXML;
+
+public interface IFragmentXML extends IPluginXML
+{
+ public static final String CONST_FRAGMENT_XML = "fragment.xml";
+
+ /**
+ * Answers the parent plugin of this fragment
+ *
+ * @return Plugin the parent plugin of this fragment
+ */
+ public PluginXML getPlugin();
+
+ /**
+ * Answers the name of the plugin which contains this fragment.
+ *
+ * @return String the name of the containing plugin, not <code>null</code>
+ */
+ public String getPluginName();
+
+ /**
+ * Answers the version of the plugin which contains this fragment.
+ *
+ * @return String the version of the containing plugin, not <code>null</code>
+ */
+ public String getPluginVersion();
+
+ public String getFragmentName();
+}
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/ILibrary.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/ILibrary.java
new file mode 100644
index 0000000..84e3b6f
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/ILibrary.java
@@ -0,0 +1,30 @@
+/**********************************************************************
+ * Copyright (c) 2002, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component;
+
+import java.util.Map;
+
+public interface ILibrary
+{
+ public static final String EXT_CLASS = "class";
+ /**
+ * Answers a mapping of (qualified) type names to <code>Type</code> objects
+ * which are found in this library.
+ *
+ * @return Map a mapping of type names to <code>Type</code> objects.
+ */
+ public Map getTypes();
+
+ public void resetTypes();
+
+ public void accept(IClazzVisitor visitor);
+}
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/ILocation.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/ILocation.java
new file mode 100644
index 0000000..deb860a
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/ILocation.java
@@ -0,0 +1,88 @@
+/**********************************************************************
+ * Copyright (c) 2002, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * An <code>ILocation</code> object is an abstraction on the idea of a file.
+ * ILocations can refer to files that are directly located in the filesystem, or
+ * they can refer to files that are housed in zip/jar files. Using an
+ * <code>ILocation</code>, clients can traverse zip/jar files like they are
+ * directories.
+ * <p>
+ * Clients can create <code>ILocation</code> objects using
+ * com.example.location.Location.createLocation(File file)
+ */
+public interface ILocation
+{
+ /**
+ * @return ILocation This location's parent, or <code>null</code> if this
+ * location was created without a parent.
+ */
+ ILocation getParent();
+
+ /**
+ * @return String The name of this location.
+ */
+ String getName();
+
+ /**
+ * @return String The absolute path of this location, this path may not be
+ * usable by new File(String) to create files because it may refer to
+ * structures inside of zip/jar files.
+ */
+ String getAbsolutePath();
+
+ /**
+ * Answers the <code>InputStream</code>
+ *
+ * @return InputStream
+ * @throws IOException
+ */
+ InputStream getInputStream() throws IOException;
+
+ /**
+ * @return ILocationChildrenIterator which iterates over the children of this
+ * location.
+ */
+ ILocationChildrenIterator childIterator();
+
+ /**
+ * @return boolean <code>true</code> if this location has children.
+ */
+ boolean hasChildren();
+
+ /**
+ * Method accept.
+ *
+ * @param visitor
+ */
+ void accept(ILocationVisitor visitor);
+
+ /**
+ * Method createChild.
+ *
+ * @param relativePath
+ * @return ILocation
+ */
+ ILocation createChild(String relativePath);
+
+ /**
+ * Method createSibling.
+ *
+ * @param relativePath
+ * @return ILocation
+ */
+ ILocation createSibling(String relativePath);
+}
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/ILocationChildrenIterator.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/ILocationChildrenIterator.java
new file mode 100644
index 0000000..72baf1b
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/ILocationChildrenIterator.java
@@ -0,0 +1,28 @@
+/**********************************************************************
+ * Copyright (c) 2002, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.wtp.releng.tools.component;
+
+/**
+ * The <code>ILocationChildrenIterator</code> is a simple iterator that
+ * iterates over the children of a location. A <code>null</code> is returned
+ * when the end of the children list is reached.
+ */
+
+public interface ILocationChildrenIterator
+{
+ /**
+ * Answers the next child location.
+ *
+ * @return ILocation The next child location, or <code>null</code> if there
+ * are no more children.
+ */
+ ILocation next();
+}
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/ILocationVisitor.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/ILocationVisitor.java
new file mode 100644
index 0000000..66d6ec0
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/ILocationVisitor.java
@@ -0,0 +1,28 @@
+/**********************************************************************
+ * Copyright (c) 2002, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.wtp.releng.tools.component;
+
+/**
+ * An <code>ILocationVisitor</code> can be used to traverse a tree of
+ * locations.
+ */
+public interface ILocationVisitor
+{
+ /**
+ * Allows this visitor to investigate the given location.
+ *
+ * @param location
+ * the current location in the traversal
+ * @return boolean <code>true</code> if the traversal should continue into
+ * the children of the given location, <code>false</code> otherwise.
+ */
+ boolean accept(ILocation location);
+}
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/IPluginXML.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/IPluginXML.java
new file mode 100644
index 0000000..d41f30a
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/IPluginXML.java
@@ -0,0 +1,52 @@
+/**********************************************************************
+ * Copyright (c) 2002, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component;
+
+import java.util.List;
+
+public interface IPluginXML
+{
+ public static final String CONST_PLUGIN_XML = "plugin.xml";
+
+ /**
+ * Answers the libraries that are declared in this plugin.
+ *
+ * @return List libraries in this plugin
+ */
+ public List getLibraries();
+
+ /**
+ * Answers the name of this plugin. Plugin names do not contain the version
+ * identifier, for example, org.eclipse.core.resources.
+ *
+ * @return String the name of the plugin, not <code>null</code>.
+ */
+ public String getName();
+
+ /**
+ * Answers the version identifier for the plugin. A version identifier is a
+ * '.' delimited set of numbers, for example, 2.0.1.5.
+ *
+ * @return String the plugin version, not <code>null</code>.
+ */
+ public String getVersion();
+
+ /**
+ * The unique identifier is a concatination of the plugin name, and '_' and
+ * the plugin version.
+ *
+ * @return String the unique identifier of the plugin.
+ */
+ public String getUniqueIdentifier();
+
+ public void accept(IClazzVisitor visitor);
+}
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/TestMain.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/TestMain.java
new file mode 100644
index 0000000..dc70a8d
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/TestMain.java
@@ -0,0 +1,178 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component;
+
+import java.io.IOException;
+import org.eclipse.wtp.releng.tools.component.api.compatibility.APICompatibilityEmitter;
+import org.eclipse.wtp.releng.tools.component.api.testcoverage.APITestCoverageEmitter;
+import org.eclipse.wtp.releng.tools.component.api.ComponentAPIEmitter;
+import org.eclipse.wtp.releng.tools.component.model.ComponentEmitter;
+import org.eclipse.wtp.releng.tools.component.violation.ComponentViolationEmitter;
+
+public class TestMain
+{
+ public static void main(String[] args) throws IOException
+ {
+ wtpMain(args);
+ //radMain(args);
+ }
+
+ public static void wtpMain(String[] args) throws IOException
+ {
+ String propsDir = "D:/wtp_v10m2/workspace_api/z/data/";
+ String compXMLDir = "C:/Documents and Settings/chng1me.T40-92U-V46/Desktop/api-test-data/component-xmls-for-wtp/";
+ String compAPIDir = "C:/Documents and Settings/chng1me.T40-92U-V46/Desktop/api-test-data/api-xmls-for-wtp/";
+ String compAPIDir2 = "C:/Documents and Settings/chng1me.T40-92U-V46/Desktop/api-test-data/api-xmls-for-wtp.2/";
+ String eclipseDir = "D:/wtp_v10m2/eclipse/";
+ String testDir = "D:/wtp_v10m2/tests/";
+
+ String[] compEmitterArgs = new String[]
+ {
+ "-eclipseDir",
+ eclipseDir,
+ "-props",
+ propsDir + "eclipse.properties",
+ "-compXMLDir",
+ compXMLDir + "eclipse-components/"
+ };
+ //ComponentEmitter.main(compEmitterArgs);
+
+ compEmitterArgs[3] = propsDir + "wtp.properties";
+ compEmitterArgs[5] = compXMLDir + "wtp-components/";
+ //ComponentEmitter.main(compEmitterArgs);
+
+ compEmitterArgs[3] = propsDir + "emf.properties";
+ compEmitterArgs[5] = compXMLDir + "emf-components/";
+ //ComponentEmitter.main(compEmitterArgs);
+
+ compEmitterArgs[3] = propsDir + "gef.properties";
+ compEmitterArgs[5] = compXMLDir + "gef-components/";
+ //ComponentEmitter.main(compEmitterArgs);
+
+ compEmitterArgs[3] = propsDir + "ve.properties";
+ compEmitterArgs[5] = compXMLDir + "ve-components/";
+ //ComponentEmitter.main(compEmitterArgs);
+
+ String[] compViolationEmitterArgs = new String[]
+ {
+ "-eclipseDir",
+ eclipseDir,
+ "-testDir",
+ testDir,
+ "-compXMLDir",
+ compXMLDir + "wtp-components/",
+ "-compRefDir",
+ compXMLDir + "depends/",
+ "-compAPIDir",
+ compAPIDir,
+ "-compUseDir",
+ compAPIDir,
+ "-compVioDir",
+ compAPIDir,
+ "-outputDir",
+ compAPIDir,
+ "-currAPIIndex",
+ compAPIDir + "index-comp-summary.xml",
+ "-refAPIIndex",
+ compAPIDir2 + "index-comp-summary.xml",
+ "-exclude",
+ "java.",
+ "javax.",
+ "org.w3c.",
+ "org.xml.",
+ "org.apache.",
+ "sun.",
+ "-genHTML",
+ "-genAPI",
+ "-genUsage",
+ "-debug"
+ };
+ //ComponentAPIEmitter.main(compViolationEmitterArgs);
+ ComponentViolationEmitter.main(compViolationEmitterArgs);
+ APITestCoverageEmitter.main(compViolationEmitterArgs);
+ APICompatibilityEmitter.main(compViolationEmitterArgs);
+ }
+
+ public static void radMain(String[] args) throws IOException
+ {
+ String compXMLDir = "C:/Documents and Settings/chng1me.T40-92U-V46/Desktop/api-test-data/component-xmls-for-rad/";
+ String compAPIDir = "C:/Documents and Settings/chng1me.T40-92U-V46/Desktop/api-test-data/api-xmls-for-rad/";
+ String compAPIDir2 = "C:/Documents and Settings/chng1me.T40-92U-V46/Desktop/api-test-data/api-xmls-for-rad/";
+ String testDir = "C:/temp/";
+
+ String[] compEmitterArgs = new String[]
+ {
+ "-eclipseDir",
+ "D:/rad_v600/csdev/",
+ "D:/rad_v600/csdevrpt_shared/",
+ "D:/rad_v600/eclipse/",
+ "D:/rad_v600/rad/",
+ "D:/rad_v600/rad_prod/",
+ "D:/rad_v600/radrsm_shared/",
+ "D:/rad_v600/rwd/",
+ "D:/rad_v600/rwdrpt_shared/",
+ "D:/rad_v600/sdpisv/",
+ "D:/rad_v600/updater/",
+ "-compXMLDir",
+ compXMLDir
+ };
+ //ComponentEmitter.main(compEmitterArgs);
+
+ String[] compViolationEmitterArgs = new String[]
+ {
+ "-eclipseDir",
+ "D:/rad_v600/csdev/",
+ "D:/rad_v600/csdevrpt_shared/",
+ "D:/rad_v600/eclipse/",
+ "D:/rad_v600/rad/",
+ "D:/rad_v600/rad_prod/",
+ "D:/rad_v600/radrsm_shared/",
+ "D:/rad_v600/rwd/",
+ "D:/rad_v600/rwdrpt_shared/",
+ "D:/rad_v600/sdpisv/",
+ "D:/rad_v600/updater/",
+ "-testDir",
+ testDir,
+ "-compXMLDir",
+ compXMLDir,
+ "-compAPIDir",
+ compAPIDir,
+ "-compUseDir",
+ compAPIDir,
+ "-compVioDir",
+ compAPIDir,
+ "-outputDir",
+ compAPIDir,
+ "-currAPIIndex",
+ compAPIDir + "index-comp-summary.xml",
+ "-refAPIIndex",
+ compAPIDir2 + "index-comp-summary.xml",
+ "-include",
+ "org.eclipse.",
+ "-exclude",
+ "java.",
+ "javax.",
+ "org.w3c.",
+ "org.xml.",
+ "org.apache.",
+ "sun.",
+ "-genHTML",
+ "-genAPI",
+ "-genUsage",
+ "-debug",
+ };
+ //ComponentAPIEmitter.main(compViolationEmitterArgs);
+ //ComponentViolationEmitter.main(compViolationEmitterArgs);
+ //APITestCoverageEmitter.main(compViolationEmitterArgs);
+ //APICompatibilityEmitter.main(compViolationEmitterArgs);
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/testcoverage/APITestCoverageEmitter.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/testcoverage/APITestCoverageEmitter.java
new file mode 100644
index 0000000..10c0e07
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/testcoverage/APITestCoverageEmitter.java
@@ -0,0 +1,600 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.wtp.releng.tools.component.api.testcoverage;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import org.eclipse.jdt.core.util.IModifierConstants;
+import org.eclipse.wtp.releng.tools.component.IClazz;
+import org.eclipse.wtp.releng.tools.component.IClazzVisitor;
+import org.eclipse.wtp.releng.tools.component.ILocation;
+import org.eclipse.wtp.releng.tools.component.IPluginXML;
+import org.eclipse.wtp.releng.tools.component.api.ClassAPI;
+import org.eclipse.wtp.releng.tools.component.api.ComponentAPI;
+import org.eclipse.wtp.releng.tools.component.api.ComponentAPIEmitter;
+import org.eclipse.wtp.releng.tools.component.api.MethodAPI;
+import org.eclipse.wtp.releng.tools.component.api.PackageAPI;
+import org.eclipse.wtp.releng.tools.component.api.TestCoverage;
+import org.eclipse.wtp.releng.tools.component.internal.AbstractEmitter;
+import org.eclipse.wtp.releng.tools.component.internal.ComponentEntry;
+import org.eclipse.wtp.releng.tools.component.internal.ComponentSummary;
+import org.eclipse.wtp.releng.tools.component.internal.FileLocation;
+import org.eclipse.wtp.releng.tools.component.model.ComponentXML;
+import org.eclipse.wtp.releng.tools.component.model.Package;
+import org.eclipse.wtp.releng.tools.component.model.Plugin;
+import org.eclipse.wtp.releng.tools.component.use.ClassUse;
+import org.eclipse.wtp.releng.tools.component.use.ComponentUse;
+import org.eclipse.wtp.releng.tools.component.use.ComponentUseEmitter;
+import org.eclipse.wtp.releng.tools.component.use.MethodUse;
+import org.eclipse.wtp.releng.tools.component.use.Source;
+import org.eclipse.wtp.releng.tools.component.util.CommandOptionParser;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class APITestCoverageEmitter extends AbstractEmitter
+{
+ public static final String OPTION_ECLIPSE_DIR = "eclipseDir";
+ public static final String OPTION_TEST_DIR = "testDir";
+ public static final String OPTION_COMPONENT_XML_DIR = "compXMLDir";
+ public static final String OPTION_COMPONENT_API_DIR = "compAPIDir";
+ public static final String OPTION_API_AGENT_OUTPUT ="apiAgentOutput";
+ public static final String OPTION_TIMESTAMP = "timestamp";
+ public static final String OPTION_GEN_HTML = "genHTML";
+
+ private String compAPIDir;
+ private Map id2Plugin;
+ private Map id2Fragment;
+ private Map id2TestPlugin;
+ private Map id2TestFragment;
+ private Map compLoc2CompXML;
+ private String apiAgentOutput;
+ private List apiAgentMethodrefs;
+ private String timestamp;
+ private boolean genHTML;
+ private ComponentAPIEmitter compAPIEmitter;
+
+ public APITestCoverageEmitter(String compAPIDir)
+ {
+ this.compAPIDir = addTrailingSeperator(compAPIDir);
+ genHTML = false;
+ }
+
+ public void init(List eclipseDirs, List testDirs, List compXMLDirs)
+ {
+ id2Plugin = new HashMap();
+ id2Fragment = new HashMap();
+ for (Iterator it = eclipseDirs.iterator(); it.hasNext();)
+ {
+ File eclipseFile = new File(addTrailingSeperator((String)it.next()));
+ if (eclipseFile.exists())
+ harvestPlugins(eclipseFile, id2Plugin, id2Fragment);
+ }
+ linkPluginsAndFragments(id2Plugin, id2Fragment);
+ id2TestPlugin = new HashMap();
+ id2TestFragment = new HashMap();
+ for (Iterator it = testDirs.iterator(); it.hasNext();)
+ {
+ File testFile = new File(addTrailingSeperator((String)it.next()));
+ if (testFile.exists())
+ harvestPlugins(testFile, id2TestPlugin, id2TestFragment);
+ }
+ linkPluginsAndFragments(id2TestPlugin, id2TestFragment);
+ compLoc2CompXML = new HashMap();
+ for (Iterator it = compXMLDirs.iterator(); it.hasNext();)
+ {
+ File compXMLFile = new File(addTrailingSeperator((String)it.next()));
+ if (compXMLFile.exists())
+ harvestComponents(compXMLFile, compLoc2CompXML);
+ }
+ init();
+ }
+
+ public void init(Map compLoc2CompXML, Map id2Plugin, Map id2Fragment, Map id2TestPlugin, Map id2TestFragment)
+ {
+ this.compLoc2CompXML = compLoc2CompXML;
+ this.id2Plugin = id2Plugin;
+ this.id2Fragment = id2Fragment;
+ this.id2TestPlugin = id2TestPlugin;
+ this.id2TestFragment = id2TestFragment;
+ init();
+ }
+
+ private void init()
+ {
+ compAPIEmitter = new ComponentAPIEmitter(null);
+ if (timestamp != null)
+ compAPIEmitter.setTimestamp(timestamp);
+ else
+ timestamp = compAPIEmitter.getTimestamp();
+ compAPIEmitter.init(compLoc2CompXML, id2Plugin, id2Fragment);
+ }
+
+ public String getAPIAgentOutput()
+ {
+ return apiAgentOutput;
+ }
+
+ public void setAPIAgentOutput(String apiAgentOutput)
+ {
+ this.apiAgentOutput = apiAgentOutput;
+ }
+
+ public String getTimestamp()
+ {
+ return timestamp;
+ }
+
+ public void setTimestamp(String timestamp)
+ {
+ this.timestamp = timestamp;
+ }
+
+ /**
+ * @return Returns the genHTML.
+ */
+ public boolean isGenHTML()
+ {
+ return genHTML;
+ }
+
+ /**
+ * @param genHTML The genHTML to set.
+ */
+ public void setGenHTML(boolean genHTML)
+ {
+ this.genHTML = genHTML;
+ }
+
+ protected String getComponentSummaryXML()
+ {
+ return ComponentSummary.INDEX_COMPONENT_SUMMARY_XML;
+ }
+
+ protected String getSummaryXML()
+ {
+ return "index-api-tc.xml";
+ }
+
+ protected String getSummaryHTML()
+ {
+ return "index-api-tc.html";
+ }
+
+ protected String getSummaryXSL()
+ {
+ return "org/eclipse/wtp/releng/tools/component/xsl/component-api-tc-summary.xsl";
+ }
+
+ protected String getCoverageXML()
+ {
+ return ComponentAPI.CONST_COMPONENT_API;
+ }
+
+ protected String getCoverageHTML()
+ {
+ return "component-api-tc.html";
+ }
+
+ protected String getCoverageXSL()
+ {
+ return "org/eclipse/wtp/releng/tools/component/xsl/component-api-tc.xsl";
+ }
+
+ public void genAPITestCoverageXML() throws IOException
+ {
+ ComponentSummary compSummary = new ComponentSummary();
+ APITestCoverageSummary summary = new APITestCoverageSummary(getCoverageHTML());
+ compSummary.setTimestamp(timestamp);
+ summary.setTimestamp(timestamp);
+ List includes = new ArrayList();
+ for (Iterator it = compLoc2CompXML.values().iterator(); it.hasNext();)
+ harvestPackages((ComponentXML)it.next(), includes);
+ ComponentUseEmitter compUseEmitter = newComponentUseEmitter(id2TestPlugin, id2TestFragment, includes);
+ ComponentUse compUse = compUseEmitter.genAll();
+ for (Iterator it = compLoc2CompXML.keySet().iterator(); it.hasNext();)
+ {
+ String compLoc = (String)it.next();
+ ComponentAPI compAPI = compAPIEmitter.genComponentApiXml(compLoc);
+ summary.add(genAPITestCoverageXML(compLoc, compUse, compAPI));
+ ComponentEntry entry = new ComponentEntry();
+ entry.setCompName(compAPI.getName());
+ entry.setRef(compAPI.getLocation().getAbsolutePath());
+ compSummary.add(entry);
+ }
+ if (compAPIDir != null)
+ {
+ compSummary.save(new FileLocation(new File(compAPIDir + getComponentSummaryXML())));
+ summary.save(new FileLocation(new File(compAPIDir + getSummaryXML())));
+ if (genHTML)
+ {
+ try
+ {
+ summary.saveAsHTML(getSummaryXSL(), new FileLocation(new File(compAPIDir + getSummaryHTML())));
+ }
+ catch (TransformerConfigurationException e)
+ {
+ e.printStackTrace();
+ }
+ catch (TransformerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public ComponentAPI genAPITestCoverageXML(String compLoc) throws IOException
+ {
+ List includes = new ArrayList();
+ ComponentXML componentXML = (ComponentXML)compLoc2CompXML.get(compLoc);
+ if (componentXML != null)
+ harvestPackages(componentXML, includes);
+ ComponentUseEmitter compUseEmitter = newComponentUseEmitter(id2TestPlugin, id2TestFragment, includes);
+ ComponentUse compUse = compUseEmitter.genAll();
+ ComponentAPI compAPI = compAPIEmitter.genComponentApiXml(compLoc);
+ compAPI.save();
+ return genAPITestCoverageXML(compLoc, compUse, compAPI);
+ }
+
+ private ComponentAPI genAPITestCoverageXML(String compLoc, ComponentUse compUse, ComponentAPI compAPI) throws IOException
+ {
+ ComponentXML componentXML = (ComponentXML)compLoc2CompXML.get(compLoc);
+ if (componentXML != null)
+ {
+ componentXML.load();
+ final Hashtable interface2implClasses = new Hashtable();
+ if (apiAgentOutput != null)
+ {
+ for (Iterator it = componentXML.getPlugins().iterator(); it.hasNext();)
+ {
+ String pluginId = ((Plugin)it.next()).getId();
+ IPluginXML plugin = (IPluginXML)id2Plugin.get(pluginId);
+ if (plugin != null)
+ {
+ plugin.accept
+ (
+ new IClazzVisitor()
+ {
+ public boolean visit(IClazz clazz)
+ {
+ String[] interfaces = clazz.getInterfaces();
+ for (int i = 0; i < interfaces.length; i++)
+ {
+ StringBuffer sb = new StringBuffer();
+ String implClasses = (String)interface2implClasses.get(interfaces[i]);
+ if (implClasses != null)
+ sb.append(implClasses);
+ sb.append(clazz.getName());
+ sb.append('#');
+ interface2implClasses.put(interfaces[i], sb.toString());
+ }
+ return true;
+ }
+ }
+ );
+ }
+ }
+ }
+ List pkgAPIs = compAPI.getPackageAPIs();
+ for (int i = 0; i < pkgAPIs.size(); i++)
+ {
+ PackageAPI pkgAPI = (PackageAPI)pkgAPIs.get(i);
+ List classAPIs = pkgAPI.getClassAPIs();
+ for (int j = 0; j < classAPIs.size(); j++)
+ {
+ ClassAPI classAPI = (ClassAPI)classAPIs.get(j);
+ int classAccess = classAPI.getAccess();
+ if ((isBit(classAccess, IModifierConstants.ACC_PUBLIC) || isBit(classAccess, IModifierConstants.ACC_PROTECTED)) && classAPI.isReference())
+ {
+ List methodAPIs = classAPI.getMethodAPIs();
+ for (Iterator it = methodAPIs.iterator(); it.hasNext();)
+ {
+ MethodAPI methodAPI = (MethodAPI)it.next();
+ methodAPI.setTestCoverage(getTestCoverage(compUse, classAPI.getName(), methodAPI, interface2implClasses));
+ }
+ }
+ }
+ }
+ if (compAPIDir != null)
+ {
+ String compName = componentXML.getName();
+ StringBuffer sb = new StringBuffer(compAPIDir);
+ sb.append(compName);
+ sb.append('/');
+ ILocation location = new FileLocation(new File(sb.toString() + getCoverageXML()));
+ compAPI.setLocation(location);
+ System.out.println("Writing " + getCoverageXML() + " for " + compName);
+ compAPI.save();
+ if (genHTML)
+ {
+ try
+ {
+ ILocation html = new FileLocation(new File(sb.toString() + getCoverageHTML()));
+ compAPI.saveAsHTML(html, getCoverageXSL());
+ copyImages();
+ }
+ catch (TransformerConfigurationException e)
+ {
+ e.printStackTrace();
+ }
+ catch (TransformerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ return compAPI;
+ }
+
+ private void harvestPackages(ComponentXML compXML, List includes) throws IOException
+ {
+ compXML.load();
+ List pkgs = compXML.getPackages();
+ for (Iterator it = pkgs.iterator(); it.hasNext();)
+ {
+ String pkgName = ((Package)it.next()).getName();
+ if (!includes.contains(pkgName))
+ includes.add(pkgName);
+ }
+ }
+
+ private ComponentUseEmitter newComponentUseEmitter(Map plugins, Map fragments, List includes)
+ {
+ ComponentUseEmitter compUseEmitter = new ComponentUseEmitter(null);
+ compUseEmitter.setDebug(false);
+ compUseEmitter.setClassUseIncludes(includes);
+ compUseEmitter.init(new HashMap(0), plugins, fragments);
+ return compUseEmitter;
+ }
+
+ private boolean isBit(int flag, int bit)
+ {
+ return ((flag & bit) == bit);
+ }
+
+ private TestCoverage getTestCoverage(ComponentUse compUse, String className, MethodAPI methodAPI, Hashtable interface2implClasses)
+ {
+ List testcases = new ArrayList();
+ for (Iterator sourcesIt = compUse.getSources().iterator(); sourcesIt.hasNext();)
+ {
+ Source source = (Source)sourcesIt.next();
+ for (Iterator classUsesIt = source.getClassUses().iterator(); classUsesIt.hasNext();)
+ {
+ ClassUse classUse = (ClassUse)classUsesIt.next();
+ if (classUse.getName().equals(className))
+ {
+ for (Iterator methodUsesIt = classUse.getMethodUses().iterator(); methodUsesIt.hasNext();)
+ {
+ MethodUse methodUse = (MethodUse)methodUsesIt.next();
+ if (methodUse.getName().equals(methodAPI.getName()) && methodUse.getDescriptor().equals(methodAPI.getDescriptor()))
+ {
+ testcases.add(source.getName());
+ }
+ }
+ }
+ }
+ }
+ if (apiAgentOutput != null)
+ {
+ if (apiAgentMethodrefs == null)
+ {
+ apiAgentMethodrefs = new ArrayList();
+ getAPIAgentMethodRefs(new File(apiAgentOutput), apiAgentMethodrefs);
+ }
+ StringBuffer methodref = new StringBuffer();
+ methodref.append('#');
+ methodref.append(methodAPI.getName());
+ methodref.append('#');
+ methodref.append(methodAPI.getDescriptor());
+ if (apiAgentMethodrefs.contains(className + methodref.toString()))
+ testcases.add("apiagent");
+ String implClasses = (String)interface2implClasses.get(className);
+ if (implClasses != null)
+ {
+ StringTokenizer st = new StringTokenizer(implClasses, "#");
+ while (st.hasMoreTokens())
+ if (apiAgentMethodrefs.contains(st.nextToken() + methodref.toString()))
+ testcases.add("apiagent");
+ }
+ }
+ if (testcases.size() > 0)
+ {
+ TestCoverage testCoverage = new TestCoverage();
+ testCoverage.addTests(testcases);
+ return testCoverage;
+ }
+ else
+ return null;
+ }
+
+ private void getAPIAgentMethodRefs(File file, List apiAgentMethodRefs)
+ {
+ if (file.exists())
+ {
+ if (file.isDirectory())
+ {
+ File[] files = file.listFiles();
+ for (int i = 0; i < files.length; i++)
+ getAPIAgentMethodRefs(files[i], apiAgentMethodRefs);
+ }
+ else if (file.getName().endsWith(".trcxml"))
+ {
+ try
+ {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(false);
+ factory.setValidating(false);
+ SAXParser parser = factory.newSAXParser();
+ parser.parse(new InputSource(new BufferedInputStream(new FileInputStream(file))), new TRCXMLHandler(apiAgentMethodRefs));
+ }
+ catch (ParserConfigurationException pce)
+ {
+ pce.printStackTrace();
+ }
+ catch (SAXException saxe)
+ {
+ saxe.printStackTrace();
+ }
+ catch (IOException ioe)
+ {
+ ioe.printStackTrace();
+ }
+ }
+ }
+ }
+
+ private void copyImages()
+ {
+ StringBuffer outputDir = new StringBuffer(compAPIDir).append('/');
+ File ok = new File(outputDir.toString() + "OK.gif");
+ if (!ok.exists())
+ {
+ try
+ {
+ copyImage("org/eclipse/wtp/releng/tools/component/images/OK.gif", ok);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ File fail = new File(outputDir.toString() + "FAIL.gif");
+ if (!fail.exists())
+ {
+ try
+ {
+ copyImage("org/eclipse/wtp/releng/tools/component/images/FAIL.gif", fail);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ CommandOptionParser optionParser = new CommandOptionParser(args);
+ Map options = optionParser.getOptions();
+ List eclipseDir = (List)options.get(APITestCoverageEmitter.OPTION_ECLIPSE_DIR);
+ List testDir = (List)options.get(APITestCoverageEmitter.OPTION_TEST_DIR);
+ List compXMLDir = (List)options.get(APITestCoverageEmitter.OPTION_COMPONENT_XML_DIR);
+ List compAPIDir = (List)options.get(APITestCoverageEmitter.OPTION_COMPONENT_API_DIR);
+ List apiAgentOutput = (List)options.get(APITestCoverageEmitter.OPTION_API_AGENT_OUTPUT);
+ List timestamp = (List)options.get(APITestCoverageEmitter.OPTION_TIMESTAMP);
+ List genHTML = (List)options.get(APITestCoverageEmitter.OPTION_GEN_HTML);
+ if (eclipseDir == null || testDir == null || compXMLDir == null || compAPIDir == null || eclipseDir.size() < 1 || testDir.size() < 1 || compXMLDir.size() < 1 || compAPIDir.size() < 1)
+ {
+ printUsage();
+ System.exit(-1);
+ }
+ APITestCoverageEmitter apiTestCoverageEmitter = new APITestCoverageEmitter((String)compAPIDir.get(0));
+ if (apiAgentOutput != null && apiAgentOutput.size() > 0)
+ apiTestCoverageEmitter.setAPIAgentOutput((String)apiAgentOutput.get(0));
+ if (timestamp != null && timestamp.size() > 0)
+ apiTestCoverageEmitter.setTimestamp((String)timestamp.get(0));
+ apiTestCoverageEmitter.setGenHTML(genHTML != null);
+ apiTestCoverageEmitter.init(eclipseDir, testDir, compXMLDir);
+ try
+ {
+ apiTestCoverageEmitter.genAPITestCoverageXML();
+ }
+ catch (IOException ioe)
+ {
+ ioe.printStackTrace();
+ }
+ }
+
+ private static void printUsage()
+ {
+ System.out.println("Usage: java org.eclipse.wtp.releng.tools.component.api.testcoverage.APITestCoverageEmitter -eclipseDir <eclipseDir> -testDir <testDir> -compXMLDir <compXMLDir> -compAPIDir <compAPIDir> [-options]");
+ System.out.println("");
+ System.out.println("\t-eclipseDir\t<eclipseDir>\tspace seperated list of directories containing Eclipse plugins");
+ System.out.println("\t-testDir\t<testDir>\tspace separated list of directories containing test plugins");
+ System.out.println("\t-compXMLDir\t<compXMLDir>\tdirectories containing component.xml that will be checked for API test coverage");
+ System.out.println("\t-compAPIDir\t<compVioDir>\toutput directory of component-api-tc.xml");
+ System.out.println("");
+ System.out.println("where options include:");
+ System.out.println("");
+ System.out.println("\t-apiAgentOutput\tdirectory containing output from the PI Agent");
+ System.out.println("\t-timestamp\ttimestamp");
+ System.out.println("\t-genHTML\tgenerate test coverage report in HTML");
+ }
+
+ private class TRCXMLHandler extends DefaultHandler
+ {
+ private Map classRefs;
+ private List methodRefs;
+
+ public TRCXMLHandler(List methodRefs)
+ {
+ this.classRefs = new HashMap();
+ this.methodRefs = methodRefs;
+ }
+
+ public void startElement(String uri, String elementName, String qName, Attributes attributes) throws SAXException
+ {
+ if (elementName.equals("classDef") || qName.equals("classDef"))
+ {
+ String id = attributes.getValue("classId");
+ String name = attributes.getValue("name");
+ if (id != null && name != null)
+ {
+ classRefs.put(id, name);
+ }
+ }
+ else if (elementName.equals("methodDef") || qName.equals("methodDef"))
+ {
+ String classId = attributes.getValue("classIdRef");
+ if (classId != null)
+ {
+ String className = (String)classRefs.get(classId);
+ if (className != null)
+ {
+ String methodName = attributes.getValue("name");
+ String signature = attributes.getValue("signature");
+ if (methodName != null & signature != null)
+ {
+ if (methodName.equals("-init-"))
+ methodName = "<init>";
+ else if (methodName.equals("-clinit-"))
+ methodName = "<clinit>";
+ StringBuffer sb = new StringBuffer();
+ sb.append(className);
+ sb.append("#");
+ sb.append(methodName);
+ sb.append("#");
+ sb.append(signature);
+ methodRefs.add(sb.toString());
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/testcoverage/APITestCoverageSummary.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/testcoverage/APITestCoverageSummary.java
new file mode 100644
index 0000000..3e6e172
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/testcoverage/APITestCoverageSummary.java
@@ -0,0 +1,137 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component.api.testcoverage;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import org.eclipse.wtp.releng.tools.component.ILocation;
+import org.eclipse.wtp.releng.tools.component.api.ClassAPI;
+import org.eclipse.wtp.releng.tools.component.api.ComponentAPI;
+import org.eclipse.wtp.releng.tools.component.api.MethodAPI;
+import org.eclipse.wtp.releng.tools.component.api.PackageAPI;
+import org.eclipse.wtp.releng.tools.component.internal.ComponentEntry;
+import org.eclipse.wtp.releng.tools.component.internal.ComponentSummary;
+
+public class APITestCoverageSummary extends ComponentSummary
+{
+ private static final String ROOT_TAG_NAME = "component-api-tc-summary";
+ private String refFileName;
+
+ public APITestCoverageSummary(String refFileName)
+ {
+ this.refFileName = refFileName;
+ }
+
+ public void add(ComponentAPI compAPI)
+ {
+ APITestCoverageEntry entry = new APITestCoverageEntry();
+ int apiCount = 0;
+ int testCoverageCount = 0;
+ entry.setCompName(compAPI.getName());
+ List pkgAPIs = compAPI.getPackageAPIs();
+ for (Iterator it = pkgAPIs.iterator(); it.hasNext();)
+ {
+ PackageAPI pkgAPI = (PackageAPI)it.next();
+ List classAPIs = pkgAPI.getClassAPIs();
+ for (Iterator classAPIsIt = classAPIs.iterator(); classAPIsIt.hasNext();)
+ {
+ ClassAPI classAPI = (ClassAPI)classAPIsIt.next();
+ List methodAPIs = classAPI.getMethodAPIs();
+ apiCount += methodAPIs.size();
+ for (Iterator methodAPIsIt = methodAPIs.iterator(); methodAPIsIt.hasNext();)
+ {
+ MethodAPI methodAPI = (MethodAPI)methodAPIsIt.next();
+ if (methodAPI.countTestcases() > 0)
+ testCoverageCount++;
+ }
+ }
+ }
+ entry.setApiCount(apiCount);
+ entry.setTestCoverageCount(testCoverageCount);
+ String ref = compAPI.getLocation().getAbsolutePath();
+ int i = ref.lastIndexOf('/');
+ if (i != -1)
+ ref = ref.substring(0, i + 1);
+ entry.setRef(ref + refFileName);
+ add(entry);
+ }
+
+ public void saveAsHTML(String xsl, ILocation html) throws TransformerConfigurationException, TransformerException, IOException
+ {
+ saveAsHTML(html, xsl, ROOT_TAG_NAME);
+ }
+
+ public void save(ILocation location) throws IOException
+ {
+ save(location, ROOT_TAG_NAME);
+ }
+
+ private class APITestCoverageEntry extends ComponentEntry
+ {
+ private int apiCount;
+ private int testCoverageCount;
+
+ public APITestCoverageEntry()
+ {
+ apiCount = 0;
+ testCoverageCount = 0;
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("<component-api-tc ");
+ sb.append(toAttribute("name", getCompName()));
+ sb.append(toAttribute("api-count", String.valueOf(apiCount)));
+ sb.append(toAttribute("test-coverage-count", String.valueOf(testCoverageCount)));
+ sb.append(toAttribute("missing-coverage-count", String.valueOf(apiCount - testCoverageCount)));
+ sb.append(toAttribute("ref", getRef()));
+ sb.append("/>");
+ return sb.toString();
+ }
+
+ /**
+ * @return Returns the apiCount.
+ */
+ public int getApiCount()
+ {
+ return apiCount;
+ }
+
+ /**
+ * @param apiCount The apiCount to set.
+ */
+ public void setApiCount(int apiCount)
+ {
+ this.apiCount = apiCount;
+ }
+
+ /**
+ * @return Returns the testCoverageCount.
+ */
+ public int getTestCoverageCount()
+ {
+ return testCoverageCount;
+ }
+
+ /**
+ * @param testCoverageCount The testCoverageCount to set.
+ */
+ public void setTestCoverageCount(int testCoverageCount)
+ {
+ this.testCoverageCount = testCoverageCount;
+ }
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/usecoverage/APIUseCoverageEmitter.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/usecoverage/APIUseCoverageEmitter.java
new file mode 100644
index 0000000..5482b46
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/usecoverage/APIUseCoverageEmitter.java
@@ -0,0 +1,96 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.wtp.releng.tools.component.api.usecoverage;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.wtp.releng.tools.component.api.testcoverage.APITestCoverageEmitter;
+import org.eclipse.wtp.releng.tools.component.util.CommandOptionParser;
+
+public class APIUseCoverageEmitter extends APITestCoverageEmitter
+{
+ public APIUseCoverageEmitter(String compAPIDir)
+ {
+ super(compAPIDir);
+ }
+
+ protected String getComponentSummaryXML()
+ {
+ return "index-comp-uc-summary.xml";
+ }
+
+ protected String getSummaryXML()
+ {
+ return "index-api-uc.xml";
+ }
+
+ protected String getSummaryHTML()
+ {
+ return "index-api-uc.html";
+ }
+
+ protected String getSummaryXSL()
+ {
+ return "org/eclipse/wtp/releng/tools/component/xsl/component-api-uc-summary.xsl";
+ }
+
+ protected String getCoverageXML()
+ {
+ return "component-api-uc.xml";
+ }
+
+ protected String getCoverageHTML()
+ {
+ return "component-api-uc.html";
+ }
+
+ public static void main(String[] args)
+ {
+ CommandOptionParser optionParser = new CommandOptionParser(args);
+ Map options = optionParser.getOptions();
+ List eclipseDir = (List)options.get(APIUseCoverageEmitter.OPTION_ECLIPSE_DIR);
+ List testDir = (List)options.get(APIUseCoverageEmitter.OPTION_TEST_DIR);
+ List compXMLDir = (List)options.get(APIUseCoverageEmitter.OPTION_COMPONENT_XML_DIR);
+ List compAPIDir = (List)options.get(APIUseCoverageEmitter.OPTION_COMPONENT_API_DIR);
+ List genHTML = (List)options.get(APIUseCoverageEmitter.OPTION_GEN_HTML);
+ if (eclipseDir == null || testDir == null || compXMLDir == null || compAPIDir == null || eclipseDir.size() < 1 || testDir.size() < 1 || compXMLDir.size() < 1 || compAPIDir.size() < 1)
+ {
+ printUsage();
+ System.exit(-1);
+ }
+ APIUseCoverageEmitter apiUseCoverageEmitter = new APIUseCoverageEmitter((String)compAPIDir.get(0));
+ apiUseCoverageEmitter.setGenHTML(genHTML != null);
+ apiUseCoverageEmitter.init(eclipseDir, testDir, compXMLDir);
+ try
+ {
+ apiUseCoverageEmitter.genAPITestCoverageXML();
+ }
+ catch (IOException ioe)
+ {
+ ioe.printStackTrace();
+ }
+ }
+
+ private static void printUsage()
+ {
+ System.out.println("Usage: java org.eclipse.wtp.releng.tools.component.api.usecoverage.APIUseCoverageEmitter -eclipseDir <eclipseDir> -testDir <testDir> -compXMLDir <compXMLDir> -compAPIDir <compAPIDir> [-options]");
+ System.out.println("");
+ System.out.println("\t-eclipseDir\t<eclipseDir>\tspace seperated list of directories containing Eclipse plugins");
+ System.out.println("\t-testDir\t<testDir>\tspace separated list of directories containing test plugins");
+ System.out.println("\t-compXMLDir\t<compXMLDir>\tdirectories containing component.xml that will be checked for API test coverage");
+ System.out.println("\t-compAPIDir\t<compVioDir>\toutput directory of component-api-tc.xml");
+ System.out.println("");
+ System.out.println("where options include:");
+ System.out.println("");
+ System.out.println("\t-genHTML\tgenerate test coverage report in HTML");
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ClassViolation.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ClassViolation.java
new file mode 100644
index 0000000..f4a2fdf
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ClassViolation.java
@@ -0,0 +1,19 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.wtp.releng.tools.component.api.violation;
+
+public class ClassViolation extends ViolationContainer
+{
+ protected String getViolationName()
+ {
+ return "class";
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ComponentAPIViolation.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ComponentAPIViolation.java
new file mode 100644
index 0000000..9c8fd9e
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ComponentAPIViolation.java
@@ -0,0 +1,20 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component.api.violation;
+
+public class ComponentAPIViolation extends ViolationContainer
+{
+ protected String getViolationName()
+ {
+ return "component-api-violation";
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ComponentAPIViolationEmitter.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ComponentAPIViolationEmitter.java
new file mode 100644
index 0000000..4441711
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ComponentAPIViolationEmitter.java
@@ -0,0 +1,387 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.wtp.releng.tools.component.api.violation;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.util.IModifierConstants;
+import org.eclipse.wtp.releng.tools.component.api.ClassAPI;
+import org.eclipse.wtp.releng.tools.component.api.ComponentAPI;
+import org.eclipse.wtp.releng.tools.component.api.ComponentAPIEmitter;
+import org.eclipse.wtp.releng.tools.component.api.FieldAPI;
+import org.eclipse.wtp.releng.tools.component.api.MethodAPI;
+import org.eclipse.wtp.releng.tools.component.api.PackageAPI;
+import org.eclipse.wtp.releng.tools.component.internal.AbstractEmitter;
+import org.eclipse.wtp.releng.tools.component.internal.ComponentEntry;
+import org.eclipse.wtp.releng.tools.component.internal.ComponentSummary;
+import org.eclipse.wtp.releng.tools.component.internal.FileLocation;
+import org.eclipse.wtp.releng.tools.component.model.ComponentXML;
+import org.eclipse.wtp.releng.tools.component.model.Package;
+import org.eclipse.wtp.releng.tools.component.model.Type;
+import org.eclipse.wtp.releng.tools.component.util.CommandOptionParser;
+import org.xml.sax.SAXException;
+
+public class ComponentAPIViolationEmitter extends AbstractEmitter
+{
+ private List compXMLDirs;
+ private List compXMLRefDirs;
+ private List eclipseDirs;
+ private List includes;
+ private List excludes;
+ private String outputDir;
+ private Map compLoc2CompXML;
+ private Map compLoc2CompRef;
+ private Map pluginId2Plugin;
+ private Map fragmentId2Fragment;
+
+ public ComponentAPIViolationEmitter(List compXMLDirs, List compXMLRefDirs, List eclipseDirs, List includes, List excludes, String outputDir)
+ {
+ this.compXMLDirs = compXMLDirs;
+ this.compXMLRefDirs = compXMLRefDirs;
+ this.eclipseDirs = eclipseDirs;
+ this.includes = includes;
+ this.excludes = excludes;
+ this.outputDir = addTrailingSeperator(outputDir);
+ }
+
+ public void genAPIViolations() throws ParserConfigurationException, SAXException, IOException, TransformerConfigurationException, TransformerException
+ {
+ compLoc2CompXML = new HashMap();
+ compLoc2CompRef = new HashMap();
+ pluginId2Plugin = new HashMap();
+ fragmentId2Fragment = new HashMap();
+ for (Iterator it = eclipseDirs.iterator(); it.hasNext();)
+ {
+ File eclipseFile = new File(addTrailingSeperator((String)it.next()));
+ if (eclipseFile.exists())
+ harvestPlugins(eclipseFile, pluginId2Plugin, fragmentId2Fragment);
+ }
+ linkPluginsAndFragments(pluginId2Plugin, fragmentId2Fragment);
+ for (Iterator it = compXMLDirs.iterator(); it.hasNext();)
+ {
+ File compXMLFile = new File(addTrailingSeperator((String)it.next()));
+ if (compXMLFile.exists())
+ harvestComponents(compXMLFile, compLoc2CompXML);
+ }
+ compLoc2CompRef.putAll(compLoc2CompXML);
+ if (compXMLRefDirs != null)
+ {
+ for (Iterator it = compXMLRefDirs.iterator(); it.hasNext();)
+ {
+ File compXMLRefFile = new File(addTrailingSeperator((String)it.next()));
+ if (compXMLRefFile.exists())
+ harvestComponents(compXMLRefFile, compLoc2CompRef);
+ }
+ }
+ ComponentSummary summary = new ComponentSummary();
+ for (Iterator it = compLoc2CompXML.keySet().iterator(); it.hasNext();)
+ {
+ String compLoc = (String)it.next();
+ ComponentAPIEmitter compAPIEmitter = new ComponentAPIEmitter(null);
+ compAPIEmitter.init(compLoc2CompXML, pluginId2Plugin, fragmentId2Fragment);
+ ComponentAPI compAPI = compAPIEmitter.genComponentApiXml(compLoc);
+ ComponentAPIViolation v = genAPIViolation(compAPI);
+ String compName = compAPI.getName();
+ StringBuffer sb = new StringBuffer(outputDir);
+ sb.append(compName);
+ sb.append("/component-api-violation.xml");
+ File file = new File(sb.toString());
+ file.getParentFile().mkdirs();
+ FileOutputStream fos = new FileOutputStream(file);
+ fos.write(v.toString().getBytes());
+ fos.close();
+ ComponentEntry entry = new ComponentEntry();
+ entry.setCompName(compName);
+ sb = new StringBuffer("./");
+ sb.append(compName);
+ sb.append("/component-api-violation.xml");
+ entry.setRef(sb.toString());
+ summary.add(entry);
+ }
+ summary.save(new FileLocation(new File(outputDir + "component-api-violation-all.xml")));
+ xslt(summary.toString(), "org/eclipse/wtp/releng/tools/component/xsl/component-api-violation.xsl", outputDir + "component-api-violation-all.html");
+ }
+
+ private void xslt(String content, String xsl, String output) throws SAXException, ParserConfigurationException, TransformerConfigurationException, TransformerException, FileNotFoundException
+ {
+ File outputFile = new File(output);
+ outputFile.getParentFile().mkdirs();
+ xslt(new ByteArrayInputStream(content.getBytes()), xsl, new FileOutputStream(outputFile));
+ }
+
+ private void xslt(InputStream is, String xsl, OutputStream os) throws SAXException, ParserConfigurationException, TransformerConfigurationException, TransformerException, FileNotFoundException
+ {
+ String user_dir = "user.dir";
+ String currUserDir = System.getProperty(user_dir);
+ System.setProperty(user_dir, outputDir);
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer transformer = factory.newTransformer(new StreamSource(ClassLoader.getSystemResourceAsStream(xsl)));
+ transformer.transform(new StreamSource(is), new StreamResult(os));
+ System.setProperty(user_dir, currUserDir);
+ }
+
+ private ComponentAPIViolation genAPIViolation(ComponentAPI compAPI)
+ {
+ ComponentAPIViolation v = new ComponentAPIViolation();
+ v.setName(compAPI.getName());
+ for (Iterator it = compAPI.getPackageAPIs().iterator(); it.hasNext();)
+ v.addAllViolations(genAPIViolation((PackageAPI)it.next()));
+ return v;
+ }
+
+ private List genAPIViolation(PackageAPI pkgAPI)
+ {
+ List classViolations = new ArrayList();
+ for (Iterator it = pkgAPI.getClassAPIs().iterator(); it.hasNext();)
+ {
+ ClassViolation classViolation = genAPIViolation((ClassAPI)it.next());
+ if (classViolation != null)
+ classViolations.add(classViolation);
+ }
+ return classViolations;
+ }
+
+ private ClassViolation genAPIViolation(ClassAPI classAPI)
+ {
+ ClassViolation classViolation = new ClassViolation();
+ classViolation.setName(classAPI.getName());
+ boolean isSuperClassAPI;
+ String superClassName = classAPI.getSuperClass();
+ if (checkAccess(classAPI.getAccess(), IModifierConstants.ACC_INTERFACE))
+ isSuperClassAPI = isAPI(superClassName, false, false, true, false);
+ else
+ isSuperClassAPI = isAPI(superClassName, false, true, false, false);
+ if (!isSuperClassAPI)
+ {
+ SuperViolation superViolation = new SuperViolation();
+ superViolation.setName(superClassName);
+ classViolation.addViolation(superViolation);
+ }
+ for (Iterator it = classAPI.getMethodAPIs().iterator(); it.hasNext();)
+ {
+ MethodAPI methodAPI = (MethodAPI)it.next();
+ MethodViolation methodViolation = new MethodViolation();
+ methodViolation.setName(methodAPI.getName());
+ String desc = methodAPI.getDescriptor();
+ String returnTypeDesc = Signature.getReturnType(desc);
+ String returnType = toFullyQualifiedName(returnTypeDesc);
+ if (Signature.getTypeSignatureKind(returnTypeDesc) != Signature.BASE_TYPE_SIGNATURE && !isAPI(returnType, true, false, false, false))
+ {
+ ReturnViolation returnViolation = new ReturnViolation();
+ returnViolation.setName(returnType);
+ methodViolation.addViolation(returnViolation);
+ }
+ String[] params = Signature.getParameterTypes(desc);
+ for (int j = 0; j < params.length; j++)
+ {
+ String param = toFullyQualifiedName(params[j]);
+ if (Signature.getTypeSignatureKind(params[j]) != Signature.BASE_TYPE_SIGNATURE && !isAPI(param, true, false, false, false))
+ {
+ ParamViolation paramViolation = new ParamViolation();
+ paramViolation.setName(param);
+ methodViolation.addViolation(paramViolation);
+ }
+ }
+ String[] throwTypes = Signature.getThrownExceptionTypes(desc);
+ for (int j = 0; j < throwTypes.length; j++)
+ {
+ String throwType = toFullyQualifiedName(throwTypes[j]);
+ if (Signature.getTypeSignatureKind(throwTypes[j]) != Signature.BASE_TYPE_SIGNATURE && !isAPI(throwType, true, false, false, false))
+ {
+ ThrowViolation throwViolation = new ThrowViolation();
+ throwViolation.setName(throwType);
+ methodViolation.addViolation(throwViolation);
+ }
+ }
+ if (methodViolation.countViolations() > 0)
+ classViolation.addViolation(methodViolation);
+ }
+ for (Iterator it = classAPI.getFieldAPIs().iterator(); it.hasNext();)
+ {
+ FieldAPI fieldAPI = (FieldAPI)it.next();
+ String desc = new String(fieldAPI.getDescriptor());
+ String field = toFullyQualifiedName(desc);
+ if (Signature.getTypeSignatureKind(desc) != Signature.BASE_TYPE_SIGNATURE && !isAPI(field, true, false, false, false))
+ {
+ FieldViolation fieldViolation = new FieldViolation();
+ fieldViolation.setName(fieldAPI.getName());
+ fieldViolation.setType(field);
+ classViolation.addViolation(fieldViolation);
+ }
+ }
+ if (classViolation.countViolations() > 0)
+ return classViolation;
+ else
+ return null;
+ }
+
+ private String toFullyQualifiedName(String descriptor)
+ {
+ StringBuffer sb = new StringBuffer();
+ descriptor = descriptor.replace('/', '.');
+ sb.append(Signature.getSignatureQualifier(descriptor));
+ sb.append('.');
+ sb.append(Signature.getSignatureSimpleName(descriptor).replace('.', '$'));
+ return sb.toString();
+ }
+
+ private boolean checkAccess(int flag, int bit)
+ {
+ return ((flag & bit) == bit);
+ }
+
+ private boolean isAPI(String className, boolean ref, boolean subclass, boolean implement, boolean instantiate)
+ {
+ if (include(className))
+ {
+ String pkgName = null;
+ String typeName = null;
+ int dot = className.lastIndexOf('.');
+ if (dot != -1)
+ {
+ pkgName = className.substring(0, dot);
+ typeName = className.substring(dot + 1);
+ }
+ if (pkgName != null && typeName != null)
+ {
+ for (Iterator it = compLoc2CompRef.values().iterator(); it.hasNext();)
+ {
+ ComponentXML compXML = (ComponentXML)it.next();
+ for (Iterator pkgIt = compXML.getPackages().iterator(); pkgIt.hasNext();)
+ {
+ Package pkg = (Package)pkgIt.next();
+ if (pkgName.equals(pkg.getName()))
+ {
+ // if not overwritten, inner class inherits usages from base class
+ int index = typeName.indexOf('$');
+ String baseTypeName = (index != -1) ? typeName.substring(0, index) : null;
+ Type baseType = null;
+ for (Iterator typeIt = pkg.getTypes().iterator(); typeIt.hasNext();)
+ {
+ Type type = (Type)typeIt.next();
+ String name = type.getName();
+ if (typeName.equals(name))
+ {
+ if (ref && !type.isReference())
+ return false;
+ if (subclass && !type.isSubclass())
+ return false;
+ if (implement && !type.isImplement())
+ return false;
+ if (instantiate && !type.isInstantiate())
+ return false;
+ return true;
+ }
+ if (baseTypeName != null && baseType == null && baseTypeName.equals(name))
+ {
+ baseType = type;
+ }
+ }
+ if (baseType != null)
+ {
+ if (ref && !baseType.isReference())
+ return false;
+ if (subclass && !baseType.isSubclass())
+ return false;
+ if (implement && !baseType.isImplement())
+ return false;
+ if (instantiate && !baseType.isInstantiate())
+ return false;
+ return true;
+ }
+ return pkg.isApi();
+ }
+ }
+ }
+ }
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ private boolean include(String className)
+ {
+ if (excludes != null)
+ for (Iterator it = excludes.iterator(); it.hasNext();)
+ if (className.startsWith((String)it.next()))
+ return false;
+ if (includes != null && includes.size() > 0)
+ {
+ for (Iterator it = includes.iterator(); it.hasNext();)
+ if (className.startsWith((String)it.next()))
+ return true;
+ return false;
+ }
+ return true;
+ }
+
+ public static void main(String[] args)
+ {
+ CommandOptionParser optionParser = new CommandOptionParser(args);
+ Map options = optionParser.getOptions();
+ List compXMLDirs = (List)options.get("compXMLDirs");
+ List compXMLRefDirs = (List)options.get("compXMLRefDirs");
+ List eclipseDirs = (List)options.get("eclipseDirs");
+ List outputDir = (List)options.get("outputDir");
+ List includes = (List)options.get("includes");
+ List excludes = (List)options.get("excludes");
+ if (compXMLDirs == null || eclipseDirs == null || outputDir == null || compXMLDirs.size() < 1 || eclipseDirs.size() < 1 || outputDir.size() < 1)
+ {
+ printUsage();
+ System.exit(-1);
+ }
+ ComponentAPIViolationEmitter emitter = new ComponentAPIViolationEmitter(compXMLDirs, compXMLRefDirs, eclipseDirs, includes, excludes, (String)outputDir.get(0));
+ try
+ {
+ emitter.genAPIViolations();
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ }
+ }
+
+ private static void printUsage()
+ {
+ System.out.println("Usage: java org.eclipse.wtp.releng.tools.component.api.violation.APIViolationEmitter -compXMLDirs <compXMLDirs> -eclipseDirs <eclipseDirs> -outputDir <outputDir> [-options]");
+ System.out.println("");
+ System.out.println("\t-compXMLDirs\t<compXMLDirs>\tspace seperated list of directories containing component.xml files");
+ System.out.println("\t-eclipseDirs\t<eclipseDirs>\tspace seperated list of directories containing Eclipse plugins");
+ System.out.println("\t-outputDir\t<outputDir>\toutput directory");
+ System.out.println("");
+ System.out.println("where options include:");
+ System.out.println("");
+ System.out.println("\t-compXMLRefDirs\t<compXMLRefDirs>\tspace seperated list of directories containing component.xml files being referenced");
+ System.out.println("\t-includes\t<includes>\tpackages to include");
+ System.out.println("\t-excludes\t<excludes>\tpackages to exclude");
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/FieldViolation.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/FieldViolation.java
new file mode 100644
index 0000000..7f764e9
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/FieldViolation.java
@@ -0,0 +1,42 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.wtp.releng.tools.component.api.violation;
+
+public class FieldViolation extends ViolationContainer
+{
+ private String type;
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ protected String getViolationName()
+ {
+ return "field";
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("<");
+ sb.append(getViolationName());
+ sb.append(toAttribute("name", getName()));
+ sb.append(toAttribute("type", getType()));
+ sb.append("/>");
+ return sb.toString();
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/MethodViolation.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/MethodViolation.java
new file mode 100644
index 0000000..d59fadb
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/MethodViolation.java
@@ -0,0 +1,46 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.wtp.releng.tools.component.api.violation;
+
+public class MethodViolation extends ViolationContainer
+{
+ protected String getViolationName()
+ {
+ return "method";
+ }
+
+ public String getName()
+ {
+ String name = super.getName();
+ StringBuffer sb = new StringBuffer(name);
+ int index = name.indexOf('<');
+ while (index != -1)
+ {
+ sb.deleteCharAt(index);
+ sb.insert(index, new char[] {'&', 'l', 't', ';'}, 0, 4);
+ index = sb.toString().indexOf('<');
+ }
+ return sb.toString();
+ }
+
+ public void setName(String name)
+ {
+ StringBuffer sb = new StringBuffer(name);
+ int index = name.indexOf("<");
+ while (index != -1)
+ {
+ sb.delete(index, index + 4);
+ sb.insert(index, '<');
+ index = sb.toString().indexOf("<");
+ }
+ super.setName(sb.toString());
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ParamViolation.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ParamViolation.java
new file mode 100644
index 0000000..87a907f
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ParamViolation.java
@@ -0,0 +1,43 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component.api.violation;
+
+public class ParamViolation extends Violation
+{
+ private String type;
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ protected String getViolationName()
+ {
+ return "param";
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("<");
+ sb.append(getViolationName());
+ sb.append(toAttribute("name", getName()));
+ sb.append(toAttribute("type", getType()));
+ sb.append("/>");
+ return sb.toString();
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ReturnViolation.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ReturnViolation.java
new file mode 100644
index 0000000..91c096d
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ReturnViolation.java
@@ -0,0 +1,20 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component.api.violation;
+
+public class ReturnViolation extends Violation
+{
+ protected String getViolationName()
+ {
+ return "return";
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/SuperViolation.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/SuperViolation.java
new file mode 100644
index 0000000..d28057b
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/SuperViolation.java
@@ -0,0 +1,20 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component.api.violation;
+
+public class SuperViolation extends Violation
+{
+ protected String getViolationName()
+ {
+ return "super";
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ThrowViolation.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ThrowViolation.java
new file mode 100644
index 0000000..bb9ac83
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ThrowViolation.java
@@ -0,0 +1,20 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component.api.violation;
+
+public class ThrowViolation extends Violation
+{
+ protected String getViolationName()
+ {
+ return "throw";
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/Violation.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/Violation.java
new file mode 100644
index 0000000..d0d8d79
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/Violation.java
@@ -0,0 +1,41 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component.api.violation;
+
+import org.eclipse.wtp.releng.tools.component.model.ComponentObject;
+
+public abstract class Violation extends ComponentObject
+{
+ private String name;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ protected abstract String getViolationName();
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("<");
+ sb.append(getViolationName());
+ sb.append(toAttribute("name", getName()));
+ sb.append("/>");
+ return sb.toString();
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ViolationContainer.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ViolationContainer.java
new file mode 100644
index 0000000..782ff51
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/ViolationContainer.java
@@ -0,0 +1,59 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component.api.violation;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public abstract class ViolationContainer extends Violation
+{
+ private List violations;
+
+ public void addViolation(Violation violation)
+ {
+ if (violations == null)
+ violations = new ArrayList();
+ violations.add(violation);
+ }
+
+ public void addAllViolations(List violations)
+ {
+ if (this.violations == null)
+ this.violations = new ArrayList();
+ this.violations.addAll(violations);
+ }
+
+ public int countViolations()
+ {
+ if (violations == null)
+ return 0;
+ else
+ return violations.size();
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("<");
+ sb.append(getViolationName());
+ sb.append(toAttribute("name", getName()));
+ sb.append(">");
+ if (violations != null)
+ for (Iterator it = violations.iterator(); it.hasNext();)
+ sb.append(it.next().toString());
+ sb.append("</");
+ sb.append(getViolationName());
+ sb.append(">");
+ return sb.toString();
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/javadoc/JavadocCoverageEmitter.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/javadoc/JavadocCoverageEmitter.java
new file mode 100644
index 0000000..b6a2878
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/javadoc/JavadocCoverageEmitter.java
@@ -0,0 +1,484 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.wtp.releng.tools.component.javadoc;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import org.eclipse.core.runtime.IPlatformRunnable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.ASTParser;
+import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.FieldDeclaration;
+import org.eclipse.jdt.core.dom.Javadoc;
+import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.MethodRef;
+import org.eclipse.jdt.core.dom.Modifier;
+import org.eclipse.jdt.core.dom.Name;
+import org.eclipse.jdt.core.dom.PrimitiveType;
+import org.eclipse.jdt.core.dom.SimpleName;
+import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.jdt.core.dom.TagElement;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
+import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
+import org.eclipse.jdt.internal.core.util.CharArrayBuffer;
+import org.eclipse.wtp.releng.tools.component.IFileLocation;
+import org.eclipse.wtp.releng.tools.component.ILocation;
+import org.eclipse.wtp.releng.tools.component.api.ClassAPI;
+import org.eclipse.wtp.releng.tools.component.api.ComponentAPI;
+import org.eclipse.wtp.releng.tools.component.api.FieldAPI;
+import org.eclipse.wtp.releng.tools.component.api.JavadocCoverage;
+import org.eclipse.wtp.releng.tools.component.api.MethodAPI;
+import org.eclipse.wtp.releng.tools.component.api.PackageAPI;
+import org.eclipse.wtp.releng.tools.component.internal.AbstractEmitter;
+import org.eclipse.wtp.releng.tools.component.internal.FileLocation;
+import org.eclipse.wtp.releng.tools.component.internal.PluginClasspath;
+import org.eclipse.wtp.releng.tools.component.model.ComponentXML;
+import org.eclipse.wtp.releng.tools.component.model.Package;
+import org.eclipse.wtp.releng.tools.component.model.Plugin;
+import org.eclipse.wtp.releng.tools.component.model.Type;
+
+public class JavadocCoverageEmitter extends AbstractEmitter implements IPlatformRunnable
+{
+ private ASTParser parser = ASTParser.newParser(AST.JLS2);
+
+ public Object run(Object arguments)
+ {
+ try
+ {
+ String compXMLDir = addTrailingSeperator(System.getProperty("compXMLDir"));
+ String compAPIDir = addTrailingSeperator(System.getProperty("compAPIDir"));
+ String srcDir = addTrailingSeperator(System.getProperty("srcDir"));
+ String outputDir = addTrailingSeperator(System.getProperty("outputDir"));
+ if (compXMLDir != null && srcDir != null && outputDir != null)
+ {
+ Map compName2CompXML = new HashMap();
+ harvestComponents(new File(compXMLDir), compName2CompXML);
+ List compAPIs = new ArrayList();
+ harvestComponentAPIs(new File(compAPIDir), compAPIs);
+ Map id2Plugin = new HashMap();
+ Map id2Fragment = new HashMap();
+ harvestPlugins(new File(srcDir), id2Plugin, id2Fragment);
+ linkPluginsAndFragments(id2Plugin, id2Fragment);
+ JavadocCoverageSummary summary = new JavadocCoverageSummary();
+ for (Iterator it = compAPIs.iterator(); it.hasNext();)
+ {
+ ComponentAPI compAPI = (ComponentAPI)it.next();
+ compAPI.load();
+ genJavadocCoverageXML(compAPI, (ComponentXML)compName2CompXML.get(compAPI.getName()), id2Plugin, outputDir);
+ summary.add(compAPI);
+ }
+ summary.save(new FileLocation(new File(outputDir + "index-api-javadoc.xml")));
+ summary.saveAsHTML("org/eclipse/wtp/releng/tools/component/xsl/component-api-javadoc-summary.xsl", new FileLocation(new File(outputDir + "index-api-javadoc.html")));
+ }
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ }
+ return IPlatformRunnable.EXIT_OK;
+ }
+
+ protected void harvestComponents(File file, Map compName2CompXML)
+ {
+ if (file.isDirectory())
+ {
+ File[] files = file.listFiles();
+ for (int i = 0; i < files.length; i++)
+ harvestComponents(files[i], compName2CompXML);
+ }
+ else if (ComponentXML.CONST_COMPONENT_XML.equalsIgnoreCase(file.getName()))
+ {
+ ComponentXML compXML = new ComponentXML();
+ ILocation location = new FileLocation(file);
+ compXML.setLocation(location);
+ try
+ {
+ compXML.load();
+ compName2CompXML.put(compXML.getName(), compXML);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ protected void harvestComponentAPIs(File file, List compAPIs)
+ {
+ if (file.isDirectory())
+ {
+ File[] files = file.listFiles();
+ for (int i = 0; i < files.length; i++)
+ harvestComponentAPIs(files[i], compAPIs);
+ }
+ else if (ComponentAPI.CONST_COMPONENT_API.equalsIgnoreCase(file.getName()))
+ {
+ ComponentAPI compAPI = new ComponentAPI();
+ ILocation location = new FileLocation(file);
+ compAPI.setLocation(location);
+ compAPIs.add(compAPI);
+ }
+ }
+
+ public PluginClasspath getPluginClasspath(IFileLocation fileLocation, boolean validate)
+ {
+ return super.getPluginClasspath(fileLocation, false);
+ }
+
+ private void genJavadocCoverageXML(ComponentAPI compAPI, ComponentXML compXML, Map id2Plugin, String outputDir) throws IOException, TransformerConfigurationException, TransformerException
+ {
+ for (Iterator it = compXML.getPlugins().iterator(); it.hasNext();)
+ {
+ Plugin plugin = (Plugin)it.next();
+ Object object = id2Plugin.get(plugin.getId());
+ if (object instanceof PluginClasspath)
+ {
+ PluginClasspath pluginCp = (PluginClasspath)object;
+ for (Iterator pkgsIt = compXML.getPackages().iterator(); pkgsIt.hasNext();)
+ {
+ genJavadocCoverageXML(compAPI, (Package)pkgsIt.next(), addTrailingSeperator(pluginCp.getDotClasspathLocation().getFile().getParentFile().getAbsolutePath()), pluginCp.getSrcPaths());
+ }
+ }
+ }
+ compAPI.save();
+ StringBuffer sb = new StringBuffer(outputDir);
+ sb.append(compAPI.getName());
+ sb.append("/component-api-javadoc.html");
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer transformer = factory.newTransformer(new StreamSource(Platform.getBundle("org.eclipse.wtp.releng.tools.component.core").getResource("org/eclipse/wtp/releng/tools/component/xsl/component-api-javadoc.xsl").openStream()));
+ transformer.transform(new StreamSource(new ByteArrayInputStream(compAPI.toString().getBytes())), new StreamResult(new FileOutputStream(new File(sb.toString()))));
+ }
+
+ private void genJavadocCoverageXML(ComponentAPI compAPI, Package pkg, String baseDir, List srcPaths) throws IOException
+ {
+ String pkgName = pkg.getName();
+ String pkgDir = pkgName.replace('.', '/');
+ PackageAPI pkgAPI = null;
+ for (Iterator pkgIt = compAPI.getPackageAPIs().iterator(); pkgIt.hasNext();)
+ {
+ PackageAPI p = (PackageAPI)pkgIt.next();
+ if (pkgName.equals(p.getName()))
+ {
+ pkgAPI = p;
+ break;
+ }
+ }
+ if (pkgAPI != null)
+ {
+ if (pkg.isApi())
+ {
+ List excludes = new ArrayList();
+ List types = pkg.getTypes();
+ for (Iterator it = types.iterator(); it.hasNext();)
+ {
+ Type type = (Type)it.next();
+ if (!type.isImplement() && !type.isInstantiate() && !type.isReference() && !type.isSubclass())
+ excludes.add(type.getName() + ".java");
+ }
+ for (Iterator it = srcPaths.iterator(); it.hasNext();)
+ {
+ StringBuffer sb = new StringBuffer(baseDir);
+ sb.append((String)it.next());
+ sb.append('/');
+ sb.append(pkgDir);
+ genJavadocCoverageXML(pkgAPI, new File(sb.toString()), excludes);
+ }
+ }
+ else
+ {
+ List types = pkg.getTypes();
+ for (Iterator it = types.iterator(); it.hasNext();)
+ {
+ Type type = (Type)it.next();
+ if (type.isImplement() || type.isInstantiate() || type.isReference() || type.isSubclass())
+ {
+ for (Iterator srcIt = srcPaths.iterator(); srcIt.hasNext();)
+ {
+ String typeName = type.getName();
+ StringBuffer sb = new StringBuffer(baseDir);
+ sb.append((String)srcIt.next());
+ sb.append('/');
+ sb.append(pkgDir);
+ sb.append('/');
+ sb.append(typeName);
+ sb.append(".java");
+ for (Iterator classIt = pkgAPI.getClassAPIs().iterator(); classIt.hasNext();)
+ {
+ ClassAPI classAPI = (ClassAPI)classIt.next();
+ if (typeName.equals(classAPI.getName()))
+ {
+ genJavadocCoverageXML(classAPI, new File(sb.toString()));
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void genJavadocCoverageXML(PackageAPI pkgAPI, File dir, List excludes) throws IOException
+ {
+ if (dir.exists() && dir.isDirectory())
+ {
+ String pkgName = pkgAPI.getName();
+ File[] children = dir.listFiles();
+ for (int i = 0; i < children.length; i++)
+ {
+ if (children[i].isFile())
+ {
+ String fileName = children[i].getName();
+ if (fileName.endsWith(".java") && (excludes == null || !excludes.contains(fileName)))
+ {
+ StringBuffer qualifiedName = new StringBuffer(pkgName);
+ qualifiedName.append('.');
+ qualifiedName.append(fileName.substring(0, fileName.length() - 5));
+ for (Iterator it = pkgAPI.getClassAPIs().iterator(); it.hasNext();)
+ {
+ ClassAPI classAPI = (ClassAPI)it.next();
+ if (qualifiedName.toString().equals(classAPI.getName()))
+ {
+ genJavadocCoverageXML(classAPI, children[i]);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void genJavadocCoverageXML(ClassAPI classAPI, File javaFile) throws IOException
+ {
+ FileReader fr = new FileReader(javaFile);
+ CharArrayBuffer cab = new CharArrayBuffer();
+ char[] c = new char[2048];
+ for (int read = fr.read(c); read != -1; read = fr.read(c))
+ cab.append(c, 0, read);
+ fr.close();
+ parser.setSource(cab.getContents());
+ ASTNode node = parser.createAST(null);
+ JavadocVisitor visitor = new JavadocVisitor(classAPI);
+ node.accept(visitor);
+ }
+
+ private class JavadocVisitor extends ASTVisitor
+ {
+ private ClassAPI classAPI;
+
+ public JavadocVisitor(ClassAPI classAPI)
+ {
+ this.classAPI = classAPI;
+ }
+
+ public boolean visit(TypeDeclaration node)
+ {
+ if (!checkModifier(node.getModifiers(), Modifier.PRIVATE))
+ {
+ Javadoc javadoc = node.getJavadoc();
+ if (javadoc != null)
+ {
+ List tags = javadoc.tags();
+ for (Iterator it = tags.iterator(); it.hasNext();)
+ {
+ TagElement tag = (TagElement)it.next();
+ String tagName = tag.getTagName();
+ if (tagName != null && tagName.equals(TagElement.TAG_SINCE))
+ {
+ return true;
+ }
+ }
+ }
+ classAPI.getJavadocCoverage().setHasSince(Boolean.FALSE);
+ }
+ return true;
+ }
+
+ public boolean visit(MethodDeclaration node)
+ {
+ String methodName = node.getName().getFullyQualifiedName();
+ if (classAPI.getName().endsWith("." + methodName))
+ methodName = "<init>";
+ MethodAPI methodAPI = null;
+ for (Iterator it = classAPI.getMethodAPIs().iterator(); it.hasNext();)
+ {
+ MethodAPI m = (MethodAPI)it.next();
+ if (methodName.equals(m.getName()) && !m.isSetJavadocCoverage())
+ {
+ methodAPI = m;
+ break;
+ }
+ }
+ if (methodAPI != null && !checkModifier(node.getModifiers(), Modifier.PRIVATE))
+ {
+ boolean hasReturn = false;
+ org.eclipse.jdt.core.dom.Type returnType = node.getReturnType();
+ if (returnType instanceof PrimitiveType)
+ if (((PrimitiveType)returnType).getPrimitiveTypeCode() == PrimitiveType.VOID)
+ hasReturn = true;
+ List paramList = new ArrayList();
+ List params = node.parameters();
+ for (Iterator it = params.iterator(); it.hasNext();)
+ {
+ SingleVariableDeclaration param = (SingleVariableDeclaration)it.next();
+ SimpleName simpleName = param.getName();
+ paramList.add(simpleName.getIdentifier());
+ }
+ List throwList = new ArrayList();
+ List thrownExceptions = node.thrownExceptions();
+ for (Iterator it = thrownExceptions.iterator(); it.hasNext();)
+ {
+ Name name = (Name)it.next();
+ throwList.add(name.getFullyQualifiedName());
+ }
+ boolean hasDoc = false;
+ Javadoc javadoc = node.getJavadoc();
+ if (javadoc != null)
+ {
+ hasDoc = true;
+ List tags = javadoc.tags();
+ for (Iterator it = tags.iterator(); it.hasNext();)
+ {
+ TagElement tag = (TagElement)it.next();
+ String tagName = tag.getTagName();
+ if (tagName != null)
+ {
+ if (tagName.equals(TagElement.TAG_RETURN))
+ hasReturn = tag.fragments().size() > 0;
+ else if (tagName.equals(TagElement.TAG_PARAM))
+ {
+ List fragments = tag.fragments();
+ if (fragments.size() > 1)
+ {
+ Object fragment = fragments.get(0);
+ if (fragment instanceof SimpleName)
+ {
+ paramList.remove(((SimpleName)fragment).getIdentifier());
+ }
+ }
+ }
+ else if (tagName.equals(TagElement.TAG_THROWS) || tagName.equals(TagElement.TAG_EXCEPTION))
+ {
+ List fragments = tag.fragments();
+ if (fragments.size() > 1)
+ {
+ Object fragment = fragments.get(0);
+ if (fragment instanceof Name)
+ {
+ throwList.remove(((Name)fragment).getFullyQualifiedName());
+ }
+ }
+ }
+ else if (tagName.equals(TagElement.TAG_SEE))
+ {
+ List fragments = tag.fragments();
+ if (fragments.size() > 0)
+ {
+ Object fragment = fragments.get(0);
+ if (fragment instanceof MethodRef)
+ {
+ MethodRef methodRef = (MethodRef)fragment;
+ if (methodName.equals(methodRef.getName().getFullyQualifiedName()))
+ {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (!hasDoc || !hasReturn || paramList.size() > 0 || throwList.size() > 0)
+ {
+ JavadocCoverage javadocCoverage = methodAPI.getJavadocCoverage();
+ if (!hasDoc)
+ {
+ javadocCoverage.setHasDoc(Boolean.FALSE);
+ }
+ if (!hasReturn)
+ {
+ javadocCoverage.setHasReturn(Boolean.FALSE);
+ }
+ if (paramList.size() > 0)
+ {
+ for (Iterator it = paramList.iterator(); it.hasNext();)
+ {
+ javadocCoverage.addMissingParam((String)it.next());
+ }
+ }
+ if (throwList.size() > 0)
+ {
+ for (Iterator it = throwList.iterator(); it.hasNext();)
+ {
+ javadocCoverage.addMissingThrow((String)it.next());
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ public boolean visit(FieldDeclaration node)
+ {
+ String fieldName = null;
+ List varDeclFragments = node.fragments();
+ for (Iterator it = varDeclFragments.iterator(); it.hasNext();)
+ {
+ VariableDeclarationFragment varDeclFragment = (VariableDeclarationFragment)it.next();
+ fieldName = varDeclFragment.getName().getFullyQualifiedName();
+ }
+ if (fieldName != null)
+ {
+ FieldAPI fieldAPI = null;
+ for (Iterator it = classAPI.getFieldAPIs().iterator(); it.hasNext();)
+ {
+ FieldAPI f = (FieldAPI)it.next();
+ if (fieldName.equals(f.getName()) && !f.isSetJavadocCoverage())
+ {
+ fieldAPI = f;
+ break;
+ }
+ }
+ if (fieldAPI != null && !checkModifier(node.getModifiers(), Modifier.PRIVATE))
+ {
+ Javadoc javadoc = node.getJavadoc();
+ if (javadoc == null)
+ {
+ fieldAPI.setJavadocCoverage(new JavadocCoverage());
+ }
+ }
+ }
+ return true;
+ }
+
+ private boolean checkModifier(int modifier, int bit)
+ {
+ return ((modifier & bit) == bit);
+ }
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/javadoc/JavadocCoverageSummary.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/javadoc/JavadocCoverageSummary.java
new file mode 100644
index 0000000..80c90f1
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/javadoc/JavadocCoverageSummary.java
@@ -0,0 +1,198 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.wtp.releng.tools.component.javadoc;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wtp.releng.tools.component.ILocation;
+import org.eclipse.wtp.releng.tools.component.api.ClassAPI;
+import org.eclipse.wtp.releng.tools.component.api.ComponentAPI;
+import org.eclipse.wtp.releng.tools.component.api.FieldAPI;
+import org.eclipse.wtp.releng.tools.component.api.MethodAPI;
+import org.eclipse.wtp.releng.tools.component.api.PackageAPI;
+import org.eclipse.wtp.releng.tools.component.internal.ComponentEntry;
+import org.eclipse.wtp.releng.tools.component.internal.ComponentSummary;
+
+public class JavadocCoverageSummary extends ComponentSummary
+{
+ private static final String ROOT_TAG_NAME = "component-api-javadoc-summary";
+
+ public void add(ComponentAPI compAPI)
+ {
+ JavadocCoverageEntry entry = new JavadocCoverageEntry();
+ int classCount = 0;
+ int methodCount = 0;
+ int fieldCount = 0;
+ int classIncompleteJavadoc = 0;
+ int methodIncompleteJavadoc = 0;
+ int fieldIncompleteJavadoc = 0;
+ entry.setCompName(compAPI.getName());
+ for (Iterator it = compAPI.getPackageAPIs().iterator(); it.hasNext();)
+ {
+ for (Iterator classIt = ((PackageAPI)it.next()).getClassAPIs().iterator(); classIt.hasNext();)
+ {
+ ClassAPI classAPI = (ClassAPI)classIt.next();
+ classCount++;
+ if (classAPI.isSetJavadocCoverage())
+ classIncompleteJavadoc++;
+ for (Iterator methodIt = classAPI.getMethodAPIs().iterator(); methodIt.hasNext();)
+ {
+ MethodAPI methodAPI = (MethodAPI)methodIt.next();
+ methodCount++;
+ if (methodAPI.isSetJavadocCoverage())
+ methodIncompleteJavadoc++;
+ }
+ for (Iterator fieldIt = classAPI.getFieldAPIs().iterator(); fieldIt.hasNext();)
+ {
+ FieldAPI fieldAPI = (FieldAPI)fieldIt.next();
+ fieldCount++;
+ if (fieldAPI.isSetJavadocCoverage())
+ fieldIncompleteJavadoc++;
+ }
+ }
+ }
+ entry.setClassCount(classCount);
+ entry.setClassJavadocCount(classCount - classIncompleteJavadoc);
+ entry.setMethodCount(methodCount);
+ entry.setMethodJavadocCount(methodCount - methodIncompleteJavadoc);
+ entry.setFieldCount(fieldCount);
+ entry.setFieldJavadocCount(fieldCount - fieldIncompleteJavadoc);
+ String ref = compAPI.getLocation().getAbsolutePath();
+ int i = ref.lastIndexOf('/');
+ if (i != -1)
+ ref = ref.substring(0, i + 1);
+ entry.setRef(ref + "component-api-javadoc.html");
+ add(entry);
+ }
+
+ protected void saveAsHTML(ILocation html, String xsl, String rootTagName) throws TransformerConfigurationException, TransformerException, IOException
+ {
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer transformer = factory.newTransformer(new StreamSource(Platform.getBundle("org.eclipse.wtp.releng.tools.component.core").getResource(xsl).openStream()));
+ transformer.transform(new StreamSource(new ByteArrayInputStream(getBytes(html, rootTagName))), new StreamResult(new FileOutputStream(new File(html.getAbsolutePath()))));
+ }
+
+ public void saveAsHTML(String xsl, ILocation html) throws TransformerConfigurationException, TransformerException, IOException
+ {
+ saveAsHTML(html, xsl, ROOT_TAG_NAME);
+ }
+
+ public void save(ILocation location) throws IOException
+ {
+ save(location, ROOT_TAG_NAME);
+ }
+
+ private class JavadocCoverageEntry extends ComponentEntry
+ {
+ private int classCount;
+ private int methodCount;
+ private int fieldCount;
+ private int classJavadocCount;
+ private int methodJavadocCount;
+ private int fieldJavadocCount;
+
+ public JavadocCoverageEntry()
+ {
+ classCount = 0;
+ methodCount = 0;
+ fieldCount = 0;
+ classJavadocCount = 0;
+ methodJavadocCount = 0;
+ fieldJavadocCount = 0;
+ }
+
+ public int getClassCount()
+ {
+ return classCount;
+ }
+
+ public void setClassCount(int classCount)
+ {
+ this.classCount = classCount;
+ }
+
+ public int getClassJavadocCount()
+ {
+ return classJavadocCount;
+ }
+
+ public void setClassJavadocCount(int classJavadocCount)
+ {
+ this.classJavadocCount = classJavadocCount;
+ }
+
+ public int getFieldCount()
+ {
+ return fieldCount;
+ }
+
+ public void setFieldCount(int fieldCount)
+ {
+ this.fieldCount = fieldCount;
+ }
+
+ public int getFieldJavadocCount()
+ {
+ return fieldJavadocCount;
+ }
+
+ public void setFieldJavadocCount(int fieldJavadocCount)
+ {
+ this.fieldJavadocCount = fieldJavadocCount;
+ }
+
+ public int getMethodCount()
+ {
+ return methodCount;
+ }
+
+ public void setMethodCount(int methodCount)
+ {
+ this.methodCount = methodCount;
+ }
+
+ public int getMethodJavadocCount()
+ {
+ return methodJavadocCount;
+ }
+
+ public void setMethodJavadocCount(int methodJavadocCount)
+ {
+ this.methodJavadocCount = methodJavadocCount;
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("<component-api-javadoc ");
+ sb.append(toAttribute("name", getCompName()));
+ sb.append(toAttribute("class-api-count", String.valueOf(classCount)));
+ sb.append(toAttribute("class-javadoc-count", String.valueOf(classJavadocCount)));
+ sb.append(toAttribute("method-api-count", String.valueOf(methodCount)));
+ sb.append(toAttribute("method-javadoc-count", String.valueOf(methodJavadocCount)));
+ sb.append(toAttribute("field-api-count", String.valueOf(fieldCount)));
+ sb.append(toAttribute("field-javadoc-count", String.valueOf(fieldJavadocCount)));
+ sb.append(toAttribute("ref", getRef()));
+ sb.append("/>");
+ return sb.toString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/piagent/PIAgentFiltersEmitter.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/piagent/PIAgentFiltersEmitter.java
new file mode 100644
index 0000000..4cb06a9
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/piagent/PIAgentFiltersEmitter.java
@@ -0,0 +1,226 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.wtp.releng.tools.component.piagent;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.wtp.releng.tools.component.IClazz;
+import org.eclipse.wtp.releng.tools.component.IClazzVisitor;
+import org.eclipse.wtp.releng.tools.component.IPluginXML;
+import org.eclipse.wtp.releng.tools.component.internal.AbstractEmitter;
+import org.eclipse.wtp.releng.tools.component.internal.FileLocation;
+import org.eclipse.wtp.releng.tools.component.model.ComponentXML;
+import org.eclipse.wtp.releng.tools.component.model.Package;
+import org.eclipse.wtp.releng.tools.component.model.Plugin;
+import org.eclipse.wtp.releng.tools.component.util.CommandOptionParser;
+
+public class PIAgentFiltersEmitter extends AbstractEmitter
+{
+ List eclipseDirs;
+ List compXMLDirs;
+ String outputFile;
+ Map id2Plugin;
+ Map id2Fragment;
+ List includes;
+ List packages;
+
+ public PIAgentFiltersEmitter(List eclipseDirs, List compXMLDirs, String outputFile)
+ {
+ this.eclipseDirs = eclipseDirs;
+ this.compXMLDirs = compXMLDirs;
+ this.outputFile = outputFile;
+ this.packages = new ArrayList();
+ this.id2Plugin = new HashMap();
+ this.id2Fragment = new HashMap();
+ for (Iterator it = eclipseDirs.iterator(); it.hasNext();)
+ {
+ File eclipseFile = new File(addTrailingSeperator((String)it.next()));
+ if (eclipseFile.exists())
+ harvestPlugins(eclipseFile, id2Plugin, id2Fragment);
+ }
+ linkPluginsAndFragments(id2Plugin, id2Fragment);
+ }
+
+ public void setIncludes(List includes)
+ {
+ this.includes = includes;
+ }
+
+ private void genFilters()
+ {
+ for (Iterator it = compXMLDirs.iterator(); it.hasNext();)
+ {
+ File file = new File(addTrailingSeperator((String)it.next()));
+ if (file.exists())
+ {
+ getPackages(file);
+ }
+ }
+ BufferedWriter bw = null;
+ try
+ {
+ File file = new File(outputFile);
+ file.getParentFile().mkdirs();
+ bw = new BufferedWriter(new FileWriter(file));
+ for (Iterator it = packages.iterator(); it.hasNext();)
+ {
+ bw.write((String)it.next());
+ bw.write(".* * INCLUDE");
+ bw.newLine();
+ }
+ bw.write("* * EXCLUDE");
+ bw.newLine();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ try
+ {
+ if (bw != null)
+ {
+ bw.close();
+ }
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private void getPackages(File file)
+ {
+ if (file.isDirectory())
+ {
+ File[] files = file.listFiles();
+ for (int i = 0; i < files.length; i++)
+ getPackages(files[i]);
+ }
+ else if (ComponentXML.CONST_COMPONENT_XML.equalsIgnoreCase(file.getName()))
+ {
+ try
+ {
+ ComponentXML compXML = new ComponentXML();
+ compXML.setLocation(new FileLocation(file));
+ compXML.load();
+ for (Iterator it = compXML.getPackages().iterator(); it.hasNext();)
+ {
+ Package pkg = (Package)it.next();
+ String pkgName = pkg.getName();
+ if (includePackage(pkgName))
+ {
+ packages.add(pkgName);
+ }
+ }
+ for (Iterator it = compXML.getPlugins().iterator(); it.hasNext();)
+ {
+ String pluginId = ((Plugin)it.next()).getId();
+ IPluginXML plugin = (IPluginXML)id2Plugin.get(pluginId);
+ if (plugin != null)
+ {
+ plugin.accept
+ (
+ new IClazzVisitor()
+ {
+ public boolean visit(IClazz clazz)
+ {
+ String className = clazz.getName();
+ int dot = className.lastIndexOf(".");
+ if (dot != -1)
+ {
+ String classPkg = className.substring(0, dot);
+ if (!packages.contains(classPkg))
+ {
+ String[] interfaces = clazz.getInterfaces();
+ for (int i = 0; i < interfaces.length; i++)
+ {
+ dot = interfaces[i].lastIndexOf(".");
+ if (dot != -1)
+ {
+ String interfacePkg = interfaces[i].substring(0, dot);
+ if (packages.contains(interfacePkg))
+ {
+ packages.add(classPkg);
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
+ }
+ );
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private boolean includePackage(String pkg)
+ {
+ if (includes != null)
+ {
+ for (Iterator it = includes.iterator(); it.hasNext();)
+ {
+ if (pkg.startsWith((String)it.next()))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+
+ public static void main(String[] args)
+ {
+ CommandOptionParser optionParser = new CommandOptionParser(args);
+ Map options = optionParser.getOptions();
+ List eclipseDirs = (List)options.get("eclipseDirs");
+ List compXMLDirs = (List)options.get("compXMLDirs");
+ List outputDir = (List)options.get("outputFile");
+ List includes = (List)options.get("includes");
+ if (eclipseDirs == null || compXMLDirs == null || outputDir == null || eclipseDirs.size() < 1 || compXMLDirs.size() < 1 || outputDir.size() < 1)
+ {
+ printUsage();
+ System.exit(-1);
+ }
+ PIAgentFiltersEmitter emitter = new PIAgentFiltersEmitter(eclipseDirs, compXMLDirs, (String)outputDir.get(0));
+ emitter.setIncludes(includes);
+ emitter.genFilters();
+ }
+
+ private static void printUsage()
+ {
+ System.out.println("Usage: java org.eclipse.wtp.releng.tools.component.piagent.PIAgentFilterEmitter -compXMLDirs <compXMLDirs> -outputFile <outputFile>");
+ System.out.println("");
+ System.out.println("\t-eclipseDirs\t<eclipseDirs>\tspace seperated list of directories containing Eclipse plugins");
+ System.out.println("\t-compXMLDirs\t<compXMLDirs>\tspace seperated list of directories containing component.xml");
+ System.out.println("\t-outputFile\t<outputFile>\toutput PIAgent filters file");
+ System.out.println("");
+ System.out.println("\t-includes\t<includes>\tpackages to include");
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/ClassUse.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/ClassUse.java
new file mode 100644
index 0000000..1b27cc5
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/ClassUse.java
@@ -0,0 +1,56 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component.use;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.wtp.releng.tools.component.api.ClassAPI;
+
+public class ClassUse extends ClassAPI
+{
+ private List lines;
+
+ /**
+ * @return Returns the lines.
+ */
+ public List getLines()
+ {
+ if (lines == null)
+ lines = new ArrayList(1);
+ return lines;
+ }
+
+ public int sizeLines()
+ {
+ return lines != null ? lines.size() : 0;
+ }
+
+ public List getMethodUses()
+ {
+ return super.getMethodAPIs();
+ }
+
+ public int sizeMethodUses()
+ {
+ return super.sizeMethodAPIs();
+ }
+
+ public List getFieldUses()
+ {
+ return super.getFieldAPIs();
+ }
+
+ public int sizeFieldUses()
+ {
+ return super.sizeFieldAPIs();
+ }
+}
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/ComponentUse.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/ComponentUse.java
new file mode 100644
index 0000000..f5df4e8
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/ComponentUse.java
@@ -0,0 +1,273 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component.use;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import org.eclipse.wtp.releng.tools.component.ILocation;
+import org.eclipse.wtp.releng.tools.component.api.ComponentAPI;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class ComponentUse extends ComponentAPI
+{
+ public static final String CONST_COMPONENT_USE_XML = "component-use.xml";
+ public static final String CONST_COMPONENT_USE_HTML = "component-use.html";
+
+ private static final String NS = "http://eclipse.org/wtp/releng/tools/component-use";
+ private static final String ELEMENT_COMPONENT_USE = "component-use";
+ private static final String ELEMENT_SOURCE = "source";
+ private static final String ELEMENT_CLASS_USE = "class-use";
+ private static final String ELEMENT_METHOD_USE = "method-use";
+ private static final String ELEMENT_FIELD_USE = "field-use";
+ private static final String ATTR_XMLNS_USE = "xmlns:use";
+
+ private static final String ATTR_ACCESS = "access";
+ private static final String ATTR_LINES = "lines";
+ private static final String ATTR_NAME = "name";
+ private static final String ATTR_DESCRIPTOR = "descriptor";
+ private static final String ATTR_REFERENCE = "reference";
+ private static final String ATTR_IMPLEMENT = "implement";
+ private static final String ATTR_SUBCLASS = "subclass";
+ private static final String ATTR_INSTANTIATE = "instantiate";
+ private static final String ATTR_THROWS = "throws";
+
+ private List sources;
+
+ /**
+ * @return Returns the sources.
+ */
+ public List getSources()
+ {
+ if (sources == null)
+ sources = new ArrayList(1);
+ return sources;
+ }
+
+ public void load() throws IOException, FileNotFoundException
+ {
+ try
+ {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(false);
+ factory.setValidating(false);
+ SAXParser parser = factory.newSAXParser();
+ parser.parse(new InputSource(new BufferedInputStream(location.getInputStream())), new ComponentAPIHandler(this));
+ }
+ catch (ParserConfigurationException pce)
+ {
+ pce.printStackTrace();
+ }
+ catch (SAXException saxe)
+ {
+ saxe.printStackTrace();
+ }
+ }
+
+ public void saveAsHTML(ILocation html) throws TransformerConfigurationException, TransformerException, IOException
+ {
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer transformer = factory.newTransformer(new StreamSource(ClassLoader.getSystemResourceAsStream("org/eclipse/wtp/releng/tools/component/xsl/component-violation.xsl")));
+ transformer.transform(new StreamSource(new ByteArrayInputStream(getBytes())), new StreamResult(new FileOutputStream(new File(html.getAbsolutePath()))));
+ }
+
+ public void save() throws IOException
+ {
+ if (location != null)
+ {
+ File file = new File(location.getAbsolutePath());
+ file.getParentFile().mkdirs();
+ FileOutputStream fos = new FileOutputStream(file);
+ fos.write(getBytes());
+ fos.close();
+ }
+ }
+
+ public String toString()
+ {
+ try
+ {
+ return new String(getBytes());
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ e.printStackTrace();
+ }
+ return super.toString();
+ }
+
+ private byte[] getBytes() throws UnsupportedEncodingException
+ {
+ StringBuffer sb = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ sb.append("<use:component-use ");
+ sb.append(toAttribute(ATTR_XMLNS_USE, NS));
+ sb.append(toAttribute(ATTR_NAME, getName()));
+ sb.append(">");
+ for (Iterator it = getSources().iterator(); it.hasNext();)
+ saveSource(sb, (Source)it.next());
+ sb.append("</use:component-use>");
+ return sb.toString().getBytes("UTF-8");
+ }
+
+ private void saveSource(StringBuffer sb, Source source)
+ {
+ sb.append("<source");
+ sb.append(toAttribute(ATTR_NAME, source.getName()));
+ sb.append(">");
+ for (Iterator it = source.getClassUses().iterator(); it.hasNext();)
+ saveClassUse(sb, (ClassUse)it.next());
+ sb.append("</source>");
+ }
+
+ private void saveClassUse(StringBuffer sb, ClassUse classUse)
+ {
+ sb.append("<class-use");
+ sb.append(toAttribute(ATTR_NAME, classUse.getName()));
+ if (classUse.sizeLines() > 0)
+ sb.append(toAttribute(ATTR_LINES, classUse.getLines(), " "));
+ int access = classUse.getAccess();
+ if (access != -1)
+ sb.append(toAttribute(ATTR_ACCESS, String.valueOf(access)));
+ if (classUse.getReference() != null)
+ sb.append(toAttribute(ATTR_REFERENCE, String.valueOf(classUse.isReference())));
+ if (classUse.getImplement() != null)
+ sb.append(toAttribute(ATTR_IMPLEMENT, String.valueOf(classUse.isImplement())));
+ if (classUse.getSubclass() != null)
+ sb.append(toAttribute(ATTR_SUBCLASS, String.valueOf(classUse.isSubclass())));
+ if (classUse.getInstantiate() != null)
+ sb.append(toAttribute(ATTR_INSTANTIATE, String.valueOf(classUse.isInstantiate())));
+ sb.append(">");
+ if (classUse.sizeMethodUses() > 0)
+ for (Iterator it = classUse.getMethodUses().iterator(); it.hasNext();)
+ saveMethodUse(sb, (MethodUse)it.next());
+ if (classUse.sizeFieldUses() > 0)
+ for (Iterator it = classUse.getFieldUses().iterator(); it.hasNext();)
+ saveFieldUse(sb, (FieldUse)it.next());
+ sb.append("</class-use>");
+ }
+
+ protected void saveMethodUse(StringBuffer sb, MethodUse methodUse)
+ {
+ sb.append("<method-use");
+ sb.append(toAttribute(ATTR_NAME, methodUse.getName()));
+ sb.append(toAttribute(ATTR_DESCRIPTOR, methodUse.getDescriptor()));
+ int access = methodUse.getAccess();
+ if (access != -1)
+ sb.append(toAttribute(ATTR_ACCESS, String.valueOf(access)));
+ if (methodUse.sizeThrows() > 0)
+ sb.append(toAttribute(ATTR_THROWS, methodUse.getThrows(), " "));
+ if (methodUse.sizeLines() > 0)
+ sb.append(toAttribute(ATTR_LINES, methodUse.getLines(), " "));
+ sb.append("/>");
+ }
+
+ protected void saveFieldUse(StringBuffer sb, FieldUse fieldUse)
+ {
+ sb.append("<field-use");
+ sb.append(toAttribute(ATTR_NAME, fieldUse.getName()));
+ sb.append(toAttribute(ATTR_DESCRIPTOR, fieldUse.getDescriptor()));
+ int access = fieldUse.getAccess();
+ if (access != -1)
+ sb.append(toAttribute(ATTR_ACCESS, String.valueOf(access)));
+ if (fieldUse.sizeLines() > 0)
+ sb.append(toAttribute(ATTR_LINES, fieldUse.getLines(), " "));
+ sb.append("/>");
+ }
+
+ protected static class ComponentUseHandler extends ComponentAPIHandler
+ {
+ private ComponentUse compUse;
+ private Source source;
+ private ClassUse classUse;
+
+ public ComponentUseHandler(ComponentUse compUse)
+ {
+ super(compUse);
+ this.compUse = compUse;
+ }
+
+ public void startElement(String uri, String elementName, String qName, Attributes attributes) throws SAXException
+ {
+ if (elementName.equals(ELEMENT_SOURCE) || qName.equals(ELEMENT_SOURCE))
+ {
+ source = new Source();
+ source.setName(attributes.getValue(ATTR_NAME));
+ compUse.getSources().add(source);
+ }
+ else if (elementName.equals(ELEMENT_CLASS_USE) || qName.equals(ELEMENT_CLASS_USE))
+ {
+ if (source != null)
+ {
+ classUse = new ClassUse();
+ classUse.setName(attributes.getValue(ATTR_NAME));
+ String attrLines = attributes.getValue(ATTR_LINES);
+ if (attrLines != null)
+ addToList(classUse.getLines(), attrLines, " ");
+ String attrAccess = attributes.getValue(ATTR_ACCESS);
+ if (attrAccess != null)
+ classUse.setAccess(Integer.parseInt(attrAccess));
+ String attrRef = attributes.getValue(ATTR_REFERENCE);
+ if (attrRef != null)
+ classUse.setReference(Boolean.valueOf(attrRef));
+ String attrImpl = attributes.getValue(ATTR_IMPLEMENT);
+ if (attrImpl != null)
+ classUse.setImplement(Boolean.valueOf(attrImpl));
+ String attrSubclass = attributes.getValue(ATTR_SUBCLASS);
+ if (attrSubclass != null)
+ classUse.setSubclass(Boolean.valueOf(attrSubclass));
+ String attrInstantiate = attributes.getValue(ATTR_INSTANTIATE);
+ if (attrInstantiate != null)
+ classUse.setInstantiate(Boolean.valueOf(attrInstantiate));
+ source.getClassUses().add(classUse);
+ }
+ }
+ else if (elementName.equals(ELEMENT_METHOD_USE) || qName.equals(ELEMENT_METHOD_USE))
+ {
+ MethodUse methodUse = new MethodUse();
+ startMethod(classUse, methodUse, attributes);
+ String attrLines = attributes.getValue(ATTR_LINES);
+ if (attrLines != null)
+ addToList(methodUse.getLines(), attrLines, " ");
+ }
+ else if (elementName.equals(ELEMENT_FIELD_USE) || qName.equals(ELEMENT_FIELD_USE))
+ {
+ FieldUse fieldUse = new FieldUse();
+ startField(classUse, fieldUse, attributes);
+ String attrLines = attributes.getValue(ATTR_LINES);
+ if (attrLines != null)
+ addToList(fieldUse.getLines(), attrLines, " ");
+ }
+ else if (elementName.equals(ELEMENT_COMPONENT_USE) || qName.equals(ELEMENT_COMPONENT_USE))
+ {
+ compUse.setName(attributes.getValue("ATTR_NAME"));
+ }
+ }
+ }
+}
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/ComponentUseEmitter.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/ComponentUseEmitter.java
new file mode 100644
index 0000000..b30508d
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/ComponentUseEmitter.java
@@ -0,0 +1,526 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.wtp.releng.tools.component.use;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.eclipse.wtp.releng.tools.component.IClazz;
+import org.eclipse.wtp.releng.tools.component.IClazzVisitor;
+import org.eclipse.wtp.releng.tools.component.ILocation;
+import org.eclipse.wtp.releng.tools.component.IPluginXML;
+import org.eclipse.wtp.releng.tools.component.api.FieldAPI;
+import org.eclipse.wtp.releng.tools.component.internal.AbstractEmitter;
+import org.eclipse.wtp.releng.tools.component.internal.FieldRef;
+import org.eclipse.wtp.releng.tools.component.internal.FileLocation;
+import org.eclipse.wtp.releng.tools.component.internal.MethodRef;
+import org.eclipse.wtp.releng.tools.component.model.ComponentXML;
+import org.eclipse.wtp.releng.tools.component.model.Plugin;
+import org.eclipse.wtp.releng.tools.component.use.ComponentUse;
+import org.eclipse.wtp.releng.tools.component.util.CommandOptionParser;
+import org.eclipse.jdt.core.Signature;
+
+public class ComponentUseEmitter extends AbstractEmitter implements IClazzVisitor
+{
+ public static final String OPTION_ECLIPSE_DIR = "eclipseDir";
+ public static final String OPTION_COMPONENT_XML_DIR = "compXMLDir";
+ public static final String OPTION_COMPONENT_USE_DIR = "compUseDir";
+ public static final String OPTION_INCLUDE = "include";
+ public static final String OPTION_EXCLUDE = "exclude";
+ public static final String OPTION_CLASS_REF_ONLY = "classRefOnly";
+ public static final String OPTION_DEBUG = "debug";
+ private String compUseDir;
+ private Map pluginId2Plugin;
+ private Map fragmentId2Fragment;
+ private Map compLoc2CompXML;
+ private List classUseIncludes;
+ private List classUseIncludesMatch;
+ private List classUseExcludes;
+ private List classUseExcludesMatch;
+ private boolean classRefOnly;
+ private boolean debug;
+ private ComponentUse compUse;
+
+ public ComponentUseEmitter(String compUseDir)
+ {
+ this.compUseDir = addTrailingSeperator(compUseDir);
+ classRefOnly = false;
+ debug = false;
+ }
+
+ public void init(List eclipseDirs, List compXMLDirs)
+ {
+ compLoc2CompXML = new HashMap();
+ pluginId2Plugin = new HashMap();
+ fragmentId2Fragment = new HashMap();
+ for (Iterator it = eclipseDirs.iterator(); it.hasNext();)
+ {
+ File eclipseFile = new File(addTrailingSeperator((String)it.next()));
+ if (eclipseFile.exists())
+ harvestPlugins(eclipseFile, pluginId2Plugin, fragmentId2Fragment);
+ }
+ linkPluginsAndFragments(pluginId2Plugin, fragmentId2Fragment);
+ for (Iterator it = compXMLDirs.iterator(); it.hasNext();)
+ {
+ File compXMLFile = new File(addTrailingSeperator((String)it.next()));
+ if (compXMLFile.exists())
+ harvestComponents(compXMLFile, compLoc2CompXML);
+ }
+ }
+
+ public void init(Map compLoc2CompXML, Map pluginId2Plugin, Map fragmentId2Fragment)
+ {
+ this.compLoc2CompXML = compLoc2CompXML;
+ this.pluginId2Plugin = pluginId2Plugin;
+ this.fragmentId2Fragment = fragmentId2Fragment;
+ }
+
+ /**
+ * @return Returns the classRefOnly.
+ */
+ public boolean isClassRefOnly()
+ {
+ return classRefOnly;
+ }
+
+ /**
+ * @param classRefOnly
+ * The classRefOnly to set.
+ */
+ public void setClassRefOnly(boolean classRefOnly)
+ {
+ this.classRefOnly = classRefOnly;
+ }
+
+ /**
+ * @return Returns the debug.
+ */
+ public boolean isDebug()
+ {
+ return debug;
+ }
+
+ /**
+ * @param debug
+ * The debug to set.
+ */
+ public void setDebug(boolean debug)
+ {
+ this.debug = debug;
+ }
+
+ public List getClassUseIncludes()
+ {
+ return classUseIncludes;
+ }
+
+ public void setClassUseIncludes(List includes)
+ {
+ this.classUseIncludes = includes;
+ }
+
+ public List getClassUseIncludesMatch()
+ {
+ return classUseIncludesMatch;
+ }
+
+ public void setClassUseIncludesMatch(List includesMatch)
+ {
+ this.classUseIncludesMatch = includesMatch;
+ }
+
+ public List getClassUseExcludes()
+ {
+ return classUseExcludes;
+ }
+
+ public void setClassUseExcludes(List excludes)
+ {
+ this.classUseExcludes = excludes;
+ }
+
+ public List getClassUseExcludesMatch()
+ {
+ return classUseExcludesMatch;
+ }
+
+ public void setClassUseExcludesMatch(List excludesMatch)
+ {
+ this.classUseExcludesMatch = excludesMatch;
+ }
+
+ public void genComponentUseXML() throws IOException
+ {
+ for (Iterator it = compLoc2CompXML.keySet().iterator(); it.hasNext();)
+ genComponentUseXML((String)it.next());
+ }
+
+ public ComponentUse genComponentUseXML(String compLoc) throws IOException
+ {
+ ComponentXML compXML = (ComponentXML)compLoc2CompXML.get(compLoc);
+ if (compXML != null)
+ {
+ compXML.load();
+ String compName = compXML.getName();
+ compUse = newComponentUse(compXML);
+ for (Iterator pluginsIt = compXML.getPlugins().iterator(); pluginsIt.hasNext();)
+ {
+ IPluginXML pluginXML = (IPluginXML)pluginId2Plugin.get(((Plugin)pluginsIt.next()).getId());
+ if (pluginXML != null)
+ pluginXML.accept(this);
+ }
+ compXML = null;
+ if (compUseDir != null)
+ System.out.println("Writing component-use.xml for " + compName);
+ compUse.save();
+ return compUse;
+ }
+ return null;
+ }
+
+ public ComponentUse genAll() throws IOException
+ {
+ compUse = new ComponentUse();
+ for (Iterator it = pluginId2Plugin.values().iterator(); it.hasNext();)
+ ((IPluginXML)it.next()).accept(this);
+ return compUse;
+ }
+
+ public Source genUse(IClazz clazz)
+ {
+ return newSource(clazz);
+ }
+
+ public boolean visit(IClazz clazz)
+ {
+ if (compUse == null)
+ return false;
+ Source source = newSource(clazz);
+ addSource(compUse, source);
+ return true;
+ }
+
+ private Source newSource(IClazz clazz)
+ {
+ String className = clazz.getName();
+ Source source = newSource(clazz.getName());
+ if (!classRefOnly)
+ {
+ // method references
+ List methodRefs = clazz.getMethodRefs(combineFilters(classUseIncludes, classUseIncludesMatch), combineFilters(classUseExcludes, classUseExcludesMatch), debug);
+ for (Iterator it = methodRefs.iterator(); it.hasNext();)
+ {
+ MethodRef methodRef = (MethodRef)it.next();
+ String refClassName = methodRef.getClassName();
+ String methodName = methodRef.getMethodName();
+ ClassUse classUse;
+ if (isConstructor(methodName))
+ {
+ // use: instantiate
+ classUse = addUniqueClassUse(source, refClassName, null, null, null, Boolean.TRUE, methodRef.getLines());
+ }
+ else
+ {
+ classUse = addUniqueClassUse(source, refClassName, Boolean.TRUE, null, null, null, null);
+ }
+ MethodUse methodUse = newMethodUse(methodName, methodRef.getMethodDescriptor(), methodRef.getLines());
+ classUse.getMethodUses().add(methodUse);
+ }
+ clazz.resetMethodRefs();
+ methodRefs = null;
+ // field references
+ List fieldRefs = clazz.getFieldRefs(combineFilters(classUseIncludes, classUseIncludesMatch), combineFilters(classUseExcludes, classUseExcludesMatch), debug);
+ for (Iterator it = fieldRefs.iterator(); it.hasNext();)
+ {
+ FieldRef fieldRef = (FieldRef)it.next();
+ String refClassName = fieldRef.getClassName();
+ ClassUse classUse = addUniqueClassUse(source, refClassName, Boolean.TRUE, null, null, null, null);
+ FieldAPI fieldUse = newFieldUse(fieldRef.getFieldName(), fieldRef.getFieldDescriptor(), fieldRef.getLines());
+ classUse.getFieldAPIs().add(fieldUse);
+ }
+ clazz.resetFieldRefs();
+ fieldRefs = null;
+ // use: subclass
+ if (!clazz.isInterface())
+ {
+ String superClass = clazz.getSuperClass();
+ if (superClass != null && isReportClassUse(className, superClass))
+ addUniqueClassUse(source, superClass, null, Boolean.TRUE, null, null, null);
+ }
+ // use: implement
+ String[] interfaces = clazz.getInterfaces();
+ for (int i = 0; i < interfaces.length; i++)
+ if (isReportClassUse(className, interfaces[i]))
+ addUniqueClassUse(source, interfaces[i], null, null, Boolean.TRUE, null, null);
+ }
+ // use: reference
+ Set refClasses = clazz.getReferencedTypes();
+ for (Iterator refClassesIt = refClasses.iterator(); refClassesIt.hasNext();)
+ {
+ String refClassName = (String)refClassesIt.next();
+ if (isReportClassUse(className, refClassName))
+ addUniqueClassUse(source, refClassName, Boolean.TRUE, null, null, null, null);
+ }
+ return source;
+ }
+
+ private List combineFilters(List filtersStart, List filtersMatch)
+ {
+ List filters = new ArrayList();
+ if (filtersStart != null)
+ filters.addAll(filtersStart);
+ if (filtersMatch != null)
+ for (Iterator it = filtersMatch.iterator(); it.hasNext();)
+ filters.add(new StringBuffer("*").append((String)it.next()).append("*").toString());
+ if (filters.size() > 0)
+ return filters;
+ else
+ return null;
+ }
+
+ private boolean isReportClassUse(String sourceClassName, String classUseName)
+ {
+ if (sourceClassName != null && sourceClassName.equals(classUseName))
+ return false;
+ if (classUseExcludes != null)
+ for (Iterator it = classUseExcludes.iterator(); it.hasNext();)
+ if (classUseName.startsWith((String)it.next()))
+ return false;
+ if (classUseExcludesMatch != null)
+ for (Iterator it = classUseExcludesMatch.iterator(); it.hasNext();)
+ if (classUseName.indexOf((String)it.next()) != -1)
+ return false;
+ if ((classUseIncludes != null && classUseIncludes.size() > 0) || (classUseIncludesMatch != null && classUseIncludesMatch.size() > 0))
+ {
+ if (classUseIncludes != null)
+ for (Iterator it = classUseIncludes.iterator(); it.hasNext();)
+ if (classUseName.startsWith((String)it.next()))
+ return true;
+ if (classUseIncludesMatch != null)
+ for (Iterator it = classUseIncludesMatch.iterator(); it.hasNext();)
+ if (classUseName.indexOf((String)it.next()) != -1)
+ return true;
+ return false;
+ }
+ return true;
+ }
+
+ private boolean isConstructor(String methodName)
+ {
+ return methodName.equals("<init>");
+ }
+
+ private void addSource(ComponentUse compUse, Source source)
+ {
+ if (source.getClassUses().size() > 0)
+ compUse.getSources().add(source);
+ }
+
+ private ClassUse addUniqueClassUse(Source source, String className, Boolean ref, Boolean subclass, Boolean implement, Boolean instantiate, List lines)
+ {
+ List classUses = source.getClassUses();
+ for (Iterator it = classUses.iterator(); it.hasNext();)
+ {
+ ClassUse classUse = (ClassUse)it.next();
+ if (!classUse.getName().equals(className))
+ continue;
+ if (ref != null && (classUse.getReference() == null || (ref.booleanValue() != classUse.isReference())))
+ continue;
+ if (subclass != null && (classUse.getSubclass() == null || (subclass.booleanValue() != classUse.isSubclass())))
+ continue;
+ if (implement != null && (classUse.getImplement() == null || (implement.booleanValue() != classUse.isImplement())))
+ continue;
+ if (instantiate != null && (classUse.getInstantiate() == null || (instantiate.booleanValue() != classUse.isInstantiate())))
+ continue;
+ if (lines != null)
+ classUse.getLines().addAll(lines);
+ return classUse;
+ }
+ ClassUse classUse = newClassUse(className, ref, subclass, implement, instantiate, lines);
+ classUses.add(classUse);
+ return classUse;
+ }
+
+ private ClassUse newClassUse(String className, Boolean ref, Boolean subclass, Boolean implement, Boolean instantiate, List lines)
+ {
+ ClassUse classUse = new ClassUse();
+ classUse.setName(className);
+ classUse.setReference(ref);
+ classUse.setSubclass(subclass);
+ classUse.setImplement(implement);
+ classUse.setInstantiate(instantiate);
+ if (lines != null)
+ classUse.getLines().addAll(lines);
+ return classUse;
+ }
+
+ private MethodUse newMethodUse(String methodName, String descriptor, List lines)
+ {
+ MethodUse methodUse = new MethodUse();
+ methodUse.setName(methodName);
+ methodUse.setDescriptor(descriptor);
+ if (lines != null)
+ methodUse.getLines().addAll(lines);
+ return methodUse;
+ }
+
+ private FieldUse newFieldUse(String fieldName, String descriptor, List lines)
+ {
+ FieldUse fieldUse = new FieldUse();
+ fieldUse.setName(fieldName);
+ fieldUse.setDescriptor(descriptor);
+ if (lines != null)
+ fieldUse.getLines().addAll(lines);
+ return fieldUse;
+ }
+
+ private ComponentUse newComponentUse(ComponentXML compXML)
+ {
+ String compName = compXML.getName();
+ ILocation location = null;
+ if (compUseDir != null)
+ {
+ StringBuffer sb = new StringBuffer(compUseDir);
+ sb.append(compName);
+ sb.append('/');
+ sb.append(ComponentUse.CONST_COMPONENT_USE_XML);
+ location = new FileLocation(new File(sb.toString()));
+ }
+ return newComponentUse(compName, location);
+ }
+
+ private ComponentUse newComponentUse(String name, ILocation location)
+ {
+ ComponentUse compUse = new ComponentUse();
+ compUse.setName(name);
+ compUse.setLocation(location);
+ return compUse;
+ }
+
+ private Source newSource(String className)
+ {
+ Source source = new Source();
+ source.setName(className);
+ return source;
+ }
+
+ private boolean isBit(int flag, int bit)
+ {
+ return ((flag & bit) == bit);
+ }
+
+ private String descriptor2Signature(char[] descriptor)
+ {
+ return toClassName(Signature.toString(new String(descriptor)));
+ }
+
+ private String toClassName(String className)
+ {
+ return className.replace('/', '.');
+ }
+
+ public static void main(String[] args)
+ {
+ CommandOptionParser optionParser = new CommandOptionParser(args);
+ Map options = optionParser.getOptions();
+ List eclipseDir = (List)options.get(ComponentUseEmitter.OPTION_ECLIPSE_DIR);
+ List compXMLDir = (List)options.get(ComponentUseEmitter.OPTION_COMPONENT_XML_DIR);
+ List compUseDir = (List)options.get(ComponentUseEmitter.OPTION_COMPONENT_USE_DIR);
+ List includes = (List)options.get(ComponentUseEmitter.OPTION_INCLUDE);
+ List excludes = (List)options.get(ComponentUseEmitter.OPTION_EXCLUDE);
+ List classRefOnly = (List)options.get(ComponentUseEmitter.OPTION_CLASS_REF_ONLY);
+ List debug = (List)options.get(ComponentUseEmitter.OPTION_DEBUG);
+ if (eclipseDir == null || compXMLDir == null || compUseDir == null || eclipseDir.size() < 1 || compXMLDir.size() < 1 || compUseDir.size() < 1)
+ {
+ printUsage();
+ System.exit(-1);
+ }
+ List includesStart = null;
+ List includesMatch = null;
+ if (includes != null)
+ {
+ for (Iterator it = includes.iterator(); it.hasNext();)
+ {
+ String s = (String)it.next();
+ if (s.charAt(0) == '*' && s.charAt(s.length() - 1) == '*')
+ {
+ if (includesMatch == null)
+ includesMatch = new ArrayList(1);
+ includesMatch.add(s.substring(1, s.length() - 1));
+ }
+ else
+ {
+ if (includesStart == null)
+ includesStart = new ArrayList(1);
+ includesStart.add(s);
+ }
+ }
+ }
+ List excludesStart = null;
+ List excludesMatch = null;
+ if (excludes != null)
+ {
+ for (Iterator it = excludes.iterator(); it.hasNext();)
+ {
+ String s = (String)it.next();
+ if (s.charAt(0) == '*' && s.charAt(s.length() - 1) == '*')
+ {
+ if (excludesMatch == null)
+ excludesMatch = new ArrayList(1);
+ excludesMatch.add(s.substring(1, s.length() - 1));
+ }
+ else
+ {
+ if (excludesStart == null)
+ excludesStart = new ArrayList(1);
+ excludesStart.add(s);
+ }
+ }
+ }
+ ComponentUseEmitter compUseEmitter = new ComponentUseEmitter((String)compUseDir.get(0));
+ compUseEmitter.setClassUseIncludes(includesStart);
+ compUseEmitter.setClassUseIncludesMatch(includesMatch);
+ compUseEmitter.setClassUseExcludes(excludesStart);
+ compUseEmitter.setClassUseExcludesMatch(excludesMatch);
+ compUseEmitter.setClassRefOnly(classRefOnly != null);
+ compUseEmitter.setDebug(debug != null);
+ compUseEmitter.init(eclipseDir, compXMLDir);
+ try
+ {
+ compUseEmitter.genComponentUseXML();
+ }
+ catch (IOException ioe)
+ {
+ ioe.printStackTrace();
+ }
+ }
+
+ private static void printUsage()
+ {
+ System.out.println("Usage: java org.eclipse.wtp.releng.tools.component.use.ComponentUseEmitter -eclipseDir <eclipseDir> -compXMLDir <compDir> [-options]");
+ System.out.println("");
+ System.out.println("\t-eclipseDir\t<eclipseDir>\tspace seperated list of directories containing Eclipse plugins");
+ System.out.println("\t-compXMLDir\t<compXMLDir>\tdirectory containing component.xml");
+ System.out.println("\t-compUseDir\t<compUseDir>\toutput directory of component-use.xml");
+ System.out.println("");
+ System.out.println("where options include:");
+ System.out.println("");
+ System.out.println("\t-include\t<include>\tspace seperated packages to include");
+ System.out.println("\t-exclude\t<exclude>\tspace seperated packages to exclude");
+ System.out.println("\t-classRefOnly\t\t\ttreat all violations as class reference");
+ System.out.println("\t-debug\t\t\t\tgenerate debug information (ex. line numbers)");
+ }
+}
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/FieldUse.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/FieldUse.java
new file mode 100644
index 0000000..07540c2
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/FieldUse.java
@@ -0,0 +1,36 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component.use;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.wtp.releng.tools.component.api.FieldAPI;
+
+public class FieldUse extends FieldAPI
+{
+ private List lines;
+
+ /**
+ * @return Returns the line.
+ */
+ public List getLines()
+ {
+ if (lines == null)
+ lines = new ArrayList(1);
+ return lines;
+ }
+
+ public int sizeLines()
+ {
+ return lines != null ? lines.size() : 0;
+ }
+}
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/MethodUse.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/MethodUse.java
new file mode 100644
index 0000000..a542e69
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/MethodUse.java
@@ -0,0 +1,36 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component.use;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.wtp.releng.tools.component.api.MethodAPI;
+
+public class MethodUse extends MethodAPI
+{
+ private List lines;
+
+ /**
+ * @return Returns the line.
+ */
+ public List getLines()
+ {
+ if (lines == null)
+ lines = new ArrayList(1);
+ return lines;
+ }
+
+ public int sizeLines()
+ {
+ return lines != null ? lines.size() : 0;
+ }
+}
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/Source.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/Source.java
new file mode 100644
index 0000000..cc94b38
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/use/Source.java
@@ -0,0 +1,47 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component.use;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Source
+{
+ private String name;
+ private List classUses;
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * @return Returns the classUses.
+ */
+ public List getClassUses()
+ {
+ if (classUses == null)
+ classUses = new ArrayList(1);
+ return classUses;
+ }
+}
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/util/CommandOptionParser.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/util/CommandOptionParser.java
new file mode 100644
index 0000000..83d84fc
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/util/CommandOptionParser.java
@@ -0,0 +1,54 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component.util;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
+
+public class CommandOptionParser
+{
+ private String delimiter = "-";
+ private Map options;
+
+ public CommandOptionParser(String[] args)
+ {
+ parse(args);
+ }
+
+ public Map getOptions()
+ {
+ return options;
+ }
+
+ private void parse(String[] args)
+ {
+ options = new HashMap();
+ String option = null;
+ for (int i = 0; i < args.length; i++)
+ {
+ if (args[i] != null)
+ {
+ if (args[i].startsWith(delimiter))
+ {
+ option = args[i].substring(1);
+ options.put(option, new ArrayList(1));
+ }
+ else if (option != null)
+ {
+ ((List)options.get(option)).add(args[i]);
+ }
+ }
+ }
+ }
+}
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/violation/ComponentViolationEmitter.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/violation/ComponentViolationEmitter.java
new file mode 100644
index 0000000..01c81b2
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/violation/ComponentViolationEmitter.java
@@ -0,0 +1,664 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.wtp.releng.tools.component.violation;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import org.eclipse.wtp.releng.tools.component.IClazz;
+import org.eclipse.wtp.releng.tools.component.ILibrary;
+import org.eclipse.wtp.releng.tools.component.ILocation;
+import org.eclipse.wtp.releng.tools.component.IPluginXML;
+import org.eclipse.wtp.releng.tools.component.api.ClassAPI;
+import org.eclipse.wtp.releng.tools.component.api.ComponentAPI;
+import org.eclipse.wtp.releng.tools.component.api.PackageAPI;
+import org.eclipse.wtp.releng.tools.component.internal.AbstractEmitter;
+import org.eclipse.wtp.releng.tools.component.internal.FileLocation;
+import org.eclipse.wtp.releng.tools.component.model.ComponentDepends;
+import org.eclipse.wtp.releng.tools.component.model.ComponentRef;
+import org.eclipse.wtp.releng.tools.component.model.ComponentXML;
+import org.eclipse.wtp.releng.tools.component.model.Package;
+import org.eclipse.wtp.releng.tools.component.model.Plugin;
+import org.eclipse.wtp.releng.tools.component.model.Type;
+import org.eclipse.wtp.releng.tools.component.use.ClassUse;
+import org.eclipse.wtp.releng.tools.component.use.ComponentUse;
+import org.eclipse.wtp.releng.tools.component.use.ComponentUseEmitter;
+import org.eclipse.wtp.releng.tools.component.use.Source;
+import org.eclipse.wtp.releng.tools.component.util.CommandOptionParser;
+
+public class ComponentViolationEmitter extends AbstractEmitter
+{
+ public static final String CONST_COMPONENT_VIOLATION_XML = "component-violation.xml";
+ public static final String CONST_COMPONENT_VIOLATION_HTML = "component-violation.html";
+ public static final String OPTION_ECLIPSE_DIR = "eclipseDir";
+ public static final String OPTION_COMPONENT_XML_DIR = "compXMLDir";
+ public static final String OPTION_COMPONENT_REF_DIR = "compRefDir";
+ public static final String OPTION_COMPONENT_VIOLATION_DIR = "compVioDir";
+ public static final String OPTION_INCLUDE = "include";
+ public static final String OPTION_EXCLUDE = "exclude";
+ public static final String OPTION_GEN_HTML = "genHTML";
+ public static final String OPTION_GEN_USAGE = "genUsage";
+ public static final String OPTION_DEBUG = "debug";
+
+ private String compViolationDir;
+ private Map pluginId2Plugin;
+ private Map fragmentId2Fragment;
+ private Map compLoc2CompXML;
+ private Map compLoc2CompRef;
+ private List classUseIncludes;
+ private List classUseIncludesMatch;
+ private List classUseExcludes;
+ private List classUseExcludesMatch;
+ private boolean genHTML;
+ private boolean genUsage;
+ private boolean classRefOnly;
+ private boolean debug;
+ private ComponentUseEmitter compUseEmitter;
+
+ public ComponentViolationEmitter(String compViolationDir)
+ {
+ this.compViolationDir = addTrailingSeperator(compViolationDir);
+ genUsage = false;
+ classRefOnly = false;
+ debug = false;
+ }
+
+ public void init(List eclipseDirs, List compXMLDirs, List compRefDirs)
+ {
+ compLoc2CompXML = new HashMap();
+ compLoc2CompRef = new HashMap();
+ pluginId2Plugin = new HashMap();
+ fragmentId2Fragment = new HashMap();
+ for (Iterator it = eclipseDirs.iterator(); it.hasNext();)
+ {
+ File eclipseFile = new File(addTrailingSeperator((String)it.next()));
+ if (eclipseFile.exists())
+ harvestPlugins(eclipseFile, pluginId2Plugin, fragmentId2Fragment);
+ }
+ linkPluginsAndFragments(pluginId2Plugin, fragmentId2Fragment);
+ for (Iterator it = compXMLDirs.iterator(); it.hasNext();)
+ {
+ File compXMLFile = new File(addTrailingSeperator((String)it.next()));
+ if (compXMLFile.exists())
+ harvestComponents(compXMLFile, compLoc2CompXML);
+ }
+ if (compRefDirs != null)
+ {
+ for (Iterator it = compRefDirs.iterator(); it.hasNext();)
+ {
+ File compRefFile = new File(addTrailingSeperator((String)it.next()));
+ if (compRefFile.exists())
+ harvestComponents(compRefFile, compLoc2CompRef);
+ }
+ }
+ init();
+ }
+
+ public void init(Map compLoc2CompXML, Map compLoc2CompRef, Map pluginId2Plugin, Map fragmentId2Fragment)
+ {
+ this.compLoc2CompXML = compLoc2CompXML;
+ this.compLoc2CompRef = compLoc2CompRef;
+ this.pluginId2Plugin = pluginId2Plugin;
+ this.fragmentId2Fragment = fragmentId2Fragment;
+ init();
+ }
+
+ private void init()
+ {
+ compUseEmitter = new ComponentUseEmitter(genUsage ? compViolationDir : null);
+ compUseEmitter.setClassUseIncludes(classUseIncludes);
+ compUseEmitter.setClassUseIncludesMatch(classUseIncludesMatch);
+ compUseEmitter.setClassUseExcludes(classUseExcludes);
+ compUseEmitter.setClassUseExcludesMatch(classUseExcludesMatch);
+ compUseEmitter.setClassRefOnly(classRefOnly);
+ compUseEmitter.setDebug(debug);
+ compUseEmitter.init(compLoc2CompXML, pluginId2Plugin, fragmentId2Fragment);
+ }
+
+ public Map getCompRefs()
+ {
+ return new HashMap(compLoc2CompRef);
+ }
+
+ public void setCompRefs(Map compLoc2CompRef)
+ {
+ this.compLoc2CompRef = compLoc2CompRef;
+ }
+
+ public List getClassUseIncludes()
+ {
+ return classUseIncludes;
+ }
+
+ public void setClassUseIncludes(List includes)
+ {
+ this.classUseIncludes = includes;
+ }
+
+ public List getClassUseIncludesMatch()
+ {
+ return classUseIncludesMatch;
+ }
+
+ public void setClassUseIncludesMatch(List includesMatch)
+ {
+ this.classUseIncludesMatch = includesMatch;
+ }
+
+ public List getClassUseExcludes()
+ {
+ return classUseExcludes;
+ }
+
+ public void setClassUseExcludes(List excludes)
+ {
+ this.classUseExcludes = excludes;
+ }
+
+ public List getClassUseExcludesMatch()
+ {
+ return classUseExcludesMatch;
+ }
+
+ public void setClassUseExcludesMatch(List excludesMatch)
+ {
+ this.classUseExcludesMatch = excludesMatch;
+ }
+
+ /**
+ * @return Returns the genHTML.
+ */
+ public boolean isGenHTML()
+ {
+ return genHTML;
+ }
+
+ /**
+ * @param genHTML The genHTML to set.
+ */
+ public void setGenHTML(boolean genHTML)
+ {
+ this.genHTML = genHTML;
+ }
+
+ public boolean getGenUsage()
+ {
+ return genUsage;
+ }
+
+ public void setGenUsage(boolean genUsage)
+ {
+ this.genUsage = genUsage;
+ }
+
+ /**
+ * @return Returns the classRefOnly.
+ */
+ public boolean isClassRefOnly()
+ {
+ return classRefOnly;
+ }
+
+ /**
+ * @param classRefOnly
+ * The classRefOnly to set.
+ */
+ public void setClassRefOnly(boolean classRefOnly)
+ {
+ this.classRefOnly = classRefOnly;
+ }
+
+ /**
+ * @return Returns the debug.
+ */
+ public boolean isDebug()
+ {
+ return debug;
+ }
+
+ /**
+ * @param debug The debug to set.
+ */
+ public void setDebug(boolean debug)
+ {
+ this.debug = debug;
+ }
+
+ public void genComponentViolationXML() throws IOException
+ {
+ ComponentViolationSummary summary = new ComponentViolationSummary();
+ for (Iterator it = compLoc2CompXML.keySet().iterator(); it.hasNext();)
+ summary.add(genComponentViolationXML((String)it.next()));
+ if (compViolationDir != null)
+ {
+ summary.save(new FileLocation(new File(compViolationDir + "index.xml")));
+ if (genHTML)
+ {
+ try
+ {
+ summary.saveAsHTML(new FileLocation(new File(compViolationDir + "index.html")));
+ }
+ catch (TransformerConfigurationException e)
+ {
+ e.printStackTrace();
+ }
+ catch (TransformerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public ComponentUse genComponentViolationXML(String compLoc) throws IOException
+ {
+ ComponentUse compUse = null;
+ ComponentXML componentXML = (ComponentXML)compLoc2CompXML.get(compLoc);
+ if (componentXML != null)
+ {
+ componentXML.load();
+ compUse = compUseEmitter.genComponentUseXML(compLoc);
+ compUse.save();
+ for (Iterator pluginsIt = componentXML.getPlugins().iterator(); pluginsIt.hasNext();)
+ {
+ IPluginXML pluginXML = (IPluginXML)pluginId2Plugin.get(((Plugin)pluginsIt.next()).getId());
+ if (pluginXML != null)
+ validateComponentUse(pluginXML, compUse);
+ }
+ ComponentDepends depends = componentXML.getComponentDepends();
+ boolean unrestricted = depends.isUnrestricted();
+ List dependNames = null;
+ if (!unrestricted)
+ {
+ dependNames = new ArrayList();
+ List compRefs = depends.getComponentRefs();
+ for (Iterator it = compRefs.iterator(); it.hasNext();)
+ dependNames.add(((ComponentRef)it.next()).getName());
+ }
+ for (Iterator it = compLoc2CompXML.values().iterator(); it.hasNext() && compUse.getSources().size() > 0;)
+ {
+ ComponentXML compXML = (ComponentXML)it.next();
+ if (unrestricted || dependNames.contains(compXML.getName()))
+ {
+ compXML.load();
+ validateComponentUse(compXML, compUse);
+ }
+ }
+ for (Iterator it = compLoc2CompRef.values().iterator(); it.hasNext() && compUse.getSources().size() > 0;)
+ {
+ ComponentXML compXML = (ComponentXML)it.next();
+ if (unrestricted || dependNames.contains(compXML.getName()))
+ {
+ compXML.load();
+ validateComponentUse(compXML, compUse);
+ }
+ }
+ if (compViolationDir != null)
+ {
+ String compName = compUse.getName();
+ System.out.println("Writing component-violation.xml for " + compName);
+ StringBuffer sb = new StringBuffer(compViolationDir);
+ sb.append(compName);
+ sb.append('/');
+ compUse.setLocation(new FileLocation(new File(sb.toString() + CONST_COMPONENT_VIOLATION_XML)));
+ compUse.save();
+ if (genHTML)
+ {
+ try
+ {
+ ILocation html = new FileLocation(new File(sb.toString() + CONST_COMPONENT_VIOLATION_HTML));
+ compUse.setLocation(html);
+ compUse.saveAsHTML(html);
+ }
+ catch (TransformerConfigurationException e)
+ {
+ e.printStackTrace();
+ }
+ catch (TransformerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ return compUse;
+ }
+
+ public Source genViolation(String compLoc, IClazz clazz)
+ {
+ Source source = null;
+ ComponentXML componentXML = (ComponentXML)compLoc2CompXML.get(compLoc);
+ if (componentXML != null)
+ {
+ boolean valid = false;
+ source = compUseEmitter.genUse(clazz);
+ for (Iterator pluginsIt = componentXML.getPlugins().iterator(); pluginsIt.hasNext();)
+ {
+ IPluginXML pluginXML = (IPluginXML)pluginId2Plugin.get(((Plugin)pluginsIt.next()).getId());
+ if (pluginXML != null)
+ {
+ if (validateComponentUse(pluginXML, source))
+ {
+ valid = true;
+ break;
+ }
+ }
+ }
+ ComponentDepends depends = componentXML.getComponentDepends();
+ boolean unrestricted = depends.isUnrestricted();
+ List dependNames = null;
+ if (!unrestricted)
+ {
+ dependNames = new ArrayList();
+ List compRefs = depends.getComponentRefs();
+ for (Iterator it = compRefs.iterator(); it.hasNext();)
+ dependNames.add(((ComponentRef)it.next()).getName());
+ }
+ if (!valid)
+ {
+ for (Iterator it = compLoc2CompXML.values().iterator(); it.hasNext();)
+ {
+ ComponentXML comp = (ComponentXML)it.next();
+ if (unrestricted || dependNames.contains(comp.getName()))
+ {
+ valid = validateComponentUse(comp, source);
+ if (valid)
+ break;
+ }
+ }
+ }
+ if (!valid)
+ {
+ for (Iterator it = compLoc2CompRef.values().iterator(); it.hasNext();)
+ {
+ ComponentXML comp = (ComponentXML)it.next();
+ if (unrestricted || dependNames.contains(comp.getName()))
+ {
+ valid = validateComponentUse(comp, source);
+ if (valid)
+ break;
+ }
+ }
+ }
+ }
+ return source;
+ }
+
+ private void validateComponentUse(IPluginXML pluginXML, ComponentUse compUse)
+ {
+ List sources = compUse.getSources();
+ for (int i = 0; i < sources.size(); i++)
+ {
+ if (validateComponentUse(pluginXML, (Source)sources.get(i)))
+ {
+ sources.remove(i);
+ i--;
+ }
+ }
+ }
+
+ private boolean validateComponentUse(IPluginXML pluginXML, Source source)
+ {
+ List classUses = source.getClassUses();
+ for (int j = 0; j < classUses.size(); j++)
+ {
+ ClassUse classUse = (ClassUse)classUses.get(j);
+ if (validateComponentUse(pluginXML, classUse))
+ {
+ classUses.remove(j);
+ j--;
+ }
+ }
+ return classUses.size() == 0;
+ }
+
+ private boolean validateComponentUse(IPluginXML pluginXML, ClassUse classUse)
+ {
+ String classUseName = classUse.getName();
+ int dollarSign = classUseName.indexOf('$');
+ if (dollarSign != -1)
+ classUseName = classUseName.substring(0, dollarSign);
+ List libs = pluginXML.getLibraries();
+ for (Iterator libsIt = libs.iterator(); libsIt.hasNext();)
+ {
+ ILibrary lib = (ILibrary)libsIt.next();
+ Map types = lib.getTypes();
+ if (types.containsKey(classUseName))
+ return true;
+ }
+ return false;
+ }
+
+ private void validateComponentUse(ComponentAPI compAPI, ComponentUse compUse, boolean useInternalApis)
+ {
+ List sources = compUse.getSources();
+ for (int i = 0; i < sources.size(); i++)
+ {
+ if (validateComponentUse(compAPI.getPackageAPIs(), (Source)sources.get(i), useInternalApis))
+ {
+ sources.remove(i);
+ i--;
+ }
+ }
+ }
+
+ private boolean validateComponentUse(List pkgAPIs, Source source, boolean useInternalApis)
+ {
+ List classUses = source.getClassUses();
+ for (int j = 0; j < classUses.size(); j++)
+ {
+ ClassUse classUse = (ClassUse)classUses.get(j);
+ if (validateComponentUse(pkgAPIs, classUse, useInternalApis))
+ {
+ classUses.remove(j);
+ j--;
+ }
+ }
+ return classUses.size() == 0;
+ }
+
+ private boolean validateComponentUse(List pkgAPIs, ClassUse classUse, boolean useInternalApis)
+ {
+ String classUseName = classUse.getName();
+ for (Iterator pkgAPIsIt = pkgAPIs.iterator(); pkgAPIsIt.hasNext();)
+ {
+ PackageAPI pkgAPI = (PackageAPI)pkgAPIsIt.next();
+ String pkgAPIName = pkgAPI.getName();
+ if (classUseName.startsWith(pkgAPIName) && classUseName.substring(pkgAPIName.length() + 1).indexOf('.') == -1)
+ {
+ List classAPIs = pkgAPI.getClassAPIs();
+ for (Iterator classAPIsIt = classAPIs.iterator(); classAPIsIt.hasNext();)
+ {
+ ClassAPI classAPI = (ClassAPI)classAPIsIt.next();
+ if (classUseName.equals(classAPI.getName()))
+ {
+ if (useInternalApis)
+ return true;
+ else
+ {
+ if (!classUse.isReference() || classAPI.isReference())
+ if (!classUse.isSubclass() || classAPI.isSubclass())
+ if (!classUse.isImplement() || classAPI.isImplement())
+ if (!classUse.isInstantiate() || classAPI.isInstantiate())
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ private void validateComponentUse(ComponentXML compXML, ComponentUse compUse)
+ {
+ List sources = compUse.getSources();
+ for (int i = 0; i < sources.size(); i++)
+ {
+ if (validateComponentUse(compXML, (Source)sources.get(i)))
+ {
+ sources.remove(i);
+ i--;
+ }
+ }
+ }
+
+ private boolean validateComponentUse(ComponentXML compXML, Source source)
+ {
+ List classUses = source.getClassUses();
+ for (int j = 0; j < classUses.size(); j++)
+ {
+ ClassUse classUse = (ClassUse)classUses.get(j);
+ if (validateComponentUse(compXML, classUse))
+ {
+ classUses.remove(j);
+ j--;
+ }
+ }
+ return classUses.size() == 0;
+ }
+
+ private boolean validateComponentUse(ComponentXML compXML, ClassUse classUse)
+ {
+ String classUseName = classUse.getName();
+ boolean foundPkg = false;
+ List pkgs = compXML.getPackages();
+ for (Iterator pkgsIt = pkgs.iterator(); pkgsIt.hasNext();)
+ {
+ Package pkg = (Package)pkgsIt.next();
+ String pkgName = pkg.getName();
+ if (classUseName.startsWith(pkgName) && classUseName.substring(pkgName.length() + 1).indexOf('.') == -1)
+ {
+ List types = pkg.getTypes();
+ for (Iterator typesIt = types.iterator(); typesIt.hasNext();)
+ {
+ Type type = (Type)typesIt.next();
+ if (classUseName.equals(type.getName()))
+ {
+ if (!classUse.isReference() || type.isReference())
+ if (!classUse.isSubclass() || type.isSubclass())
+ if (!classUse.isImplement() || type.isImplement())
+ if (!classUse.isInstantiate() || type.isInstantiate())
+ return true;
+ return false;
+ }
+ }
+ return pkg.isApi();
+ }
+ }
+ return false;
+ }
+
+ public static void main(String[] args)
+ {
+ CommandOptionParser optionParser = new CommandOptionParser(args);
+ Map options = optionParser.getOptions();
+ List eclipseDir = (List)options.get(ComponentViolationEmitter.OPTION_ECLIPSE_DIR);
+ List compXMLDir = (List)options.get(ComponentViolationEmitter.OPTION_COMPONENT_XML_DIR);
+ List compRefDir = (List)options.get(ComponentViolationEmitter.OPTION_COMPONENT_REF_DIR);
+ List compViolationDir = (List)options.get(ComponentViolationEmitter.OPTION_COMPONENT_VIOLATION_DIR);
+ List includes = (List)options.get(ComponentViolationEmitter.OPTION_INCLUDE);
+ List excludes = (List)options.get(ComponentViolationEmitter.OPTION_EXCLUDE);
+ List genHTML = (List)options.get(ComponentViolationEmitter.OPTION_GEN_HTML);
+ List genUsage = (List)options.get(ComponentViolationEmitter.OPTION_GEN_USAGE);
+ List classRefOnly = (List)options.get(ComponentUseEmitter.OPTION_CLASS_REF_ONLY);
+ List debug = (List)options.get(ComponentUseEmitter.OPTION_DEBUG);
+ if (eclipseDir == null || compXMLDir == null || compViolationDir == null || eclipseDir.size() < 1 || compXMLDir.size() < 1 || compViolationDir.size() < 1)
+ {
+ printUsage();
+ System.exit(-1);
+ }
+ List includesStart = null;
+ List includesMatch = null;
+ if (includes != null)
+ {
+ for (Iterator it = includes.iterator(); it.hasNext();)
+ {
+ String s = (String)it.next();
+ if (s.charAt(0) == '*' && s.charAt(s.length() - 1) == '*')
+ {
+ if (includesMatch == null)
+ includesMatch = new ArrayList(1);
+ includesMatch.add(s.substring(1, s.length() - 1));
+ }
+ else
+ {
+ if (includesStart == null)
+ includesStart = new ArrayList(1);
+ includesStart.add(s);
+ }
+ }
+ }
+ List excludesStart = null;
+ List excludesMatch = null;
+ if (excludes != null)
+ {
+ for (Iterator it = excludes.iterator(); it.hasNext();)
+ {
+ String s = (String)it.next();
+ if (s.charAt(0) == '*' && s.charAt(s.length() - 1) == '*')
+ {
+ if (excludesMatch == null)
+ excludesMatch = new ArrayList(1);
+ excludesMatch.add(s.substring(1, s.length() - 1));
+ }
+ else
+ {
+ if (excludesStart == null)
+ excludesStart = new ArrayList(1);
+ excludesStart.add(s);
+ }
+ }
+ }
+ ComponentViolationEmitter compViolationEmitter = new ComponentViolationEmitter((String)compViolationDir.get(0));
+ compViolationEmitter.setClassUseIncludes(includesStart);
+ compViolationEmitter.setClassUseExcludesMatch(includesMatch);
+ compViolationEmitter.setClassUseExcludes(excludesStart);
+ compViolationEmitter.setClassUseExcludesMatch(excludesMatch);
+ compViolationEmitter.setGenHTML(genHTML != null);
+ compViolationEmitter.setGenUsage(genUsage != null);
+ compViolationEmitter.setClassRefOnly(classRefOnly != null);
+ compViolationEmitter.setDebug(debug != null);
+ compViolationEmitter.init(eclipseDir, compXMLDir, compRefDir);
+ try
+ {
+ compViolationEmitter.genComponentViolationXML();
+ }
+ catch (IOException ioe)
+ {
+ ioe.printStackTrace();
+ }
+ }
+
+ private static void printUsage()
+ {
+ System.out.println("Usage: java org.eclipse.wtp.releng.tools.component.violaion.ComponentViolationEmitter -eclipseDir <eclipseDir> -compXMLDir <compXMLDir> -compVioDir <compVioDir> [-options]");
+ System.out.println("");
+ System.out.println("\t-eclipseDir\t<eclipseDir>\tspace seperated list of directories containing Eclipse plugins");
+ System.out.println("\t-compXMLDir\t<compXMLDir>\tdirectories containing component.xml that will be checked for API violations");
+ System.out.println("\t-compVioDir\t<compVioDir>\toutput directory of component-violation.xml");
+ System.out.println("");
+ System.out.println("where options include:");
+ System.out.println("");
+ System.out.println("\t-compRefDir\t<compRefDir>\tdirectories containing component.xml being referenced");
+ System.out.println("\t-include\t<include>\tspace seperated packages to include");
+ System.out.println("\t-exclude\t<exclude>\tspace seperated packages to exclude");
+ System.out.println("\t-genHTML\t\t\tgenerate violation report in HTML");
+ System.out.println("\t-genUsage\t\t\tgenerate component-use.xml");
+ System.out.println("\t-classRefOnly\t\t\ttreat all violations as class reference");
+ System.out.println("\t-debug\t\t\t\tgenerate debug information (ex. line numbers)");
+ }
+}
\ No newline at end of file
diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/violation/ComponentViolationSummary.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/violation/ComponentViolationSummary.java
new file mode 100644
index 0000000..392b640
--- /dev/null
+++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/violation/ComponentViolationSummary.java
@@ -0,0 +1,88 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.wtp.releng.tools.component.violation;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import org.eclipse.wtp.releng.tools.component.ILocation;
+import org.eclipse.wtp.releng.tools.component.internal.ComponentEntry;
+import org.eclipse.wtp.releng.tools.component.internal.ComponentSummary;
+import org.eclipse.wtp.releng.tools.component.use.ComponentUse;
+import org.eclipse.wtp.releng.tools.component.use.Source;
+
+public class ComponentViolationSummary extends ComponentSummary
+{
+ private static final String ROOT_TAG_NAME = "component-violation-summary";
+
+ public void add(ComponentUse compViolation)
+ {
+ ComponentViolationEntry entry = new ComponentViolationEntry();
+ entry.setCompName(compViolation.getName());
+ int numViolations = 0;
+ List sources = compViolation.getSources();
+ for (Iterator it = sources.iterator(); it.hasNext();)
+ numViolations += ((Source)it.next()).getClassUses().size();
+ entry.setNumViolations(numViolations);
+ entry.setRef(compViolation.getLocation().getAbsolutePath());
+ add(entry);
+ }
+
+ public void saveAsHTML(ILocation html) throws TransformerConfigurationException, TransformerException, IOException
+ {
+ saveAsHTML(html, "org/eclipse/wtp/releng/tools/component/xsl/component-violation-summary.xsl", ROOT_TAG_NAME);
+ }
+
+ public void save(ILocation location) throws IOException
+ {
+ save(location, ROOT_TAG_NAME);
+ }
+
+ private class ComponentViolationEntry extends ComponentEntry
+ {
+ private int numViolations;
+
+ protected ComponentViolationEntry()
+ {
+ this.numViolations = -1;
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("<component-violation ");
+ sb.append(toAttribute("name", getCompName()));
+ sb.append(toAttribute("count", String.valueOf(numViolations)));
+ sb.append(toAttribute("ref", getRef()));
+ sb.append("/>");
+ return sb.toString();
+ }
+
+ /**
+ * @return Returns the numViolations.
+ */
+ public int getNumViolations()
+ {
+ return numViolations;
+ }
+
+ /**
+ * @param numViolations The numViolations to set.
+ */
+ public void setNumViolations(int numViolations)
+ {
+ this.numViolations = numViolations;
+ }
+ }
+}
\ No newline at end of file