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 188475 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]
first cut
20110204.txt (text/plain), 35.76 KB, created by
Ankur Sharma
on 2011-02-07 15:46:59 EST
(
hide
)
Description:
first cut
Filename:
MIME Type:
Creator:
Ankur Sharma
Created:
2011-02-07 15:46:59 EST
Size:
35.76 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 4 Feb 2011 17:00:52 -0000 >@@ -224,6 +224,11 @@ > library="lib/apitooling-ant.jar" > name="apitooling.analysis_reportconversion"> > </antTask> >+ <antTask >+ class="org.eclipse.pde.api.tools.internal.tasks.APIUseScanTask" >+ library="lib/apitooling-ant.jar" >+ name="apitooling.apiusescan"> >+ </antTask> > <antTask > class="org.eclipse.pde.api.tools.internal.tasks.ApiUseTask" > 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.126 >diff -u -r1.126 BaseApiAnalyzer.java >--- src/org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer.java 13 Dec 2010 17:39:27 -0000 1.126 >+++ src/org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer.java 4 Feb 2011 17:00:52 -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 >@@ -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,10 +305,10 @@ > * @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); > if (DEBUG) { > System.out.println("Fetching external dependencies for the types : " + Arrays.asList(apiUseTypes)); //$NON-NLS-1$ >@@ -367,19 +367,34 @@ > } > } > >- public boolean isSeverityEnabled() { >- IEclipsePreferences node = (new InstanceScope()).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; >+ public boolean isSeverityEnabled(Properties properties) { >+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode(ApiPlugin.PLUGIN_ID); >+ 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_ant/org/eclipse/pde/api/tools/internal/tasks/APIUseScanTask.java >=================================================================== >RCS file: src_ant/org/eclipse/pde/api/tools/internal/tasks/APIUseScanTask.java >diff -N src_ant/org/eclipse/pde/api/tools/internal/tasks/APIUseScanTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/pde/api/tools/internal/tasks/APIUseScanTask.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,688 @@ >+/******************************************************************************* >+ * 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.File; >+import java.io.FileInputStream; >+import java.io.IOException; >+import java.io.PrintWriter; >+import java.io.StringWriter; >+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.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.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.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 APIUseScanTask extends CommonUtilsTask { >+ >+ private FilteredElements fExcludedElements; >+ private FilteredElements fIncludedElements; >+ private String fFilters; >+ private String[] fAPIUseScans; >+ private Properties fProperties = new Properties(); >+ >+// public static final String BUNDLE_VERSION = "bundleVersion"; //$NON-NLS-1$ >+ public static final String COMPATIBILITY = "compatibility"; //$NON-NLS-1$ >+// public static final String USAGE = "usage"; //$NON-NLS-1$ >+ >+ private static final Summary[] NO_SUMMARIES = new Summary[0]; >+ >+ private static class Summary { >+// List apiBundleVersionProblems = new ArrayList(); >+// List apiCompatibilityProblems = new ArrayList(); >+// List apiUsageProblems = new ArrayList(); >+ String fComponentID; >+ List fApiProblems; >+ >+ public Summary(String componentID, IApiProblem[] apiProblems) { >+ fComponentID = componentID; >+ fApiProblems = Arrays.asList(apiProblems); >+// for (int i = 0, max = apiProblems.length; i < max; i++) { >+// IApiProblem problem = apiProblems[i]; >+// switch (problem.getCategory()) { >+// case IApiProblem.CATEGORY_COMPATIBILITY : >+// apiCompatibilityProblems.add(problem); >+// break; >+// case IApiProblem.CATEGORY_USAGE : >+// apiUsageProblems.add(problem); >+// break; >+// case IApiProblem.CATEGORY_VERSION : >+// apiBundleVersionProblems.add(problem); >+// } >+// } >+ } >+ >+ 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('('); >+ printWriter.print("total: "); //$NON-NLS-1$ >+ printWriter.print(fApiProblems.size()); >+ printWriter.println(')'); >+ } >+ >+ public String toString() { >+ StringWriter writer = new StringWriter(); >+ PrintWriter printWriter = new PrintWriter(writer); >+ printTitle(printWriter); >+ >+ dumpProblems("All Problems",printWriter); //$NON-NLS-1$ >+ >+ printWriter.flush(); >+ printWriter.close(); >+ return String.valueOf(writer.getBuffer()); >+ } >+ } >+ >+ /** >+ * Run the api tools verification 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) { >+ StringWriter out = new StringWriter(); >+ PrintWriter writer = new PrintWriter(out); >+ writer.println(NLS.bind(Messages.printArguments, // TODO put new message >+ new String[] {super.currentBaselineLocation, super.reportLocation,})); >+ writer.flush(); >+ writer.close(); >+ throw new BuildException(String.valueOf(out.getBuffer())); >+ } >+ 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 (this.fFilters != null) { >+ System.out.println("filter store : " + this.fFilters); //$NON-NLS-1$ >+ } else { >+ System.out.println("No filter store"); //$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(); >+ } >+ // run the comparison >+ // create baseline for the reference >+ IApiBaseline currentBaseline = createBaseline(CURRENT_BASELINE_NAME, baselineInstallDir.getAbsolutePath(), super.eeFileLocation); >+ if (super.debug) { //TODO >+ System.out.println("Creation of baseline : " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ >+ time = System.currentTimeMillis(); >+ } >+ >+ if (this.excludeListLocation != null) { >+ this.fExcludedElements = CommonUtilsTask.initializeFilteredElements(this.excludeListLocation, currentBaseline, super.debug); >+ if (super.debug) { >+ System.out.println("===================================================================================="); //$NON-NLS-1$ >+ System.out.println("Excluded elements list:"); //$NON-NLS-1$ >+ System.out.println(this.fExcludedElements); >+ } >+ } >+ if (this.includeListLocation != null) { >+ this.fIncludedElements = CommonUtilsTask.initializeFilteredElements(this.includeListLocation, currentBaseline, super.debug); >+ if (super.debug) { >+ System.out.println("===================================================================================="); //$NON-NLS-1$ >+ System.out.println("Included elements list:"); //$NON-NLS-1$ >+ System.out.println(this.fIncludedElements); >+ } >+ } >+ >+ UseScanManager.getInstance().setReportLocations(fAPIUseScans); >+ >+ if (super.debug) { >+ System.out.println("===================================================================================="); //$NON-NLS-1$ >+ System.out.println("API Use Scan locations:"); //$NON-NLS-1$ >+ for (int i = 0; i < fAPIUseScans.length; i++) { >+ System.out.println("Location " + i + " : " + fAPIUseScans[i]); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ } >+ >+ Map allProblems = new HashMap(); >+ List allNonApiBundles = new ArrayList(); >+ List allApiBundles = new ArrayList(); >+ try { >+ IApiComponent[] apiComponents = currentBaseline.getApiComponents(); >+ int length = apiComponents.length; >+ Set visitedApiComponentNames = new HashSet(); >+ for (int i = 0; i < length; i++) { >+ IApiComponent apiComponent = apiComponents[i]; >+ String name = apiComponent.getSymbolicName(); >+ visitedApiComponentNames.add(name); >+ if (apiComponent.isSystemComponent()) { >+ continue; >+ } >+ if (!Util.isApiToolsComponent(apiComponent)) { >+ allNonApiBundles.add(name); >+ continue; >+ } >+ >+ allApiBundles.add(name); >+ BaseApiAnalyzer analyzer = new BaseApiAnalyzer(); >+ try { >+ BaseApiAnalyzer.setDebug(super.debug); >+ analyzer.checkExternalDependencies(apiComponent, new BuildContext(), this.fProperties, 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("Total number of api tools components in current baseline :" + allApiBundles.size()); //$NON-NLS-1$ >+ System.out.println("Details:"); //$NON-NLS-1$ >+ Collections.sort(allApiBundles); >+ for (Iterator iterator = allApiBundles.iterator(); iterator.hasNext();) { >+ System.out.println(iterator.next()); >+ } >+ 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(); >+ } >+ currentBaseline.dispose(); >+ StubApiComponent.disposeAllCaches(); >+ deleteBaseline(super.currentBaselineLocation, baselineInstallDir); >+ if (super.debug) { >+ System.out.println("Cleanup : " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ } >+ Summary[] summaries = createAllSummaries(allProblems); >+ >+ try { >+ dumpReport(summaries, allNonApiBundles); >+ } catch (RuntimeException e) { >+ ApiPlugin.log(e); >+ throw 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, List bundlesNames) { >+ for (int i = 0, max = summaries.length; i < max; i++) { >+ Summary summary = summaries[i]; >+ String contents = null; >+ String componentID = summary.fComponentID; >+ if (this.fExcludedElements != null && (this.fExcludedElements.containsExactMatch(componentID) || this.fExcludedElements.containsPartialMatch(componentID))) { >+ continue; >+ } >+ if (this.fIncludedElements != null && !this.fIncludedElements.isEmpty() && !(this.fIncludedElements.containsExactMatch(componentID) || this.fIncludedElements.containsPartialMatch(componentID))) { >+ continue; >+ } >+ 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$ >+ } >+ } >+ if (bundlesNames != null && bundlesNames.size() != 0) { >+ 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 = bundlesNames.iterator(); iterator.hasNext();) { >+ String bundleName = (String) iterator.next(); >+ if (this.fExcludedElements == null || !this.fExcludedElements.containsPartialMatch(bundleName) && (this.fIncludedElements == null || this.fIncludedElements.isEmpty() || this.fIncludedElements.containsPartialMatch(bundleName))) { >+ 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("allNonApiBundles", contents, "report.xml"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ } >+ } >+ >+ 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$); >+ } >+ >+ /** >+ * Returns an element that contains all the api problem nodes. >+ * >+ * @param document the given xml document >+ * @param problems the given problem to dump into the document >+ * @return an element that contains all the api problem nodes or null if an error occured >+ */ >+ 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_SEVERITY, Integer.toString(getSeverity(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); >+ } >+ } >+ >+ /** >+ * By default, we return a warning severity. >+ * @param problem the given problem >+ * @return the problem's severity >+ */ >+ private int getSeverity(IApiProblem problem) { >+ if (this.fProperties != null) { >+ String key = ApiProblemFactory.getProblemSeverityId(problem); >+ if (key != null) { >+ String value = this.fProperties.getProperty(key, null); >+ if (value != null) { >+ if (ApiPlugin.VALUE_ERROR.equals(value)) { >+ return ApiPlugin.SEVERITY_ERROR; >+ } >+ } >+ } >+ } >+ return ApiPlugin.SEVERITY_WARNING; >+ } >+ >+ /** >+ * 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) { >+ super.debug = Boolean.toString(true).equals(debugValue); >+ } >+ >+ /** >+ * Set the execution environment file to use. >+ * <p>By default, an execution environment file corresponding to a JavaSE-1.6 execution environment >+ * is used.</p> >+ * <p>The file is specified using an absolute path. This is optional.</p> >+ * >+ * @param eeFileLocation the given execution environment file >+ */ >+ public void setEEFile(String eeFileLocation) { >+ this.eeFileLocation = eeFileLocation; >+ } >+ >+ /** >+ * 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 root directory of API fFilters to use during the analysis. >+ * >+ * <p>The argument is the root directory of the .api_filters files that should be used to filter potential >+ * problems created by the api tooling analysis. The root needs to contain the following structure:</p> >+ * <pre> >+ * root >+ * | >+ * +-- component name (i.e. org.eclipse.jface) >+ * | >+ * +--- .api_filters >+ * </pre> >+ * >+ * @param fFilters the root of the .api_filters files >+ */ >+ public void setFilters(String filters) { >+ this.fFilters = filters; >+ } >+ >+ /** >+ * 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.fProperties = 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) { >+ fAPIUseScans = apiUseScans.split(";"); //$NON-NLS-1$ >+ } >+ >+ /* *//** >+ * Set the location of 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> >+ * <p>The location is set using an absolute path.</p> >+ * >+ * @param baselineLocation the given location for the reference baseline to analyze >+ */ >+ /* >+ public void setBaseline(String baselineLocation) { >+ this.referenceBaselineLocation = baselineLocation; >+ }*/ >+ /** >+ * 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; >+ } >+}
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