Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 190273 Details for
Bug 332763
Producer oriented API Use Scan Migration task
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
v01
20110303.txt (text/plain), 95.81 KB, created by
Ankur Sharma
on 2011-03-03 09:59:08 EST
(
hide
)
Description:
v01
Filename:
MIME Type:
Creator:
Ankur Sharma
Created:
2011-03-03 09:59:08 EST
Size:
95.81 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.api.tools >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/plugin.xml,v >retrieving revision 1.38 >diff -u -r1.38 plugin.xml >--- plugin.xml 14 Jan 2011 19:10:37 -0000 1.38 >+++ plugin.xml 3 Mar 2011 14:43:50 -0000 >@@ -1,7 +1,7 @@ > <?xml version="1.0" encoding="UTF-8"?> > <?eclipse version="3.2"?> > <!-- >- Copyright (c) 2009, 2010 IBM Corporation and others. >+ Copyright (c) 2009, 2011 IBM Corporation and others. > All rights reserved. This program and the accompanying materials > are made available under the terms of the Eclipse Public License v1.0 > which accompanies this distribution, and is available at >@@ -239,6 +239,16 @@ > library="lib/apitooling-ant.jar" > name="apitooling.apiuse_reportconversion"> > </antTask> >+ <antTask >+ class="org.eclipse.pde.api.tools.internal.tasks.MissingRefProblemsTask" >+ library="lib/apitooling-ant.jar" >+ name="apitooling.apiusescanproblems"> >+ </antTask> >+ <antTask >+ class="org.eclipse.pde.api.tools.internal.tasks.MissingRefProblemsReportConversionTask" >+ library="lib/apitooling-ant.jar" >+ name="apitooling.apiusescanproblem_reportconversion"> >+ </antTask> > <antTask > class="org.eclipse.pde.api.tools.internal.tasks.ApiMigrationTask" > library="lib/apitooling-ant.jar" >Index: src/org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer.java,v >retrieving revision 1.127 >diff -u -r1.127 BaseApiAnalyzer.java >--- src/org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer.java 28 Feb 2011 19:04:23 -0000 1.127 >+++ src/org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer.java 3 Mar 2011 14:43:52 -0000 >@@ -280,7 +280,7 @@ > Util.updateMonitor(localMonitor); > > if (component instanceof ProjectComponent) { >- checkExternalDependencies(component, bcontext, localMonitor.newChild(1)); >+ checkExternalDependencies(component, bcontext, null, localMonitor.newChild(1)); > } > } catch(CoreException e) { > ApiPlugin.log(e); >@@ -305,8 +305,8 @@ > * @param monitor > * @throws CoreException > */ >- void checkExternalDependencies(IApiComponent apiComponent, IBuildContext bcontext, IProgressMonitor monitor) throws CoreException { >- if (!isSeverityEnabled()) { >+ public void checkExternalDependencies(IApiComponent apiComponent, IBuildContext bcontext, Properties properties, IProgressMonitor monitor) throws CoreException { >+ if (!isSeverityEnabled(properties)) { > return; > } > String[] apiUseTypes = getApiUseTypes(bcontext); >@@ -367,19 +367,34 @@ > } > } > >- public boolean isSeverityEnabled() { >+ public boolean isSeverityEnabled(Properties properties) { > IEclipsePreferences node = InstanceScope.INSTANCE.getNode(ApiPlugin.PLUGIN_ID); >- >- if (!node.get(IApiProblemTypes.API_USE_SCAN_TYPE_SEVERITY, ApiPlugin.VALUE_IGNORE).equalsIgnoreCase(ApiPlugin.VALUE_IGNORE)) { >- return true; >- } >- if (!node.get(IApiProblemTypes.API_USE_SCAN_METHOD_SEVERITY, ApiPlugin.VALUE_IGNORE).equalsIgnoreCase(ApiPlugin.VALUE_IGNORE)) { >- return true; >+ if (properties == null) { >+ if (!isIgnore(node.get(IApiProblemTypes.API_USE_SCAN_TYPE_SEVERITY, ApiPlugin.VALUE_IGNORE))) >+ return true; >+ if (!isIgnore(node.get(IApiProblemTypes.API_USE_SCAN_METHOD_SEVERITY, ApiPlugin.VALUE_IGNORE))) >+ return true; >+ if (isIgnore(node.get(IApiProblemTypes.API_USE_SCAN_FIELD_SEVERITY, ApiPlugin.VALUE_IGNORE))) >+ return true; >+ return false; >+ } else { >+ if (properties.isEmpty()) >+ return true; // preferences parameter not provided >+ if (!isIgnore(properties.get(IApiProblemTypes.API_USE_SCAN_TYPE_SEVERITY))) >+ return true; >+ if (!isIgnore(properties.get(IApiProblemTypes.API_USE_SCAN_METHOD_SEVERITY))) >+ return true; >+ if (!isIgnore(properties.get(IApiProblemTypes.API_USE_SCAN_FIELD_SEVERITY))) >+ return true; >+ return false; > } >- if (!node.get(IApiProblemTypes.API_USE_SCAN_FIELD_SEVERITY, ApiPlugin.VALUE_IGNORE).equalsIgnoreCase(ApiPlugin.VALUE_IGNORE)) { >- return true; >+ } >+ >+ private boolean isIgnore(Object value) { >+ if (value != null && (value.toString().equalsIgnoreCase(ApiPlugin.VALUE_ERROR) || value.toString().equalsIgnoreCase(ApiPlugin.VALUE_WARNING))) { >+ return false; > } >- return false; >+ return true; > } > > /** >@@ -395,33 +410,36 @@ > */ > protected IApiProblem createExternalDependenciesProblem(HashMap problems, IReferenceDescriptor dependency, String referenceTypeName, IMemberDescriptor referencedMember, int elementType, int flag) { > String resource = referenceTypeName; >- String primaryTypeName = referenceTypeName.replace('$', '.'); >+ String primaryTypeName = referenceTypeName.replace('$', '.'); > int charStart = -1, charEnd = -1, lineNumber = -1; >- try { >- IType type = fJavaProject.findType(primaryTypeName); >- IResource res = Util.getResource(fJavaProject.getProject(), type); >- if(res == null) { >- return null; >- } >- if(!Util.isManifest(res.getProjectRelativePath())) { >- resource = res.getProjectRelativePath().toString(); >- } >- else { >- resource = "."; //$NON-NLS-1$ >- } >- if (type != null) { >- ISourceRange range = type.getNameRange(); >- charStart = range.getOffset(); >- charEnd = charStart + range.getLength(); >- try { >- IDocument document = Util.getDocument(type.getCompilationUnit()); >- lineNumber = document.getLineOfOffset(charStart); >- } catch (BadLocationException e) { >- // ignore >- } >- catch (CoreException ce) {} >- } >- } catch (JavaModelException e) {} >+ if (fJavaProject != null) { >+ try { >+ >+ IType type = fJavaProject.findType(primaryTypeName); >+ IResource res = Util.getResource(fJavaProject.getProject(), type); >+ if(res == null) { >+ return null; >+ } >+ if(!Util.isManifest(res.getProjectRelativePath())) { >+ resource = res.getProjectRelativePath().toString(); >+ } >+ else { >+ resource = "."; //$NON-NLS-1$ >+ } >+ if (type != null) { >+ ISourceRange range = type.getNameRange(); >+ charStart = range.getOffset(); >+ charEnd = charStart + range.getLength(); >+ try { >+ IDocument document = Util.getDocument(type.getCompilationUnit()); >+ lineNumber = document.getLineOfOffset(charStart); >+ } catch (BadLocationException e) { >+ // ignore >+ } >+ catch (CoreException ce) {} >+ } >+ } catch (JavaModelException e) {} >+ } > String[] msgArgs = new String[] {referenceTypeName, referencedMember.getName(), dependency.getComponent().getId()}; > int kind = 0; > switch (elementType) { >@@ -441,7 +459,8 @@ > } > > int dependencyNameIndex = 2; // the comma separated list of dependent plugins >- String problemKey = referenceTypeName + resource + dependency.getReferenceKind() + elementType + kind + flag; >+ int problemId = ApiProblemFactory.createProblemId(IApiProblem.CATEGORY_API_USE_SCAN_PROBLEM, elementType, kind, flag); >+ String problemKey = referenceTypeName + problemId; > IApiProblem similarProblem = (IApiProblem) problems.get(problemKey); > if (similarProblem != null) { > String[] existingMsgArgs = similarProblem.getMessageArguments()[dependencyNameIndex].split(", "); //$NON-NLS-1$ >Index: src/org/eclipse/pde/api/tools/internal/search/MissingRefMetadata.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/internal/search/MissingRefMetadata.java >diff -N src/org/eclipse/pde/api/tools/internal/search/MissingRefMetadata.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/internal/search/MissingRefMetadata.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,231 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.api.tools.internal.search; >+ >+import java.io.BufferedWriter; >+import java.io.File; >+import java.io.FileOutputStream; >+import java.io.IOException; >+import java.io.OutputStreamWriter; >+import java.util.Calendar; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.pde.api.tools.internal.IApiCoreConstants; >+import org.eclipse.pde.api.tools.internal.provisional.search.IMetadata; >+import org.eclipse.pde.api.tools.internal.util.Util; >+import org.w3c.dom.Document; >+import org.w3c.dom.Element; >+import org.w3c.dom.NodeList; >+ >+import com.ibm.icu.text.DateFormat; >+ >+/** >+ * Implementation of {@link IMetadata} for API Use Scan problem report >+ */ >+public class MissingRefMetadata implements IMetadata { >+ >+ /** >+ * XML tag name for Profile >+ */ >+ public static final String PROFILE = "profile"; //$NON-NLS-1$ >+ /** >+ * XML tag name for the date the scan was run >+ */ >+ public static final String RUNATDATE = "runatdate"; //$NON-NLS-1$ >+ /** >+ * XML tag name for the report location >+ */ >+ public static final String REPORTLOCATION = "reportlocation"; //$NON-NLS-1$ >+ /** >+ * XML tag name for api use scan list >+ */ >+ public static final String APIUUSESCANS = "apiusescans"; //$NON-NLS-1$ >+ /** >+ * XML tag name for the value >+ */ >+ public static final String VALUE = "value"; //$NON-NLS-1$ >+ /** >+ * Root tag for the metadata file >+ */ >+ public static final String METADATA = "metadata"; //$NON-NLS-1$ >+ >+ private String profile = null; >+ private String runatdate = null; >+ private String reportlocation = null; >+ private String apiusescans = null; >+ >+ /** >+ * Constructor >+ */ >+ public MissingRefMetadata() { >+ //create an empty metadata object >+ } >+ >+ /** >+ * Constructor >+ * @param profile >+ * @param runatdate >+ * @param reportlocation >+ * @param scopepattern >+ * @param refpattern >+ * @param apiusescans >+ */ >+ public MissingRefMetadata(String profile, String reportlocation, String apiusescans) { >+ this.profile = profile; >+ this.runatdate = DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime()); >+ this.reportlocation = reportlocation; >+ this.apiusescans = apiusescans; >+ } >+ >+ /** >+ * Returns the use metadata from meta.xml >+ * @return >+ * @throws Exception >+ */ >+ public static MissingRefMetadata getMetadata(File xmlFile) throws Exception { >+ MissingRefMetadata metadata = new MissingRefMetadata(); >+ try { >+ if (xmlFile.exists()) { >+ String xmlstr = Util.getFileContentAsString(xmlFile); >+ Element doc = Util.parseDocument(xmlstr.trim()); >+ Element element = null; >+ String value = null, name = null; >+ NodeList nodes = doc.getElementsByTagName("*"); //$NON-NLS-1$ >+ for (int i = 0; i < nodes.getLength(); i++) { >+ element = (Element) nodes.item(i); >+ value = element.getAttribute(MissingRefMetadata.VALUE); >+ name = element.getNodeName(); >+ >+ if (PROFILE.equals(name)) { >+ metadata.setProfile(value); >+ continue; >+ } >+ if (RUNATDATE.equals(name)) { >+ metadata.setRunAtDate(value); >+ continue; >+ } >+ if (REPORTLOCATION.equals(name)) { >+ metadata.setReportLocation(value); >+ continue; >+ } >+ if (APIUUSESCANS.equals(name)) { >+ metadata.setApiUseScans(value); >+ continue; >+ } >+ } >+ } >+ } catch (CoreException e) { >+ throw new Exception(NLS.bind(SearchMessages.MissingRefMetadata_CoreExceptionInParsing, xmlFile.getAbsolutePath())); >+ } >+ return metadata; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.api.tools.internal.provisional.search.IMetadata#serializeToFile(java.io.File) >+ */ >+ public void serializeToFile(File file) throws IOException, CoreException { >+ BufferedWriter writer = null; >+ try { >+ Document doc = Util.newDocument(); >+ Element root = doc.createElement(MissingRefMetadata.METADATA); >+ doc.appendChild(root); >+ >+ Element child = doc.createElement(MissingRefMetadata.PROFILE); >+ root.appendChild(child); >+ child.setAttribute(MissingRefMetadata.VALUE, profile); >+ >+ child = doc.createElement(MissingRefMetadata.RUNATDATE); >+ root.appendChild(child); >+ child.setAttribute(MissingRefMetadata.VALUE, runatdate); >+ >+ child = doc.createElement(MissingRefMetadata.REPORTLOCATION); >+ root.appendChild(child); >+ child.setAttribute(MissingRefMetadata.VALUE, reportlocation); >+ >+ child = doc.createElement(MissingRefMetadata.APIUUSESCANS); >+ root.appendChild(child); >+ child.setAttribute(MissingRefMetadata.VALUE, apiusescans); >+ >+ writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), IApiCoreConstants.UTF_8)); >+ writer.write(Util.serializeDocument(doc)); >+ writer.flush(); >+ } finally { >+ if (writer != null) { >+ writer.close(); >+ } >+ } >+ } >+ >+ /** >+ * Allows the profile to be set. This method accepts <code>null</code> >+ * @param profile the profile to set >+ */ >+ public void setProfile(String profile) { >+ this.profile = profile; >+ } >+ >+ /** >+ * Returns the profile set in this metadata or <code>null</code> if none. >+ * @return the profile >+ */ >+ public String getProfile() { >+ return profile; >+ } >+ >+ /** >+ * Allows the run-at date to be set. This method accepts <code>null</code> >+ * @param date the date to set >+ */ >+ public void setRunAtDate(String date) { >+ this.runatdate = date; >+ } >+ >+ /** >+ * Returns the run-at date set in this metadata or <code>null</code> if none. >+ * @return the run-at date or <code>null</code> >+ */ >+ public String getRunAtDate() { >+ return this.runatdate; >+ } >+ >+ /** >+ * Returns the report location set in this metadata or <code>null</code> if none. >+ * @return the report location or <code>null</code> >+ */ >+ public String getReportLocation() { >+ return this.reportlocation; >+ } >+ >+ /** >+ * Allows the report location to be set. This method accepts <code>null</code>. >+ * @param location the new report location >+ */ >+ public void setReportLocation(String location) { >+ this.reportlocation = location; >+ } >+ >+ /** >+ * Returns the API Use Scans set in this metadata or <code>null</code> if none. >+ * @return the apiusescans >+ */ >+ public String getApiUseScans() { >+ return apiusescans; >+ } >+ >+ /** >+ * Allows the API Use Scan to be set. This method accepts <code>null</code> >+ * @param apiusescans the apiusescans to set >+ */ >+ public void setApiUseScans(String apiusescans) { >+ this.apiusescans = apiusescans; >+ } >+} >Index: src/org/eclipse/pde/api/tools/internal/search/MissingRefParser.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/internal/search/MissingRefParser.java >diff -N src/org/eclipse/pde/api/tools/internal/search/MissingRefParser.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/internal/search/MissingRefParser.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,199 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.api.tools.internal.search; >+ >+import java.io.File; >+import java.io.FileFilter; >+import java.io.IOException; >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import javax.xml.parsers.ParserConfigurationException; >+import javax.xml.parsers.SAXParser; >+import javax.xml.parsers.SAXParserFactory; >+ >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.pde.api.tools.internal.IApiXmlConstants; >+import org.eclipse.pde.api.tools.internal.problems.ApiProblem; >+import org.eclipse.pde.api.tools.internal.provisional.Factory; >+import org.eclipse.pde.api.tools.internal.provisional.descriptors.IComponentDescriptor; >+import org.eclipse.pde.api.tools.internal.search.MissingRefReportConverter.MissingRefVisitor; >+import org.eclipse.pde.api.tools.internal.util.Util; >+import org.xml.sax.Attributes; >+import org.xml.sax.SAXException; >+import org.xml.sax.helpers.DefaultHandler; >+ >+class MissingRefParser { >+ >+ class MissingRefProblemHandler extends DefaultHandler { >+ >+ List problems = new ArrayList(); >+ private String typename; >+ private int linenumber; >+ private int charstart; >+ private int charend; >+ private int id; >+ private List messageargs = new ArrayList(); >+ private Map extraargs = new HashMap(); >+ >+ public void startDocument() throws SAXException { >+ >+ } >+ >+ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { >+ if (IApiXmlConstants.ELEMENT_API_PROBLEM.equalsIgnoreCase(qName)) { >+ typename = attributes.getValue(IApiXmlConstants.ATTR_TYPE_NAME); >+ linenumber = Integer.parseInt(attributes.getValue(IApiXmlConstants.ATTR_LINE_NUMBER)); >+ charstart = Integer.parseInt(attributes.getValue(IApiXmlConstants.ATTR_CHAR_START)); >+ charend = Integer.parseInt(attributes.getValue(IApiXmlConstants.ATTR_CHAR_END)); >+ id = Integer.parseInt(attributes.getValue(IApiXmlConstants.ATTR_ID)); >+ } else if (IApiXmlConstants.ELEMENT_PROBLEM_MESSAGE_ARGUMENTS.equalsIgnoreCase(qName)) { >+ messageargs.clear(); >+ } else if (IApiXmlConstants.ELEMENT_PROBLEM_MESSAGE_ARGUMENT.equalsIgnoreCase(qName)) { >+ messageargs.add(attributes.getValue(IApiXmlConstants.ATTR_VALUE)); >+ } else if (IApiXmlConstants.ELEMENT_PROBLEM_EXTRA_ARGUMENTS.equalsIgnoreCase(qName)) { >+ extraargs.clear(); >+ } else if (IApiXmlConstants.ELEMENT_PROBLEM_EXTRA_ARGUMENT.equalsIgnoreCase(qName)) { >+ extraargs.put(attributes.getValue(IApiXmlConstants.ATTR_ID), attributes.getValue(IApiXmlConstants.ATTR_VALUE)); >+ } >+ } >+ >+ public void endElement(String uri, String localName, String qName) throws SAXException { >+ if (IApiXmlConstants.ELEMENT_API_PROBLEM.equalsIgnoreCase(qName)) { >+ String[] argumentids = new String[extraargs.size()]; >+ Object[] arguments = new Object[extraargs.size()]; >+ int i = 0; >+ for (Iterator iterator = extraargs.keySet().iterator(); iterator.hasNext(); i++) { >+ argumentids[i] = (String) iterator.next(); >+ arguments[i] = extraargs.get(argumentids[i]); >+ } >+ ApiProblem problem = new ApiProblem(null, typename, (String[]) messageargs.toArray(new String[messageargs.size()]), argumentids, arguments, linenumber, charstart, charend, id); >+ problems.add(problem); >+ } >+ } >+ >+ public void endDocument() throws SAXException { >+ } >+ >+ public List getProblems() { >+ return problems; >+ } >+ } >+ >+ public void parse(String xmlLocation, MissingRefVisitor visitor) throws Exception { >+ if (xmlLocation == null) { >+ throw new Exception(SearchMessages.missing_xml_files_location); >+ } >+ File reportsRoot = new File(xmlLocation); >+ if (!reportsRoot.exists() || !reportsRoot.isDirectory()) { >+ throw new Exception(NLS.bind(SearchMessages.invalid_directory_name, xmlLocation)); >+ } >+ File[] components = getDirectories(reportsRoot); >+ components = sort(components); >+ >+ visitor.visitScan(); >+ SAXParser parser = getParser(); >+ // Treat each top level directory as a producer component >+ for (int i = 0; i < components.length; i++) { >+ if (components[i].isDirectory()) { >+ String[] idv = getIdVersion(components[i].getName()); >+ IComponentDescriptor targetComponent = Factory.componentDescriptor(idv[0], idv[1]); >+ if (visitor.visitComponent(targetComponent)) { >+ File[] xmlfiles = Util.getAllFiles(components[i], new FileFilter() { >+ public boolean accept(File pathname) { >+ return pathname.isFile() && pathname.getName().endsWith(".xml"); //$NON-NLS-1$ >+ } >+ }); >+ if (xmlfiles != null && xmlfiles.length > 0) { >+ xmlfiles = sort(xmlfiles); // sort to visit in determined order >+ for (int k = 0; k < xmlfiles.length; k++) { >+ try { >+ MissingRefProblemHandler handler = new MissingRefProblemHandler(); >+ parser.parse(xmlfiles[k], handler); >+ List apiProblems = handler.getProblems(); >+ visitor.addToCuurentReport(apiProblems); >+ } catch (SAXException e) { >+ } catch (IOException e) { >+ } >+ } >+ } >+ visitor.endVisitComponent(); >+ } >+ } >+ } >+ } >+ >+ /** >+ * Sorts the given files by name (not path). >+ * >+ * @param files >+ * @return sorted files >+ */ >+ private File[] sort(File[] files) { >+ List sorted = new ArrayList(files.length + 2); >+ for (int i = 0; i < files.length; i++) { >+ sorted.add(files[i]); >+ } >+ >+ Collections.sort(sorted, Util.filesorter); >+ return (File[]) sorted.toArray(new File[sorted.size()]); >+ } >+ >+ private String[] getIdVersion(String value) { >+ int index = value.indexOf(' '); >+ if (index > 0) { >+ String id = value.substring(0, index); >+ String version = value.substring(index + 1); >+ if (version.startsWith("(")) { //$NON-NLS-1$ >+ version = version.substring(1); >+ if (version.endsWith(")")) { //$NON-NLS-1$ >+ version = version.substring(0, version.length() - 1); >+ } >+ } >+ return new String[] {id, version}; >+ } >+ return new String[] {value, null}; >+ } >+ >+ /** >+ * Returns a parser >+ * @return default parser >+ * @throws Exception forwarded general exception that can be trapped in Ant builds >+ */ >+ SAXParser getParser() throws Exception { >+ SAXParserFactory factory = SAXParserFactory.newInstance(); >+ try { >+ return factory.newSAXParser(); >+ } catch (ParserConfigurationException pce) { >+ throw new Exception(SearchMessages.UseReportConverter_pce_error_getting_parser, pce); >+ } catch (SAXException se) { >+ throw new Exception(SearchMessages.UseReportConverter_se_error_parser_handle, se); >+ } >+ } >+ >+ /** >+ * Returns all the child directories form the given directory >+ * @param file >+ * @return >+ */ >+ private File[] getDirectories(File file) { >+ File[] directories = file.listFiles(new FileFilter() { >+ public boolean accept(File pathname) { >+ return pathname.isDirectory() && !pathname.isHidden(); >+ } >+ }); >+ return directories; >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/pde/api/tools/internal/search/MissingRefReportConverter.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/internal/search/MissingRefReportConverter.java >diff -N src/org/eclipse/pde/api/tools/internal/search/MissingRefReportConverter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/internal/search/MissingRefReportConverter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,726 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.api.tools.internal.search; >+ >+import java.io.BufferedInputStream; >+import java.io.File; >+import java.io.FileOutputStream; >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.OutputStreamWriter; >+import java.io.PrintWriter; >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.Comparator; >+import java.util.Iterator; >+import java.util.List; >+ >+import javax.xml.transform.Result; >+import javax.xml.transform.Source; >+import javax.xml.transform.Transformer; >+import javax.xml.transform.TransformerException; >+import javax.xml.transform.TransformerFactory; >+import javax.xml.transform.stream.StreamResult; >+import javax.xml.transform.stream.StreamSource; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.pde.api.tools.internal.IApiCoreConstants; >+import org.eclipse.pde.api.tools.internal.problems.ApiProblem; >+import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; >+import org.eclipse.pde.api.tools.internal.provisional.descriptors.IComponentDescriptor; >+import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem; >+import org.eclipse.pde.api.tools.internal.util.Util; >+import org.osgi.framework.Version; >+ >+public class MissingRefReportConverter extends HTMLConvertor { >+ >+ /** >+ * Constant used for controlling tracing in the report converter >+ */ >+ protected static boolean DEBUG = Util.DEBUG; >+ >+ private String xmlLocation = null; >+ private String htmlLocation = null; >+ private File reportsRoot = null; >+ private File htmlIndex = null; >+ Report currentreport = null; >+ >+ /** >+ * Colour gold for the problems table header. >+ */ >+ public static final String PROBLEMS_TABLE_HEADER_COLOUR = "#E0C040"; //$NON-NLS-1$ >+ /** >+ * Style HTML bits for a page that shows references >+ */ >+ static final String REF_STYLE; >+ /** >+ * The script block used to show an expanding table of references >+ */ >+ static final String REF_SCRIPT; >+ >+ static { >+ StringBuffer buffer = new StringBuffer(); >+ buffer.append("<style type=\"text/css\">\n"); //$NON-NLS-1$ >+ buffer.append("\t.main {\t\tfont-family:Arial, Helvetica, sans-serif;\n\t}\n"); //$NON-NLS-1$ >+ buffer.append("\t.main h3 {\n\t\tfont-family:Arial, Helvetica, sans-serif;\n\t\t\background-color:#FFFFFF;\n\t\tfont-size:14px;\n\t\tmargin:0.1em;\n\t}\n"); //$NON-NLS-1$ >+ buffer.append("\t.main h4 {\n\t\tbackground-color:#CCCCCC;\n\t\tmargin:0.15em;\n\t}\n"); //$NON-NLS-1$ >+ buffer.append("\ta.typeslnk {\n\t\tfont-family:Arial, Helvetica, sans-serif;\n\t\ttext-decoration:none;\n\t\tmargin-left:0.25em;\n\t}\n"); //$NON-NLS-1$ >+ buffer.append("\ta.typeslnk:hover {\n\t\ttext-decoration:underline;\n\t}\n"); //$NON-NLS-1$ >+ buffer.append("\ta.kindslnk {\n\t\tfont-family:Arial, Helvetica, sans-serif;\n\t\ttext-decoration:none;\n\t\tmargin-left:0.25em;\n\t}\n"); //$NON-NLS-1$ >+ buffer.append("\t.types {\n\t\tdisplay:none;\n\t\tmargin-bottom:0.25em;\n\t\tmargin-top:0.25em;\n\t\tmargin-right:0.25em;\n\t\tmargin-left:0.75em;\n\t}\n"); //$NON-NLS-1$ >+ buffer.append("</style>\n"); //$NON-NLS-1$ >+ REF_STYLE = buffer.toString(); >+ >+ buffer = new StringBuffer(); >+ buffer.append("<script type=\"text/javascript\">\n\tfunction expand(location) {\n\t\tif(document.getElementById) {\n\t\t\tvar childhtml = location.firstChild;\n\t\t\tif(!childhtml.innerHTML) {\n\t\t\t\tchildhtml = childhtml.nextSibling;\n\t\t\t}\n\t\t\tchildhtml.innerHTML = childhtml.innerHTML == '[+] ' ? '[-] ' : '[+] ';\n\t\t\tvar parent = location.parentNode;\n\t\t\tchildhtml = parent.nextSibling.style ? parent.nextSibling : parent.nextSibling.nextSibling;\n\t\t\tchildhtml.style.display = childhtml.style.display == 'block' ? 'none' : 'block';\n\t\t}\n\t}\n</script>\n"); //$NON-NLS-1$ >+ buffer.append("<noscript>\n\t<style type=\"text/css\">\n\t\t.types {display:block;}\n\t\t.kinds{display:block;}\n\t</style>\n</noscript>\n"); //$NON-NLS-1$ >+ REF_SCRIPT = buffer.toString(); >+ } >+ >+ /** >+ * Root item describing the use of one component >+ */ >+ static class Report { >+ String name = null; >+ List apiProblems; >+ int typeProblems = 0; >+ int methodProblems = 0; >+ int fieldProblems = 0; >+ >+ public void add(List apiProblems) { >+ this.apiProblems = apiProblems; >+ for (Iterator iterator = apiProblems.iterator(); iterator.hasNext();) { >+ ApiProblem apiProblem = (ApiProblem) iterator.next(); >+ switch (apiProblem.getKind()) { >+ case 1 : >+ ++typeProblems; >+ break; >+ case 2 : >+ ++methodProblems; >+ break; >+ case 3 : >+ ++fieldProblems; >+ break; >+ } >+ } >+ } >+ >+ public int getTotal() { >+ return typeProblems + methodProblems + fieldProblems; >+ } >+ >+ } >+ >+ /** >+ * Constructor >+ * @param htmlroot the folder root where the HTML reports should be written >+ * @param xmlroot the folder root where the current API use scan output is located >+ */ >+ public MissingRefReportConverter(String htmlroot, String xmlroot) { >+ this.xmlLocation = xmlroot; >+ this.htmlLocation = htmlroot; >+ } >+ >+ /** >+ * Method used for initializing tracing in the report converter >+ */ >+ public static void setDebug(boolean debugValue) { >+ DEBUG = debugValue || Util.DEBUG; >+ } >+ >+ /** >+ * Runs the converter on the given locations >+ */ >+ public void convert() throws Exception { >+ if (getHtmlLocation() == null) { >+ return; >+ } >+ File htmlRoot = new File(getHtmlLocation()); >+ if (!htmlRoot.exists()) { >+ if (!htmlRoot.mkdirs()) { >+ throw new Exception(NLS.bind(SearchMessages.could_not_create_file, getHtmlLocation())); >+ } >+ } else { >+ htmlRoot.mkdirs(); >+ } >+ if (getXmlLocation() == null) { >+ throw new Exception(SearchMessages.missing_xml_files_location); >+ } >+ File reportsRoot = getReportsRoot(); >+ if (!reportsRoot.exists() || !reportsRoot.isDirectory()) { >+ throw new Exception(NLS.bind(SearchMessages.invalid_directory_name, getXmlLocation())); >+ } >+ >+ long start = 0; >+ if (DEBUG) { >+ start = System.currentTimeMillis(); >+ } >+ writeNotSearchedPage(htmlRoot); >+ writeMissingPage(htmlRoot); >+ >+ if (DEBUG) { >+ System.out.println("done in: " + (System.currentTimeMillis() - start) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$ >+ System.out.println("Parsing use scan..."); //$NON-NLS-1$ >+ start = System.currentTimeMillis(); >+ } >+ List result = parse(); >+ if (DEBUG) { >+ System.out.println("done in: " + (System.currentTimeMillis() - start) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$ >+ System.out.println("Sorting reports and writing index..."); //$NON-NLS-1$ >+ start = System.currentTimeMillis(); >+ } >+ writeIndexPage(result); >+ } >+ >+ private void writeMissingPage(File htmlRoot) { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ /** >+ * Writes out the file of components that were not searched: either because they appeared in an exclude list >+ * or they have no .api_description file >+ * >+ * @param htmlroot >+ */ >+ void writeNotSearchedPage(final File htmlroot) throws Exception { >+ File originhtml = null; >+ try { >+ String filename = "not_searched"; //$NON-NLS-1$ >+ originhtml = new File(htmlroot, filename+HTML_EXTENSION); >+ if(!originhtml.exists()) { >+ originhtml.createNewFile(); >+ } >+ File xml = new File(getReportsRoot(), filename+XML_EXTENSION); >+ if(!xml.exists()) { >+ //try <root>/xml in case a raw report root is specified >+ xml = new File(getReportsRoot()+File.separator+"xml", filename+XML_EXTENSION); //$NON-NLS-1$ >+ } >+ InputStream defaultXsltInputStream = MissingRefReportConverter.class.getResourceAsStream(getNotSearchedXSLPath()); >+ Source xslt = null; >+ if (defaultXsltInputStream != null) { >+ xslt = new StreamSource(new BufferedInputStream(defaultXsltInputStream)); >+ } >+ if(xslt == null) { >+ throw new Exception(SearchMessages.UseReportConverter_no_xstl_specified); >+ } >+ if (xml.exists()) { >+ applyXSLT(xslt, xml, originhtml); >+ } >+ } >+ catch(IOException ioe) { >+ throw new Exception(NLS.bind(SearchMessages.ioexception_writing_html_file, originhtml.getAbsolutePath())); >+ } >+ catch (TransformerException te) { >+ throw new Exception(SearchMessages.UseReportConverter_te_applying_xslt_skipped, te); >+ } >+ catch (CoreException e) { >+ throw new Exception(NLS.bind(SearchMessages.UseReportConverter_coreexception_writing_html_file, originhtml.getAbsolutePath())); >+ } >+ } >+ >+ /** >+ * Returns path of XSL file to use when generating "not searched" information. >+ * >+ * @return path to the XSL file >+ */ >+ String getNotSearchedXSLPath() { >+ return "/notsearched.xsl"; //$NON-NLS-1$ >+ } >+ >+ /** >+ * Applies the given XSLT source to the given XML file outputting to the given HTML file >+ * @param xslt >+ * @param xmlfile >+ * @param htmlfile >+ * @throws TransformerException >+ */ >+ protected void applyXSLT(Source xslt, File xmlfile, File htmlfile) throws TransformerException { >+ Source xml = new StreamSource(xmlfile); >+ Result html = new StreamResult(htmlfile); >+ TransformerFactory factory = TransformerFactory.newInstance(); >+ Transformer former = factory.newTransformer(xslt); >+ former.transform(xml, html); >+ } >+ >+ /** >+ * Gets the HTML path to write out the transformed XML file to >+ * @param reportroot >+ * @param xmlfile >+ * @return >+ */ >+ protected String getHTMLFileLocation(File xmlfile) { >+ File reportRoot = new File(getXmlLocation()); >+ IPath xml = new Path(xmlfile.getPath()); >+ IPath report = new Path(reportRoot.getPath()); >+ int segments = xml.matchingFirstSegments(report); >+ if (segments > 0) { >+ if (xml.getDevice() != null) { >+ xml = xml.setDevice(null); >+ } >+ IPath html = xml.removeFirstSegments(segments); >+ return html.removeLastSegments(1).toOSString(); >+ } >+ return null; >+ } >+ >+ class MissingRefVisitor { >+ public List reports; >+ >+ public void visitScan() { >+ reports = new ArrayList(); >+ } >+ >+ public boolean visitComponent(IComponentDescriptor targetComponent) { >+ currentreport = new Report(); >+ currentreport.name = composeName(targetComponent.getId(), targetComponent.getVersion()); >+ reports.add(currentreport); >+ return true; >+ } >+ >+ /** >+ * Builds the name for the component >+ * @param id id of the component >+ * @param version version of the component, can be <code>null</code> >+ * @return string name >+ */ >+ protected String composeName(String id, String version) { >+ String versionName = version; >+ if (version == null) { >+ versionName = Version.emptyVersion.toString(); >+ } >+ StringBuffer buffer = new StringBuffer(3 + id.length() + versionName.length()); >+ buffer.append(id).append(" (").append(versionName).append(")"); //$NON-NLS-1$ //$NON-NLS-2$ >+ return buffer.toString(); >+ } >+ >+ public void endVisitComponent() { >+ try { >+ writeIndexFileForComponent(currentreport); >+ } catch (Exception e) { >+ ApiPlugin.log(e); >+ } >+ } >+ >+ private void writeIndexFileForComponent(Report report) throws Exception { >+ PrintWriter writer = null; >+ File originhtml = null; >+ try { >+ File htmlroot = new File(getHtmlLocation(), report.name); >+ if (!htmlroot.exists()) { >+ htmlroot.mkdirs(); >+ } >+ originhtml = new File(htmlroot, "index.html"); //$NON-NLS-1$ >+ if (!originhtml.exists()) { >+ originhtml.createNewFile(); >+ } >+ StringBuffer buffer = new StringBuffer(); >+ buffer.append(HTML_HEADER); >+ buffer.append(OPEN_HTML).append(OPEN_HEAD).append(CONTENT_TYPE_META); >+ buffer.append(REF_STYLE); >+ buffer.append(REF_SCRIPT); >+ buffer.append(OPEN_TITLE).append(getProblemTitle(report.name)).append(CLOSE_TITLE); >+ buffer.append(CLOSE_HEAD); >+ buffer.append(OPEN_BODY); >+ buffer.append(OPEN_H3).append(getProblemTitle(report.name)).append(CLOSE_H3); >+ buffer.append(getProblemSummary(report)); >+ >+ StringBuffer typeProblems = new StringBuffer(); >+ StringBuffer methodProblems = new StringBuffer(); >+ StringBuffer fieldProblems = new StringBuffer(); >+ for (Iterator iterator = report.apiProblems.iterator(); iterator.hasNext();) { >+ ApiProblem apiProblem = (ApiProblem) iterator.next(); >+ switch (apiProblem.getKind()) { >+ case IApiProblem.API_USE_SCAN_TYPE_PROBLEM : >+ typeProblems.append(getProblemTable(apiProblem)); >+ break; >+ case IApiProblem.API_USE_SCAN_METHOD_PROBLEM : >+ methodProblems.append(getProblemTable(apiProblem)); >+ break; >+ case IApiProblem.API_USE_SCAN_FIELD_PROBLEM : >+ fieldProblems.append(getProblemTable(apiProblem)); >+ } >+ >+ } >+ buffer.append(getProblemsTableHeader(SearchMessages.MissingRefReportConverter_ProblemDetails, SearchMessages.MissingRefReportConverter_ProblemTypes)); >+ if (typeProblems.length() > 0) { >+ buffer.append(getProblemRow(typeProblems, SearchMessages.MissingRefReportConverter_Type)); >+ } >+ if (methodProblems.length() > 0) { >+ buffer.append(getProblemRow(methodProblems, SearchMessages.MissingRefReportConverter_Method)); >+ } >+ if (fieldProblems.length() > 0) { >+ buffer.append(getProblemRow(fieldProblems, SearchMessages.MissingRefReportConverter_Field)); >+ } >+ buffer.append(CLOSE_TABLE); >+ >+ buffer.append(OPEN_P).append("<a href=\"../index.html\">").append(SearchMessages.MissingRefReportConverter_BackToIndex).append(CLOSE_A).append(CLOSE_P); //$NON-NLS-1$ >+ buffer.append(W3C_FOOTER); >+ buffer.append(CLOSE_BODY); >+ >+ writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(originhtml), IApiCoreConstants.UTF_8));; >+ writer.println(buffer.toString()); >+ writer.flush(); >+ } catch (IOException ioe) { >+ throw new Exception(NLS.bind(SearchMessages.ioexception_writing_html_file, originhtml.getAbsolutePath())); >+ } finally { >+ if (writer != null) { >+ writer.close(); >+ } >+ >+ } >+ } >+ >+ private StringBuffer getProblemRow(StringBuffer type, String header) { >+ StringBuffer buffer = new StringBuffer(); >+ buffer.append(OPEN_TR); >+ buffer.append("<td align=\"left\">\n"); //$NON-NLS-1$ >+ buffer.append(OPEN_B); >+ buffer.append("<a href=\"javascript:void(0)\" class=\"typeslnk\" onclick=\"expand(this)\" title=\""); //$NON-NLS-1$ >+ buffer.append(header).append("\">\n"); //$NON-NLS-1$ >+ buffer.append("<span>[+] </span>").append(header).append("\n"); //$NON-NLS-1$//$NON-NLS-2$ >+ buffer.append(CLOSE_A).append(CLOSE_B); >+ buffer.append("<div colspan=\"6\" class=\"types\">\n"); //$NON-NLS-1$ >+ buffer.append(type).append("\n"); //$NON-NLS-1$ >+ buffer.append(CLOSE_DIV); >+ buffer.append(CLOSE_TR); >+ return buffer; >+ } >+ >+ private StringBuffer getProblemTable(ApiProblem apiProblem) { >+ StringBuffer buffer = new StringBuffer(); >+ buffer.append("<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"6\">\n"); //$NON-NLS-1$ >+ buffer.append("<tr align=\"left\"> \n"); //$NON-NLS-1$ >+ buffer.append("<td colspan=\"3\" bgcolor=\"#CCCCCC\">").append(OPEN_B).append(apiProblem.getTypeName()).append(CLOSE_B).append(CLOSE_TD); //$NON-NLS-1$ >+ buffer.append(CLOSE_TR); >+ >+ buffer.append("<tr bgcolor=\"").append(PROBLEMS_TABLE_HEADER_COLOUR).append("\">"); //$NON-NLS-1$ //$NON-NLS-2$ >+ buffer.append("<td align=\"center\" width=\"79%\">").append(OPEN_B).append(SearchMessages.MissingRefReportConverter_ErrorMessage).append(CLOSE_B).append(CLOSE_TD); //$NON-NLS-1$ >+ buffer.append("<td align=\"center\" width=\"7%\">").append(OPEN_B).append(SearchMessages.MissingRefReportConverter_LineNumber).append(CLOSE_B).append(CLOSE_TD); //$NON-NLS-1$ >+ buffer.append("<td align=\"left\" width=\"7%\">").append(OPEN_B).append(SearchMessages.MissingRefReportConverter_CharStart).append(CLOSE_B).append(CLOSE_TD); //$NON-NLS-1$ >+ buffer.append("<td align=\"center\" width=\"7%\">").append(OPEN_B).append(SearchMessages.MissingRefReportConverter_CharEnd).append(CLOSE_B).append(CLOSE_TD); //$NON-NLS-1$ >+ buffer.append(CLOSE_TR); >+ >+ buffer.append(OPEN_TR); >+ buffer.append("<td align=\"left\" width=\"79%\">").append(OPEN_B).append(apiProblem.getMessage()).append(CLOSE_B).append(CLOSE_TD); //$NON-NLS-1$ >+ buffer.append("<td align=\"center\" width=\"7%\">").append(OPEN_B).append(apiProblem.getCharStart()).append(CLOSE_B).append(CLOSE_TD); //$NON-NLS-1$ >+ buffer.append("<td align=\"center\" width=\"7%\">").append(OPEN_B).append(apiProblem.getCharEnd()).append(CLOSE_B).append(CLOSE_TD); //$NON-NLS-1$ >+ buffer.append("<td align=\"center\" width=\"7%\">").append(OPEN_B).append(apiProblem.getCharEnd()).append(CLOSE_B).append(CLOSE_TD); //$NON-NLS-1$ >+ buffer.append(CLOSE_TR); >+ buffer.append(CLOSE_TABLE); >+ return buffer; >+ } >+ >+ private Object getProblemSummary(Report report) { >+ StringBuffer buffer = new StringBuffer(); >+ buffer.append(OPEN_H4).append(SearchMessages.MissingRefReportConverter_Summary).append(CLOSE_H4); >+ buffer.append(OPEN_P).append(NLS.bind(SearchMessages.MissingRefReportConverter_SummaryDesc, new String[] {report.name, Integer.toString(report.apiProblems.size())})).append(CLOSE_P); >+ return buffer.toString(); >+ } >+ >+ /** >+ * Returns the HTML markup for the problems table header. >+ * @param sectionname >+ * @param type >+ * @return the default references table header >+ */ >+ String getProblemsTableHeader(String sectionname, String type) { >+ StringBuffer buffer = new StringBuffer(); >+ buffer.append(OPEN_H4).append(sectionname).append(CLOSE_H4); >+ buffer.append(OPEN_P).append(SearchMessages.MissingRefReportConverter_ProblemTableHeader).append(CLOSE_P); >+ buffer.append("<div align=\"left\" class=\"main\">"); //$NON-NLS-1$ >+ buffer.append("<table border=\"1\" width=\"80%\">\n"); //$NON-NLS-1$ >+ >+ buffer.append(OPEN_TR); >+ buffer.append("<td bgcolor=\"").append(PROBLEMS_TABLE_HEADER_COLOUR).append("\">").append(OPEN_B).append(type).append("</b></td>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ buffer.append(CLOSE_TR); >+ >+ return buffer.toString(); >+ } >+ >+ /** >+ * @param bundle >+ * @return the page title >+ */ >+ protected String getProblemTitle(String bundle) { >+ return NLS.bind(SearchMessages.MissingRefReportConverter_ProblemTitle, bundle); >+ } >+ >+ public void addToCuurentReport(List apiProblems) { >+ currentreport.add(apiProblems); >+ } >+ } >+ >+ /** >+ * Writes the main index file for the reports >+ * @param result a list of {@link Report} objects returns from the use scan parser >+ */ >+ void writeIndexPage(List result) throws Exception { >+ Collections.sort(result, new Comparator() { >+ public int compare(Object o1, Object o2) { >+ return ((Report) o1).name.compareTo(((Report) o2).name); >+ } >+ }); >+ >+ PrintWriter writer = null; >+ try { >+ File reportIndex = new File(getHtmlLocation(), "index.html"); //$NON-NLS-1$ >+ if (!reportIndex.exists()) { >+ reportIndex.createNewFile(); >+ } >+// setReportIndex(reportIndex); >+ >+ StringBuffer buffer = new StringBuffer(); >+ buffer.append(HTML_HEADER); >+ buffer.append(OPEN_HTML).append(OPEN_HEAD).append(CONTENT_TYPE_META); >+ writeMetadataHeaders(buffer); >+ buffer.append(OPEN_TITLE).append(getIndexTitle()).append(CLOSE_TITLE); >+ buffer.append(CLOSE_HEAD); >+ buffer.append(OPEN_BODY); >+ buffer.append(OPEN_H3).append(getIndexTitle()).append(CLOSE_H3); >+ >+ writeMetadataSummary(buffer); >+ >+ buffer.append(OPEN_H4).append(SearchMessages.MissingRefReportConverter_AddlBundleInfo).append(CLOSE_H4); >+// if(hasMissing()) { >+// buffer.append(OPEN_P); >+// buffer.append(NLS.bind(SearchMessages.UseReportConverter_missing_bundles_prevented_scan, >+// new String[] {" <a href=\"./missing.html\">", "</a>"})); //$NON-NLS-1$ //$NON-NLS-2$ >+// buffer.append(CLOSE_P); >+// } >+ buffer.append(OPEN_P); >+ buffer.append(NLS.bind(SearchMessages.MissingRefReportConverter_NotSearched, new String[] {"<a href=\"./not_searched.html\">", "</a></p>\n"})); //$NON-NLS-1$//$NON-NLS-2$ >+// String additional = getAdditionalIndexInfo(scanResult.size() > 0); >+// if(additional != null) { >+// buffer.append(additional); >+// } >+ if (result.size() > 0) { >+ buffer.append(getProblemSummaryTable()); >+ if (result.size() > 0) { >+ Report report = null; >+ for (Iterator iter = result.iterator(); iter.hasNext();) { >+ report = (Report) iter.next(); >+ if (report != null) { >+ File refereehtml = new File(getReportsRoot(), report.name + File.separator + "index.html"); //$NON-NLS-1$ >+ String link = extractLinkFrom(getReportsRoot(), refereehtml.getAbsolutePath()); >+ buffer.append(getReferenceTableEntry(report, link)); >+ } >+ } >+ buffer.append(CLOSE_TABLE); >+ } >+ } else { >+// buffer.append(getNoReportsInformation()); >+ } >+ buffer.append(W3C_FOOTER); >+ buffer.append(CLOSE_BODY).append(CLOSE_HTML); >+ >+ //write the file >+ writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(reportIndex), IApiCoreConstants.UTF_8)); >+ writer.print(buffer.toString()); >+ writer.flush(); >+ } catch (IOException e) { >+ throw new Exception(NLS.bind(SearchMessages.ioexception_writing_html_file, getReportIndex().getAbsolutePath())); >+ } finally { >+ if (writer != null) { >+ writer.close(); >+ } >+ } >+ } >+ >+ /** >+ * Returns the HTML markup for one entry in the problem summary table. >+ * @param report >+ * @param link >+ * @return a single reference table entry >+ */ >+ private Object getReferenceTableEntry(Report report, String link) { >+ StringBuffer buffer = new StringBuffer(); >+ buffer.append(OPEN_TR); >+ buffer.append("<td><b><a href=\"").append(link).append("\">").append(getBundleOnlyName(report.name)).append("</a>").append(CLOSE_B).append(CLOSE_TD); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ buffer.append("\t<td align=\"left\">").append(getVersion(report.name)).append(CLOSE_TD); //$NON-NLS-1$ >+ buffer.append("\t<td align=\"center\">").append(report.typeProblems).append(CLOSE_TD); //$NON-NLS-1$ >+ buffer.append("\t<td align=\"center\">").append(report.methodProblems).append(CLOSE_TD); //$NON-NLS-1$ >+ buffer.append("\t<td align=\"center\">").append(report.fieldProblems).append(CLOSE_TD); //$NON-NLS-1$ >+ buffer.append("\t<td align=\"center\">").append(report.getTotal()).append(CLOSE_TD); //$NON-NLS-1$ >+ buffer.append(CLOSE_TR); >+ return buffer.toString(); >+ } >+ >+ String getBundleOnlyName(String text) { >+ int idx = text.indexOf('('); >+ if (idx > -1) { >+ return text.substring(0, idx - 1); >+ } >+ return text; >+ } >+ >+ /** >+ * Returns the version string from the text (if any) >+ * @param text >+ * @return >+ */ >+ String getVersion(String text) { >+ int idx = text.indexOf('('); >+ if (idx > -1) { >+ int idx2 = text.indexOf(')', idx); >+ String version = text.substring(idx + 1, idx2); >+ try { >+ Version ver = new Version(version); >+ return ver.toString(); >+ } catch (IllegalArgumentException iae) { >+ //do nothing, not a valid version >+ } >+ } >+ return "-"; //$NON-NLS-1$ >+ } >+ >+ /** >+ * Extracts underlying link text from the given absolute filename based off the root file >+ * @param root >+ * @param fileName >+ * @return link text pruned via the given root file >+ */ >+ private String extractLinkFrom(File root, String fileName) { >+ StringBuffer buffer = new StringBuffer(); >+ String substring = fileName.substring(root.getAbsolutePath().length()).replace('\\', '/'); >+ buffer.append('.'); >+ if (substring.charAt(0) != '/') { >+ buffer.append('/'); >+ } >+ buffer.append(substring); >+ return buffer.toString(); >+ } >+ >+ private StringBuffer getProblemSummaryTable() { >+ StringBuffer buffer = new StringBuffer(); >+ buffer.append(OPEN_H4).append(SearchMessages.MissingRefReportConverter_ProblemSummaryTitle).append(CLOSE_H4); >+ buffer.append(OPEN_P).append(SearchMessages.MissingRefReportConverter_ProblemSummary).append(CLOSE_P); >+ buffer.append("<table border=\"1\" width=\"80%\">\n"); //$NON-NLS-1$ >+ buffer.append(OPEN_TR); >+ buffer.append("\t<td bgcolor=\"").append(PROBLEMS_TABLE_HEADER_COLOUR).append("\" width=\"25%\" title=\""); //$NON-NLS-1$ //$NON-NLS-2$ >+ buffer.append(SearchMessages.MissingRefReportConverter_ProblemTable_ColumnBundleTooltip).append("\"\">"); //$NON-NLS-1$ >+ buffer.append(OPEN_B).append(SearchMessages.MissingRefReportConverter_ProblemTable_ColumnBundle).append(CLOSE_B).append(CLOSE_TD); >+ //version header >+ buffer.append("\t<td bgcolor=\"").append(PROBLEMS_TABLE_HEADER_COLOUR).append("\" align=\"center\" width=\"15%\" title=\""); //$NON-NLS-1$ //$NON-NLS-2$ >+ buffer.append(SearchMessages.MissingRefReportConverter_ProblemTable_ColumnVersionTooltip).append("\"\">"); //$NON-NLS-1$ >+ buffer.append(OPEN_B).append(SearchMessages.MissingRefReportConverter_ProblemTable_ColumnVersion).append(CLOSE_B).append(CLOSE_TD); >+ //Missing Types >+ buffer.append("\t<td bgcolor=\"").append(PROBLEMS_TABLE_HEADER_COLOUR).append("\" align=\"center\" width=\"15%\" title=\""); //$NON-NLS-1$ //$NON-NLS-2$ >+ buffer.append(SearchMessages.MissingRefReportConverter_ProblemTable_ColumnMissingTypesTooltip).append("\">"); //$NON-NLS-1$ >+ buffer.append(OPEN_B).append(SearchMessages.MissingRefReportConverter_ProblemTable_ColumnMissingTypes).append(CLOSE_B).append(CLOSE_TD); >+ //Missing Methods >+ buffer.append("\t<td bgcolor=\"").append(PROBLEMS_TABLE_HEADER_COLOUR).append("\" align=\"center\" width=\"15%\" title=\""); //$NON-NLS-1$ //$NON-NLS-2$ >+ buffer.append(SearchMessages.MissingRefReportConverter_ProblemTable_ColumnMissingMethodsTooltip).append("\">"); //$NON-NLS-1$ >+ buffer.append(OPEN_B).append(SearchMessages.MissingRefReportConverter_ProblemTable_ColumnMissingMethods).append(CLOSE_B).append(CLOSE_TD); >+ //Missing Fields >+ buffer.append("\t<td bgcolor=\"").append(PROBLEMS_TABLE_HEADER_COLOUR).append("\" align=\"center\" width=\"15%\" title=\""); //$NON-NLS-1$ //$NON-NLS-2$ >+ buffer.append(SearchMessages.MissingRefReportConverter_ProblemTable_ColumnMissingFieldsTooltip).append("\">"); //$NON-NLS-1$ >+ buffer.append(OPEN_B).append(SearchMessages.MissingRefReportConverter_ProblemTable_ColumnMissingFields).append(CLOSE_B).append(CLOSE_TD); >+ //Total >+ buffer.append("\t<td bgcolor=\"").append(PROBLEMS_TABLE_HEADER_COLOUR).append("\" align=\"center\" width=\"15%\" title=\""); //$NON-NLS-1$ //$NON-NLS-2$ >+ buffer.append(SearchMessages.MissingRefReportConverter_ProblemTable_ColumnTotalTooltip).append("\">"); //$NON-NLS-1$ >+ buffer.append(OPEN_B).append(SearchMessages.MissingRefReportConverter_ProblemTable_ColumnTotal).append(CLOSE_B).append(CLOSE_TD); >+ return buffer; >+ } >+ >+ private void writeMetadataSummary(StringBuffer buffer) throws Exception { >+ MissingRefMetadata metadata = getMetadata(); >+ buffer.append(OPEN_H4).append(SearchMessages.MissingRefReportConverter_MetadataTitle).append(CLOSE_H4); >+ buffer.append("<table border=\"0px\" title=\"").append(SearchMessages.MissingRefReportConverter_MetadataTableTitle).append("\"width=\"50%\">"); //$NON-NLS-1$ //$NON-NLS-2$ >+ >+ buffer.append(OPEN_TR); >+ buffer.append(openTD(14)).append(SearchMessages.MissingRefReportConverter_ReportDate).append(CLOSE_TD); >+ buffer.append(openTD(36)).append(metadata.getRunAtDate()).append(CLOSE_TD); >+ buffer.append(CLOSE_TR); >+ >+ buffer.append(OPEN_TR); >+ buffer.append(openTD(14)).append(SearchMessages.MissingRefReportConverter_ProfileLocation).append(CLOSE_TD); >+ String value = metadata.getProfile(); >+ buffer.append(openTD(36)).append((value != null ? value : SearchMessages.MissingRefReportConverter_NONE)).append(CLOSE_TD); >+ buffer.append(CLOSE_TR); >+ >+ buffer.append(OPEN_TR); >+ buffer.append(openTD(14)).append(SearchMessages.MissingRefReportConverter_ReportLocation).append(CLOSE_TD); >+ value = metadata.getReportLocation(); >+ buffer.append(openTD(36)).append((value != null ? value : SearchMessages.MissingRefReportConverter_NONE)).append(CLOSE_TD); >+ buffer.append(CLOSE_TR); >+ >+ buffer.append(OPEN_TR); >+ buffer.append(openTD(14)).append(SearchMessages.MissingRefReportConverter_ApiUseScanLocations).append(CLOSE_TD); >+ value = metadata.getApiUseScans(); >+ buffer.append(openTD(36)).append((value != null ? value : SearchMessages.MissingRefReportConverter_NONE)).append(CLOSE_TD); >+ buffer.append(CLOSE_TR); >+ >+ buffer.append(CLOSE_TD); >+ buffer.append(CLOSE_TR); >+ buffer.append(CLOSE_TABLE); >+ } >+ >+ private MissingRefMetadata getMetadata() throws Exception { >+ File xmlFile = new File(getReportsRoot(), "meta" + XML_EXTENSION); //$NON-NLS-1$ >+ if (!xmlFile.exists()) { >+ //try looking in the default 'xml' directory as a raw report root >+ //might have been specified >+ xmlFile = new File(getReportsRoot() + File.separator + "xml", "meta" + XML_EXTENSION); //$NON-NLS-1$//$NON-NLS-2$ >+ } >+ return MissingRefMetadata.getMetadata(xmlFile); >+ >+ } >+ >+ private String getIndexTitle() { >+ return SearchMessages.MissingRefReportConverter_ReportTitle; >+ } >+ >+ private void writeMetadataHeaders(StringBuffer buffer) { >+ buffer.append("<meta name=\"").append("description").append("\" content=\"").append(SearchMessages.MissingRefReportConverter_IndexMetaTag).append("\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ >+ } >+ >+ /** >+ * Parse the xml directories and report.xml and generate html for them >+ */ >+ protected List parse() throws Exception { >+ MissingRefParser parser = new MissingRefParser(); >+ MissingRefVisitor visitor = new MissingRefVisitor(); >+ parser.parse(getXmlLocation(), visitor); >+ return visitor.reports; >+ } >+ >+ protected String getHtmlLocation() { >+ return this.htmlLocation; >+ } >+ >+ protected String getXmlLocation() { >+ return this.xmlLocation; >+ } >+ >+ protected File getReportsRoot() { >+ if (this.reportsRoot == null) { >+ this.reportsRoot = new File(getXmlLocation()); >+ } >+ return this.reportsRoot; >+ } >+ >+ /** >+ * @return the index.html file created from the report conversion or <code>null</code> >+ * if the conversion failed >+ */ >+ public File getReportIndex() { >+ //TODO remove if >+ if (htmlIndex == null) >+ return new File(htmlLocation); >+ else >+ return htmlIndex; >+ } >+ >+} >Index: src/org/eclipse/pde/api/tools/internal/search/SearchMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/SearchMessages.java,v >retrieving revision 1.27 >diff -u -r1.27 SearchMessages.java >--- src/org/eclipse/pde/api/tools/internal/search/SearchMessages.java 2 Dec 2010 17:42:05 -0000 1.27 >+++ src/org/eclipse/pde/api/tools/internal/search/SearchMessages.java 3 Mar 2011 14:43:56 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2009, 2010 IBM Corporation and others. >+ * Copyright (c) 2009, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -52,6 +52,46 @@ > public static String MigrationReportConvertor_table_shows_unresolved; > public static String MigrationReportConvertor_type_migration_information; > public static String MigrationReportConvertor_type_with_unresolved_refs; >+ public static String MissingRefMetadata_CoreExceptionInParsing; >+ public static String MissingRefReportConverter_AddlBundleInfo; >+ public static String MissingRefReportConverter_ApiUseScanLocations; >+ public static String MissingRefReportConverter_BackToIndex; >+ public static String MissingRefReportConverter_CharEnd; >+ public static String MissingRefReportConverter_CharStart; >+ public static String MissingRefReportConverter_ErrorMessage; >+ public static String MissingRefReportConverter_Field; >+ public static String MissingRefReportConverter_IndexMetaTag; >+ public static String MissingRefReportConverter_LineNumber; >+ public static String MissingRefReportConverter_MetadataTableTitle; >+ public static String MissingRefReportConverter_MetadataTitle; >+ public static String MissingRefReportConverter_Method; >+ public static String MissingRefReportConverter_NONE; >+ public static String MissingRefReportConverter_NotSearched; >+ public static String MissingRefReportConverter_ProblemDetails; >+ public static String MissingRefReportConverter_ProblemSummary; >+ public static String MissingRefReportConverter_ProblemSummaryTitle; >+ public static String MissingRefReportConverter_ProblemTable_ColumnMissingFields; >+ public static String MissingRefReportConverter_ProblemTable_ColumnMissingFieldsTooltip; >+ public static String MissingRefReportConverter_ProblemTable_ColumnMissingMethods; >+ public static String MissingRefReportConverter_ProblemTable_ColumnMissingMethodsTooltip; >+ public static String MissingRefReportConverter_ProblemTable_ColumnMissingTypes; >+ public static String MissingRefReportConverter_ProblemTable_ColumnMissingTypesTooltip; >+ public static String MissingRefReportConverter_ProblemTable_ColumnBundle; >+ public static String MissingRefReportConverter_ProblemTable_ColumnBundleTooltip; >+ public static String MissingRefReportConverter_ProblemTable_ColumnTotal; >+ public static String MissingRefReportConverter_ProblemTable_ColumnTotalTooltip; >+ public static String MissingRefReportConverter_ProblemTable_ColumnVersion; >+ public static String MissingRefReportConverter_ProblemTable_ColumnVersionTooltip; >+ public static String MissingRefReportConverter_ProblemTableHeader; >+ public static String MissingRefReportConverter_ProblemTitle; >+ public static String MissingRefReportConverter_ProblemTypes; >+ public static String MissingRefReportConverter_ProfileLocation; >+ public static String MissingRefReportConverter_ReportDate; >+ public static String MissingRefReportConverter_ReportLocation; >+ public static String MissingRefReportConverter_ReportTitle; >+ public static String MissingRefReportConverter_Summary; >+ public static String MissingRefReportConverter_SummaryDesc; >+ public static String MissingRefReportConverter_Type; > public static String ReferenceLookupVisitor_0; > public static String SkippedComponent_component_was_excluded; > public static String UseReportConverter_xslt_file_not_valid; >Index: src/org/eclipse/pde/api/tools/internal/search/searchmessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/searchmessages.properties,v >retrieving revision 1.34 >diff -u -r1.34 searchmessages.properties >--- src/org/eclipse/pde/api/tools/internal/search/searchmessages.properties 2 Dec 2010 17:42:05 -0000 1.34 >+++ src/org/eclipse/pde/api/tools/internal/search/searchmessages.properties 3 Mar 2011 14:43:56 -0000 >@@ -1,5 +1,5 @@ > ############################################################################### >-# Copyright (c) 2008, 2010 IBM Corporation and others. >+# Copyright (c) 2008, 2011 IBM Corporation and others. > # All rights reserved. This program and the accompanying materials > # are made available under the terms of the Eclipse Public License v1.0 > # which accompanies this distribution, and is available at >@@ -45,6 +45,46 @@ > MigrationReportConvertor_table_shows_unresolved=The following table shows the complete listing of types that have un-resolvable references to them. > MigrationReportConvertor_type_migration_information={0} migration information > MigrationReportConvertor_type_with_unresolved_refs=Types in {0} with un-resolved references >+MissingRefMetadata_CoreExceptionInParsing=CoreException parsing XML file: {0} >+MissingRefReportConverter_AddlBundleInfo=Additional Bundle Information >+MissingRefReportConverter_ApiUseScanLocations=API Use Scan locations >+MissingRefReportConverter_BackToIndex=Back to problem index >+MissingRefReportConverter_CharEnd=Offset End >+MissingRefReportConverter_CharStart=Offset Start >+MissingRefReportConverter_ErrorMessage=Error Message >+MissingRefReportConverter_Field=Field >+MissingRefReportConverter_IndexMetaTag=The root index page for the entire API Use Scan Problem page >+MissingRefReportConverter_LineNumber=Line Number >+MissingRefReportConverter_MetadataTableTitle=Report Parameter Table >+MissingRefReportConverter_MetadataTitle=Report Parameters >+MissingRefReportConverter_Method=Method >+MissingRefReportConverter_NONE=None >+MissingRefReportConverter_NotSearched=Bundles that were {0} not searched {1} >+MissingRefReportConverter_ProblemDetails=Problem Details >+MissingRefReportConverter_ProblemSummary=The table below displays the bundles and the problems reported for them. You can hover over a column header to see its description. >+MissingRefReportConverter_ProblemSummaryTitle=Problem Summary >+MissingRefReportConverter_ProblemTable_ColumnMissingFields=Missing Fields >+MissingRefReportConverter_ProblemTable_ColumnMissingFieldsTooltip=References to fields which are now missing from the profile >+MissingRefReportConverter_ProblemTable_ColumnMissingMethods=Missing Methods >+MissingRefReportConverter_ProblemTable_ColumnMissingMethodsTooltip=References to methods which are now missing from the profile >+MissingRefReportConverter_ProblemTable_ColumnMissingTypes=Missing Types >+MissingRefReportConverter_ProblemTable_ColumnMissingTypesTooltip=References to types which are now missing from the profile >+MissingRefReportConverter_ProblemTable_ColumnBundle=Bundle >+MissingRefReportConverter_ProblemTable_ColumnBundleTooltip=List of Bundles and the problems reported for them >+MissingRefReportConverter_ProblemTable_ColumnTotal=Total >+MissingRefReportConverter_ProblemTable_ColumnTotalTooltip=Total references which are now missing from the profile >+MissingRefReportConverter_ProblemTable_ColumnVersion=Version >+MissingRefReportConverter_ProblemTable_ColumnVersionTooltip=The version or version range of the bundle >+MissingRefReportConverter_ProblemTableHeader=Click an entry in the table below to reveal the details of the problems related to that element. >+MissingRefReportConverter_ProblemTitle=Problems report for {0} >+MissingRefReportConverter_ProblemTypes=Problem Types >+MissingRefReportConverter_ProfileLocation=Profile location >+MissingRefReportConverter_ReportDate=Report date >+MissingRefReportConverter_ReportLocation=Report Location >+MissingRefReportConverter_ReportTitle=Missing API Use Scan references report >+MissingRefReportConverter_Summary=Summary >+MissingRefReportConverter_SummaryDesc={1} problems were found for the bundle {0}. >+MissingRefReportConverter_Type=Type > ReferenceLookupVisitor_0=A corresponding bundle does not exist in the migration candidate. > > SkippedComponent_component_was_excluded=This component was excluded from the search by the search parameters. >Index: src_ant/org/eclipse/pde/api/tools/internal/tasks/Messages.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/Messages.java,v >retrieving revision 1.28 >diff -u -r1.28 Messages.java >--- src_ant/org/eclipse/pde/api/tools/internal/tasks/Messages.java 30 Sep 2010 15:13:26 -0000 1.28 >+++ src_ant/org/eclipse/pde/api/tools/internal/tasks/Messages.java 3 Mar 2011 14:43:56 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008, 2010 IBM Corporation and others. >+ * Copyright (c) 2008, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -108,6 +108,10 @@ > public static String deprecationReportTask_header; > public static String deprecationReportTask_missingXmlFileLocation; > >+ public static String MissingRefProblemsTask_invalidApiUseScanLocation; >+ >+ public static String MissingRefProblemsTask_missingArguments; >+ > static { > // initialize resource bundle > NLS.initializeMessages(BUNDLE_NAME, Messages.class); >Index: src_ant/org/eclipse/pde/api/tools/internal/tasks/MissingRefProblemsReportConversionTask.java >=================================================================== >RCS file: src_ant/org/eclipse/pde/api/tools/internal/tasks/MissingRefProblemsReportConversionTask.java >diff -N src_ant/org/eclipse/pde/api/tools/internal/tasks/MissingRefProblemsReportConversionTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/pde/api/tools/internal/tasks/MissingRefProblemsReportConversionTask.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,84 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.api.tools.internal.tasks; >+ >+import java.io.File; >+ >+import org.apache.tools.ant.BuildException; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.pde.api.tools.internal.search.MissingRefReportConverter; >+import org.eclipse.pde.api.tools.internal.util.Util; >+ >+/** >+ * Default task for converting the XML output from the apitooling.apiuse ants to HTML >+ * >+ * @noinstantiate This class is not intended to be instantiated by clients. >+ */ >+public final class MissingRefProblemsReportConversionTask extends CommonUtilsTask { >+ >+ private String xmlReportsLocation = null; >+ private String htmlReportsLocation = null; >+ >+ /** >+ * Set the debug value. >+ * <p>The possible values are: <code>true</code>, <code>false</code></p> >+ * <p>Default is <code>false</code>.</p> >+ * >+ * @param debugValue the given debug value >+ */ >+ public void setDebug(String debugValue) { >+ this.debug = Boolean.toString(true).equals(debugValue); >+ } >+ >+ /** >+ * Set the location where the html reports are generated. >+ * >+ * <p>This is optional. If not set, the html files are created in the same folder as the >+ * xml files.</p> >+ * <p>The location is set using an absolute path.</p> >+ * >+ * @param htmlFilesLocation the given the location where the html reports are generated >+ */ >+ public void setHtmlFiles(String htmlFilesLocation) { >+ this.htmlReportsLocation = htmlFilesLocation; >+ } >+ >+ /** >+ * Set the location where the xml reports are retrieved. >+ * >+ * <p>The location is set using an absolute path.</p> >+ * >+ * @param xmlFilesLocation the given location to retrieve the xml reports >+ */ >+ public void setXmlFiles(String xmlFilesLocation) { >+ this.xmlReportsLocation = xmlFilesLocation; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.apache.tools.ant.Task#execute() >+ */ >+ public void execute() throws BuildException { >+ if (this.debug) { >+ System.out.println("XML report location: " + this.xmlReportsLocation); //$NON-NLS-1$ >+ System.out.println("HTML report location: " + this.htmlReportsLocation); //$NON-NLS-1$ >+ } >+ try { >+ Util.delete(new File(this.htmlReportsLocation)); >+ MissingRefReportConverter converter = new MissingRefReportConverter(this.htmlReportsLocation, this.xmlReportsLocation); >+ MissingRefReportConverter.setDebug(this.debug); >+ converter.convert(); >+ File index = converter.getReportIndex(); >+ System.out.println(NLS.bind(Messages.ApiUseReportConversionTask_conversion_complete, index.getAbsolutePath())); >+ } catch (Exception e) { >+ throw new BuildException(e); >+ } >+ } >+} >Index: src_ant/org/eclipse/pde/api/tools/internal/tasks/MissingRefProblemsTask.java >=================================================================== >RCS file: src_ant/org/eclipse/pde/api/tools/internal/tasks/MissingRefProblemsTask.java >diff -N src_ant/org/eclipse/pde/api/tools/internal/tasks/MissingRefProblemsTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/pde/api/tools/internal/tasks/MissingRefProblemsTask.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,733 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.api.tools.internal.tasks; >+ >+import java.io.BufferedInputStream; >+import java.io.BufferedWriter; >+import java.io.File; >+import java.io.FileInputStream; >+import java.io.FileNotFoundException; >+import java.io.FileOutputStream; >+import java.io.IOException; >+import java.io.OutputStreamWriter; >+import java.io.PrintWriter; >+import java.io.StringWriter; >+import java.io.UnsupportedEncodingException; >+import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.Collections; >+import java.util.Comparator; >+import java.util.HashMap; >+import java.util.HashSet; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+import java.util.Properties; >+import java.util.Set; >+ >+import org.apache.tools.ant.BuildException; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.pde.api.tools.internal.IApiCoreConstants; >+import org.eclipse.pde.api.tools.internal.IApiXmlConstants; >+import org.eclipse.pde.api.tools.internal.builder.BaseApiAnalyzer; >+import org.eclipse.pde.api.tools.internal.builder.BuildContext; >+import org.eclipse.pde.api.tools.internal.model.StubApiComponent; >+import org.eclipse.pde.api.tools.internal.problems.ApiProblem; >+import org.eclipse.pde.api.tools.internal.problems.ApiProblemFactory; >+import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; >+import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline; >+import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent; >+import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem; >+import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemTypes; >+import org.eclipse.pde.api.tools.internal.search.MissingRefMetadata; >+import org.eclipse.pde.api.tools.internal.search.SkippedComponent; >+import org.eclipse.pde.api.tools.internal.search.UseScanManager; >+import org.eclipse.pde.api.tools.internal.util.FilteredElements; >+import org.eclipse.pde.api.tools.internal.util.Util; >+import org.w3c.dom.DOMException; >+import org.w3c.dom.Document; >+import org.w3c.dom.Element; >+ >+/** >+ * Ant task to headlessly run the API Analysis builder and generate a report of >+ * missing references in the API Use Scans >+ */ >+public class MissingRefProblemsTask extends CommonUtilsTask { >+ >+ private FilteredElements excludedElements; >+ private FilteredElements includedElements; >+ private String apiUseScans; >+ private String[] apiUseScanArray; >+ private Properties properties = new Properties(); >+ >+ public static final String COMPATIBILITY = "compatibility"; //$NON-NLS-1$ >+ private static final Summary[] NO_SUMMARIES = new Summary[0]; >+ >+ private static class Summary { >+ String fComponentID; >+ List fApiProblems; >+ >+ public Summary(String componentID, IApiProblem[] apiProblems) { >+ fComponentID = componentID; >+ fApiProblems = Arrays.asList(apiProblems); >+ } >+ >+ private void dumpProblems(String title, PrintWriter printWriter) { >+ printWriter.println(title); >+ if (fApiProblems.size() != 0) { >+ for (Iterator iterator = fApiProblems.iterator(); iterator.hasNext();) { >+ IApiProblem problem = (IApiProblem) iterator.next(); >+ printWriter.println(problem.getMessage()); >+ } >+ } else { >+ printWriter.println("None"); //$NON-NLS-1$ >+ } >+ } >+ >+ public String getDetails() { >+ StringWriter writer = new StringWriter(); >+ PrintWriter printWriter = new PrintWriter(writer); >+ >+ printWriter.println("=================================================================================="); //$NON-NLS-1$ >+ printWriter.println("Details for " + fComponentID + ":"); //$NON-NLS-1$//$NON-NLS-2$ >+ printWriter.println("=================================================================================="); //$NON-NLS-1$ >+ dumpProblems("All Problems", printWriter); //$NON-NLS-1$ >+ printWriter.println("=================================================================================="); //$NON-NLS-1$ >+ printWriter.flush(); >+ printWriter.close(); >+ return String.valueOf(writer.getBuffer()); >+ } >+ >+ public String getTitle() { >+ StringWriter writer = new StringWriter(); >+ PrintWriter printWriter = new PrintWriter(writer); >+ printTitle(printWriter); >+ >+ printWriter.flush(); >+ printWriter.close(); >+ return String.valueOf(writer.getBuffer()); >+ } >+ >+ private void printTitle(PrintWriter printWriter) { >+ printWriter.print("Results for " + fComponentID + " : "); //$NON-NLS-1$ //$NON-NLS-2$ >+ printWriter.print("(total: " + fApiProblems.size() + ")"); //$NON-NLS-1$//$NON-NLS-2$ >+ } >+ >+ } >+ >+ /** >+ * Run the api use scan problems task >+ * >+ * @throws BuildException >+ * exception is thrown if anything goes wrong during the >+ * verification >+ */ >+ public void execute() throws BuildException { >+ if (super.currentBaselineLocation == null || super.reportLocation == null || this.apiUseScans == null) { >+ StringBuffer error = new StringBuffer(NLS.bind(Messages.MissingRefProblemsTask_missingArguments, new String[] {super.currentBaselineLocation, super.reportLocation,})); >+ throw new BuildException(error.toString()); >+ } >+ if (apiUseScanArray != null && apiUseScanArray.length > 0) { >+ for (int i = 0; i < apiUseScanArray.length; i++) { >+ File file = new File(apiUseScanArray[i]); >+ if (!file.exists()) { >+ StringBuffer error = new StringBuffer(Messages.MissingRefProblemsTask_invalidApiUseScanLocation); >+ error.append(apiUseScanArray[i]); >+ throw new BuildException(error.toString()); >+ } >+ } >+ } >+ >+ if (super.debug) { >+ System.out.println("profile to compare : " + super.currentBaselineLocation); //$NON-NLS-1$ >+ System.out.println("report location : " + super.reportLocation); //$NON-NLS-1$ >+ >+ if (super.excludeListLocation != null) { >+ System.out.println("exclude list location : " + super.excludeListLocation); //$NON-NLS-1$ >+ } else { >+ System.out.println("No exclude list location"); //$NON-NLS-1$ >+ } >+ if (super.includeListLocation != null) { >+ System.out.println("include list location : " + super.includeListLocation); //$NON-NLS-1$ >+ } else { >+ System.out.println("No include list location"); //$NON-NLS-1$ >+ } >+ } >+ // unzip profile >+ long time = 0; >+ if (super.debug) { >+ time = System.currentTimeMillis(); >+ } >+ >+ File baselineInstallDir = extractSDK(CURRENT, super.currentBaselineLocation); >+ if (super.debug) { >+ System.out.println("Preparation of profile installation : " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ >+ time = System.currentTimeMillis(); >+ } >+ >+ // create baseline = profile >+ IApiBaseline profile = createBaseline(CURRENT_BASELINE_NAME, baselineInstallDir.getAbsolutePath(), null); >+ if (super.debug) { >+ System.out.println("Creation of baseline : " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ >+ time = System.currentTimeMillis(); >+ } >+ >+ if (this.excludeListLocation != null) { >+ this.excludedElements = CommonUtilsTask.initializeFilteredElements(this.excludeListLocation, profile, super.debug); >+ if (super.debug) { >+ System.out.println("===================================================================================="); //$NON-NLS-1$ >+ System.out.println("Excluded elements list:"); //$NON-NLS-1$ >+ System.out.println(this.excludedElements); >+ } >+ } >+ if (this.includeListLocation != null) { >+ this.includedElements = CommonUtilsTask.initializeFilteredElements(this.includeListLocation, profile, super.debug); >+ if (super.debug) { >+ System.out.println("===================================================================================="); //$NON-NLS-1$ >+ System.out.println("Included elements list:"); //$NON-NLS-1$ >+ System.out.println(this.includedElements); >+ } >+ } >+ >+ UseScanManager.getInstance().setReportLocations(apiUseScanArray); >+ >+ if (super.debug) { >+ System.out.println("===================================================================================="); //$NON-NLS-1$ >+ System.out.println("API Use Scan locations:"); //$NON-NLS-1$ >+ for (int i = 0; i < apiUseScanArray.length; i++) { >+ System.out.println("Location " + i + " : " + apiUseScanArray[i]); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ } >+ >+ Map allProblems = new HashMap(); >+ List allNonApiBundles = new ArrayList(); >+ List notSearchedList = new ArrayList(); >+ try { >+ IApiComponent[] apiComponents = profile.getApiComponents(); >+ int length = apiComponents.length; >+ Set visitedApiComponentNames = new HashSet(); >+ for (int i = 0; i < length; i++) { >+ IApiComponent apiComponent = apiComponents[i]; >+ String name = apiComponent.getSymbolicName(); >+ >+ if (this.excludedElements != null && (this.excludedElements.containsExactMatch(name) || this.excludedElements.containsPartialMatch(name))) { >+ notSearchedList.add(new SkippedComponent(name, apiComponents[i].getVersion(), null)); >+ continue; >+ } >+ if (this.includedElements != null && !this.includedElements.isEmpty() && !(this.includedElements.containsExactMatch(name) || this.includedElements.containsPartialMatch(name))) { >+ notSearchedList.add(new SkippedComponent(name, apiComponents[i].getVersion(), null)); >+ continue; >+ } >+ >+ visitedApiComponentNames.add(name); >+ if (apiComponent.isSystemComponent()) { >+ continue; >+ } >+ if (!Util.isApiToolsComponent(apiComponent)) { >+ allNonApiBundles.add(name); >+ continue; >+ } >+ >+ BaseApiAnalyzer analyzer = new BaseApiAnalyzer(); >+ try { >+ BaseApiAnalyzer.setDebug(super.debug); >+ if (this.properties.isEmpty()) { >+ addDefaultProperties(); >+ } >+ analyzer.checkExternalDependencies(apiComponent, new BuildContext(), this.properties, new NullProgressMonitor()); >+ IApiProblem[] problems = analyzer.getProblems(); >+ if (problems.length != 0) { >+ allProblems.put(name, problems); >+ } >+ } catch (RuntimeException e) { >+ ApiPlugin.log(e); >+ throw e; >+ } catch (CoreException e) { >+ ApiPlugin.log(e); >+ } finally { >+ analyzer.dispose(); >+ } >+ } >+ if (super.debug) { >+ System.out.println("Total number of components in current baseline :" + length); //$NON-NLS-1$ >+ System.out.println("=============================================================================="); //$NON-NLS-1$ >+ System.out.println("Total number of non-api tools components in current baseline :" + allNonApiBundles.size()); //$NON-NLS-1$ >+ System.out.println("Details:"); //$NON-NLS-1$ >+ Collections.sort(allNonApiBundles); >+ for (Iterator iterator = allNonApiBundles.iterator(); iterator.hasNext();) { >+ System.out.println(iterator.next()); >+ } >+ } >+ } finally { >+ if (super.debug) { >+ System.out.println("API tools verification check : " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ >+ time = System.currentTimeMillis(); >+ } >+ profile.dispose(); >+ StubApiComponent.disposeAllCaches(); >+ deleteBaseline(super.currentBaselineLocation, baselineInstallDir); >+ if (super.debug) { >+ System.out.println("Cleanup : " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ writeMetaData(new File(this.reportLocation, "meta.xml")); //$NON-NLS-1$ >+ } >+ Summary[] summaries = createAllSummaries(allProblems); >+ >+ try { >+ dumpReport(summaries); >+ reportNonApiBundles(allNonApiBundles); >+ reportNotSearched(notSearchedList); >+ } catch (RuntimeException e) { >+ ApiPlugin.log(e); >+ throw e; >+ } >+ } >+ >+ private void addDefaultProperties() { >+ this.properties.put(IApiProblemTypes.API_USE_SCAN_TYPE_SEVERITY, ApiPlugin.VALUE_ERROR); >+ this.properties.put(IApiProblemTypes.API_USE_SCAN_METHOD_SEVERITY, ApiPlugin.VALUE_ERROR); >+ this.properties.put(IApiProblemTypes.API_USE_SCAN_FIELD_SEVERITY, ApiPlugin.VALUE_ERROR); >+ } >+ >+ private void writeMetaData(File file) { >+ try { >+ if (!file.exists()) { >+ file.getParentFile().mkdirs(); >+ if (!file.createNewFile()) >+ return; // could not create meta.xml >+ } >+ if (super.debug) { >+ System.out.println("Writing metadata to " + file.getAbsolutePath()); //$NON-NLS-1$ >+ } >+ >+ MissingRefMetadata metadata = new MissingRefMetadata(super.currentBaselineLocation, super.reportLocation, this.apiUseScans); >+ metadata.serializeToFile(file); >+ } catch (UnsupportedEncodingException e) { >+ ApiPlugin.log(e); >+ } catch (FileNotFoundException e) { >+ ApiPlugin.log(e); >+ } catch (IOException e) { >+ ApiPlugin.log(e); >+ } catch (CoreException e) { >+ ApiPlugin.log(e); >+ } >+ } >+ >+ private Summary[] createAllSummaries(Map allProblems) { >+ Set entrySet = allProblems.entrySet(); >+ int size = entrySet.size(); >+ if (size == 0) { >+ return NO_SUMMARIES; >+ } >+ List allEntries = new ArrayList(); >+ allEntries.addAll(entrySet); >+ Collections.sort(allEntries, new Comparator() { >+ public int compare(Object o1, Object o2) { >+ Map.Entry entry1 = (Map.Entry) o1; >+ Map.Entry entry2 = (Map.Entry) o2; >+ return ((String) entry1.getKey()).compareTo((String) entry2.getKey()); >+ } >+ }); >+ Summary[] summaries = new Summary[size]; >+ int i = 0; >+ for (Iterator iterator = allEntries.iterator(); iterator.hasNext();) { >+ Map.Entry entry = (Map.Entry) iterator.next(); >+ summaries[i++] = new Summary((String) entry.getKey(), (IApiProblem[]) entry.getValue()); >+ } >+ if (super.debug) { >+ dumpSummaries(summaries); >+ } >+ return summaries; >+ } >+ >+ private void dumpReport(Summary[] summaries) { >+ for (int i = 0, max = summaries.length; i < max; i++) { >+ Summary summary = summaries[i]; >+ String contents = null; >+ String componentID = summary.fComponentID; >+ >+ try { >+ Document document = Util.newDocument(); >+ Element report = document.createElement(IApiXmlConstants.ELEMENT_API_TOOL_REPORT); >+ report.setAttribute(IApiXmlConstants.ATTR_VERSION, IApiXmlConstants.API_REPORT_CURRENT_VERSION); >+ report.setAttribute(IApiXmlConstants.ATTR_COMPONENT_ID, componentID); >+ document.appendChild(report); >+ >+ Element category = document.createElement(IApiXmlConstants.ATTR_CATEGORY); >+ category.setAttribute(IApiXmlConstants.ATTR_KEY, Integer.toString(IApiProblem.CATEGORY_API_USE_SCAN_PROBLEM)); >+ category.setAttribute(IApiXmlConstants.ATTR_VALUE, COMPATIBILITY); >+ insertAPIProblems(category, document, summary.fApiProblems); >+ report.appendChild(category); >+ >+ contents = Util.serializeDocument(document); >+ } catch (DOMException e) { >+ throw new BuildException(e); >+ } catch (CoreException e) { >+ throw new BuildException(e); >+ } >+ if (contents != null) { >+ saveReport(componentID, contents, "report.xml"); //$NON-NLS-1$ >+ } >+ } >+ >+ } >+ >+ private void reportNonApiBundles(List allNonApiBundles) { >+ if (allNonApiBundles.isEmpty()) { >+ return; >+ } >+ String contents = null; >+ try { >+ Document document = Util.newDocument(); >+ Element report = document.createElement(IApiXmlConstants.ELEMENT_API_TOOL_REPORT); >+ report.setAttribute(IApiXmlConstants.ATTR_VERSION, IApiXmlConstants.API_REPORT_CURRENT_VERSION); >+ document.appendChild(report); >+ >+ for (Iterator iterator = allNonApiBundles.iterator(); iterator.hasNext();) { >+ String bundleName = (String) iterator.next(); >+ Element bundle = document.createElement(IApiXmlConstants.ELEMENT_BUNDLE); >+ bundle.setAttribute(IApiXmlConstants.ATTR_NAME, bundleName); >+ report.appendChild(bundle); >+ } >+ >+ contents = Util.serializeDocument(document); >+ } catch (DOMException e) { >+ throw new BuildException(e); >+ } catch (CoreException e) { >+ throw new BuildException(e); >+ } >+ if (contents != null) { >+ saveReport(".", contents, "allNonApiBundles.xml"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ } >+ >+ public void reportNotSearched(List notSearchedList) { >+ if (notSearchedList.isEmpty()) { >+ return; >+ } >+ BufferedWriter writer = null; >+ try { >+ if (this.debug) { >+ System.out.println("Writing file for projects that were not searched..."); //$NON-NLS-1$ >+ } >+ File rootfile = new File(reportLocation); >+ if (!rootfile.exists()) { >+ rootfile.mkdirs(); >+ } >+ File file = new File(rootfile, "not_searched.xml"); //$NON-NLS-1$ >+ if (!file.exists()) { >+ file.createNewFile(); >+ } >+ Document doc = Util.newDocument(); >+ Element root = doc.createElement(IApiXmlConstants.ELEMENT_COMPONENTS); >+ root.setAttribute("ShowMissing", "false"); //$NON-NLS-1$ //$NON-NLS-2$ >+ doc.appendChild(root); >+ Element comp = null; >+ for (Iterator iterator = notSearchedList.iterator(); iterator.hasNext();) { >+ SkippedComponent component = (SkippedComponent) iterator.next(); >+ comp = doc.createElement(IApiXmlConstants.ELEMENT_COMPONENT); >+ comp.setAttribute(IApiXmlConstants.ATTR_ID, component.getComponentId()); >+ comp.setAttribute(IApiXmlConstants.ATTR_VERSION, component.getVersion()); >+ comp.setAttribute(IApiXmlConstants.SKIPPED_DETAILS, component.getErrorDetails()); >+ root.appendChild(comp); >+ } >+ writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), IApiCoreConstants.UTF_8)); >+ writer.write(Util.serializeDocument(doc)); >+ writer.flush(); >+ } catch (FileNotFoundException fnfe) { >+ } catch (IOException ioe) { >+ } catch (CoreException ce) { >+ } finally { >+ if (writer != null) { >+ try { >+ writer.close(); >+ } catch (IOException e) { >+ } >+ } >+ } >+ } >+ >+ private void dumpSummaries(Summary[] summaries) { >+ System.out.println("=================================================================================="); //$NON-NLS-1$); >+ System.out.println("Summaries"); //$NON-NLS-1$ >+ for (int i = 0, max = summaries.length; i < max; i++) { >+ System.out.println(summaries[i].getTitle()); >+ } >+ for (int i = 0, max = summaries.length; i < max; i++) { >+ System.out.println(summaries[i].getDetails()); >+ } >+ System.out.println("=================================================================================="); //$NON-NLS-1$); >+ } >+ >+ private void insertAPIProblems(Element root, Document document, List problems) throws CoreException { >+ Element apiProblems = document.createElement(IApiXmlConstants.ELEMENT_API_PROBLEMS); >+ root.appendChild(apiProblems); >+ Element element = null; >+ // sort the problem by type name >+ Collections.sort(problems, new Comparator() { >+ public int compare(Object o1, Object o2) { >+ IApiProblem p1 = (IApiProblem) o1; >+ IApiProblem p2 = (IApiProblem) o2; >+ return p1.getTypeName().compareTo(p2.getTypeName()); >+ } >+ }); >+ for (Iterator iterator = problems.iterator(); iterator.hasNext();) { >+ IApiProblem problem = (IApiProblem) iterator.next(); >+ element = document.createElement(IApiXmlConstants.ELEMENT_API_PROBLEM); >+ element.setAttribute(IApiXmlConstants.ATTR_TYPE_NAME, String.valueOf(problem.getTypeName())); >+ element.setAttribute(IApiXmlConstants.ATTR_ID, Integer.toString(problem.getId())); >+ element.setAttribute(IApiXmlConstants.ATTR_LINE_NUMBER, Integer.toString(problem.getLineNumber())); >+ element.setAttribute(IApiXmlConstants.ATTR_CHAR_START, Integer.toString(problem.getCharStart())); >+ element.setAttribute(IApiXmlConstants.ATTR_CHAR_END, Integer.toString(problem.getCharEnd())); >+ element.setAttribute(IApiXmlConstants.ATTR_ELEMENT_KIND, Integer.toString(problem.getElementKind())); >+ element.setAttribute(IApiXmlConstants.ATTR_NAME_ELEMENT_TYPE, ApiProblem.getProblemElementKind(problem.getCategory(), problem.getElementKind())); >+ element.setAttribute(IApiXmlConstants.ATTR_CATEGORY, ApiProblem.getProblemCategory(problem.getCategory())); >+ element.setAttribute(IApiXmlConstants.ATTR_SEVERITY, this.properties.getProperty(ApiProblemFactory.getProblemSeverityId(problem))); >+ element.setAttribute(IApiXmlConstants.ATTR_KIND, Integer.toString(problem.getKind())); >+ element.setAttribute(IApiXmlConstants.ATTR_FLAGS, Integer.toString(problem.getFlags())); >+ element.setAttribute(IApiXmlConstants.ATTR_MESSAGE, problem.getMessage()); >+ String[] extraMarkerAttributeIds = problem.getExtraMarkerAttributeIds(); >+ if (extraMarkerAttributeIds != null && extraMarkerAttributeIds.length != 0) { >+ int length = extraMarkerAttributeIds.length; >+ Object[] extraMarkerAttributeValues = problem.getExtraMarkerAttributeValues(); >+ Element extraArgumentsElement = document.createElement(IApiXmlConstants.ELEMENT_PROBLEM_EXTRA_ARGUMENTS); >+ for (int j = 0; j < length; j++) { >+ Element extraArgumentElement = document.createElement(IApiXmlConstants.ELEMENT_PROBLEM_EXTRA_ARGUMENT); >+ extraArgumentElement.setAttribute(IApiXmlConstants.ATTR_ID, extraMarkerAttributeIds[j]); >+ extraArgumentElement.setAttribute(IApiXmlConstants.ATTR_VALUE, String.valueOf(extraMarkerAttributeValues[j])); >+ extraArgumentsElement.appendChild(extraArgumentElement); >+ } >+ element.appendChild(extraArgumentsElement); >+ } >+ String[] messageArguments = problem.getMessageArguments(); >+ if (messageArguments != null && messageArguments.length != 0) { >+ int length = messageArguments.length; >+ Element messageArgumentsElement = document.createElement(IApiXmlConstants.ELEMENT_PROBLEM_MESSAGE_ARGUMENTS); >+ for (int j = 0; j < length; j++) { >+ Element messageArgumentElement = document.createElement(IApiXmlConstants.ELEMENT_PROBLEM_MESSAGE_ARGUMENT); >+ messageArgumentElement.setAttribute(IApiXmlConstants.ATTR_VALUE, String.valueOf(messageArguments[j])); >+ messageArgumentsElement.appendChild(messageArgumentElement); >+ } >+ element.appendChild(messageArgumentsElement); >+ } >+ apiProblems.appendChild(element); >+ } >+ } >+ >+ /** >+ * Set the debug value. >+ * <p> >+ * The possible values are: <code>true</code>, <code>false</code> >+ * </p> >+ * <p> >+ * Default is <code>false</code>. >+ * </p> >+ * >+ * @param debugValue >+ * the given debug value >+ */ >+ public void setDebug(boolean debugValue) { >+ super.debug = debugValue; >+ } >+ >+ /** >+ * Set the exclude list location. >+ * >+ * <p> >+ * The exclude list is used to know what bundles should excluded from the >+ * xml report generated by the task execution. Lines starting with '#' are >+ * ignored from the excluded elements. >+ * </p> >+ * <p> >+ * The format of the exclude list file looks like this: >+ * </p> >+ * >+ * <pre> >+ * # DOC BUNDLES >+ * org.eclipse.jdt.doc.isv >+ * org.eclipse.jdt.doc.user >+ * org.eclipse.pde.doc.user >+ * org.eclipse.platform.doc.isv >+ * org.eclipse.platform.doc.user >+ * # NON-ECLIPSE BUNDLES >+ * com.ibm.icu >+ * com.jcraft.jsch >+ * javax.servlet >+ * javax.servlet.jsp >+ * ... >+ * </pre> >+ * <p> >+ * The location is set using an absolute path. >+ * </p> >+ * >+ * @param excludeListLocation >+ * the given location for the excluded list file >+ */ >+ public void setExcludeList(String excludeListLocation) { >+ this.excludeListLocation = excludeListLocation; >+ } >+ >+ /** >+ * Set the include list location. >+ * >+ * <p> >+ * The include list is used to know what bundles should included from the >+ * xml report generated by the task execution. Lines starting with '#' are >+ * ignored from the included elements. >+ * </p> >+ * <p> >+ * The format of the include list file looks like this: >+ * </p> >+ * >+ * <pre> >+ * # DOC BUNDLES >+ * org.eclipse.jdt.doc.isv >+ * org.eclipse.jdt.doc.user >+ * org.eclipse.pde.doc.user >+ * org.eclipse.platform.doc.isv >+ * org.eclipse.platform.doc.user >+ * # NON-ECLIPSE BUNDLES >+ * com.ibm.icu >+ * com.jcraft.jsch >+ * javax.servlet >+ * javax.servlet.jsp >+ * ... >+ * </pre> >+ * <p> >+ * The location is set using an absolute path. >+ * </p> >+ * >+ * @param includeListLocation >+ * the given location for the included list file >+ */ >+ public void setIncludeList(String includeListLocation) { >+ this.includeListLocation = includeListLocation; >+ } >+ >+ /** >+ * Set the preferences for the task. >+ * >+ * <p> >+ * The preferences are used to configure problem severities. Problem >+ * severities have three possible values: Ignore, Warning, or Error. The set >+ * of problems detected is defined by corresponding problem preference keys >+ * in API tools. >+ * </p> >+ * <p> >+ * If the given location doesn't exist, the preferences won't be set. >+ * </p> >+ * <p> >+ * Lines starting with '#' are ignored. The format of the preferences file >+ * looks like this: >+ * </p> >+ * >+ * <pre> >+ * #Thu Jan 11 17:03:09 IST 2011 >+ * API_USE_SCAN_TYPE_SEVERITY=Error >+ * API_USE_SCAN_METHOD_SEVERITY=Ignore >+ * API_USE_SCAN_FIELD_SEVERITY=Ignore >+ * </pre> >+ * <p> >+ * The keys can be found in >+ * {@link org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemTypes} >+ * . >+ * </p> >+ * <p> >+ * The location is set using an absolute path. >+ * </p> >+ * >+ * @param preferencesLocation >+ * the location of the preference file >+ */ >+ public void setPreferences(String preferencesLocation) { >+ File preferencesFile = new File(preferencesLocation); >+ if (!preferencesFile.exists()) { >+ return; >+ } >+ BufferedInputStream inputStream = null; >+ try { >+ inputStream = new BufferedInputStream(new FileInputStream(preferencesFile)); >+ Properties temp = new Properties(); >+ temp.load(inputStream); >+ this.properties = temp; >+ } catch (IOException e) { >+ // ignore >+ } finally { >+ if (inputStream != null) { >+ try { >+ inputStream.close(); >+ } catch (IOException e) { >+ // ignore >+ } >+ } >+ } >+ } >+ >+ /** >+ * Set the location of the current product or baseline that you want to >+ * compare against the reference baseline. >+ * >+ * <p> >+ * It can be a .zip, .jar, .tgz, .tar.gz file, or a directory that >+ * corresponds to the Eclipse installation folder. This is the directory is >+ * which you can find the Eclipse executable. >+ * </p> >+ * >+ * @param baselineLocation >+ * the given location for the baseline to analyze >+ */ >+ public void setProfile(String baselineLocation) { >+ this.currentBaselineLocation = baselineLocation; >+ } >+ >+ /** >+ * Comma-separated list of the locations of the API Use Scans that you want >+ * to check against the reference baseline. >+ * >+ * <p> >+ * It can be a .zip, .jar, .tgz, .tar.gz file, or a directory that >+ * corresponds to the API Use Scan report. This is the directory is which >+ * you can find the XML folder. >+ * </p> >+ * >+ * @param baselineLocation >+ * the given location for the baseline to analyze >+ */ >+ public void setAPIUseScans(String apiUseScans) { >+ this.apiUseScans = apiUseScans; >+ this.apiUseScanArray = apiUseScans.split(","); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Set the output location where the reports will be generated. >+ * >+ * <p> >+ * Once the task is completed, reports are available in this directory using >+ * a structure similar to the filter root. A sub-folder is created for each >+ * component that has problems to be reported. Each sub-folder contains a >+ * file called "report.xml". >+ * </p> >+ * >+ * <p> >+ * A special folder called "allNonApiBundles" is also created in this folder >+ * that contains a xml file called "report.xml". This file lists all the >+ * bundles that are not using the api tooling nature. >+ * </p> >+ * >+ * @param baselineLocation >+ * the given location for the reference baseline to analyze >+ */ >+ public void setReport(String reportLocation) { >+ this.reportLocation = reportLocation; >+ } >+} >Index: src_ant/org/eclipse/pde/api/tools/internal/tasks/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/messages.properties,v >retrieving revision 1.47 >diff -u -r1.47 messages.properties >--- src_ant/org/eclipse/pde/api/tools/internal/tasks/messages.properties 31 Jan 2011 18:08:32 -0000 1.47 >+++ src_ant/org/eclipse/pde/api/tools/internal/tasks/messages.properties 3 Mar 2011 14:44:00 -0000 >@@ -212,4 +212,9 @@ > </html>\n > deprecationReportTask_missingXmlFileLocation=Missing the xml file location argument > deltaReportTask_xmlFileLocationShouldHaveAnXMLExtension=The report location must be an xml file location >-deltaReportTask_htmlFileLocationShouldHaveAnHtmlExtension=The report location must be an html file location >\ No newline at end of file >+deltaReportTask_htmlFileLocationShouldHaveAnHtmlExtension=The report location must be an html file location >+MissingRefProblemsTask_invalidApiUseScanLocation=Invalid API Use Scan location: >+MissingRefProblemsTask_missingArguments=Missing arguments:\n\ >+profile location : {0}\n\ >+api use scan locations : {1}\n\ >+report location : {2} >Index: xslt/notsearched.xsl >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/xslt/notsearched.xsl,v >retrieving revision 1.4 >diff -u -r1.4 notsearched.xsl >--- xslt/notsearched.xsl 13 Jan 2010 18:08:34 -0000 1.4 >+++ xslt/notsearched.xsl 3 Mar 2011 14:44:00 -0000 >@@ -56,9 +56,12 @@ > </h3> > <xsl:choose> > <xsl:when test="count(components/component) > 0"> >+ <xsl:variable name="ShowMissing" select="components/@ShowMissing" /> >+ <xsl:if test="$ShowMissing != 'false'"> > <p> > A summary of the missing required bundles is <a href="missing.html">available here</a>. > </p> >+ </xsl:if> > <p> > Click an entry in the table below to reveal the details of why it was not searched. > </p>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 332763
:
188475
|
190273
|
190395