diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/ComponentXMLVisitor.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/ComponentXMLVisitor.java index 0e843f0a8daa3a0395a267385e556af41e6726a7..d93490cdd491068f9ef4e11bf6faee54e92c15b2 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/ComponentXMLVisitor.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/ComponentXMLVisitor.java @@ -2,23 +2,24 @@ package org.eclipse.wtp.releng.tools.component.api; import java.util.ArrayList; import java.util.Collection; -import java.util.List; +import java.util.HashMap; +import java.util.Map; import org.eclipse.wtp.releng.tools.component.ILocation; import org.eclipse.wtp.releng.tools.component.ILocationVisitor; import org.eclipse.wtp.releng.tools.component.model.ComponentXML; public class ComponentXMLVisitor implements ILocationVisitor { - private List compXMLs; + private Map compXMLs; public ComponentXMLVisitor() { - this.compXMLs = new ArrayList(); + this.compXMLs = new HashMap(); } public Collection getCompXMLs() { - return new ArrayList(compXMLs); + return new ArrayList(compXMLs.values()); } public boolean accept(ILocation location) @@ -31,7 +32,9 @@ public class ComponentXMLVisitor implements ILocationVisitor ComponentXML compXML = new ComponentXML(); compXML.setLocation(location); compXML.load(); - compXMLs.add(compXML); + String name = compXML.getName(); + if (!compXMLs.containsKey(name)) + compXMLs.put(name, compXML); } catch (Throwable e) { diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/classes/LibVisitor.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/classes/LibVisitor.java index 87e6e398bca813400c829c50f4bb8565129513b4..262a481d1afd3a96586b33389ce4597c6a19a177 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/classes/LibVisitor.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/classes/LibVisitor.java @@ -18,6 +18,7 @@ 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; @@ -65,12 +66,32 @@ public class LibVisitor implements ILocationVisitor { acceptSingleJar(location); } + else if (locationName.endsWith(".classpath")) + { + acceptDotClasspath(location); + } } else if (classVisitor != null) { - String id = (String)lib2pluginId.get(locationName.replace('\\', '/')); + String idTemp = (String)lib2pluginId.get(locationName.replace('\\', '/')); + if (idTemp == null) + idTemp = (String)lib2pluginId.get(location.getAbsolutePath().replace('\\', '/')); + final String id = idTemp; if (id != null) { + location.accept + ( + new ILocationVisitor() + { + public boolean accept(ILocation location) + { + if (location.getName().endsWith(".class")) + classVisitor.visit(id, location); + return true; + } + } + ); + /* ILocationChildrenIterator it = location.childIterator(); for (ILocation child = it.next(); child != null; child = it.next()) { @@ -79,9 +100,15 @@ public class LibVisitor implements ILocationVisitor classVisitor.visit(id, child); } } + */ } } - return (location instanceof IZipLocation); + 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) @@ -271,4 +298,40 @@ public class LibVisitor implements ILocationVisitor } } } + + 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 path = cpEntry.getAttribute("path"); + String absPath = location.getAbsolutePath().replace('\\', '/'); + StringBuffer lib = new StringBuffer(); + int j = absPath.lastIndexOf('/'); + String s = absPath.substring(0, j); + String id = s.substring(s.lastIndexOf('/') + 1, j); + lib.append(s); + lib.append('/'); + lib.append(path); + lib2pluginId.put(lib.toString(), 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/images/ImagesUtil.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/images/ImagesUtil.java index e6a35ec4f345ff0049b8cad89d87db03833a1a56..bba1355e0a75889d0e3d4203733238127bc117c9 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/images/ImagesUtil.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/images/ImagesUtil.java @@ -16,6 +16,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import org.eclipse.core.runtime.Platform; import org.osgi.framework.Bundle; public class ImagesUtil @@ -82,8 +83,13 @@ public class ImagesUtil try { InputStream is = ClassLoader.getSystemResourceAsStream("org/eclipse/wtp/releng/tools/component/images/" + imageId); - BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file)); - copy(is, bos); + if (is != null) + { + BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file)); + copy(is, bos); + } + else + copyFromBundle(Platform.getBundle("org.eclipse.wtp.releng.tools.component.core"), imageId, dest); } catch (IOException e) { diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/internal/Location.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/internal/Location.java index 520dd9bfe1471a9c896ffd53c21e345dea3341b4..c28e77770f7df6da0170337ecc09f5113c8a573c 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/internal/Location.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/internal/Location.java @@ -102,7 +102,7 @@ public abstract class Location implements ILocation { return new ZipLocation(file); } - return null; + return new FileLocation(file); } /** diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/java/Java2API.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/java/Java2API.java index 593ffecc40b7cd0da627e6f7df1999087411728a..82eac2a77b71d062224b775cf956980b149c2b2f 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/java/Java2API.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/java/Java2API.java @@ -35,6 +35,7 @@ public class Java2API implements IJavaVisitor, IPlatformRunnable private String outputDir; private Collection includes; private Collection excludes; + private Collection excludePlugins; public String getOutputDir() { @@ -76,10 +77,21 @@ public class Java2API implements IJavaVisitor, IPlatformRunnable this.excludes = excludes; } + public Collection getExcludePlugins() + { + return excludePlugins; + } + + public void setExcludePlugins(Collection excludePlugins) + { + this.excludePlugins = excludePlugins; + } + public void execute() { ILocation srcLocation = Location.createLocation(new File(src)); PDESourceVisitor pdeSrcVisitor = new PDESourceVisitor(); + pdeSrcVisitor.setExcludes(excludePlugins); srcLocation.accept(pdeSrcVisitor); pdeSrcVisitor.setJavaVisitor(this); srcLocation.accept(pdeSrcVisitor); @@ -230,6 +242,7 @@ public class Java2API implements IJavaVisitor, IPlatformRunnable Collection outputDir = (Collection)options.get("outputDir"); Collection includes = (Collection)options.get("includes"); Collection excludes = (Collection)options.get("excludes"); + Collection excludePlugins = (Collection)options.get("excludePlugins"); if (src == null || outputDir == null || src.isEmpty() || outputDir.isEmpty()) { printUsage(); @@ -240,6 +253,7 @@ public class Java2API implements IJavaVisitor, IPlatformRunnable java2API.setOutputDir((String)outputDir.iterator().next()); java2API.setIncludes(includes); java2API.setExcludes(excludes); + java2API.setExcludePlugins(excludePlugins); java2API.execute(); } @@ -254,5 +268,6 @@ public class Java2API implements IJavaVisitor, IPlatformRunnable System.out.println(""); System.out.println("\t-includes\t<includes>\tspace seperated packages to include"); System.out.println("\t-excludes\t<excludes>\tspace seperated packages to exclude"); + System.out.println("\t-excludePlugins\t<excludePlugins>\tspace seperated plugins 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/java/JavadocScanner.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/java/JavadocScanner.java index f760d133315a80a481571fab89667d09866a45cc..b29ef3dc6f323444b07fd5235c32ac8bdb2fdec6 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/java/JavadocScanner.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/java/JavadocScanner.java @@ -41,7 +41,7 @@ import org.eclipse.wtp.releng.tools.component.xsl.XSLUtil; public class JavadocScanner implements IJavaVisitor, IPlatformRunnable { - private String src; + private Collection src; private String api; private String outputDir; private Collection includes; @@ -59,12 +59,12 @@ public class JavadocScanner implements IJavaVisitor, IPlatformRunnable this.outputDir = addTrailingSeperator(outputDir); } - public String getSrc() + public Collection getSrc() { return src; } - public void setSrc(String src) + public void setSrc(Collection src) { this.src = src; } @@ -137,11 +137,9 @@ public class JavadocScanner implements IJavaVisitor, IPlatformRunnable } // visit .java - ILocation srcLocation = Location.createLocation(new File(src)); - PDESourceVisitor pdeSrcVisitor = new PDESourceVisitor(); - srcLocation.accept(pdeSrcVisitor); - pdeSrcVisitor.setJavaVisitor(this); - srcLocation.accept(pdeSrcVisitor); + scanJavaSources(); + + // Save report try { if (cachedCompAPI != null) @@ -158,6 +156,18 @@ public class JavadocScanner implements IJavaVisitor, IPlatformRunnable } } + protected void scanJavaSources() + { + for (Iterator it = src.iterator(); it.hasNext();) + { + ILocation srcLocation = Location.createLocation(new File((String)it.next())); + PDESourceVisitor pdeSrcVisitor = new PDESourceVisitor(); + srcLocation.accept(pdeSrcVisitor); + pdeSrcVisitor.setJavaVisitor(this); + srcLocation.accept(pdeSrcVisitor); + } + } + private void genHTML() { final StringBuffer summary = new StringBuffer(); @@ -210,7 +220,7 @@ public class JavadocScanner implements IJavaVisitor, IPlatformRunnable } } - private ASTParser astParser; + protected ASTParser astParser; public boolean visit(String pluginId, ILocation java) { @@ -241,7 +251,7 @@ public class JavadocScanner implements IJavaVisitor, IPlatformRunnable return true; } - private boolean isAPI(String pluginId, String name) + protected boolean isAPI(String pluginId, String name) { ComponentXML compXML = (ComponentXML)pluginId2CompXML.get(pluginId); if (compXML != null) @@ -269,7 +279,7 @@ public class JavadocScanner implements IJavaVisitor, IPlatformRunnable return false; } - private boolean include(String name) + protected boolean include(String name) { name = name.replace('/', '.'); name = name.replace('\\', '.'); @@ -288,7 +298,7 @@ public class JavadocScanner implements IJavaVisitor, IPlatformRunnable } private ComponentAPI cachedCompAPI; - private ComponentAPI getComponentAPI(String id) throws IOException + protected ComponentAPI getComponentAPI(String id) throws IOException { if (cachedCompAPI != null) { @@ -357,7 +367,7 @@ public class JavadocScanner implements IJavaVisitor, IPlatformRunnable System.exit(-1); } JavadocScanner javadocScanner = new JavadocScanner(); - javadocScanner.setSrc((String)src.iterator().next()); + javadocScanner.setSrc(src); javadocScanner.setApi((String)api.iterator().next()); javadocScanner.setOutputDir((String)outputDir.iterator().next()); javadocScanner.setIncludes(includes); @@ -367,7 +377,7 @@ public class JavadocScanner implements IJavaVisitor, IPlatformRunnable javadocScanner.execute(); } - private static void printUsage() + protected static void printUsage() { System.out.println("Usage: java org.eclipse.wtp.releng.tools.component.java.JavadocScanner -src <src> -api <api> -outputDir <outputDir> [-options]"); System.out.println(""); diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/java/PDESourceVisitor.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/java/PDESourceVisitor.java index fd33a6d8ec84b22f8f523aeb4cf476437f3867a1..0334cb1de6217258a4c8f6d52bc08ef9052c0785 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/java/PDESourceVisitor.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/java/PDESourceVisitor.java @@ -1,10 +1,12 @@ package org.eclipse.wtp.releng.tools.component.java; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.List; 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; @@ -17,6 +19,7 @@ public class PDESourceVisitor implements ILocationVisitor { private IJavaVisitor javaVisitor; private List srcs; + private Collection excludes; public PDESourceVisitor() { @@ -29,9 +32,15 @@ public class PDESourceVisitor implements ILocationVisitor this.javaVisitor = javaVisitor; } + public void setExcludes(Collection excludes) + { + this.excludes = excludes; + } + public boolean accept(ILocation location) { String locationName = location.getName(); + String absPath = location.getAbsolutePath(); if (javaVisitor == null && (locationName.endsWith("plugin.xml") || locationName.endsWith("fragment.xml"))) { try @@ -55,9 +64,11 @@ public class PDESourceVisitor implements ILocationVisitor { StringBuffer sb = new StringBuffer(); if (locationName.endsWith("plugin.xml")) - sb.append(locationName.substring(0, locationName.length() - "plugin.xml".length() - 1)); + //sb.append(locationName.substring(0, locationName.length() - "plugin.xml".length() - 1)); + sb.append(absPath.substring(0, absPath.length() - "plugin.xml".length() - 1)); else - sb.append(locationName.substring(0, locationName.length() - "fragment.xml".length() - 1)); + //sb.append(locationName.substring(0, locationName.length() - "fragment.xml".length() - 1)); + sb.append(absPath.substring(0, absPath.length() - "fragment.xml".length() - 1)); sb.append("/"); sb.append(path); srcs.add(sb.toString()); @@ -72,8 +83,9 @@ public class PDESourceVisitor implements ILocationVisitor } else if (javaVisitor != null && locationName.endsWith("src.zip")) { - String pluginId = getPluginId(locationName); - if (pluginId != null) + //String pluginId = getPluginId(locationName); + String pluginId = getPluginId(absPath); + if (pluginId != null && (excludes == null || !excludes.contains(pluginId))) { ILocationChildrenIterator it = location.childIterator(); for (ILocation child = it.next(); child != null; child = it.next()) @@ -85,7 +97,12 @@ public class PDESourceVisitor implements ILocationVisitor } } } - return (location instanceof IZipLocation); + if (location instanceof IZipLocation) + return true; + else if ((location instanceof IFileLocation) && ((IFileLocation)location).getFile().isDirectory()) + return true; + else + return false; } private String getPluginId(String name) diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/violation/APIViolationScanner.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/violation/APIViolationScanner.java index 80a68b4af2d13d67c18050c294ceddd01f2644cb..f27b5f363b52608a003e5cb3d33cb773f54317ad 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/violation/APIViolationScanner.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/violation/APIViolationScanner.java @@ -20,6 +20,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import org.eclipse.core.runtime.Platform; import org.eclipse.jdt.core.util.ClassFormatException; import org.eclipse.wtp.releng.tools.component.ILocation; import org.eclipse.wtp.releng.tools.component.ILocationVisitor; @@ -43,7 +44,7 @@ import org.eclipse.wtp.releng.tools.component.xsl.XSLUtil; public class APIViolationScanner implements IClassVisitor { - private String src; + private Collection src; private Collection api; private String outputDir; private Collection includes; @@ -63,12 +64,12 @@ public class APIViolationScanner implements IClassVisitor this.outputDir = addTrailingSeperator(outputDir); } - public String getSrc() + public Collection getSrc() { return src; } - public void setSrc(String src) + public void setSrc(Collection src) { this.src = src; } @@ -161,16 +162,20 @@ public class APIViolationScanner implements IClassVisitor } } } - // Visit all .class files - ILocation srcLocation = Location.createLocation(new File(src)); - LibVisitor libVisitor = new LibVisitor(); - srcLocation.accept(libVisitor); - libVisitor.setClassVisitor(this); - // 1st visit is to recreate the plugin to packages map - srcLocation.accept(libVisitor); - visit1 = false; - // 2nd visit is to scan .class for API violations - srcLocation.accept(libVisitor); + for (Iterator it = src.iterator(); it.hasNext();) + { + // Visit all .class files + visit1 = true; + ILocation srcLocation = Location.createLocation(new File((String)it.next())); + LibVisitor libVisitor = new LibVisitor(); + srcLocation.accept(libVisitor); + libVisitor.setClassVisitor(this); + // 1st visit is to recreate the plugin to packages map + srcLocation.accept(libVisitor); + visit1 = false; + // 2nd visit is to scan .class for API violations + srcLocation.accept(libVisitor); + } try { if (cachedCompUse != null) @@ -207,14 +212,26 @@ public class APIViolationScanner implements IClassVisitor location.getInputStream(), new FileOutputStream(((FileLocation)location.createSibling("api-violation.html")).getFile()) ); - summary.append("<violation file=\""); - summary.append(location.getAbsolutePath().substring(outputDir.length())); - summary.append("\"/>"); } catch (Throwable e) { - e.printStackTrace(); + try + { + XSLUtil.transform + ( + Platform.getBundle("org.eclipse.wtp.releng.tools.component.core").getResource("org/eclipse/wtp/releng/tools/component/xsl/api-violation.xsl").openStream(), + location.getInputStream(), + new FileOutputStream(((FileLocation)location.createSibling("api-violation.html")).getFile()) + ); + } + catch (Throwable e2) + { + e2.printStackTrace(); + } } + summary.append("<violation file=\""); + summary.append(location.getAbsolutePath().substring(outputDir.length())); + summary.append("\"/>"); } return true; } @@ -232,7 +249,20 @@ public class APIViolationScanner implements IClassVisitor } catch (Throwable e) { - e.printStackTrace(); + try + { + XSLUtil.transform + ( + Platform.getBundle("org.eclipse.wtp.releng.tools.component.core").getResource("org/eclipse/wtp/releng/tools/component/xsl/api-violation-summary.xsl").openStream(), + new ByteArrayInputStream(summary.toString().getBytes()), + new FileOutputStream(new File(outputDir + "/api-violation-summary.html")), + outputDir + ); + } + catch (Throwable e2) + { + e2.printStackTrace(); + } } } @@ -461,7 +491,7 @@ public class APIViolationScanner implements IClassVisitor System.exit(-1); } APIViolationScanner vioScanner = new APIViolationScanner(); - vioScanner.setSrc((String)src.iterator().next()); + vioScanner.setSrc(src); vioScanner.setApi(api); vioScanner.setOutputDir((String)outputDir.iterator().next()); vioScanner.setIncludes(includes); diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/XSLUtil.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/XSLUtil.java index 2c2f7c80077895aa65a583c48358fe12d0f59ac7..f42901122316c211d2527c9027a5f66b00aabb18 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/XSLUtil.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/XSLUtil.java @@ -36,5 +36,7 @@ public class XSLUtil TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(new StreamSource(xsl)); transformer.transform(new StreamSource(data), new StreamResult(os)); + os.close(); + xsl.close(); } } \ No newline at end of file diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/plugin.properties b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/plugin.properties index 194e4e4b03df4fb71ff43e076633db5f98e4417c..4651d9137d2b351e9b16b4fa1d219d9ae3a464e5 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/plugin.properties +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/plugin.properties @@ -1,3 +1,4 @@ -LABEL_POPUP_MENU_COMPONENT=Component -LABEL_POPUP_ACTION_API_SCAN_COMPONENT=Scan API +LABEL_POPUP_MENU_API=API +LABEL_POPUP_ACTION_API_VIOLATION=Scan for API Violation +LABEL_POPUP_ACTION_SCAN_4_MISSING_JAVADOC=Scan for Missing javadoc EDITOR_COMPONENT_XML=Component.xml Editor \ No newline at end of file diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/plugin.xml b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/plugin.xml index 6216a8f2a1891046981806fed39c975f33860c4f..05ca00c0aa951611685e83feccce25c7e19c660c 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/plugin.xml +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/plugin.xml @@ -25,8 +25,6 @@ <import plugin="org.eclipse.pde.ui"/> </requires> - <extension point="org.eclipse.ui.startup"/> - <extension point="org.eclipse.ui.editors"> <editor default="true" @@ -42,18 +40,23 @@ <objectContribution objectClass="org.eclipse.core.resources.IFile" nameFilter="component.xml" - id="org.eclipse.wtp.releng.tools.component.ui.internal.action.ScanAPI"> + id="org.eclipse.wtp.releng.tools.component.ui.internal.action.Scan"> <menu - label="%LABEL_POPUP_MENU_COMPONENT" + label="%LABEL_POPUP_MENU_API" path="additions" id="org.eclipse.wtp.releng.tools.component.ui.popupMenu"> <separator name="popupActions"/> </menu> <action - label="%LABEL_POPUP_ACTION_API_SCAN_COMPONENT" - class="org.eclipse.wtp.releng.tools.component.ui.internal.action.ScanAPI" + label="%LABEL_POPUP_ACTION_API_VIOLATION" + class="org.eclipse.wtp.releng.tools.component.ui.internal.action.Scan4APIViolation" + menubarPath="org.eclipse.wtp.releng.tools.component.ui.popupMenu/popupActions" + id="org.eclipse.wtp.releng.tools.component.ui.internal.action.Scan4APIViolation"/> + <action + label="%LABEL_POPUP_ACTION_SCAN_4_MISSING_JAVADOC" + class="org.eclipse.wtp.releng.tools.component.ui.internal.action.Scan4MissingJavadoc" menubarPath="org.eclipse.wtp.releng.tools.component.ui.popupMenu/popupActions" - id="org.eclipse.wtp.releng.tools.component.ui.internal.action.ScanAPI"/> + id="org.eclipse.wtp.releng.tools.component.ui.internal.action.Scan4MissingJavadoc"/> </objectContribution> </extension> diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/ComponentManager.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/ComponentManager.java index 181853be27a6c8551b6be98177478149965a7519..07d8a19bfa071f37f4607bfa69d9809c3d23470a 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/ComponentManager.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/ComponentManager.java @@ -13,6 +13,7 @@ package org.eclipse.wtp.releng.tools.component.ui; import java.text.MessageFormat; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -29,7 +30,6 @@ import org.eclipse.core.resources.IResourceDeltaVisitor; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Platform; -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.model.ComponentXML; @@ -41,7 +41,6 @@ import org.eclipse.wtp.releng.tools.component.ui.internal.WorkspacePluginXML; import org.eclipse.wtp.releng.tools.component.ui.internal.job.AddComponent; import org.eclipse.wtp.releng.tools.component.ui.internal.job.InitComponentManager; import org.eclipse.wtp.releng.tools.component.ui.internal.job.RemoveComponent; -import org.eclipse.wtp.releng.tools.component.ui.internal.job.ScanComponent; import org.eclipse.wtp.releng.tools.component.violation.ComponentViolationEmitter; import org.osgi.framework.Bundle; @@ -270,7 +269,7 @@ public class ComponentManager implements IResourceChangeListener, IResourceDelta { Map compXMLs = new HashMap(1); compXMLs.put(compXML.getLocation().getAbsolutePath(), compXML); - List plugins = compXML.getPlugins(); + Collection plugins = compXML.getPlugins(); Map pluginId2Plugins = new HashMap(plugins.size()); List projects = new ArrayList(1); for (Iterator it = plugins.iterator(); it.hasNext();) @@ -363,11 +362,6 @@ public class ComponentManager implements IResourceChangeListener, IResourceDelta ((ScannableComponent)it.next()).removeCompRef(location); } - private void rescanAffectedComps(String compName) - { - - } - public String getMessage(String key) { if (bundle == null) diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/ScannableComponent.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/ScannableComponent.java index da21bca8e8dd0d21a24f1066e64ef753535c7a12..781a40859902acb201a656f8d159082277c9997c 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/ScannableComponent.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/ScannableComponent.java @@ -14,6 +14,7 @@ package org.eclipse.wtp.releng.tools.component.ui.internal; import java.io.IOException; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -128,7 +129,7 @@ public class ScannableComponent implements IResourceProxyVisitor return true; else { - List compRefs = depends.getComponentRefs(); + Collection compRefs = depends.getComponentRefs(); for (Iterator it = compRefs.iterator(); it.hasNext();) if (((ComponentRef)it.next()).getName().equals(compRefName)) return true; diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/action/JavadocScanner2.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/action/JavadocScanner2.java new file mode 100644 index 0000000000000000000000000000000000000000..978e69c8acf3f5cf6a6cef73d3b847d54ea87d0e --- /dev/null +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/action/JavadocScanner2.java @@ -0,0 +1,146 @@ +/********************************************************************** + * 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.ui.internal.action; + +import java.io.CharArrayWriter; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.util.Collection; +import java.util.Iterator; +import java.util.Map; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; +import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.core.dom.AST; +import org.eclipse.jdt.core.dom.ASTNode; +import org.eclipse.jdt.core.dom.ASTParser; +import org.eclipse.wtp.releng.tools.component.ILocation; +import org.eclipse.wtp.releng.tools.component.ILocationVisitor; +import org.eclipse.wtp.releng.tools.component.api.ComponentAPI; +import org.eclipse.wtp.releng.tools.component.internal.Location; +import org.eclipse.wtp.releng.tools.component.java.JavadocScanner; +import org.eclipse.wtp.releng.tools.component.java.JavadocVisitor; +import org.eclipse.wtp.releng.tools.component.util.CommandOptionParser; + +public class JavadocScanner2 extends JavadocScanner +{ + private String currSrc = null; + + protected void scanJavaSources() + { + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + IPath workspace = workspaceRoot.getLocation(); + for (Iterator it = getSrc().iterator(); it.hasNext();) + { + final String pluginId = new File((String)it.next()).getName(); + IProject project = workspaceRoot.getProject(pluginId); + if (project.exists()) + { + try + { + IJavaProject javaProj = JavaCore.create(project); + IClasspathEntry[] cpEntries = javaProj.getRawClasspath(); + for (int i = 0; i < cpEntries.length; i++) + { + if (cpEntries[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) + { + currSrc = workspace.append(cpEntries[i].getPath()).toFile().toURL().toString().substring(6); + ILocation srcLocation = Location.createLocation(new File(currSrc)); + srcLocation.accept(new ILocationVisitor() + { + public boolean accept(ILocation location) + { + if (location.getName().endsWith(".java")) + visit(pluginId, location); + return true; + } + }); + } + } + } + catch (JavaModelException jme) + { + jme.printStackTrace(); + } + catch (MalformedURLException murle) + { + murle.printStackTrace(); + } + } + } + } + + public boolean visit(String pluginId, ILocation java) + { + String qualifiedName = java.getAbsolutePath().substring(currSrc.length()); + char firstChar = qualifiedName.charAt(0); + if (firstChar == '/' || firstChar == '\\') + qualifiedName = qualifiedName.substring(1); + if (include(qualifiedName) && isAPI(pluginId, qualifiedName)) + { + try + { + ComponentAPI compAPI = getComponentAPI(pluginId); + InputStreamReader isr = new InputStreamReader(java.getInputStream()); + CharArrayWriter caw = new CharArrayWriter(); + char[] c = new char[2048]; + for (int read = isr.read(c); read != -1; read = isr.read(c)) + caw.write(c, 0, read); + isr.close(); + caw.close(); + if (astParser == null) + astParser = ASTParser.newParser(AST.JLS3); + astParser.setSource(caw.toCharArray()); + ASTNode node = astParser.createAST(null); + node.accept(new JavadocVisitor(compAPI)); + } + catch (IOException e) + { + throw new RuntimeException(e); + } + } + return true; + } + + public static void main(String[] args) + { + CommandOptionParser optionParser = new CommandOptionParser(args); + Map options = optionParser.getOptions(); + Collection src = (Collection)options.get("src"); + Collection api = (Collection)options.get("api"); + Collection outputDir = (Collection)options.get("outputDir"); + Collection includes = (Collection)options.get("includes"); + Collection excludes = (Collection)options.get("excludes"); + Collection html = (Collection)options.get("html"); + Collection xsl = (Collection)options.get("xsl"); + if (src == null || api == null || outputDir == null || src.isEmpty() || api.isEmpty() || outputDir.isEmpty()) + { + printUsage(); + System.exit(-1); + } + JavadocScanner2 javadocScanner2 = new JavadocScanner2(); + javadocScanner2.setSrc(src); + javadocScanner2.setApi((String)api.iterator().next()); + javadocScanner2.setOutputDir((String)outputDir.iterator().next()); + javadocScanner2.setIncludes(includes); + javadocScanner2.setExcludes(excludes); + javadocScanner2.setHtml(html != null); + javadocScanner2.setXsl(xsl != null && !xsl.isEmpty() ? (String)xsl.iterator().next() : null); + javadocScanner2.execute(); + } +} \ No newline at end of file diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/action/Scan4APIViolation.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/action/Scan4APIViolation.java new file mode 100644 index 0000000000000000000000000000000000000000..23e8f5c6cd4e885fc1bc034f428bbea1e84cc007 --- /dev/null +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/action/Scan4APIViolation.java @@ -0,0 +1,172 @@ +/********************************************************************** + * 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.ui.internal.action; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.IPreferencesService; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IActionDelegate; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.browser.IWebBrowser; +import org.eclipse.ui.browser.IWorkbenchBrowserSupport; +import org.eclipse.wtp.releng.tools.component.ILocation; +import org.eclipse.wtp.releng.tools.component.api.ComponentXMLVisitor; +import org.eclipse.wtp.releng.tools.component.internal.Location; +import org.eclipse.wtp.releng.tools.component.java.Java2API; +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.ui.internal.ComponentUIPlugin; +import org.eclipse.wtp.releng.tools.component.ui.internal.WorkspaceFileLocation; +import org.eclipse.wtp.releng.tools.component.violation.APIViolationScanner; +import org.osgi.service.prefs.Preferences; + +public class Scan4APIViolation extends Action implements IActionDelegate +{ + public void run() + { + // Get src + IPreferencesService prefService = Platform.getPreferencesService(); + IEclipsePreferences eclipsePref = prefService.getRootNode(); + Preferences pdePref = eclipsePref.node("/instance/org.eclipse.pde.core"); + String platformPath = pdePref.get("platform_path", null); + String src = platformPath != null ? platformPath : Platform.getInstallLocation().toString(); + // Get outputDir + IPath outputDir = Platform.getPluginStateLocation(ComponentUIPlugin.getDefault()); + String compXMLOutputDir = outputDir.addTrailingSeparator().append(src.replace(':', '_').replace('/', '_').replace('\\', '_')).toString(); + if (!(new File(compXMLOutputDir).exists())) + { + // Get existing component.xml + List excludePlugins = new ArrayList(); + ComponentXMLVisitor compXMLVisitor = new ComponentXMLVisitor(); + Location.createLocation(new File(src)).accept(compXMLVisitor); + for (Iterator it = compXMLVisitor.getCompXMLs().iterator(); it.hasNext();) + { + ComponentXML compXML = (ComponentXML)it.next(); + for (Iterator it2 = compXML.getPlugins().iterator(); it2.hasNext();) + { + Plugin plugin = (Plugin)it2.next(); + excludePlugins.add(plugin.getId()); + } + } + // Generate missing component.xml + List excludes = new ArrayList(1); + excludes.add(".*internal.*"); + Java2API java2api = new Java2API(); + java2api.setSrc(src); + java2api.setOutputDir(compXMLOutputDir); + java2api.setExcludes(excludes); + java2api.setExcludePlugins(excludePlugins); + java2api.execute(); + } + // Generate violation report + String reportDir = null; + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) + { + IStructuredSelection selection = (IStructuredSelection)window.getSelectionService().getSelection(); + if (selection != null && !selection.isEmpty()) + { + Object firstElement = selection.getFirstElement(); + if (firstElement != null && firstElement instanceof IFile) + { + try + { + IFile file = (IFile)firstElement; + ILocation compXMLLoc = new WorkspaceFileLocation(file); + ComponentXML selectedCompXML = new ComponentXML(); + selectedCompXML.setLocation(compXMLLoc); + selectedCompXML.load(); + Collection plugins = selectedCompXML.getPlugins(); + List srcs = new ArrayList(plugins.size()); + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + IPath workspace = workspaceRoot.getLocation(); + for (Iterator it = plugins.iterator(); it.hasNext();) + { + Plugin plugin = (Plugin)it.next(); + IProject project = workspaceRoot.getProject(plugin.getId()); + if (project.exists()) + srcs.add(workspace.append(project.getFullPath()).toFile().toURL().toString().substring(6)); + } + String violationOutputDir = outputDir.append("_output_").toString(); + StringBuffer sb = new StringBuffer(); + sb.append(violationOutputDir); + sb.append('/'); + sb.append(selectedCompXML.getName()); + reportDir = sb.toString(); + (new File(reportDir + "/api-violation.xml")).delete(); + String[] args = new String[srcs.size() + 13]; + int i = 0; + args[i++] = "-src"; + for (Iterator it = srcs.iterator(); it.hasNext();) + args[i++] = (String)it.next(); + args[i++] = "-api"; + args[i++] = compXMLLoc.getAbsolutePath(); + args[i++] = compXMLOutputDir; + args[i++] = "-outputDir"; + args[i++] = violationOutputDir; + args[i++] = "-includes"; + args[i++] = "org.eclipse.*"; + args[i++] = "-excludes"; + args[i++] = "org.eclipse.wst.*"; + args[i++] = "org.eclipse.jst.*"; + args[i++] = "-debug"; + args[i++] = "-html"; + APIViolationScanner.main(args); + } + catch (IOException ioe) + { + ioe.printStackTrace(); + } + } + } + } + // Open report + try + { + IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport(); + IWebBrowser browser = browserSupport.createBrowser("org.eclipse.wtp.releng.tools.component.ui.internal.action.Scan4APIViolation"); + browser.openURL(new File(reportDir + "/api-violation.html").toURL()); + } + catch (PartInitException e) + { + } + catch (MalformedURLException e) + { + } + } + + public void run(IAction action) + { + run(); + } + + public void selectionChanged(IAction action, ISelection selection) + { + } +} \ No newline at end of file diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/action/Scan4MissingJavadoc.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/action/Scan4MissingJavadoc.java new file mode 100644 index 0000000000000000000000000000000000000000..fa17ad802191ee1ae20a87f0aa924e43cc2ea37d --- /dev/null +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/action/Scan4MissingJavadoc.java @@ -0,0 +1,124 @@ +/********************************************************************** + * 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.ui.internal.action; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IActionDelegate; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.browser.IWebBrowser; +import org.eclipse.ui.browser.IWorkbenchBrowserSupport; +import org.eclipse.wtp.releng.tools.component.ILocation; +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.ui.internal.ComponentUIPlugin; +import org.eclipse.wtp.releng.tools.component.ui.internal.WorkspaceFileLocation; + +public class Scan4MissingJavadoc extends Action implements IActionDelegate +{ + public void run() + { + String outputDir = Platform.getPluginStateLocation(ComponentUIPlugin.getDefault()).append("_output_").toString(); + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) + { + IStructuredSelection selection = (IStructuredSelection)window.getSelectionService().getSelection(); + if (selection != null && !selection.isEmpty()) + { + Object firstElement = selection.getFirstElement(); + if (firstElement != null && firstElement instanceof IFile) + { + try + { + IFile file = (IFile)firstElement; + ILocation compXMLLoc = new WorkspaceFileLocation(file); + ComponentXML selectedCompXML = new ComponentXML(); + selectedCompXML.setLocation(compXMLLoc); + selectedCompXML.load(); + Collection plugins = selectedCompXML.getPlugins(); + List srcs = new ArrayList(plugins.size()); + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + IPath workspace = workspaceRoot.getLocation(); + for (Iterator it = plugins.iterator(); it.hasNext();) + { + Plugin plugin = (Plugin)it.next(); + IProject project = workspaceRoot.getProject(plugin.getId()); + if (project.exists()) + { + StringBuffer sb = new StringBuffer(); + sb.append(outputDir); + sb.append('/'); + sb.append(project.getName()); + sb.append("/api-info.xml"); + new File(sb.toString()).delete(); + srcs.add(workspace.append(project.getFullPath()).toFile().toURL().toString().substring(6)); + } + } + String[] args = new String[srcs.size() + 6]; + int i = 0; + args[i++] = "-src"; + for (Iterator it = srcs.iterator(); it.hasNext();) + args[i++] = (String)it.next(); + args[i++] = "-api"; + args[i++] = compXMLLoc.getAbsolutePath(); + args[i++] = "-outputDir"; + args[i++] = outputDir; + args[i++] = "-html"; + JavadocScanner2.main(args); + } + catch (IOException ioe) + { + ioe.printStackTrace(); + } + } + } + } + // Open report + try + { + IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport(); + IWebBrowser browser = browserSupport.createBrowser("org.eclipse.wtp.releng.tools.component.ui.internal.action.Scan4MissingJavadoc"); + browser.openURL(new File(outputDir + "/api-javadoc-summary.html").toURL()); + } + catch (PartInitException e) + { + } + catch (MalformedURLException e) + { + } + } + + public void run(IAction action) + { + run(); + } + + public void selectionChanged(IAction action, ISelection selection) + { + } +} \ No newline at end of file diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/action/ScanAPI.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/action/ScanAPI.java index f2dba3445519bfd97855aff9c097a1683614eecc..56a6a01b88ad1da61d46984be9833daf0f32d1a7 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/action/ScanAPI.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/action/ScanAPI.java @@ -14,6 +14,7 @@ package org.eclipse.wtp.releng.tools.component.ui.internal.action; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -122,7 +123,7 @@ public class ScanAPI extends Action implements IActionDelegate { return null; } - List plugins = compXML.getPlugins(); + Collection plugins = compXML.getPlugins(); Map pluginId2Plugins = new HashMap(plugins.size()); List workspacePluginProjects = new ArrayList(); ComponentManager manager = ComponentManager.getManager(); diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/editor/APIDialog.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/editor/APIDialog.java index 9d8bfcb6d4eb9e0a1af84a41ac46b7b35b1f1498..f55ef6d48865f8ac5b543d447d5ce1400015df92 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/editor/APIDialog.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/editor/APIDialog.java @@ -12,6 +12,7 @@ package org.eclipse.wtp.releng.tools.component.ui.internal.editor; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -89,7 +90,7 @@ public class APIDialog extends Dialog implements ITreeContentProvider { if (option == OPTION_PACKAGE) { - List pkgs = compXML.getPackages(); + Collection pkgs = compXML.getPackages(); TreeItem[] items = tree.getSelection(); for (int i = 0; i < items.length; i++) { @@ -100,7 +101,7 @@ public class APIDialog extends Dialog implements ITreeContentProvider } else { - List types = pkg.getTypes(); + Collection types = pkg.getTypes(); TreeItem[] items = tree.getSelection(); for (int i = 0; i < items.length; i++) { @@ -147,7 +148,7 @@ public class APIDialog extends Dialog implements ITreeContentProvider List nameList = new ArrayList(); if (inputElement instanceof ComponentXML) { - List plugins = ((ComponentXML)inputElement).getPlugins(); + Collection plugins = ((ComponentXML)inputElement).getPlugins(); for (Iterator pluginsIt = plugins.iterator(); pluginsIt.hasNext();) { String pluginId = ((Plugin)pluginsIt.next()).getId(); diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/editor/APIPage.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/editor/APIPage.java index addb0ec86776c0836ffa9e34e99e64426ca7cb6b..90ee8e2f79a208ea51187b4ea6e4b3addf631a76 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/editor/APIPage.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/editor/APIPage.java @@ -12,6 +12,7 @@ package org.eclipse.wtp.releng.tools.component.ui.internal.editor; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.List; import org.eclipse.jface.dialogs.Dialog; @@ -279,7 +280,7 @@ public class APIPage extends FormPage } if (pkg != null) { - List types = pkg.getTypes(); + Collection types = pkg.getTypes(); List ignoreNames = new ArrayList(types.size()); for (Iterator it = types.iterator(); it.hasNext();) ignoreNames.add(((Type)it.next()).getName()); diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/editor/ComponentPage.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/editor/ComponentPage.java index 8d0e5dcc95e8108fa6595ccda73ca10afda1f5a8..979e798c4b9cc8955ffdd5fbb4d143cffb08e3a2 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/editor/ComponentPage.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/editor/ComponentPage.java @@ -12,6 +12,7 @@ package org.eclipse.wtp.releng.tools.component.ui.internal.editor; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.List; import org.eclipse.jface.dialogs.Dialog; @@ -128,7 +129,6 @@ public class ComponentPage extends FormPage gl.verticalSpacing = 10; parent.setLayout(gl); parent.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_VERTICAL)); - ComponentManager manager = ComponentManager.getManager(); FormToolkit toolkit = managedForm.getToolkit(); Composite generalInfo = toolkit.createComposite(parent); Composite compDepends = toolkit.createComposite(parent); @@ -369,7 +369,7 @@ public class ComponentPage extends FormPage if (items.length > 0) { ComponentXMLEditor editor = (ComponentXMLEditor)getEditor(); - List refs = editor.getComponentXML().getComponentDepends().getComponentRefs(); + Collection refs = editor.getComponentXML().getComponentDepends().getComponentRefs(); for (int i = 0; i < items.length; i++) { refs.remove(items[i].getData()); @@ -384,7 +384,7 @@ public class ComponentPage extends FormPage { ComponentXMLEditor editor = (ComponentXMLEditor)getEditor(); ComponentDepends depends = editor.getComponentXML().getComponentDepends(); - List refs = depends.getComponentRefs(); + Collection refs = depends.getComponentRefs(); List ignoreNames = new ArrayList(refs.size() + 1); for (Iterator it = refs.iterator(); it.hasNext();) ignoreNames.add(((ComponentRef)it.next()).getName()); @@ -415,7 +415,7 @@ public class ComponentPage extends FormPage if (items.length > 0) { ComponentXMLEditor editor = (ComponentXMLEditor)getEditor(); - List pluginList = editor.getComponentXML().getPlugins(); + Collection pluginList = editor.getComponentXML().getPlugins(); for (int i = 0; i < items.length; i++) { pluginList.remove(items[i].getData()); @@ -435,7 +435,7 @@ public class ComponentPage extends FormPage if (results.length > 0) { ComponentXMLEditor editor = (ComponentXMLEditor)getEditor(); - List pluginList = editor.getComponentXML().getPlugins(); + Collection pluginList = editor.getComponentXML().getPlugins(); boolean added = false; for (int i = 0; i < results.length; i++) { diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/editor/ComponentXMLProvider.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/editor/ComponentXMLProvider.java index e78195b9f9fddd3170c39ff5bbf83212015ef8a8..ee165d588498848a3da4bd4c10d94c39939fc4e5 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/editor/ComponentXMLProvider.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/editor/ComponentXMLProvider.java @@ -11,7 +11,7 @@ package org.eclipse.wtp.releng.tools.component.ui.internal.editor; -import java.util.List; +import java.util.Collection; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.LabelProvider; @@ -50,7 +50,7 @@ public class ComponentXMLProvider extends LabelProvider implements ITreeContentP { if (parentElement instanceof Package) { - List types = ((Package)parentElement).getTypes(); + Collection types = ((Package)parentElement).getTypes(); return types.toArray(new Type[0]); } return new Object[0]; @@ -60,17 +60,17 @@ public class ComponentXMLProvider extends LabelProvider implements ITreeContentP { if (show == SHOW_COMPONENT_REFS && inputElement instanceof ComponentDepends) { - List compRefs = ((ComponentDepends)inputElement).getComponentRefs(); + Collection compRefs = ((ComponentDepends)inputElement).getComponentRefs(); return compRefs.toArray(new ComponentRef[0]); } else if (show == SHOW_PLUGINS && inputElement instanceof ComponentXML) { - List plugins = ((ComponentXML)inputElement).getPlugins(); + Collection plugins = ((ComponentXML)inputElement).getPlugins(); return plugins.toArray(new Plugin[0]); } else if (show == SHOW_APIS && inputElement instanceof ComponentXML) { - List packages = ((ComponentXML)inputElement).getPackages(); + Collection packages = ((ComponentXML)inputElement).getPackages(); return packages.toArray(new Package[0]); } return new Object[0]; diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/AbstractModifyMarkersJob.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/AbstractModifyMarkersJob.java index d0603f09e71165757f6d3ae2b937aeb5d037908b..2b696982e88528f5f5451300de6baf41ee380396 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/AbstractModifyMarkersJob.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/AbstractModifyMarkersJob.java @@ -11,8 +11,8 @@ package org.eclipse.wtp.releng.tools.component.ui.internal.job; +import java.util.Collection; import java.util.Iterator; -import java.util.List; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; @@ -44,13 +44,13 @@ public abstract class AbstractModifyMarkersJob extends Job { if (methodRefCount > 0) { - List methodUses = classUse.getMethodUses(); + Collection methodUses = classUse.getMethodUses(); for (Iterator it = methodUses.iterator(); it.hasNext();) createMethodViolationMarker(javaSource, classUse, (MethodUse)it.next()); } if (fieldRefCount > 0) { - List fieldUses = classUse.getFieldUses(); + Collection fieldUses = classUse.getFieldUses(); for (Iterator it = fieldUses.iterator(); it.hasNext();) createFieldViolationMarker(javaSource, classUse, (FieldUse)it.next()); } @@ -95,7 +95,7 @@ public abstract class AbstractModifyMarkersJob extends Job createMarker(javaSource, manager.getMessage("VIOLATION_FIELD_REF", new String[] {fieldName, className}), -1); } - private void createMarker(IResource resource, String message, List lines) throws CoreException + private void createMarker(IResource resource, String message, Collection lines) throws CoreException { for (Iterator it = lines.iterator(); it.hasNext();) { diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/AddComponent.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/AddComponent.java index 23c1a9dc9436dbb8f96e4f6ef6a052b7fa7d0706..cacf69275105d91a14a612afa837be8d98e9284f 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/AddComponent.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/AddComponent.java @@ -11,8 +11,8 @@ package org.eclipse.wtp.releng.tools.component.ui.internal.job; import java.io.IOException; +import java.util.Collection; import java.util.Iterator; -import java.util.List; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -47,7 +47,7 @@ public class AddComponent extends Job { compXML.load(); manager.addCompRef(compXML); - List plugins = compXML.getPlugins(); + Collection plugins = compXML.getPlugins(); for (Iterator it = plugins.iterator(); it.hasNext();) { if (manager.isWorkspacePlugin(((Plugin)it.next()).getId())) diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/InitComponentManager.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/InitComponentManager.java index dc7921d1aac08eb8a84d3d74a923264b6fac69ba..ce616f4bda67994e9481b44786f099b81fe5ca8a 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/InitComponentManager.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/InitComponentManager.java @@ -12,6 +12,7 @@ package org.eclipse.wtp.releng.tools.component.ui.internal.job; import java.io.IOException; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.List; import org.eclipse.core.resources.IFile; @@ -85,7 +86,7 @@ public class InitComponentManager extends Job implements IResourceProxyVisitor } ComponentManager manager = ComponentManager.getManager(); manager.addCompRef(compXML); - List plugins = compXML.getPlugins(); + Collection plugins = compXML.getPlugins(); for (Iterator it = plugins.iterator(); it.hasNext();) { if (manager.isWorkspacePlugin(((Plugin)it.next()).getId())) diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/ScanComponent.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/ScanComponent.java index 8b75b0c76b2f95595a93ad83dfdcc4bc66c12891..2f9533cfbd7e1e2d874f7060e5e9ff3246f82ec7 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/ScanComponent.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/ScanComponent.java @@ -13,6 +13,7 @@ package org.eclipse.wtp.releng.tools.component.ui.internal.job; import java.io.IOException; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.List; import org.eclipse.core.resources.IProject; @@ -98,7 +99,7 @@ public class ScanComponent extends AbstractScanJob return new Status(IStatus.OK, ComponentUIPlugin.ID, IStatus.OK, "", null); } - private void createMarker(String sourceName, List classUses, boolean isInnerClass) + private void createMarker(String sourceName, Collection classUses, boolean isInnerClass) { List projects = scannableComponent.getProjects(); for (Iterator projectsIt = projects.iterator(); projectsIt.hasNext();)