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 index ba077a4031add5b3a04384f8b9cfc414efbf47dd..2aa93fbf116ee06ce92f704f1fd4da5547ab1a4f 100644 --- 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 @@ -1 +1,4 @@ bin +@dot +build.xml +org.eclipse.wtp.releng.tools.component.core_1.0.0.jar diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/API2ComponentAPI.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/API2ComponentAPI.java index fbe8c71623c7f322deb090346596abc595349786..ff6b4b6939d59cb5e6d589e288fd65be647ebfae 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/API2ComponentAPI.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/API2ComponentAPI.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import org.eclipse.jdt.core.dom.Modifier; import org.eclipse.jdt.core.util.ClassFormatException; import org.eclipse.jdt.core.util.IClassFileReader; import org.eclipse.jdt.core.util.IExceptionAttribute; @@ -254,39 +255,7 @@ public class API2ComponentAPI implements IClassVisitor int i = className.lastIndexOf('.'); String packageName = (i != -1) ? className.substring(0, i) : ""; String localName = (i != -1) ? className.substring(i + 1) : className; - boolean isAPI; - ComponentXML compXML = (ComponentXML)pluginId2CompXML.get(pluginId); - if (compXML != null) - { - Package pkg = compXML.getPackage(packageName); - if (pkg != null) - { - Type type = pkg.getType(localName); - if (type != null) - { - if (!type.isReference() && !type.isSubclass() && !type.isImplement() && !type.isInstantiate()) - { - isAPI = false; - } - else - { - isAPI = true; - } - } - else - { - isAPI = pkg.isApi(); - } - } - else - { - isAPI = false; - } - } - else - { - isAPI = false; - } + boolean isAPI = isAPI(reader, pluginId, packageName, localName); if (readInterface) { String superClassName = new String(reader.getSuperclassName()).replace('/', '.'); @@ -328,6 +297,7 @@ public class API2ComponentAPI implements IClassVisitor ClassAPI classAPI = pkgAPI.getClassAPI(localName); if (classAPI == null) { + boolean isExclusive = isExclusive(pluginId, packageName); if (reader == null) reader = read(classLoc); classAPI = new ClassAPI(); @@ -338,31 +308,45 @@ public class API2ComponentAPI implements IClassVisitor IMethodInfo[] methods = reader.getMethodInfos(); for (int j = 0; j < methods.length; j++) { - MethodAPI methodAPI = new MethodAPI(); - methodAPI.setName(new String(methods[j].getName())); - methodAPI.setAccess(methods[j].getAccessFlags()); - methodAPI.setDescriptor(new String(methods[j].getDescriptor())); - IExceptionAttribute exceptionAttr = methods[j].getExceptionAttribute(); - if (exceptionAttr != null) + int methodAccessFlag = methods[j].getAccessFlags(); + if (!Modifier.isPrivate(methodAccessFlag)) { - char[][] exceptionNames = exceptionAttr.getExceptionNames(); - List exceptions = new ArrayList(exceptionNames.length); - for (int k = 0; k < exceptionNames.length; k++) + if (!isExclusive || Modifier.isPublic(methodAccessFlag) || Modifier.isProtected(methodAccessFlag)) { - exceptions.add(new String(exceptionNames[k]).replace('/', '.')); + MethodAPI methodAPI = new MethodAPI(); + methodAPI.setName(new String(methods[j].getName())); + methodAPI.setAccess(methodAccessFlag); + methodAPI.setDescriptor(new String(methods[j].getDescriptor())); + IExceptionAttribute exceptionAttr = methods[j].getExceptionAttribute(); + if (exceptionAttr != null) + { + char[][] exceptionNames = exceptionAttr.getExceptionNames(); + List exceptions = new ArrayList(exceptionNames.length); + for (int k = 0; k < exceptionNames.length; k++) + { + exceptions.add(new String(exceptionNames[k]).replace('/', '.')); + } + methodAPI.addThrows(exceptions); + } + classAPI.addMethodAPI(methodAPI); } - methodAPI.addThrows(exceptions); } - classAPI.addMethodAPI(methodAPI); } IFieldInfo[] fields = reader.getFieldInfos(); for (int j = 0; j < fields.length; j++) { - FieldAPI fieldAPI = new FieldAPI(); - fieldAPI.setName(new String(fields[j].getName())); - fieldAPI.setAccess(fields[j].getAccessFlags()); - fieldAPI.setDescriptor(new String(fields[j].getDescriptor())); - classAPI.addFieldAPI(fieldAPI); + int fieldAccessFlag = fields[j].getAccessFlags(); + if (!Modifier.isPrivate(fieldAccessFlag)) + { + if (!isExclusive || Modifier.isPublic(fieldAccessFlag) || Modifier.isProtected(fieldAccessFlag)) + { + FieldAPI fieldAPI = new FieldAPI(); + fieldAPI.setName(new String(fields[j].getName())); + fieldAPI.setAccess(fieldAccessFlag); + fieldAPI.setDescriptor(new String(fields[j].getDescriptor())); + classAPI.addFieldAPI(fieldAPI); + } + } } } } @@ -388,6 +372,79 @@ public class API2ComponentAPI implements IClassVisitor return true; } + private boolean isAPI(IClassFileReader reader, String pluginId, String packageName, String localName) + { + boolean innerClass = localName.indexOf('$') != -1; + int classAccessFlag = reader.getAccessFlags(); + if (Modifier.isPrivate(classAccessFlag)) + { + return false; + } + else if (innerClass && !Modifier.isPublic(classAccessFlag) && !Modifier.isProtected(classAccessFlag)) + { + return false; + } + else + { + ComponentXML compXML = (ComponentXML)pluginId2CompXML.get(pluginId); + if (compXML != null) + { + Package pkg = compXML.getPackage(packageName); + if (pkg != null) + { + // package protected, check exclusive + if (pkg.isExclusive() && !Modifier.isPublic(classAccessFlag) && !Modifier.isProtected(classAccessFlag)) + { + return false; + } + Type type; + int innerClassSep = localName.indexOf('$'); + if (innerClassSep == -1) + type = pkg.getType(localName); + else + type = pkg.getType(localName.substring(0, innerClassSep)); + if (type != null) + { + if (!type.isReference() && !type.isSubclass() && !type.isImplement() && !type.isInstantiate()) + { + return false; + } + else + { + return true; + } + } + else + { + return pkg.isApi(); + } + } + else + { + return false; + } + } + else + { + return false; + } + } + } + + private boolean isExclusive(String pluginId, String packageName) + { + ComponentXML compXML = (ComponentXML)pluginId2CompXML.get(pluginId); + if (compXML != null) + { + Package pkg = compXML.getPackage(packageName); + if (pkg != null) + { + return pkg.isExclusive(); + } + } + return true; + } + private IClassFileReader read(ILocation classLoc) throws IOException, ClassFormatException { InputStream is = null; diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/ClassAPI.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/ClassAPI.java index 092babe85e0760697e0a473f4441ca452c14d8bc..ca1510c0b05d5a38f3000703999e0423a6234d32 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/ClassAPI.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/ClassAPI.java @@ -14,6 +14,7 @@ package org.eclipse.wtp.releng.tools.component.api; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import org.eclipse.wtp.releng.tools.component.model.Type; @@ -115,6 +116,43 @@ public class ClassAPI extends Type } } + public MethodAPI getMethodAPI(String name, List inputs, String returnType) + { + for (Iterator it = methodAPIs.values().iterator(); it.hasNext();) + { + MethodAPI methodAPI = (MethodAPI)it.next(); + if (name.equals(methodAPI.getName())) + { + if (match(inputs, methodAPI.getInputs())) + { + if (methodAPI.getReturn().endsWith(returnType)) + { + return methodAPI; + } + } + } + } + return null; + } + + private boolean match(List list1, List list2) + { + if (list1.size() == list2.size()) + { + for (int i = 0; i < list1.size(); i++) + { + String x = (String)list1.get(0); + String y = (String)list2.get(0); + if (!y.endsWith(x)) + { + return false; + } + } + return true; + } + return false; + } + public void addMethodAPI(MethodAPI methodAPI) { if (methodAPIs == null) diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/ComponentAPI.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/ComponentAPI.java index d8229bfaa866b4402c1f6e59d0801047087dc5d9..13816dcf28f56a716c3c7311075771c902678120 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/ComponentAPI.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/ComponentAPI.java @@ -206,14 +206,19 @@ public class ComponentAPI extends ComponentObject private PackageAPI packageAPI; private ClassAPI classAPI; private MethodAPI methodAPI; + private FieldAPI fieldAPI; private TestCoverage testCoverage; private JavadocCoverage javadocCoverage; private boolean classJavadoc; + private boolean methodJavadoc; + private boolean fieldJavadoc; public ComponentAPIHandler(ComponentAPI compAPI) { this.compAPI = compAPI; classJavadoc = true; + methodJavadoc = false; + fieldJavadoc = false; } public void startElement(String uri, String elementName, String qName, Attributes attributes) throws SAXException @@ -246,8 +251,10 @@ public class ComponentAPI extends ComponentObject javadocCoverage.setHasReturn(Boolean.valueOf(hasReturn)); if (classJavadoc && classAPI != null) classAPI.setJavadocCoverage(javadocCoverage); - else if (methodAPI != null) + else if (methodJavadoc && methodAPI != null) methodAPI.setJavadocCoverage(javadocCoverage); + else if (fieldJavadoc && fieldAPI != null) + fieldAPI.setJavadocCoverage(javadocCoverage); } else if (elementName.equals(ELEMENT_PARAM) || qName.equals(ELEMENT_PARAM)) { @@ -269,16 +276,25 @@ public class ComponentAPI extends ComponentObject } else if (elementName.equals(ELEMENT_METHOD_API) || qName.equals(ELEMENT_METHOD_API)) { + classJavadoc = false; + methodJavadoc = true; + fieldJavadoc = false; methodAPI = new MethodAPI(); startMethod(classAPI, methodAPI, attributes); } else if (elementName.equals(ELEMENT_FIELD_API) || qName.equals(ELEMENT_FIELD_API)) { - FieldAPI fieldAPI = new FieldAPI(); + classJavadoc = false; + methodJavadoc = false; + fieldJavadoc = true; + fieldAPI = new FieldAPI(); startField(classAPI, fieldAPI, attributes); } else if (elementName.equals(ELEMENT_CLASS_API) || qName.equals(ELEMENT_CLASS_API)) { + classJavadoc = true; + methodJavadoc = false; + fieldJavadoc = false; if (packageAPI != null) { classAPI = new ClassAPI(); diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/progress/APIProgressScanner.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/progress/APIProgressScanner.java new file mode 100644 index 0000000000000000000000000000000000000000..e6edb05cd60e59de0c28d9c0fd61d1ddfde4b431 --- /dev/null +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/progress/APIProgressScanner.java @@ -0,0 +1,431 @@ +/********************************************************************** + * 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.progress; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collection; +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.core.runtime.Platform; +import org.eclipse.wtp.releng.tools.component.ILocation; +import org.eclipse.wtp.releng.tools.component.ILocationChildrenIterator; +import org.eclipse.wtp.releng.tools.component.ILocationVisitor; +import org.eclipse.wtp.releng.tools.component.api.ComponentAPI; +import org.eclipse.wtp.releng.tools.component.api.ComponentXMLVisitor; +import org.eclipse.wtp.releng.tools.component.classes.PluginVisitor; +import org.eclipse.wtp.releng.tools.component.images.ImagesUtil; +import org.eclipse.wtp.releng.tools.component.internal.AbstractEmitter; +import org.eclipse.wtp.releng.tools.component.internal.Location; +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.util.CommandOptionParser; +import org.eclipse.wtp.releng.tools.component.xsl.XSLUtil; + +public class APIProgressScanner extends AbstractEmitter +{ + private Collection api; + private Collection src; + private String timestamp; + private String progressDir; + private String outputDir; + + public String getTimestamp() + { + return timestamp; + } + + public void setTimestamp(String timestamp) + { + this.timestamp = timestamp; + } + + public String getProgressDir() + { + return progressDir; + } + + public void setProgressDir(String progressDir) + { + this.progressDir = addTrailingSeperator(progressDir); + } + + public Collection getApi() + { + return api; + } + + public void setApi(Collection api) + { + this.api = api; + } + + public String getOutputDir() + { + return outputDir; + } + + public void setOutputDir(String outputDir) + { + this.outputDir = addTrailingSeperator(outputDir); + } + + public Collection getSrc() + { + return src; + } + + public void setSrc(Collection src) + { + this.src = src; + } + + public void execute() + { + genAPIInfoSummary(); + if (timestamp != null && progressDir != null) + genSVG(); + } + + private void genAPIInfoSummary() + { + final StringBuffer apiProgress = new StringBuffer(); + apiProgress.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); + apiProgress.append("<root>"); + ILocation loc = Location.createLocation(new File(outputDir)); + loc.accept( + new ILocationVisitor() + { + public boolean accept(ILocation location) + { + if (location.getName().endsWith("api-info.xml")) + { + apiProgress.append("<api-info file=\"./"); + apiProgress.append(location.getAbsolutePath().substring(outputDir.length())); + apiProgress.append("\"/>"); + } + return true; + } + }); + if (src != null && api != null) + apiProgress.append(validatePlugins()); + apiProgress.append("</root>"); + try + { + ImagesUtil.copyAll(outputDir); + XSLUtil.transform + ( + ClassLoader.getSystemResourceAsStream("org/eclipse/wtp/releng/tools/component/xsl/api-progress.xsl"), + new ByteArrayInputStream(apiProgress.toString().getBytes()), + new FileOutputStream(new File(outputDir + "api-progress.html")), + outputDir + ); + XSLUtil.transform + ( + ClassLoader.getSystemResourceAsStream("org/eclipse/wtp/releng/tools/component/xsl/api-progress-summary.xsl"), + new ByteArrayInputStream(apiProgress.toString().getBytes()), + new FileOutputStream(new File(outputDir + "api-info-summary.xml")), + outputDir + ); + } + catch (Throwable e) + { + try + { + XSLUtil.transform + ( + Platform.getBundle("org.eclipse.wtp.releng.tools.component.core").getResource("org/eclipse/wtp/releng/tools/component/xsl/api-progress.xsl").openStream(), + new ByteArrayInputStream(apiProgress.toString().getBytes()), + new FileOutputStream(new File(outputDir + "api-progress.html")), + outputDir + ); + XSLUtil.transform + ( + Platform.getBundle("org.eclipse.wtp.releng.tools.component.core").getResource("org/eclipse/wtp/releng/tools/component/xsl/api-progress-summary.xsl").openStream(), + new ByteArrayInputStream(apiProgress.toString().getBytes()), + new FileOutputStream(new File(outputDir + "api-info-summary.xml")), + outputDir + ); + } + catch (Throwable e2) + { + e2.printStackTrace(); + } + } + } + + private String validatePlugins() + { + StringBuffer sb = new StringBuffer(); + List pluginsWithoutComp = new ArrayList(); + List pluginsNotFoundInSrc = new ArrayList(); + List pluginsInMoreThan1Comp = new ArrayList(); + List pluginIds = new ArrayList(); + + // Collection component.xml files + for (Iterator i = api.iterator(); i.hasNext();) + { + ILocation apiLocation = Location.createLocation(new File((String)i.next())); + ComponentXMLVisitor compXMLVisitor = new ComponentXMLVisitor(); + apiLocation.accept(compXMLVisitor); + for (Iterator it = compXMLVisitor.getCompXMLs().iterator(); it.hasNext();) + { + ComponentXML compXML = (ComponentXML)it.next(); + for (Iterator it2 = compXML.getPlugins().iterator(); it2.hasNext();) + { + String id = ((Plugin)it2.next()).getId(); + if (pluginIds.contains(id)) + pluginsInMoreThan1Comp.add(id); + else + pluginIds.add(id); + } + } + } + + // Visit Src + for (Iterator it = src.iterator(); it.hasNext();) + { + ILocation srcLocation = Location.createLocation(new File((String)it.next())); + PluginVisitor v = new PluginVisitor(); + srcLocation.accept(v); + for (Iterator it2 = v.getPluginIds().iterator(); it2.hasNext();) + { + String id = (String)it2.next(); + if (!pluginIds.remove(id)) + pluginsWithoutComp.add(id); + } + } + for (Iterator it = pluginIds.iterator(); it.hasNext();) + pluginsNotFoundInSrc.add((String)it.next()); + + // Print results + for (Iterator it = pluginsWithoutComp.iterator(); it.hasNext();) + { + sb.append("<plugin-without-comp id=\""); + sb.append((String)it.next()); + sb.append("\"/>"); + } + for (Iterator it = pluginsNotFoundInSrc.iterator(); it.hasNext();) + { + sb.append("<missing-plugin id=\""); + sb.append((String)it.next()); + sb.append("\"/>"); + } + for (Iterator it = pluginsInMoreThan1Comp.iterator(); it.hasNext();) + { + sb.append("<dup-plugin id=\""); + sb.append((String)it.next()); + sb.append("\"/>"); + } + return sb.toString(); + } + + private void genSVG() + { + File src = new File(outputDir + "api-info-summary.xml"); + File dest = new File(progressDir + timestamp + "/api-info-summary.xml"); + try + { + copy(src, dest); + } + catch (IOException ioe) + { + ioe.printStackTrace(); + } + final StringBuffer content = new StringBuffer(); + content.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); + content.append("<root name=\"#name\">"); + ILocation progress = Location.createLocation(new File(progressDir)); + ILocationChildrenIterator it = progress.childIterator(); + ILocation child = it.next(); + while (child != null) + { + content.append("<summary timestamp=\""); + content.append(child.getName()); + content.append("\"/>"); + child = it.next(); + } + content.append("</root>"); + ILocation loc = Location.createLocation(new File(outputDir)); + loc.accept( + new ILocationVisitor() + { + public boolean accept(ILocation location) + { + if (location.getName().endsWith("api-info.xml")) + { + try + { + ComponentAPI compAPI = new ComponentAPI(); + compAPI.setLocation(location); + compAPI.load(); + String compName = compAPI.getName(); + StringBuffer sb = new StringBuffer(); + sb.append(outputDir); + sb.append("svg/"); + new File(sb.toString()).mkdirs(); + genSVG(content.toString(), compName, sb.toString()); + } + catch (Throwable t) + { + t.printStackTrace(); + } + } + return true; + } + }); + try + { + genSVG(content.toString(), "total", outputDir + "svg/"); + } + catch (Throwable t) + { + t.printStackTrace(); + } + } + + private void genSVG(String content, String name, String outDir) throws IOException, TransformerConfigurationException, TransformerException + { + XSLUtil.transform + ( + ClassLoader.getSystemResourceAsStream("org/eclipse/wtp/releng/tools/component/xsl/api-progress-svg.xsl"), + new ByteArrayInputStream(content.replaceAll("#name", name).getBytes()), + new FileOutputStream(outDir + name + ".svg"), + progressDir + ); + } + + private void copy(File src, File dest) throws IOException + { + dest.getParentFile().mkdirs(); + FileOutputStream fos = new FileOutputStream(dest); + FileInputStream fis = new FileInputStream(src); + byte[] b = new byte[2048]; + int read = fis.read(b); + while (read != -1) + { + fos.write(b, 0, read); + read = fis.read(b); + } + fis.close(); + fos.close(); + } + + public static void main(String[] args) + { + CommandOptionParser optionParser = new CommandOptionParser(args); + Map options = optionParser.getOptions(); + List api = (List)options.get("api"); + List src = (List)options.get("src"); + List timestamp = (List)options.get("timestamp"); + List progressDir = (List)options.get("progressDir"); + List outputDir = (List)options.get("outputDir"); + if (outputDir == null || outputDir.size() < 1) + { + printUsage(); + System.exit(-1); + } + APIProgressScanner scanner = new APIProgressScanner(); + if (api != null && api.size() > 0) + scanner.setApi(api); + if (src != null && src.size() > 0) + scanner.setSrc(src); + if (timestamp != null && timestamp.size() > 0) + scanner.setTimestamp((String)timestamp.iterator().next()); + if (progressDir != null && progressDir.size() > 0) + scanner.setProgressDir((String)progressDir.iterator().next()); + scanner.setOutputDir((String)outputDir.iterator().next()); + scanner.execute(); + } + + private static void printUsage() + { + System.out.println("Usage: java org.eclipse.wtp.releng.tools.component.api.progress.APIProgressScanner -compIndex <compIndex> -eclipseDir <eclipseDir> -compXMLDir <compXMLDir> -outputDir <outputDir>"); + System.out.println(""); + System.out.println("\t-outputDir\t<outputDir>\toutput directory of component.xml files"); + System.out.println(""); + System.out.println("where options include:"); + System.out.println(""); + System.out.println("\t-api\t\t<api>\t\tlocation of your component.xml"); + System.out.println("\t-src\t\t<src>\t\tlocation of a Eclipse-based product"); + System.out.println("\t-timestamp\t<timestamp>\ttimestamp"); + System.out.println("\t-progressDir\t<progressDir>\tdirectory containing API progress documents"); + } + + private class OverviewDocLoader extends Thread + { + private APIProgressEntry entry; + private boolean done; + + public OverviewDocLoader(APIProgressEntry entry) + { + this.entry = entry; + this.done = false; + } + + public void run() + { + try + { + String compName = entry.getCompName(); + String subproject = null; + String component = null; + if (compName.startsWith("org.eclipse.")) + { + compName = compName.substring(12); + int index = compName.indexOf('.'); + if (index != -1) + { + subproject = compName.substring(0, index); + component = compName.substring(index + 1); + } + } + if (subproject != null && component != null) + { + StringBuffer url = new StringBuffer("http://eclipse.org/webtools/"); + url.append(subproject); + url.append("/components/"); + url.append(component); + url.append("/overview.html"); + URL overviewDoc = new URL(url.toString()); + InputStream is = overviewDoc.openStream(); + is.close(); + entry.setOverviewDoc(url.toString()); + } + } + catch (Throwable t) + { + } + finally + { + done = true; + } + } + + public void waitFor() + { + long start = Calendar.getInstance().getTimeInMillis(); + while (!done && (Calendar.getInstance().getTimeInMillis() - start) < 60000) + Thread.yield(); + } + } +} \ 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/NonAPIDependencyScanner.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/NonAPIDependencyScanner.java index ec3e2365e65b1433ad4678bbf34dfa30f9c55beb..c0f2bbb961c527d56be0a6c1a8e7fe94e742043c 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/NonAPIDependencyScanner.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/violation/NonAPIDependencyScanner.java @@ -257,15 +257,18 @@ public class NonAPIDependencyScanner implements ILocationVisitor classViolation.setName(classAPI.getName()); boolean isSuperClassAPI; String superClassName = classAPI.getSuperClass(); - if (isInterface(classAPI.getAccess())) - isSuperClassAPI = isAPI(superClassName, false, false, true, false); - else - isSuperClassAPI = isAPI(superClassName, false, true, false, false); - if (!isSuperClassAPI) + if (superClassName != null) { - SuperViolation superViolation = new SuperViolation(); - superViolation.setName(superClassName); - classViolation.addViolation(superViolation); + if (isInterface(classAPI.getAccess())) + 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();) { @@ -369,6 +372,9 @@ public class NonAPIDependencyScanner implements ILocationVisitor { pkgName = className.substring(0, dot); typeName = className.substring(dot + 1); + int brackets = typeName.indexOf("[]"); + if (brackets != -1) + typeName = typeName.substring(0, brackets); } if (pkgName != null && typeName != null) { diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/classes/PluginVisitor.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/classes/PluginVisitor.java new file mode 100644 index 0000000000000000000000000000000000000000..659063ad5d571b057438d07222917fdb78e9a362 --- /dev/null +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/classes/PluginVisitor.java @@ -0,0 +1,233 @@ +/********************************************************************** + * 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.classes; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.StringTokenizer; +import java.util.jar.Manifest; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import org.eclipse.wtp.releng.tools.component.IFileLocation; +import org.eclipse.wtp.releng.tools.component.ILocation; +import org.eclipse.wtp.releng.tools.component.ILocationChildrenIterator; +import org.eclipse.wtp.releng.tools.component.ILocationVisitor; +import org.eclipse.wtp.releng.tools.component.IZipLocation; +import org.eclipse.wtp.releng.tools.component.internal.Bundle; +import org.eclipse.wtp.releng.tools.component.internal.Location; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +public class PluginVisitor implements ILocationVisitor +{ + private List pluginIds; + + public PluginVisitor() + { + this.pluginIds = new ArrayList(); + } + + public Collection getPluginIds() + { + return new ArrayList(pluginIds); + } + + public boolean accept(ILocation location) + { + String locationName = location.getName(); + if (locationName.endsWith("plugin.xml")) + { + acceptPluginXML(location); + } + else if (locationName.endsWith("fragment.xml")) + { + acceptFragmentXML(location); + } + else if (locationName.endsWith("MANIFEST.MF")) + { + acceptManifest(location); + } + else if (Location.isArchive(locationName)) + { + return acceptSingleJar(location); + } + else if (locationName.endsWith(".classpath")) + { + acceptDotClasspath(location); + } + if (location instanceof IZipLocation) + return true; + else if ((location instanceof IFileLocation) && ((IFileLocation)location).getFile().isDirectory()) + return true; + else + return false; + } + + private void acceptPluginXML(ILocation location) + { + try + { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + Document doc = builder.parse(location.getInputStream()); + Element root = doc.getDocumentElement(); + if (root.getTagName().equals("plugin")) + { + String id = root.getAttribute("id"); + if (id != null && id.length() > 0 && !pluginIds.contains(id)) + pluginIds.add(id); + } + } + catch (Throwable e) + { + } + } + + private void acceptFragmentXML(ILocation location) + { + try + { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + Document doc = builder.parse(location.getInputStream()); + Element root = doc.getDocumentElement(); + if (root.getTagName().equals("fragment")) + { + String id = root.getAttribute("id"); + if (id != null && id.length() > 0 && !pluginIds.contains(id)) + pluginIds.add(id); + } + } + catch (Throwable e) + { + } + } + + private void acceptManifest(ILocation location) + { + try + { + Manifest manifest = new Manifest(location.getInputStream()); + java.util.jar.Attributes attrs = manifest.getMainAttributes(); + String bundleNameAttr = attrs.getValue(new java.util.jar.Attributes.Name(Bundle.CONST_BUNDLE_NAME)); + if (bundleNameAttr != null) + { + String bundleName = (new StringTokenizer(bundleNameAttr, ";")).nextToken().trim(); + if (bundleName != null && bundleName.length() > 0 && !pluginIds.contains(bundleName)) + pluginIds.add(bundleName); + } + } + catch (IOException e) + { + } + } + + private boolean acceptSingleJar(ILocation location) + { + ILocationChildrenIterator it = location.childIterator(); + for (ILocation child = it.next(); child != null; child = it.next()) + { + String name = child.getName(); + if (name.equalsIgnoreCase("META-INF/MANIFEST.MF")) + { + try + { + Manifest manifest = new Manifest(child.getInputStream()); + java.util.jar.Attributes attrs = manifest.getMainAttributes(); + String bundleNameAttr = attrs.getValue(new java.util.jar.Attributes.Name(Bundle.CONST_BUNDLE_NAME)); + if (bundleNameAttr != null) + { + String bundleName = (new StringTokenizer(bundleNameAttr, ";")).nextToken().trim(); + if (bundleName != null && bundleName.length() > 0 && !pluginIds.contains(bundleName)) + pluginIds.add(bundleName); + } + } + catch (IOException e) + { + } + } + else if (name.endsWith("plugin.xml")) + { + try + { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + Document doc = builder.parse(location.getInputStream()); + Element root = doc.getDocumentElement(); + if (root.getTagName().equals("plugin")) + { + String id = root.getAttribute("id"); + if (id != null && id.length() > 0 && !pluginIds.contains(id)) + pluginIds.add(id); + } + } + catch (Throwable e) + { + } + } + else if (name.endsWith("fragment.xml")) + { + try + { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + Document doc = builder.parse(location.getInputStream()); + Element root = doc.getDocumentElement(); + if (root.getTagName().equals("fragment")) + { + String id = root.getAttribute("id"); + if (id != null && id.length() > 0 && !pluginIds.contains(id)) + pluginIds.add(id); + } + } + catch (Throwable e) + { + } + } + } + return true; + } + + private void acceptDotClasspath(ILocation location) + { + try + { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + Document doc = builder.parse(location.getInputStream()); + Element root = doc.getDocumentElement(); + if (root.getTagName().equals("classpath")) + { + NodeList cpEntries = root.getElementsByTagName("classpathentry"); + for (int i = 0; i < cpEntries.getLength(); i++) + { + Element cpEntry = (Element)cpEntries.item(i); + String kind = cpEntry.getAttribute("kind"); + if (kind != null && kind.equals("output")) + { + String absPath = location.getAbsolutePath().replace('\\', '/'); + int j = absPath.lastIndexOf('/'); + String s = absPath.substring(0, j); + String id = s.substring(s.lastIndexOf('/') + 1, j); + if (id != null && id.length() > 0 && !pluginIds.contains(id)) + pluginIds.add(id); + } + } + } + } + catch (Throwable e) + { + } + } +} \ 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/java/JavadocVisitor.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/java/JavadocVisitor.java index 4c7407f18b623e6a6dd177975505edebe2b40eb5..b53e5ed06fa506b69449a8f53b70fca9047a050c 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/java/JavadocVisitor.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/java/JavadocVisitor.java @@ -15,7 +15,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import org.eclipse.jdt.core.Signature; +import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.ASTVisitor; import org.eclipse.jdt.core.dom.FieldDeclaration; import org.eclipse.jdt.core.dom.ImportDeclaration; @@ -29,6 +29,7 @@ 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.Type; import org.eclipse.jdt.core.dom.TypeDeclaration; import org.eclipse.jdt.core.dom.VariableDeclarationFragment; import org.eclipse.wtp.releng.tools.component.api.ClassAPI; @@ -43,7 +44,7 @@ public class JavadocVisitor extends ASTVisitor private ComponentAPI compAPI; private String packageName; private Map imports; - private ClassAPI classAPI; + private List classAPIs; public JavadocVisitor(ComponentAPI compAPI) { @@ -51,7 +52,7 @@ public class JavadocVisitor extends ASTVisitor this.compAPI = compAPI; this.packageName = null; this.imports = new HashMap(); - this.classAPI = null; + this.classAPIs = new ArrayList(); } public boolean visit(PackageDeclaration node) @@ -71,79 +72,105 @@ public class JavadocVisitor extends ASTVisitor public boolean visit(TypeDeclaration node) { - boolean isPrivate = Modifier.isPrivate(node.getModifiers()); - if (!isPrivate && isAPI(node)) + int modifiers = node.getModifiers(); + if (!Modifier.isPrivate(modifiers)) { PackageAPI pkgAPI = compAPI.getPackageAPI(packageName); - if (pkgAPI == null) + if (pkgAPI != null) { - pkgAPI = new PackageAPI(); - pkgAPI.setName(packageName); - compAPI.addPackageAPI(pkgAPI); - } - String className = node.getName().getFullyQualifiedName(); - classAPI = pkgAPI.getClassAPI(className); - if (classAPI == null) - { - classAPI = new ClassAPI(); - classAPI.setName(className); - classAPI.setAccess(node.getModifiers()); - pkgAPI.addClassAPI(classAPI); - } - Javadoc javadoc = node.getJavadoc(); - if (javadoc != null) - { - for (Iterator it = javadoc.tags().iterator(); it.hasNext();) + String className = getClassName(node.getName().getFullyQualifiedName()); + ClassAPI classAPI = pkgAPI.getClassAPI(className); + if (classAPI != null) { - TagElement tag = (TagElement)it.next(); - String tagName = tag.getTagName(); - if (tagName != null && tagName.equals(TagElement.TAG_SINCE)) + classAPIs.add(classAPI); + Javadoc javadoc = node.getJavadoc(); + if (javadoc != null) { - // do nothing because default is true - return true; + for (Iterator it = javadoc.tags().iterator(); it.hasNext();) + { + TagElement tag = (TagElement)it.next(); + String tagName = tag.getTagName(); + if (tagName != null && tagName.equals(TagElement.TAG_SINCE)) + { + // do nothing because default is true + return true; + } + } } + classAPI.getJavadocCoverage().setHasSince(Boolean.FALSE); } } - classAPI.getJavadocCoverage().setHasSince(Boolean.FALSE); return true; } - return false; + else + { + return false; + } } - private boolean isAPI(TypeDeclaration node) + public void endVisit(TypeDeclaration node) { - return true; + int modifiers = node.getModifiers(); + if (!Modifier.isPrivate(modifiers)) + { + PackageAPI pkgAPI = compAPI.getPackageAPI(packageName); + if (pkgAPI != null) + { + String className = getClassName(node.getName().getFullyQualifiedName()); + ClassAPI classAPI = pkgAPI.getClassAPI(className); + if (classAPI != null) + { + classAPIs.remove(classAPIs.size() - 1); + } + } + } + } + + private String getClassName(String name) + { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < classAPIs.size(); i++) + { + sb.append(((ClassAPI)classAPIs.get(i)).getName()); + sb.append('$'); + } + sb.append(name); + return sb.toString(); } public boolean visit(MethodDeclaration node) { + if (node.getParent().getNodeType() == ASTNode.ANONYMOUS_CLASS_DECLARATION) + return false; + ClassAPI classAPI = (ClassAPI)classAPIs.get(classAPIs.size() - 1); if (classAPI != null && !Modifier.isPrivate(node.getModifiers())) { String methodName = node.isConstructor() ? "<init>" : node.getName().getFullyQualifiedName(); - StringBuffer descriptor = new StringBuffer(); - // input params - descriptor.append(Signature.C_PARAM_START); - List params = new ArrayList(); - for (Iterator it = node.parameters().iterator(); it.hasNext();) + // input parameters + List parameters = node.parameters(); + List params = new ArrayList(parameters.size()); + List inputs = new ArrayList(parameters.size()); + for (Iterator it = parameters.iterator(); it.hasNext();) { - SingleVariableDeclaration param = (SingleVariableDeclaration)it.next(); - params.add(param.getName().getIdentifier()); - descriptor.append(getDescriptor(param.getType())); + SingleVariableDeclaration parameter = (SingleVariableDeclaration)it.next(); + params.add(parameter.getName().getIdentifier()); + inputs.add(getTypeString(parameter)); } - descriptor.append(Signature.C_PARAM_END); // return type - boolean hasReturn = node.isConstructor(); - org.eclipse.jdt.core.dom.Type returnType = node.getReturnType2(); + boolean isConstructor = node.isConstructor(); + boolean hasReturn = isConstructor; + Type returnType = node.getReturnType2(); + String returnTypeString = !isConstructor ? returnType.toString() : PrimitiveType.VOID.toString(); if (!hasReturn && returnType instanceof PrimitiveType) if (((PrimitiveType)returnType).getPrimitiveTypeCode() == PrimitiveType.VOID) hasReturn = true; - descriptor.append(getDescriptor(returnType)); // exceptions - List thrownExceptions = new ArrayList(); - for (Iterator it = node.thrownExceptions().iterator(); it.hasNext();) + List exs = node.thrownExceptions(); + List thrownExceptions = new ArrayList(exs.size()); + for (Iterator it = exs.iterator(); it.hasNext();) { Name name = (Name)it.next(); thrownExceptions.add(name.getFullyQualifiedName()); @@ -206,6 +233,7 @@ public class JavadocVisitor extends ASTVisitor } } } + /* String methodDescriptor = descriptor.toString(); MethodAPI methodAPI = classAPI.getMethodAPI(methodName, methodDescriptor); if (methodAPI == null) @@ -216,7 +244,9 @@ public class JavadocVisitor extends ASTVisitor methodAPI.setDescriptor(methodDescriptor); classAPI.addMethodAPI(methodAPI); } - if (!hasJavadoc || !hasReturn || params.size() > 0 || thrownExceptions.size() > 0) + */ + MethodAPI methodAPI = classAPI.getMethodAPI(methodName, inputs, returnTypeString); + if (methodAPI != null && (!hasJavadoc || !hasReturn || params.size() > 0 || thrownExceptions.size() > 0)) { JavadocCoverage javadocCoverage = methodAPI.getJavadocCoverage(); if (!hasJavadoc) @@ -246,111 +276,25 @@ public class JavadocVisitor extends ASTVisitor return true; } - private String getDescriptor(org.eclipse.jdt.core.dom.Type type) + private String getTypeString(SingleVariableDeclaration svd) { - if (type != null) - { - String descriptor; - if (type.isPrimitiveType()) - { - descriptor = Signature.createTypeSignature(type.toString(), true); - } - else if (type.isArrayType()) - { - String s = type.toString(); - int i = s.lastIndexOf('['); - StringBuffer sb = new StringBuffer(); - if (i != -1) - { - String s2 = s.substring(0, i); - if (isPrimitiveType(s2)) - { - sb.append(s); - } - else - { - sb.append(resolveFromImports(s2)); - sb.append(s.substring(i)); - } - } - else - { - sb.append(s); - } - descriptor = Signature.createTypeSignature(sb.toString(), true); - } - else - { - descriptor = Signature.createTypeSignature(resolveFromImports(type.toString()), true); - } - return descriptor.replace('.', '/'); - } - else - { - StringBuffer sb = new StringBuffer(); - sb.append(Signature.C_VOID); - return sb.toString(); - } - } - - private boolean isPrimitiveType(String type) - { - return type.equals("byte") || - type.equals("short") || - type.equals("char") || - type.equals("int") || - type.equals("long") || - type.equals("float") || - type.equals("double") || - type.equals("boolean"); - } - - private String resolveFromImports(String name) - { - String resolvedName = (String)imports.get(name); - if (resolvedName != null) - { - return resolvedName; - } - else - { - StringBuffer sb = new StringBuffer(); - sb.append("java.lang."); - sb.append(name); - try - { - Class.forName(sb.toString()); - imports.put(name, sb.toString()); - return sb.toString(); - } - catch (ClassNotFoundException e) - { - } - sb = new StringBuffer(); - sb.append(packageName); - sb.append('.'); - sb.append(name); - imports.put(name, sb.toString()); - return sb.toString(); - } + int dim = svd.getExtraDimensions(); + StringBuffer sb = new StringBuffer(); + sb.append(svd.getType().toString()); + for (int i = 0; i < dim; i++) + sb.append("[]"); + return sb.toString(); } public boolean visit(FieldDeclaration node) { + ClassAPI classAPI = (ClassAPI)classAPIs.get(classAPIs.size() - 1); if (classAPI != null && !Modifier.isPrivate(node.getModifiers())) { VariableDeclarationFragment varDeclFragment = (VariableDeclarationFragment)node.fragments().iterator().next(); String fieldName = varDeclFragment.getName().getFullyQualifiedName(); FieldAPI fieldAPI = classAPI.getFieldAPI(fieldName); - if (fieldAPI == null) - { - fieldAPI = new FieldAPI(); - fieldAPI.setName(fieldName); - fieldAPI.setAccess(node.getModifiers()); - fieldAPI.setDescriptor(getDescriptor(node.getType())); - classAPI.addFieldAPI(fieldAPI); - } - if (node.getJavadoc() == null) + if (fieldAPI != null && node.getJavadoc() == null) { fieldAPI.setJavadocCoverage(new JavadocCoverage()); } diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/tptp/CodeCoverageScanner.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/tptp/CodeCoverageScanner.java index 95f5f5af78d1be97f0500a296b721d7e04e1e32a..15bad774d44a95f571a801258b3c10e389d2a690 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/tptp/CodeCoverageScanner.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/tptp/CodeCoverageScanner.java @@ -195,9 +195,9 @@ public class CodeCoverageScanner implements ILocationVisitor summary.append(location.getAbsolutePath().substring(outputDir.length())); summary.append("\"/>"); } - catch (Throwable e) + catch (Throwable t) { - e.printStackTrace(); + t.printStackTrace(); } } return true; @@ -266,11 +266,14 @@ public class CodeCoverageScanner implements ILocationVisitor for (Iterator it3 = classAPI.getMethodAPIs().iterator(); it3.hasNext();) { MethodAPI methodAPI = (MethodAPI)it3.next(); - String methodName = methodAPI.getName().replace('<', '-').replace('>', '-'); + String methodName = methodAPI.getName().replace('>', '-'); + if (methodName.startsWith("<")) + methodName = "-" + methodName.substring(4); String signature = methodAPI.getDescriptor(); String classMethodName = getClassMethodName(qualifiedClassName.toString(), methodName, signature); String countString = (String)classMethodName2Count.get(classMethodName); - if (countString != null && Integer.parseInt(countString) > 0) + // TODO + if (countString != null) { TestCoverage tc = methodAPI.getTestCoverage(); tc.addTest(testcaseName); @@ -283,7 +286,8 @@ public class CodeCoverageScanner implements ILocationVisitor { classMethodName = getClassMethodName((String)it4.next(), methodName, signature); countString = (String)classMethodName2Count.get(classMethodName); - if (countString != null && Integer.parseInt(countString) > 0) + // TODO + if (countString != null) { TestCoverage tc = methodAPI.getTestCoverage(); tc.addTest(testcaseName); diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/api-progress-summary.xsl b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/api-progress-summary.xsl new file mode 100644 index 0000000000000000000000000000000000000000..8fab3ef5f3498682ac20ceb0ff3fe4172ccd5bb2 --- /dev/null +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/api-progress-summary.xsl @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<xsl:stylesheet version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + + <xsl:output method="xml" encoding="ISO-8859-1" indent="yes" /> + + <xsl:template match="/"> + <api-info-summary> + <xsl:for-each select="root/api-info"> + <xsl:sort select="@file"/> + <xsl:variable name="report" select="document(@file)"/> + <xsl:apply-templates select="$report/component-api"/> + </xsl:for-each> + <xsl:call-template name="total"> + <xsl:with-param name="root" select="root"/> + <xsl:with-param name="total-class-count" select="0"/> + <xsl:with-param name="total-method-count" select="0"/> + <xsl:with-param name="total-field-count" select="0"/> + <xsl:with-param name="total-method-tested" select="0"/> + <xsl:with-param name="total-class-javadoced" select="0"/> + <xsl:with-param name="total-method-javadoced" select="0"/> + <xsl:with-param name="total-field-javadoced" select="0"/> + <xsl:with-param name="i" select="1"/> + </xsl:call-template> + </api-info-summary> + </xsl:template> + + <xsl:template match="component-api"> + <xsl:variable name="class-count" select="count(package-api/class-api)"/> + <xsl:variable name="method-count" select="count(package-api/class-api/method-api)"/> + <xsl:variable name="field-count" select="count(package-api/class-api/field-api)"/> + <api-info + name="{@name}" + class-count="{$class-count}" + method-count="{$method-count}" + field-count="{$field-count}" + method-tested="{count(package-api/class-api/method-api/test-coverage)}" + class-javadoced="{$class-count - count(package-api/class-api/javadoc-coverage)}" + method-javadoced="{$method-count - count(package-api/class-api/method-api/javadoc-coverage)}" + field-javadoced="{$field-count - count(package-api/class-api/field-api/javadoc-coverage)}"/> + </xsl:template> + + <xsl:template name="total"> + <xsl:param name="root"/> + <xsl:param name="total-class-count"/> + <xsl:param name="total-method-count"/> + <xsl:param name="total-field-count"/> + <xsl:param name="total-method-tested"/> + <xsl:param name="total-class-javadoced"/> + <xsl:param name="total-method-javadoced"/> + <xsl:param name="total-field-javadoced"/> + <xsl:param name="i"/> + <xsl:if test="$root/api-info[$i]"> + <xsl:variable name="report" select="document($root/api-info[$i]/@file)"/> + <xsl:variable name="class-count" select="count($report/component-api/package-api/class-api)"/> + <xsl:variable name="method-count" select="count($report/component-api/package-api/class-api/method-api)"/> + <xsl:variable name="field-count" select="count($report/component-api/package-api/class-api/field-api)"/> + <xsl:variable name="method-tested" select="count($report/component-api/package-api/class-api/method-api/test-coverage)"/> + <xsl:variable name="class-javadoced" select="$class-count - count($report/component-api/package-api/class-api/javadoc-coverage)"/> + <xsl:variable name="method-javadoced" select="$method-count - count($report/component-api/package-api/class-api/method-api/javadoc-coverage)"/> + <xsl:variable name="field-javadoced" select="$field-count - count($report/component-api/package-api/class-api/field-api/javadoc-coverage)"/> + <xsl:choose> + <xsl:when test="$root/api-info[$i + 1]"> + <xsl:call-template name="total"> + <xsl:with-param name="root" select="$root"/> + <xsl:with-param name="total-class-count" select="$total-class-count + $class-count"/> + <xsl:with-param name="total-method-count" select="$total-method-count + $method-count"/> + <xsl:with-param name="total-field-count" select="$total-field-count + $field-count"/> + <xsl:with-param name="total-method-tested" select="$total-method-tested + $method-tested"/> + <xsl:with-param name="total-class-javadoced" select="$total-class-javadoced + $class-javadoced"/> + <xsl:with-param name="total-method-javadoced" select="$total-method-javadoced + $method-javadoced"/> + <xsl:with-param name="total-field-javadoced" select="$total-field-javadoced + $field-javadoced"/> + <xsl:with-param name="i" select="$i + 1"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <api-info + name="total" + class-count="{$total-class-count + $class-count}" + method-count="{$total-method-count + $method-count}" + field-count="{$total-field-count + $field-count}" + method-tested="{$total-method-tested + $method-tested}" + class-javadoced="{$total-class-javadoced + $class-javadoced}" + method-javadoced="{$total-method-javadoced + $method-javadoced}" + field-javadoced="{$total-field-javadoced + $field-javadoced}"/> + </xsl:otherwise> + </xsl:choose> + </xsl:if> + </xsl:template> + +</xsl:stylesheet> \ 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/xsl/api-progress-svg.xsl b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/api-progress-svg.xsl index 1a7239a266962ec7316283b51481f041958cb173..73923de6515a48cdfa504fb00d96a9cd335191d4 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/api-progress-svg.xsl +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/api-progress-svg.xsl @@ -7,11 +7,11 @@ extension-element-prefixes="func"> <xsl:template match="/"> - <xsl:apply-templates select="component"/> + <xsl:apply-templates select="root"/> </xsl:template> - <xsl:template match="component"> - <xsl:variable name="xcount" select="component:max(count(timestamp), 10)"/> + <xsl:template match="root"> + <xsl:variable name="xcount" select="component:max(count(summary), 10)"/> <xsl:variable name="ycount" select="10"/> <xsl:variable name="leftborder" select="150"/> <xsl:variable name="rightborder" select="50"/> @@ -51,7 +51,7 @@ <xsl:call-template name="printProgress"> <xsl:with-param name="root" select="."/> <xsl:with-param name="componentname" select="@name"/> - <xsl:with-param name="tscount" select="count(timestamp)"/> + <xsl:with-param name="tscount" select="count(summary)"/> <xsl:with-param name="currIndex" select="1"/> <xsl:with-param name="xorigin" select="$leftborder"/> <xsl:with-param name="yorigin" select="$svgheight - $bottomborder"/> @@ -73,16 +73,14 @@ <xsl:choose> <xsl:when test="$tscount > $currIndex"> <xsl:call-template name="printProgress2"> - <xsl:with-param name="curr-testcoverage" select="document($root/timestamp[$currIndex]/testcoverage/@ref)/component-api-tc-summary/component-api-tc[@name=$componentname or concat('org.eclipse.', @name)=$componentname]"/> - <xsl:with-param name="next-testcoverage" select="document($root/timestamp[$currIndex + 1]/testcoverage/@ref)/component-api-tc-summary/component-api-tc[@name=$componentname or concat('org.eclipse.', @name)=$componentname]"/> - <xsl:with-param name="curr-javadoccoverage" select="document($root/timestamp[$currIndex]/javadoccoverage/@ref)/component-api-javadoc-summary/component-api-javadoc[@name=$componentname or concat('org.eclipse.', @name)=$componentname]"/> - <xsl:with-param name="next-javadoccoverage" select="document($root/timestamp[$currIndex + 1]/javadoccoverage/@ref)/component-api-javadoc-summary/component-api-javadoc[@name=$componentname or concat('org.eclipse.', @name)=$componentname]"/> + <xsl:with-param name="curr-api-info" select="document(concat($root/summary[$currIndex]/@timestamp, '/api-info-summary.xml'))/api-info-summary/api-info[@name=$componentname or concat('org.eclipse.', @name)=$componentname]"/> + <xsl:with-param name="next-api-info" select="document(concat($root/summary[$currIndex + 1]/@timestamp, '/api-info-summary.xml'))/api-info-summary/api-info[@name=$componentname or concat('org.eclipse.', @name)=$componentname]"/> <xsl:with-param name="currIndex" select="$currIndex"/> <xsl:with-param name="xorigin" select="$xorigin"/> <xsl:with-param name="yorigin" select="$yorigin"/> <xsl:with-param name="gridwidth" select="$gridwidth"/> <xsl:with-param name="percentwidth" select="$percentwidth"/> - <xsl:with-param name="date" select="$root/timestamp[$currIndex]/@id"/> + <xsl:with-param name="date" select="$root/summary[$currIndex]/@timestamp"/> </xsl:call-template> <xsl:call-template name="printProgress"> <xsl:with-param name="root" select="$root"/> @@ -97,40 +95,36 @@ </xsl:when> <xsl:otherwise> <xsl:call-template name="printProgress2"> - <xsl:with-param name="curr-testcoverage" select="document($root/timestamp[$currIndex]/testcoverage/@ref)/component-api-tc-summary/component-api-tc[@name=$componentname or concat('org.eclipse.', @name)=$componentname]"/> - <xsl:with-param name="next-testcoverage" select="-1"/> - <xsl:with-param name="curr-javadoccoverage" select="document($root/timestamp[$currIndex]/javadoccoverage/@ref)/component-api-javadoc-summary/component-api-javadoc[@name=$componentname or concat('org.eclipse.', @name)=$componentname]"/> - <xsl:with-param name="next-javadoccoverage" select="-1"/> + <xsl:with-param name="curr-api-info" select="document(concat($root/summary[$currIndex]/@timestamp, '/api-info-summary.xml'))/api-info-summary/api-info[@name=$componentname or concat('org.eclipse.', @name)=$componentname]"/> + <xsl:with-param name="next-api-info" select="-1"/> <xsl:with-param name="currIndex" select="$currIndex"/> <xsl:with-param name="xorigin" select="$xorigin"/> <xsl:with-param name="yorigin" select="$yorigin"/> <xsl:with-param name="gridwidth" select="$gridwidth"/> <xsl:with-param name="percentwidth" select="$percentwidth"/> - <xsl:with-param name="date" select="$root/timestamp[$currIndex]/@id"/> + <xsl:with-param name="date" select="$root/summary[$currIndex]/@timestamp"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="printProgress2"> - <xsl:param name="curr-testcoverage"/> - <xsl:param name="next-testcoverage"/> - <xsl:param name="curr-javadoccoverage"/> - <xsl:param name="next-javadoccoverage"/> + <xsl:param name="curr-api-info"/> + <xsl:param name="next-api-info"/> <xsl:param name="currIndex"/> <xsl:param name="xorigin"/> <xsl:param name="yorigin"/> <xsl:param name="gridwidth"/> <xsl:param name="percentwidth"/> <xsl:param name="date"/> - <xsl:variable name="currapicount" select="$curr-testcoverage/@api-count"/> + <xsl:variable name="currapicount" select="$curr-api-info/@method-count"/> <xsl:variable name="currx" select="$xorigin + ($currIndex * $gridwidth)"/> <xsl:variable name="hundredpercent" select="$yorigin - (100 * $percentwidth)"/> <svg:text x="{$currx}" y="{$yorigin + 15 + (($currIndex + 1) mod 2 * 15)}" style="text-anchor:middle"><xsl:value-of select="$date"/></svg:text> <xsl:choose> <xsl:when test="$currapicount > 0"> - <xsl:variable name="currtestcount" select="$curr-testcoverage/@test-coverage-count"/> - <xsl:variable name="currjavadoccount" select="$curr-javadoccoverage/@method-javadoc-count"/> + <xsl:variable name="currtestcount" select="$curr-api-info/@method-tested"/> + <xsl:variable name="currjavadoccount" select="$curr-api-info/@method-javadoced"/> <xsl:variable name="currtestpercent" select="$currtestcount div $currapicount * 100"/> <xsl:variable name="currjavadocpercent" select="$currjavadoccount div $currapicount * 100"/> <xsl:variable name="currtesty" select="$yorigin - round($currtestpercent * $percentwidth)"/> @@ -145,8 +139,7 @@ <svg:text x="{$currx}" y="{$currjavadocy - 10}" style="text-anchor:middle">(<xsl:value-of select="round($currjavadocpercent)"/>%)</svg:text> <xsl:call-template name="printProgress3"> - <xsl:with-param name="next-testcoverage" select="$next-testcoverage"/> - <xsl:with-param name="next-javadoccoverage" select="$next-javadoccoverage"/> + <xsl:with-param name="next-api-info" select="$next-api-info"/> <xsl:with-param name="currIndex" select="$currIndex"/> <xsl:with-param name="xorigin" select="$xorigin"/> <xsl:with-param name="yorigin" select="$yorigin"/> @@ -163,8 +156,7 @@ <svg:circle cx="{$currx}" cy="{$hundredpercent}" r="3" fill="orange"/> <svg:text x="{$currx}" y="{$hundredpercent - 8}" style="text-anchor:middle">No API</svg:text> <xsl:call-template name="printProgress3"> - <xsl:with-param name="next-testcoverage" select="$next-testcoverage"/> - <xsl:with-param name="next-javadoccoverage" select="$next-javadoccoverage"/> + <xsl:with-param name="next-api-info" select="$next-api-info"/> <xsl:with-param name="currIndex" select="$currIndex"/> <xsl:with-param name="xorigin" select="$xorigin"/> <xsl:with-param name="yorigin" select="$yorigin"/> @@ -180,8 +172,7 @@ </xsl:template> <xsl:template name="printProgress3"> - <xsl:param name="next-testcoverage"/> - <xsl:param name="next-javadoccoverage"/> + <xsl:param name="next-api-info"/> <xsl:param name="currIndex"/> <xsl:param name="xorigin"/> <xsl:param name="yorigin"/> @@ -191,12 +182,12 @@ <xsl:param name="currtesty"/> <xsl:param name="currjavadocy"/> <xsl:param name="hundredpercent"/> - <xsl:if test="$next-testcoverage != -1"> - <xsl:variable name="nextapicount" select="$next-testcoverage/@api-count"/> + <xsl:if test="$next-api-info != -1"> + <xsl:variable name="nextapicount" select="$next-api-info/@method-count"/> <xsl:variable name="nextx" select="$xorigin + (($currIndex + 1) * $gridwidth)"/> <xsl:choose> <xsl:when test="$nextapicount > 0"> - <xsl:variable name="nexttestcount" select="$next-testcoverage/@test-coverage-count"/> + <xsl:variable name="nexttestcount" select="$next-api-info/@method-tested"/> <xsl:variable name="nexttestpercent" select="$nexttestcount div $nextapicount * 100"/> <xsl:variable name="nexttesty" select="$yorigin - round($nexttestpercent * $percentwidth)"/> <svg:line x1="{$currx}" y1="{$currtesty}" x2="{$nextx}" y2="{$nexttesty}" style="stroke:blue;stroke-width:1"/> @@ -206,12 +197,12 @@ </xsl:otherwise> </xsl:choose> </xsl:if> - <xsl:if test="$next-javadoccoverage != -1"> - <xsl:variable name="nextapicount" select="$next-javadoccoverage/@method-api-count"/> + <xsl:if test="$next-api-info != -1"> + <xsl:variable name="nextapicount" select="$next-api-info/@method-count"/> <xsl:variable name="nextx" select="$xorigin + (($currIndex + 1) * $gridwidth)"/> <xsl:choose> <xsl:when test="$nextapicount > 0"> - <xsl:variable name="nextjavadoccount" select="$next-javadoccoverage/@method-javadoc-count"/> + <xsl:variable name="nextjavadoccount" select="$next-api-info/@method-javadoced"/> <xsl:variable name="nextjavadocpercent" select="$nextjavadoccount div $nextapicount * 100"/> <xsl:variable name="nextjavadocy" select="$yorigin - round($nextjavadocpercent * $percentwidth)"/> <svg:line x1="{$currx}" y1="{$currjavadocy}" x2="{$nextx}" y2="{$nextjavadocy}" style="stroke:orange;stroke-width:1"/> @@ -282,4 +273,4 @@ <text x="{$leftborder - 20}" y="{$svgheight - $bottomborder - ($y * $gridheight)}"><xsl:value-of select="$y * $ycount"/></text> </xsl:template> -</xsl:stylesheet> \ No newline at end of file +</xsl:stylesheet> diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/api-progress.xsl b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/api-progress.xsl index 712b22bda6f1d706dcb8a119cb82b08399272729..47d218006fd2ff63fcfd2380c103973d3f6da625 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/api-progress.xsl +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/api-progress.xsl @@ -185,15 +185,15 @@ <th width="80">Score (/100)</th> </tr> <xsl:call-template name="printTotal"> - <xsl:with-param name="summary" select="component-summary"/> + <xsl:with-param name="root" select="root"/> <xsl:with-param name="apicount" select="0"/> <xsl:with-param name="testcount" select="0"/> <xsl:with-param name="javadoccount" select="0"/> <xsl:with-param name="i" select="1"/> </xsl:call-template> - <xsl:for-each select="component-summary/component"> - <xsl:sort select="@name"/> - <xsl:variable name="report" select="document(@ref)"/> + <xsl:for-each select="root/api-info"> + <xsl:sort select="@file"/> + <xsl:variable name="report" select="document(@file)"/> <xsl:apply-templates select="$report/component-api"> <xsl:with-param name="overviewDoc" select="@overviewDoc"/> </xsl:apply-templates> @@ -208,8 +208,8 @@ <font face="Arial,Helvetica"> <table> <xsl:choose> - <xsl:when test="component-summary/plugin-without-comp"> - <xsl:for-each select="component-summary/plugin-without-comp"> + <xsl:when test="root/plugin-without-comp"> + <xsl:for-each select="root/plugin-without-comp"> <xsl:sort select="@id"/> <tr> <td><xsl:value-of select="@id"/></td> @@ -232,8 +232,8 @@ <font face="Arial,Helvetica"> <table> <xsl:choose> - <xsl:when test="component-summary/missing-plugin"> - <xsl:for-each select="component-summary/missing-plugin"> + <xsl:when test="root/missing-plugin"> + <xsl:for-each select="root/missing-plugin"> <xsl:sort select="@id"/> <tr> <td><xsl:value-of select="@id"/></td> @@ -256,8 +256,8 @@ <font face="Arial,Helvetica"> <table> <xsl:choose> - <xsl:when test="component-summary/dup-plugin"> - <xsl:for-each select="component-summary/dup-plugin"> + <xsl:when test="root/dup-plugin"> + <xsl:for-each select="root/dup-plugin"> <xsl:sort select="@id"/> <tr> <td><xsl:value-of select="@id"/></td> @@ -491,21 +491,21 @@ </xsl:template> <xsl:template name="printTotal"> - <xsl:param name="summary"/> + <xsl:param name="root"/> <xsl:param name="apicount"/> <xsl:param name="testcount"/> <xsl:param name="javadoccount"/> <xsl:param name="i"/> - <xsl:if test="$summary/component[$i]"> - <xsl:variable name="report" select="document($summary/component[$i]/@ref)"/> + <xsl:if test="$root/api-info[$i]"> + <xsl:variable name="report" select="document($root/api-info[$i]/@file)"/> <xsl:variable name="compapicount" select="count($report/component-api/package-api/class-api/method-api)"/> <xsl:variable name="totalapicount" select="$apicount + $compapicount"/> <xsl:variable name="totaltestcount" select="$testcount + count($report/component-api/package-api/class-api/method-api/test-coverage)"/> <xsl:variable name="totaljavadoccount" select="$javadoccount + ($compapicount - count($report/component-api/package-api/class-api/method-api/javadoc-coverage))"/> <xsl:choose> - <xsl:when test="$summary/component[$i + 1]"> + <xsl:when test="$root/api-info[$i + 1]"> <xsl:call-template name="printTotal"> - <xsl:with-param name="summary" select="$summary"/> + <xsl:with-param name="root" select="$root"/> <xsl:with-param name="apicount" select="$totalapicount"/> <xsl:with-param name="testcount" select="$totaltestcount"/> <xsl:with-param name="javadoccount" select="$totaljavadoccount"/>