### Eclipse Workspace Patch 1.0
#P org.eclipse.pde.api.tools
Index: src/org/eclipse/pde/api/tools/internal/ApiBaselineManager.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiBaselineManager.java,v
retrieving revision 1.14
diff -u -r1.14 ApiBaselineManager.java
--- src/org/eclipse/pde/api/tools/internal/ApiBaselineManager.java 14 Jul 2009 02:03:01 -0000 1.14
+++ src/org/eclipse/pde/api/tools/internal/ApiBaselineManager.java 30 Nov 2009 15:41:43 -0000
@@ -23,6 +23,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -59,6 +60,7 @@
import org.eclipse.pde.api.tools.internal.model.ApiModelCache;
import org.eclipse.pde.api.tools.internal.model.ApiModelFactory;
import org.eclipse.pde.api.tools.internal.model.StubApiComponent;
+import org.eclipse.pde.api.tools.internal.model.WorkspaceBaseline;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.IApiBaselineManager;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline;
@@ -66,6 +68,7 @@
import org.eclipse.pde.api.tools.internal.util.Util;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.core.plugin.PluginRegistry;
+import org.eclipse.pde.internal.core.DependencyManager;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -403,7 +406,7 @@
IApiComponent comp = components[i];
if (!comp.isSystemComponent()) {
celement = document.createElement(IApiXmlConstants.ELEMENT_APICOMPONENT);
- celement.setAttribute(IApiXmlConstants.ATTR_ID, comp.getId());
+ celement.setAttribute(IApiXmlConstants.ATTR_ID, comp.getSymbolicName());
celement.setAttribute(IApiXmlConstants.ATTR_VERSION, comp.getVersion());
celement.setAttribute(IApiXmlConstants.ATTR_LOCATION, new Path(comp.getLocation()).toPortableString());
root.appendChild(celement);
@@ -665,14 +668,19 @@
long time = System.currentTimeMillis();
IApiBaseline baseline = null;
try {
- baseline = ApiModelFactory.newApiBaseline(ApiBaselineManager.WORKSPACE_API_BASELINE_ID);
+ baseline = new WorkspaceBaseline();
// populate it with only projects that are API aware
- IPluginModelBase[] models = PluginRegistry.getActiveModels();
- List componentsList = new ArrayList(models.length);
+ Set ids = DependencyManager.getSelfandDependencies(PluginRegistry.getWorkspaceModels(), null);
+ List componentsList = new ArrayList(ids.size());
IApiComponent apiComponent = null;
- for (int i = 0, length = models.length; i < length; i++) {
+ IPluginModelBase model = null;
+ for (Iterator iter = ids.iterator(); iter.hasNext();) {
+ model = PluginRegistry.findModel((String) iter.next());
+ if(model == null) {
+ continue;
+ }
try {
- apiComponent = ApiModelFactory.newApiComponent(baseline, models[i]);
+ apiComponent = ApiModelFactory.newApiComponent(baseline, model);
if (apiComponent != null) {
componentsList.add(apiComponent);
}
@@ -683,7 +691,7 @@
baseline.addApiComponents((IApiComponent[]) componentsList.toArray(new IApiComponent[componentsList.size()]));
} finally {
if (DEBUG) {
- System.out.println("Time to create a workspace profile : " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println("Time to create a workspace baseline : " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
return baseline;
Index: src/org/eclipse/pde/api/tools/internal/ApiDescriptionManager.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiDescriptionManager.java,v
retrieving revision 1.32
diff -u -r1.32 ApiDescriptionManager.java
--- src/org/eclipse/pde/api/tools/internal/ApiDescriptionManager.java 21 Aug 2009 18:51:11 -0000 1.32
+++ src/org/eclipse/pde/api/tools/internal/ApiDescriptionManager.java 30 Nov 2009 15:41:43 -0000
@@ -41,7 +41,7 @@
import org.eclipse.pde.api.tools.internal.ApiDescription.ManifestNode;
import org.eclipse.pde.api.tools.internal.ProjectApiDescription.TypeNode;
import org.eclipse.pde.api.tools.internal.model.ApiModelCache;
-import org.eclipse.pde.api.tools.internal.model.PluginProjectApiComponent;
+import org.eclipse.pde.api.tools.internal.model.ProjectComponent;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.Factory;
import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
@@ -118,7 +118,7 @@
* @param project Java project
* @return API description
*/
- public synchronized IApiDescription getApiDescription(PluginProjectApiComponent component, BundleDescription bundle) {
+ public synchronized IApiDescription getApiDescription(ProjectComponent component, BundleDescription bundle) {
IJavaProject project = component.getJavaProject();
ProjectApiDescription description = (ProjectApiDescription) fDescriptions.get(project);
if (description == null) {
Index: src/org/eclipse/pde/api/tools/internal/ApiDescriptionXmlCreator.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiDescriptionXmlCreator.java,v
retrieving revision 1.1
diff -u -r1.1 ApiDescriptionXmlCreator.java
--- src/org/eclipse/pde/api/tools/internal/ApiDescriptionXmlCreator.java 24 Apr 2009 19:57:41 -0000 1.1
+++ src/org/eclipse/pde/api/tools/internal/ApiDescriptionXmlCreator.java 30 Nov 2009 15:41:43 -0000
@@ -72,7 +72,7 @@
* @throws CoreException if unable to construct the visitor
*/
public ApiDescriptionXmlCreator(IApiComponent component) throws CoreException {
- this(component.getName(), component.getId());
+ this(component.getName(), component.getSymbolicName());
}
/**
Index: src/org/eclipse/pde/api/tools/internal/ProjectApiDescription.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ProjectApiDescription.java,v
retrieving revision 1.37
diff -u -r1.37 ProjectApiDescription.java
--- src/org/eclipse/pde/api/tools/internal/ProjectApiDescription.java 21 Aug 2009 18:51:11 -0000 1.37
+++ src/org/eclipse/pde/api/tools/internal/ProjectApiDescription.java 30 Nov 2009 15:41:43 -0000
@@ -33,8 +33,8 @@
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.pde.api.tools.internal.model.BundleApiComponent;
-import org.eclipse.pde.api.tools.internal.model.PluginProjectApiComponent;
+import org.eclipse.pde.api.tools.internal.model.BundleComponent;
+import org.eclipse.pde.api.tools.internal.model.ProjectComponent;
import org.eclipse.pde.api.tools.internal.provisional.ApiDescriptionVisitor;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.Factory;
@@ -563,8 +563,8 @@
for (int i = 0; i < fragments.length; i++) {
names.add(fragments[i].getElementName());
}
- PluginProjectApiComponent component = getApiComponent();
- BundleApiComponent.initializeApiDescription(this, component.getBundleDescription(), names);
+ ProjectComponent component = getApiComponent();
+ BundleComponent.initializeApiDescription(this, component.getBundleDescription(), names);
fPackageTimeStamp = fManifestFile.getModificationStamp();
} catch (CoreException e) {
ApiPlugin.log(e.getStatus());
@@ -712,9 +712,9 @@
* @return API component
* @exception CoreException if the API component cannot be located
*/
- private PluginProjectApiComponent getApiComponent() throws CoreException {
+ private ProjectComponent getApiComponent() throws CoreException {
IApiBaseline baseline = ApiBaselineManager.getManager().getWorkspaceBaseline();
- PluginProjectApiComponent component = (PluginProjectApiComponent) baseline.getApiComponent(getJavaProject().getProject());
+ ProjectComponent component = (ProjectComponent) baseline.getApiComponent(getJavaProject().getProject());
if (component == null) {
throw new CoreException(new Status(IStatus.ERROR, ApiPlugin.PLUGIN_ID, "Unable to resolve project API component for API description")); //$NON-NLS-1$
}
Index: src/org/eclipse/pde/api/tools/internal/builder/AbstractIllegalMethodReference.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractIllegalMethodReference.java,v
retrieving revision 1.5
diff -u -r1.5 AbstractIllegalMethodReference.java
--- src/org/eclipse/pde/api/tools/internal/builder/AbstractIllegalMethodReference.java 5 Aug 2009 16:46:12 -0000 1.5
+++ src/org/eclipse/pde/api/tools/internal/builder/AbstractIllegalMethodReference.java 30 Nov 2009 15:41:43 -0000
@@ -72,7 +72,7 @@
IApiMember method = reference.getResolvedReference();
String componentId = (String) fMethodComponents.get(method.getHandle());
// TODO: would it be faster to store component objects and use identity instead of equals?
- return componentId != null && method.getApiComponent().getId().equals(componentId);
+ return componentId != null && method.getApiComponent().getSymbolicName().equals(componentId);
}
/* (non-Javadoc)
Index: src/org/eclipse/pde/api/tools/internal/builder/AbstractIllegalTypeReference.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractIllegalTypeReference.java,v
retrieving revision 1.7
diff -u -r1.7 AbstractIllegalTypeReference.java
--- src/org/eclipse/pde/api/tools/internal/builder/AbstractIllegalTypeReference.java 5 Aug 2009 16:46:12 -0000 1.7
+++ src/org/eclipse/pde/api/tools/internal/builder/AbstractIllegalTypeReference.java 30 Nov 2009 15:41:43 -0000
@@ -79,7 +79,7 @@
}
IApiMember type = reference.getResolvedReference();
Object componentId = fIllegalTypes.get(type.getName());
- return componentId != null && type.getApiComponent().getId().equals(componentId);
+ return componentId != null && type.getApiComponent().getSymbolicName().equals(componentId);
}
/* (non-Javadoc)
* @see org.eclipse.pde.api.tools.internal.search.AbstractProblemDetector#getSourceRange(org.eclipse.jdt.core.IType, org.eclipse.jface.text.IDocument, org.eclipse.pde.api.tools.internal.provisional.model.IReference)
Index: src/org/eclipse/pde/api/tools/internal/builder/AbstractProblemDetector.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractProblemDetector.java,v
retrieving revision 1.13
diff -u -r1.13 AbstractProblemDetector.java
--- src/org/eclipse/pde/api/tools/internal/builder/AbstractProblemDetector.java 29 Apr 2009 15:12:19 -0000 1.13
+++ src/org/eclipse/pde/api/tools/internal/builder/AbstractProblemDetector.java 30 Nov 2009 15:41:43 -0000
@@ -31,7 +31,7 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position;
-import org.eclipse.pde.api.tools.internal.model.PluginProjectApiComponent;
+import org.eclipse.pde.api.tools.internal.model.ProjectComponent;
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.IApiMarkerConstants;
@@ -368,8 +368,8 @@
try {
IApiProblem problem = null;
IApiComponent component = reference.getMember().getApiComponent();
- if (component instanceof PluginProjectApiComponent) {
- PluginProjectApiComponent ppac = (PluginProjectApiComponent) component;
+ if (component instanceof ProjectComponent) {
+ ProjectComponent ppac = (ProjectComponent) component;
IJavaProject project = ppac.getJavaProject();
problem = createProblem(reference, project);
} else {
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.106
diff -u -r1.106 BaseApiAnalyzer.java
--- src/org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer.java 24 Aug 2009 16:43:15 -0000 1.106
+++ src/org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer.java 30 Nov 2009 15:41:43 -0000
@@ -59,7 +59,7 @@
import org.eclipse.pde.api.tools.internal.ApiFilterStore;
import org.eclipse.pde.api.tools.internal.IApiCoreConstants;
import org.eclipse.pde.api.tools.internal.comparator.Delta;
-import org.eclipse.pde.api.tools.internal.model.PluginProjectApiComponent;
+import org.eclipse.pde.api.tools.internal.model.ProjectComponent;
import org.eclipse.pde.api.tools.internal.problems.ApiProblemFactory;
import org.eclipse.pde.api.tools.internal.problems.ApiProblemFilter;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
@@ -218,14 +218,14 @@
}
boolean checkfilters = false;
if(baseline != null) {
- IApiComponent reference = baseline.getApiComponent(component.getId());
+ IApiComponent reference = baseline.getApiComponent(component.getSymbolicName());
this.fBuildState = state;
if(fBuildState == null) {
fBuildState = getBuildState();
}
//compatibility checks
if(reference != null) {
- localMonitor.subTask(NLS.bind(BuilderMessages.BaseApiAnalyzer_comparing_api_profiles, new String[] {reference.getId(), baseline.getName()}));
+ localMonitor.subTask(NLS.bind(BuilderMessages.BaseApiAnalyzer_comparing_api_profiles, new String[] {reference.getSymbolicName(), baseline.getName()}));
if(bcontext.hasChangedTypes()) {
String[] changedtypes = bcontext.getStructurallyChangedTypes();
for(int i = 0; i < changedtypes.length; i++) {
@@ -242,7 +242,7 @@
}
this.fBuildState.setReexportedComponents(Util.getReexportedComponents(component));
} else {
- localMonitor.subTask(NLS.bind(BuilderMessages.BaseApiAnalyzer_comparing_api_profiles, new String[] {component.getId(), baseline.getName()}));
+ localMonitor.subTask(NLS.bind(BuilderMessages.BaseApiAnalyzer_comparing_api_profiles, new String[] {component.getSymbolicName(), baseline.getName()}));
checkCompatibility(null, component, localMonitor.newChild(1));
Util.updateMonitor(localMonitor);
}
@@ -823,7 +823,7 @@
}
scope = getSearchScope(component, (String[]) typenames.toArray(new String[typenames.size()]));
}
- SubMonitor localMonitor = SubMonitor.convert(monitor, MessageFormat.format(BuilderMessages.checking_api_usage, new String[] {component.getId()}), 2);
+ SubMonitor localMonitor = SubMonitor.convert(monitor, MessageFormat.format(BuilderMessages.checking_api_usage, new String[] {component.getSymbolicName()}), 2);
ReferenceAnalyzer analyzer = new ReferenceAnalyzer();
try {
long start = System.currentTimeMillis();
@@ -858,9 +858,9 @@
* @param monitor
*/
private void checkCompatibility(final String typeName, final IApiComponent reference, final IApiComponent component, IProgressMonitor monitor) throws CoreException {
- String id = component.getId();
+ String id = component.getSymbolicName();
if (DEBUG) {
- System.out.println("comparing profiles ["+reference.getId()+"] and ["+id+"] for type ["+typeName+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ System.out.println("comparing profiles ["+reference.getSymbolicName()+"] and ["+id+"] for type ["+typeName+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
IApiTypeRoot classFile = null;
try {
@@ -884,7 +884,7 @@
while (classFile == null && index < providers.length) {
IApiComponent p = providers[index];
if (!p.equals(component)) {
- String id2 = p.getId();
+ String id2 = p.getSymbolicName();
if (Util.ORG_ECLIPSE_SWT.equals(id2)) {
classFile = p.findTypeRoot(typeName);
} else {
@@ -1011,15 +1011,15 @@
IDelta.ADDED,
IDelta.API_COMPONENT,
null,
- component.getId(),
- component.getId());
+ component.getSymbolicName(),
+ component.getSymbolicName());
Util.updateMonitor(localmonitor, 5);
} else {
try {
delta = ApiComparator.compare(reference, component, VisibilityModifiers.API, localmonitor.newChild(1));
} finally {
if (DEBUG) {
- System.out.println("Time spent for " + component.getId() + " : " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ System.out.println("Time spent for " + component.getSymbolicName() + " : " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
fPendingDeltaInfos.clear();
}
@@ -1350,7 +1350,7 @@
private void createApiComponentResolutionProblem(final IApiComponent component, final String message) throws CoreException {
IApiProblem problem = ApiProblemFactory.newApiComponentResolutionProblem(
Path.EMPTY.toPortableString(),
- new String[] {component.getId(), message },
+ new String[] {component.getSymbolicName(), message },
new String[] {IApiMarkerConstants.API_MARKER_ATTR_ID},
new Object[] {new Integer(IApiMarkerConstants.API_COMPONENT_RESOLUTION_MARKER_ID)},
IElementDescriptor.RESOURCE,
@@ -1377,7 +1377,7 @@
IApiTypeRoot typeRoot = null;
IApiType type = null;
try {
- String id = component.getId();
+ String id = component.getSymbolicName();
if (Util.ORG_ECLIPSE_SWT.equals(id)) {
typeRoot = component.findTypeRoot(typeName);
} else {
@@ -1391,7 +1391,7 @@
while (typeRoot == null && index < providers.length) {
IApiComponent p = providers[index];
if (!p.equals(component)) {
- String id2 = p.getId();
+ String id2 = p.getSymbolicName();
if (Util.ORG_ECLIPSE_SWT.equals(id2)) {
typeRoot = p.findTypeRoot(typeName);
} else {
@@ -1496,8 +1496,8 @@
Version compversion = new Version(compversionval);
Version newversion = null;
if (DEBUG) {
- System.out.println("reference version of " + reference.getId() + " : " + refversion); //$NON-NLS-1$ //$NON-NLS-2$
- System.out.println("component version of " + component.getId() + " : " + compversion); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println("reference version of " + reference.getSymbolicName() + " : " + refversion); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println("component version of " + component.getSymbolicName() + " : " + compversion); //$NON-NLS-1$ //$NON-NLS-2$
}
IDelta[] breakingChanges = fBuildState.getBreakingChanges();
if (breakingChanges.length != 0) {
@@ -1835,8 +1835,8 @@
* @return Java project or null
*/
private IJavaProject getJavaProject(IApiComponent component) {
- if (component instanceof PluginProjectApiComponent) {
- PluginProjectApiComponent pp = (PluginProjectApiComponent) component;
+ if (component instanceof ProjectComponent) {
+ ProjectComponent pp = (ProjectComponent) component;
return pp.getJavaProject();
}
return null;
Index: src/org/eclipse/pde/api/tools/internal/builder/BuildState.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/BuildState.java,v
retrieving revision 1.14
diff -u -r1.14 BuildState.java
--- src/org/eclipse/pde/api/tools/internal/builder/BuildState.java 5 Aug 2009 16:46:12 -0000 1.14
+++ src/org/eclipse/pde/api/tools/internal/builder/BuildState.java 30 Nov 2009 15:41:43 -0000
@@ -315,7 +315,7 @@
final int length = components.length;
String[] result = new String[length];
for (int i = 0; i < length; i++) {
- result[i] = components[i].getId();
+ result[i] = components[i].getSymbolicName();
}
this.reexportedComponents = result;
}
Index: src/org/eclipse/pde/api/tools/internal/builder/IllegalFieldReferenceDetector.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/IllegalFieldReferenceDetector.java,v
retrieving revision 1.9
diff -u -r1.9 IllegalFieldReferenceDetector.java
--- src/org/eclipse/pde/api/tools/internal/builder/IllegalFieldReferenceDetector.java 21 Sep 2009 19:13:17 -0000 1.9
+++ src/org/eclipse/pde/api/tools/internal/builder/IllegalFieldReferenceDetector.java 30 Nov 2009 15:41:43 -0000
@@ -144,6 +144,6 @@
return false;
}
Object componentId = fFieldComponents.get(reference.getResolvedReference().getHandle());
- return componentId != null && reference.getResolvedReference().getApiComponent().getId().equals(componentId);
+ return componentId != null && reference.getResolvedReference().getApiComponent().getSymbolicName().equals(componentId);
}
}
Index: src/org/eclipse/pde/api/tools/internal/builder/ProblemDetectorBuilder.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ProblemDetectorBuilder.java,v
retrieving revision 1.4
diff -u -r1.4 ProblemDetectorBuilder.java
--- src/org/eclipse/pde/api/tools/internal/builder/ProblemDetectorBuilder.java 5 Aug 2009 16:46:12 -0000 1.4
+++ src/org/eclipse/pde/api/tools/internal/builder/ProblemDetectorBuilder.java 30 Nov 2009 15:41:43 -0000
@@ -16,7 +16,7 @@
import java.util.Set;
import org.eclipse.core.resources.IProject;
-import org.eclipse.pde.api.tools.internal.model.PluginProjectApiComponent;
+import org.eclipse.pde.api.tools.internal.model.ProjectComponent;
import org.eclipse.pde.api.tools.internal.provisional.ApiDescriptionVisitor;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.IApiAnnotations;
@@ -86,22 +86,22 @@
default:
if (!RestrictionModifiers.isUnrestricted(mask)) {
if(RestrictionModifiers.isOverrideRestriction(mask) && fIllegalOverride != null) {
- fIllegalOverride.addIllegalMethod((IMethodDescriptor) element, fComponent.getId());
+ fIllegalOverride.addIllegalMethod((IMethodDescriptor) element, fComponent.getSymbolicName());
}
if (RestrictionModifiers.isExtendRestriction(mask) && fIllegalExtends != null) {
- fIllegalExtends.addIllegalType((IReferenceTypeDescriptor) element, fComponent.getId());
+ fIllegalExtends.addIllegalType((IReferenceTypeDescriptor) element, fComponent.getSymbolicName());
}
if (RestrictionModifiers.isImplementRestriction(mask) && fIllegalImplements != null) {
- fIllegalImplements.addIllegalType((IReferenceTypeDescriptor) element, fComponent.getId());
+ fIllegalImplements.addIllegalType((IReferenceTypeDescriptor) element, fComponent.getSymbolicName());
}
if (RestrictionModifiers.isInstantiateRestriction(mask) && fIllegalInstantiate != null) {
- fIllegalInstantiate.addIllegalType((IReferenceTypeDescriptor) element, fComponent.getId());
+ fIllegalInstantiate.addIllegalType((IReferenceTypeDescriptor) element, fComponent.getSymbolicName());
}
if (RestrictionModifiers.isReferenceRestriction(mask)) {
if (element.getElementType() == IElementDescriptor.METHOD && fIllegalMethodRef != null) {
- fIllegalMethodRef.addIllegalMethod((IMethodDescriptor) element, fComponent.getId());
+ fIllegalMethodRef.addIllegalMethod((IMethodDescriptor) element, fComponent.getSymbolicName());
} else if (element.getElementType() == IElementDescriptor.FIELD && fIllegalFieldRef != null) {
- fIllegalFieldRef.addIllegalField((IFieldDescriptor) element, fComponent.getId());
+ fIllegalFieldRef.addIllegalField((IFieldDescriptor) element, fComponent.getSymbolicName());
}
}
}
@@ -122,8 +122,8 @@
* if the component is not a {@link PluginProjectApiComponent}
*/
private IProject getProject(IApiComponent component) {
- if(component instanceof PluginProjectApiComponent) {
- PluginProjectApiComponent comp = (PluginProjectApiComponent) component;
+ if(component instanceof ProjectComponent) {
+ ProjectComponent comp = (ProjectComponent) component;
return comp.getJavaProject().getProject();
}
return null;
Index: src/org/eclipse/pde/api/tools/internal/builder/Reference.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/Reference.java,v
retrieving revision 1.11
diff -u -r1.11 Reference.java
--- src/org/eclipse/pde/api/tools/internal/builder/Reference.java 27 Oct 2009 16:37:34 -0000 1.11
+++ src/org/eclipse/pde/api/tools/internal/builder/Reference.java 30 Nov 2009 15:41:43 -0000
@@ -643,12 +643,12 @@
visibility = annot.getVisibility();
if(annot.getVisibility() == VisibilityModifiers.PRIVATE) {
IApiComponent host = mcomponent.getHost();
- if(host != null && host.getId().equals(rcomponent.getId())) {
+ if(host != null && host.getSymbolicName().equals(rcomponent.getSymbolicName())) {
visibility = UseReportConverter.FRAGMENT_PERMISSIBLE;
}
else {
IApiAccess access = description.resolveAccessLevel(
- Factory.componentDescriptor(mcomponent.getId()), // component descriptors in API description are not version qualified
+ Factory.componentDescriptor(mcomponent.getSymbolicName()), // component descriptors in API description are not version qualified
getResolvedReference().getHandle().getPackage());
if(access != null && access.getAccessLevel() == IApiAccess.FRIEND) {
visibility = VisibilityModifiers.PRIVATE_PERMISSIBLE;
Index: src/org/eclipse/pde/api/tools/internal/builder/ReferenceResolver.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ReferenceResolver.java,v
retrieving revision 1.4
diff -u -r1.4 ReferenceResolver.java
--- src/org/eclipse/pde/api/tools/internal/builder/ReferenceResolver.java 17 Mar 2009 17:05:17 -0000 1.4
+++ src/org/eclipse/pde/api/tools/internal/builder/ReferenceResolver.java 30 Nov 2009 15:41:43 -0000
@@ -145,7 +145,7 @@
*/
private static String createSignatureKey(IReference reference) throws CoreException {
StringBuffer buffer = new StringBuffer();
- buffer.append(reference.getMember().getApiComponent().getId());
+ buffer.append(reference.getMember().getApiComponent().getSymbolicName());
buffer.append("#"); //$NON-NLS-1$
buffer.append(reference.getReferencedTypeName());
switch (reference.getReferenceType()) {
Index: src/org/eclipse/pde/api/tools/internal/builder/SystemApiDetector.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/SystemApiDetector.java,v
retrieving revision 1.13
diff -u -r1.13 SystemApiDetector.java
--- src/org/eclipse/pde/api/tools/internal/builder/SystemApiDetector.java 6 Jul 2009 18:27:08 -0000 1.13
+++ src/org/eclipse/pde/api/tools/internal/builder/SystemApiDetector.java 30 Nov 2009 15:41:43 -0000
@@ -26,8 +26,8 @@
import org.eclipse.jface.text.Position;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
-import org.eclipse.pde.api.tools.internal.model.BundleApiComponent;
-import org.eclipse.pde.api.tools.internal.model.PluginProjectApiComponent;
+import org.eclipse.pde.api.tools.internal.model.BundleComponent;
+import org.eclipse.pde.api.tools.internal.model.ProjectComponent;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.ProfileModifiers;
import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
@@ -353,8 +353,8 @@
* Make sure that the resolved reference doesn't below to one of the imported package of
* the current component
*/
- if (apiComponent instanceof BundleApiComponent) {
- BundleDescription bundle = ((BundleApiComponent)apiComponent).getBundleDescription();
+ if (apiComponent instanceof BundleComponent) {
+ BundleDescription bundle = ((BundleComponent)apiComponent).getBundleDescription();
ImportPackageSpecification[] importPackages = bundle.getImportPackages();
String referencedTypeName = reference.getReferencedTypeName();
int index = referencedTypeName.lastIndexOf('.');
@@ -434,8 +434,8 @@
try {
IApiProblem problem = null;
IApiComponent component = reference.getMember().getApiComponent();
- if (component instanceof PluginProjectApiComponent) {
- PluginProjectApiComponent ppac = (PluginProjectApiComponent) component;
+ if (component instanceof ProjectComponent) {
+ ProjectComponent ppac = (ProjectComponent) component;
IJavaProject project = ppac.getJavaProject();
problem = createProblem(reference, project);
} else {
Index: src/org/eclipse/pde/api/tools/internal/builder/TypeScope.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/TypeScope.java,v
retrieving revision 1.2
diff -u -r1.2 TypeScope.java
--- src/org/eclipse/pde/api/tools/internal/builder/TypeScope.java 22 Oct 2009 15:57:57 -0000 1.2
+++ src/org/eclipse/pde/api/tools/internal/builder/TypeScope.java 30 Nov 2009 15:41:43 -0000
@@ -130,7 +130,7 @@
* @see org.eclipse.pde.api.tools.internal.provisional.IApiTypeContainer#findClassFile(java.lang.String, java.lang.String)
*/
public IApiTypeRoot findTypeRoot(String qualifiedName, String id) throws CoreException {
- if (fComponent.getId().equals(id)) {
+ if (fComponent.getSymbolicName().equals(id)) {
return findTypeRoot(qualifiedName);
}
return null;
Index: src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java,v
retrieving revision 1.89
diff -u -r1.89 ClassFileComparator.java
--- src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java 18 Aug 2009 16:56:18 -0000 1.89
+++ src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java 30 Nov 2009 15:41:43 -0000
@@ -92,7 +92,7 @@
if (result == null) {
// TODO should we report this failure ?
if (Debug) {
- System.err.println("CHECKED EXCEPTION LOOKUP: Could not find " + superName + " in profile " + profile.getName() + " from component " + apiComponent.getId()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ System.err.println("CHECKED EXCEPTION LOOKUP: Could not find " + superName + " in profile " + profile.getName() + " from component " + apiComponent.getSymbolicName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
break;
}
@@ -3228,20 +3228,20 @@
String packageName = Signatures.getPackageName(typeName);
IApiComponent[] components = profile.resolvePackage(component, packageName);
if (components == null) {
- String msg = MessageFormat.format(ComparatorMessages.ClassFileComparator_1, new String[] {packageName, profile.getName(), component.getId()});
+ String msg = MessageFormat.format(ComparatorMessages.ClassFileComparator_1, new String[] {packageName, profile.getName(), component.getSymbolicName()});
if (Debug) {
System.err.println("TYPE LOOKUP: "+msg); //$NON-NLS-1$
}
- reportStatus(new Status(IStatus.ERROR, component.getId(), msg));
+ reportStatus(new Status(IStatus.ERROR, component.getSymbolicName(), msg));
return null;
}
IApiTypeRoot result = Util.getClassFile(components, typeName);
if (result == null) {
- String msg = MessageFormat.format(ComparatorMessages.ClassFileComparator_2, new String[] {typeName, profile.getName(), component.getId()});
+ String msg = MessageFormat.format(ComparatorMessages.ClassFileComparator_2, new String[] {typeName, profile.getName(), component.getSymbolicName()});
if (Debug) {
System.err.println("TYPE LOOKUP: "+msg); //$NON-NLS-1$
}
- reportStatus(new Status(IStatus.ERROR, component.getId(), msg));
+ reportStatus(new Status(IStatus.ERROR, component.getSymbolicName(), msg));
return null;
}
return result;
Index: src/org/eclipse/pde/api/tools/internal/model/AbstractApiComponent.java
===================================================================
RCS file: src/org/eclipse/pde/api/tools/internal/model/AbstractApiComponent.java
diff -N src/org/eclipse/pde/api/tools/internal/model/AbstractApiComponent.java
--- src/org/eclipse/pde/api/tools/internal/model/AbstractApiComponent.java 22 Oct 2009 15:57:56 -0000 1.7
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.model;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.pde.api.tools.internal.problems.ApiProblemFilter;
-import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
-import org.eclipse.pde.api.tools.internal.provisional.Factory;
-import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
-import org.eclipse.pde.api.tools.internal.provisional.IApiFilterStore;
-import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;
-import org.eclipse.pde.api.tools.internal.provisional.model.ApiTypeContainerVisitor;
-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.model.IApiElement;
-import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;
-import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
-import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemFilter;
-
-/**
- * Common implementation of an API component as a composite class file container.
- *
- * @since 1.0.0
- */
-public abstract class AbstractApiComponent extends AbstractApiTypeContainer implements IApiComponent {
- /**
- * API description
- */
- private IApiDescription fApiDescription = null;
-
- /**
- * Api Filter store
- */
- private IApiFilterStore fFilterStore = null;
-
- /**
- * Constructs an API component in the given {@link IApiBaseline}.
- *
- * @param baseline the parent {@link IApiBaseline}
- */
- public AbstractApiComponent(IApiBaseline baseline) {
- super(baseline, IApiElement.COMPONENT, null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.model.component.IClassFileContainer#accept(org.eclipse.pde.api.tools.model.component.ClassFileContainerVisitor)
- */
- public void accept(ApiTypeContainerVisitor visitor) throws CoreException {
- if (visitor.visit(this)) {
- super.accept(visitor);
- }
- visitor.end(this);
- }
-
- /**
- * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent#getHost()
- */
- public IApiComponent getHost() throws CoreException {
- return null;
- }
-
- /**
- * @see org.eclipse.pde.api.tools.internal.provisional.IApiComponent#getBaseline()
- */
- public IApiBaseline getBaseline() {
- return (IApiBaseline) getAncestor(IApiElement.BASELINE);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.model.component.IApiComponent#dispose()
- */
- public void dispose() {
- try {
- close();
- } catch (CoreException e) {
- ApiPlugin.log(e);
- }
- fApiDescription = null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.internal.model.ApiElement#getApiComponent()
- */
- public IApiComponent getApiComponent() {
- return this;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.model.component.IApiComponent#getApiDescription()
- */
- public synchronized IApiDescription getApiDescription() throws CoreException {
- if (fApiDescription == null) {
- fApiDescription = createApiDescription();
- }
- return fApiDescription;
- }
-
- /**
- * Returns whether this component has created an API description.
- *
- * @return whether this component has created an API description
- */
- protected synchronized boolean isApiDescriptionInitialized() {
- return fApiDescription != null;
- }
-
- /**
- * Returns if this component has created an API filter store
- *
- * @return true if a store has been created, false other wise
- */
- protected synchronized boolean hasApiFilterStore() {
- return fFilterStore != null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.internal.model.AbstractApiTypeContainer#getApiTypeContainers()
- */
- public synchronized IApiTypeContainer[] getApiTypeContainers() throws CoreException {
- return super.getApiTypeContainers();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.internal.model.AbstractApiTypeContainer#getApiTypeContainers()
- */
- public synchronized IApiTypeContainer[] getApiTypeContainers(String id) throws CoreException {
- if (this.hasFragments()) {
- return super.getApiTypeContainers(id);
- } else {
- return super.getApiTypeContainers();
- }
- }
-
- /**
- * Creates and returns the API description for this component.
- *
- * @return newly created API description for this component
- */
- protected abstract IApiDescription createApiDescription() throws CoreException;
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.IApiComponent#getFilterStore()
- */
- public IApiFilterStore getFilterStore() throws CoreException {
- if(fFilterStore == null) {
- fFilterStore = createApiFilterStore();
- }
- return fFilterStore;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.internal.provisional.IApiComponent#newProblemFilter(org.eclipse.pde.api.tools.internal.provisional.IApiProblem)
- */
- public IApiProblemFilter newProblemFilter(IApiProblem problem) throws CoreException {
- //TODO either expose a way to make problems or change the method to accept the parts of a problem
- return new ApiProblemFilter(getId(), problem);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent#getHandle()
- */
- public IElementDescriptor getHandle() {
- return Factory.componentDescriptor(this.getId(), this.getVersion());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer#getContainerType()
- */
- public int getContainerType() {
- return IApiTypeContainer.COMPONENT;
- }
-
- /**
- * Lazily creates a new {@link IApiFilterStore} when it is requested
- *
- * @return the current {@link IApiFilterStore} for this component
- * @throws CoreException
- */
- protected abstract IApiFilterStore createApiFilterStore() throws CoreException;
-}
Index: src/org/eclipse/pde/api/tools/internal/model/AbstractApiTypeContainer.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/AbstractApiTypeContainer.java,v
retrieving revision 1.6
diff -u -r1.6 AbstractApiTypeContainer.java
--- src/org/eclipse/pde/api/tools/internal/model/AbstractApiTypeContainer.java 22 Oct 2009 15:57:56 -0000 1.6
+++ src/org/eclipse/pde/api/tools/internal/model/AbstractApiTypeContainer.java 30 Nov 2009 15:41:44 -0000
@@ -116,7 +116,7 @@
for (int i = 0; i < containers.length; i++) {
comp = (IApiComponent) containers[i].getAncestor(IApiElement.COMPONENT);
if(comp != null) {
- origin = comp.getId();
+ origin = comp.getSymbolicName();
}
if (origin == null) {
IApiTypeRoot file = containers[i].findTypeRoot(qualifiedName);
@@ -180,7 +180,7 @@
IApiTypeContainer container = null;
for (Iterator iterator = this.fApiTypeContainers.iterator(); iterator.hasNext(); ) {
container = (IApiTypeContainer) iterator.next();
- origin = ((IApiComponent)container.getAncestor(IApiElement.COMPONENT)).getId();
+ origin = ((IApiComponent)container.getAncestor(IApiElement.COMPONENT)).getSymbolicName();
if (origin != null && origin.equals(id)) {
containers.add(container);
}
Index: src/org/eclipse/pde/api/tools/internal/model/AbstractApiTypeRoot.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/AbstractApiTypeRoot.java,v
retrieving revision 1.5
diff -u -r1.5 AbstractApiTypeRoot.java
--- src/org/eclipse/pde/api/tools/internal/model/AbstractApiTypeRoot.java 28 Sep 2009 16:09:44 -0000 1.5
+++ src/org/eclipse/pde/api/tools/internal/model/AbstractApiTypeRoot.java 30 Nov 2009 15:41:44 -0000
@@ -47,7 +47,7 @@
IApiType type = null;
if(comp != null) {
IApiBaseline baseline = comp.getBaseline();
- type = (IApiType) cache.getElementInfo(baseline.getName(), comp.getId(), this.getTypeName(), IApiElement.TYPE);
+ type = (IApiType) cache.getElementInfo(baseline.getName(), comp.getSymbolicName(), this.getTypeName(), IApiElement.TYPE);
}
if(type == null) {
type = TypeStructureBuilder.buildTypeStructure(getContents(), getApiComponent(), this);
Index: src/org/eclipse/pde/api/tools/internal/model/ApiBaseline.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiBaseline.java,v
retrieving revision 1.18
diff -u -r1.18 ApiBaseline.java
--- src/org/eclipse/pde/api/tools/internal/model/ApiBaseline.java 14 Jul 2009 02:03:01 -0000 1.18
+++ src/org/eclipse/pde/api/tools/internal/model/ApiBaseline.java 30 Nov 2009 15:41:44 -0000
@@ -275,7 +275,7 @@
getState().setPlatformProperties(dictionary);
// clean up previous system library
if (fSystemLibraryComponent != null && fComponentsById != null) {
- fComponentsById.remove(fSystemLibraryComponent.getId());
+ fComponentsById.remove(fSystemLibraryComponent.getSymbolicName());
}
if(fSystemPackageNames != null) {
fSystemPackageNames.clear();
@@ -301,16 +301,16 @@
* Adds an {@link IApiComponent} to the fComponentsById mapping
* @param component
*/
- private void addComponent(IApiComponent component) throws CoreException {
+ protected void addComponent(IApiComponent component) throws CoreException {
if(component == null) {
return;
}
if(fComponentsById == null) {
fComponentsById = new HashMap();
}
- fComponentsById.put(component.getId(), component);
- if (component instanceof PluginProjectApiComponent) {
- PluginProjectApiComponent projectApiComponent = (PluginProjectApiComponent) component;
+ fComponentsById.put(component.getSymbolicName(), component);
+ if (component instanceof ProjectComponent) {
+ ProjectComponent projectApiComponent = (ProjectComponent) component;
if (this.fComponentsByProjectNames == null) {
this.fComponentsByProjectNames = new HashMap();
}
@@ -324,7 +324,7 @@
public void addApiComponents(IApiComponent[] components) throws CoreException {
HashSet ees = new HashSet();
for (int i = 0; i < components.length; i++) {
- BundleApiComponent component = (BundleApiComponent) components[i];
+ BundleComponent component = (BundleComponent) components[i];
if (component.isSourceComponent()) {
continue;
}
@@ -341,7 +341,7 @@
* Resolves and initializes the system library to use based on API component requirements.
* Only works when running in the framework. Has no effect if not running in the framework.
*/
- private void resolveSystemLibrary(HashSet ees) {
+ protected void resolveSystemLibrary(HashSet ees) {
if (ApiPlugin.isRunningInFramework() && fAutoResolve) {
IStatus error = null;
IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
@@ -526,8 +526,8 @@
* @throws CoreException
*/
private void resolvePackage0(IApiComponent component, String packageName, List componentsList) throws CoreException {
- if (component instanceof BundleApiComponent) {
- BundleDescription bundle = ((BundleApiComponent)component).getBundleDescription();
+ if (component instanceof BundleComponent) {
+ BundleDescription bundle = ((BundleComponent)component).getBundleDescription();
if (bundle != null) {
StateHelper helper = getState().getStateHelper();
ExportPackageDescription[] visiblePackages = helper.getVisiblePackages(bundle);
@@ -793,8 +793,8 @@
ArrayList bundles = new ArrayList(components.length);
for (int i = 0; i < components.length; i++) {
IApiComponent component = components[i];
- if (component instanceof BundleApiComponent) {
- bundles.add(((BundleApiComponent)component).getBundleDescription());
+ if (component instanceof BundleComponent) {
+ bundles.add(((BundleComponent)component).getBundleDescription());
}
}
return bundles;
Index: src/org/eclipse/pde/api/tools/internal/model/ApiModelCache.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiModelCache.java,v
retrieving revision 1.3
diff -u -r1.3 ApiModelCache.java
--- src/org/eclipse/pde/api/tools/internal/model/ApiModelCache.java 14 Jul 2009 02:03:01 -0000 1.3
+++ src/org/eclipse/pde/api/tools/internal/model/ApiModelCache.java 30 Nov 2009 15:41:44 -0000
@@ -117,7 +117,7 @@
IApiComponent comp = element.getApiComponent();
if(comp != null) {
IApiBaseline baseline = comp.getBaseline();
- String id = comp.getId();
+ String id = comp.getSymbolicName();
if(id == null) {
return;
}
@@ -129,7 +129,7 @@
Cache typecache = (Cache) compcache.get(id);
if(typecache == null) {
typecache = new Cache(DEFAULT_CACHE_SIZE, DEFAULT_OVERFLOW);
- compcache.put(comp.getId(), typecache);
+ compcache.put(comp.getSymbolicName(), typecache);
}
ApiType type = (ApiType) element;
if(type.isMemberType() || isMemberType(type.getName()) /*cache even a root type with a '$' in its name here as well*/) {
@@ -314,7 +314,7 @@
if(comp != null) {
try {
IApiBaseline baseline = comp.getBaseline();
- return removeElementInfo(baseline.getName(), comp.getId(), element.getName(), element.getType());
+ return removeElementInfo(baseline.getName(), comp.getSymbolicName(), element.getName(), element.getType());
}
catch(CoreException ce) {}
}
Index: src/org/eclipse/pde/api/tools/internal/model/ApiModelFactory.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiModelFactory.java,v
retrieving revision 1.8
diff -u -r1.8 ApiModelFactory.java
--- src/org/eclipse/pde/api/tools/internal/model/ApiModelFactory.java 26 Mar 2009 18:43:54 -0000 1.8
+++ src/org/eclipse/pde/api/tools/internal/model/ApiModelFactory.java 30 Nov 2009 15:41:44 -0000
@@ -22,7 +22,6 @@
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
import org.eclipse.pde.api.tools.internal.util.Util;
import org.eclipse.pde.core.plugin.IPluginModelBase;
-import org.eclipse.pde.core.plugin.PluginRegistry;
/**
* Utility class for creating new {@link org.eclipse.pde.api.tools.internal.provisional.model.IApiElement}s
@@ -55,9 +54,8 @@
* @exception CoreException if unable to create the component
*/
public static IApiComponent newApiComponent(IApiBaseline profile, String location) throws CoreException {
- BundleApiComponent component = new BundleApiComponent(profile, location);
+ BundleComponent component = new BundleComponent(profile, location, getBundleID());
if(component.isValidBundle()) {
- component.init(getBundleID());
return component;
}
return null;
@@ -66,14 +64,15 @@
/**
* Creates and returns a new API component for this profile based on the given
* model or null
if the given model cannot be resolved or does not contain
- * a valid API component. The component is not added to the profile.
+ * a valid API component. The component is not added to the baseline.
*
+ * @param baseline
* @param model the given model
* @return API component or null
if the given model cannot be resolved or does not contain
* a valid API component
* @exception CoreException if unable to create the component
*/
- public static IApiComponent newApiComponent(IApiBaseline profile, IPluginModelBase model) throws CoreException {
+ public static IApiComponent newApiComponent(IApiBaseline baseline, IPluginModelBase model) throws CoreException {
BundleDescription bundleDescription = model.getBundleDescription();
if (bundleDescription == null) {
return null;
@@ -82,41 +81,19 @@
if (location == null) {
return null;
}
- BundleApiComponent component = null;
- IPluginModelBase model2 = getProjectModel(location);
- if (model2 != null && model == model2) {
- if (isBinaryProject(location)) {
- component = new BundleApiComponent(profile, location);
- } else {
- component = new PluginProjectApiComponent(profile, location, model);
- }
+ BundleComponent component = null;
+ if (isBinaryProject(location)) {
+ component = new BundleComponent(baseline, location, getBundleID());
} else {
- component = new BundleApiComponent(profile, location);
+ component = new ProjectComponent(baseline, location, model, getBundleID());
}
if(component.isValidBundle()) {
- component.init(getBundleID());
return component;
}
return null;
}
/**
- * Returns the plug-in model associated with the project at the specified location
- * or null
if none (i.e. if its an external model).
- *
- * @param project location
- * @return plug-in model or null
if none
- */
- private static IPluginModelBase getProjectModel(String location) {
- String projectName = (new Path(location)).lastSegment();
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- if (project != null) {
- return PluginRegistry.findModel(project);
- }
- return null;
- }
-
- /**
* Returns if the specified location is an imported binary project.
*
* We accept projects that are plug-ins even if not API enabled (i.e.
@@ -130,7 +107,7 @@
private static boolean isBinaryProject(String location) throws CoreException {
IPath path = new Path(location);
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.lastSegment());
- return project != null && Util.isBinaryProject(project);
+ return project != null && (!project.exists() || Util.isBinaryProject(project));
}
/**
Index: src/org/eclipse/pde/api/tools/internal/model/BundleApiComponent.java
===================================================================
RCS file: src/org/eclipse/pde/api/tools/internal/model/BundleApiComponent.java
diff -N src/org/eclipse/pde/api/tools/internal/model/BundleApiComponent.java
--- src/org/eclipse/pde/api/tools/internal/model/BundleApiComponent.java 2 Sep 2009 21:15:06 -0000 1.27
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,1206 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.model;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import javax.xml.parsers.FactoryConfigurationError;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.osgi.service.resolver.BundleDescription;
-import org.eclipse.osgi.service.resolver.BundleSpecification;
-import org.eclipse.osgi.service.resolver.ExportPackageDescription;
-import org.eclipse.osgi.service.resolver.HostSpecification;
-import org.eclipse.osgi.service.resolver.ResolverError;
-import org.eclipse.osgi.service.resolver.StateObjectFactory;
-import org.eclipse.osgi.util.ManifestElement;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.pde.api.tools.internal.ApiBaselineManager;
-import org.eclipse.pde.api.tools.internal.ApiDescription;
-import org.eclipse.pde.api.tools.internal.ApiDescriptionProcessor;
-import org.eclipse.pde.api.tools.internal.BundleVersionRange;
-import org.eclipse.pde.api.tools.internal.CompositeApiDescription;
-import org.eclipse.pde.api.tools.internal.IApiCoreConstants;
-import org.eclipse.pde.api.tools.internal.RequiredComponentDescription;
-import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
-import org.eclipse.pde.api.tools.internal.provisional.Factory;
-import org.eclipse.pde.api.tools.internal.provisional.IApiAccess;
-import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
-import org.eclipse.pde.api.tools.internal.provisional.IApiFilterStore;
-import org.eclipse.pde.api.tools.internal.provisional.IRequiredComponentDescription;
-import org.eclipse.pde.api.tools.internal.provisional.ProfileModifiers;
-import org.eclipse.pde.api.tools.internal.provisional.VisibilityModifiers;
-import org.eclipse.pde.api.tools.internal.provisional.descriptors.IPackageDescriptor;
-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.model.IApiElement;
-import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;
-import org.eclipse.pde.api.tools.internal.util.FileManager;
-import org.eclipse.pde.api.tools.internal.util.SourceDefaultHandler;
-import org.eclipse.pde.api.tools.internal.util.Util;
-import org.eclipse.pde.internal.core.TargetWeaver;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Version;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * Implementation of an API component based on a bundle in the file system.
- *
- * @since 1.0.0
- */
-public class BundleApiComponent extends AbstractApiComponent {
-
- static final String TMP_API_FILE_PREFIX = "api"; //$NON-NLS-1$
- static final String TMP_API_FILE_POSTFIX = "tmp"; //$NON-NLS-1$
-
- /**
- * Dictionary parsed from MANIFEST.MF
- */
- private Dictionary fManifest;
-
- /**
- * Manifest headers that are maintained after {@link BundleDescription} creation.
- * Only these headers are maintained in the manifest dictionary to reduce footprint.
- */
- private static final String[] MANIFEST_HEADERS = new String[] {
- IApiCoreConstants.ECLIPSE_SOURCE_BUNDLE,
- Constants.BUNDLE_CLASSPATH,
- Constants.BUNDLE_NAME,
- Constants.BUNDLE_VERSION
- };
-
- /**
- * Whether there is an underlying .api_description file
- */
- private boolean fHasApiDescription = false;
-
- /**
- * Root location of component in the file system
- */
- private String fLocation;
-
- /**
- * Underlying bundle description (OSGi model of a bundle)
- */
- private BundleDescription fBundleDescription;
-
- /**
- * Symbolic name of this bundle
- */
- private String fSymbolicName = null;
-
- /**
- * Bundle version
- */
- private Version fVersion = null;
-
- /**
- * Cached value for the lowest EEs
- */
- private String[] lowestEEs;
-
- /**
- * Constructs a new API component from the specified location in the file system
- * in the given profile.
- *
- * @param profile owning profile
- * @param location directory or jar file
- * @exception CoreException if unable to create a component from the specified location
- */
- public BundleApiComponent(IApiBaseline profile, String location) throws CoreException {
- super(profile);
- fLocation = location;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.internal.descriptors.AbstractApiComponent#dispose()
- */
- public void dispose() {
- try {
- super.dispose();
- } finally {
- synchronized(this) {
- fManifest = null;
- fBundleDescription = null;
- }
- }
- }
-
- /**
- * Returns this bundle's manifest as a dictionary.
- *
- * @return manifest dictionary
- * @exception CoreException if something goes terribly wrong
- */
- protected synchronized Dictionary getManifest() throws CoreException {
- if(fManifest == null) {
- try {
- fManifest = (Dictionary) loadManifest(new File(fLocation));
- } catch (IOException e) {
- abort("Unable to load manifest due to IO error", e); //$NON-NLS-1$
- }
- }
- return fManifest;
- }
-
- /**
- * Reduce the manifest to only contain required headers after {@link BundleDescription} creation.
- */
- protected synchronized void doManifestCompaction() throws CoreException {
- Dictionary temp = fManifest;
- fManifest = new Hashtable(MANIFEST_HEADERS.length);
- for (int i = 0; i < MANIFEST_HEADERS.length; i++) {
- String header = MANIFEST_HEADERS[i];
- Object value = temp.get(header);
- if (value != null) {
- fManifest.put(header, value);
- }
- }
- }
-
- /**
- * Returns if the bundle at the specified location is a valid bundle or not.
- * Validity is determined via the existence of a readable manifest file
- * @param location
- * @return true if the bundle at the given location is valid false otherwise
- * @throws IOException
- */
- public boolean isValidBundle() throws CoreException {
- Dictionary manifest = getManifest();
- return manifest != null && (manifest.get(Constants.BUNDLE_NAME) != null && manifest.get(Constants.BUNDLE_VERSION) != null);
- }
-
- /**
- * Initializes component state from the underlying bundle for the given
- * state.
- *
- * @param state PDE state
- * @throws CoreException on failure
- */
- protected synchronized void init(long bundleId) throws CoreException {
- try {
- Dictionary manifest = getManifest();
- if (isBinaryBundle() && ApiBaselineManager.WORKSPACE_API_BASELINE_ID.equals(getBaseline().getName())) {
- // must account for bundles in development mode - look for class files in output
- // folders rather than jars
- TargetWeaver.weaveManifest(manifest);
- }
- StateObjectFactory factory = StateObjectFactory.defaultFactory;
- fBundleDescription = factory.createBundleDescription(((ApiBaseline)getBaseline()).getState(), manifest, fLocation, bundleId);
- fSymbolicName = fBundleDescription.getSymbolicName();
- fVersion = fBundleDescription.getVersion();
- setName((String)getManifest().get(Constants.BUNDLE_NAME));
- } catch (BundleException e) {
- abort("Unable to create API component from specified location: " + fLocation, e); //$NON-NLS-1$
- }
- // compact manifest after initialization - only keep used headers
- doManifestCompaction();
- }
-
- /**
- * Returns whether this API component represents a binary bundle versus a project bundle.
- *
- * @return whether this API component represents a binary bundle
- */
- protected boolean isBinaryBundle() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.internal.AbstractApiComponent#createApiDescription()
- */
- protected IApiDescription createApiDescription() throws CoreException {
- BundleDescription[] fragments = getBundleDescription().getFragments();
- if (fragments.length == 0) {
- return createLocalApiDescription();
- }
- // build a composite description
- IApiDescription[] descriptions = new IApiDescription[fragments.length + 1];
- for (int i = 0; i < fragments.length; i++) {
- BundleDescription fragment = fragments[i];
- BundleApiComponent component = (BundleApiComponent) getBaseline().getApiComponent(fragment.getSymbolicName());
- descriptions[i + 1] = component.getApiDescription();
- }
- descriptions[0] = createLocalApiDescription();
- return new CompositeApiDescription(descriptions);
- }
-
- /**
- * Creates and returns this component's API description based on packages
- * supplied by this component, exported packages, and associated directives.
- *
- * @return API description
- * @throws CoreException if unable to initialize
- */
- protected IApiDescription createLocalApiDescription() throws CoreException {
- IApiDescription apiDesc = new ApiDescription(getId());
- // first mark all packages as internal
- initializeApiDescription(apiDesc, getBundleDescription(), getLocalPackageNames());
- try {
- String xml = loadApiDescription(new File(fLocation));
- setHasApiDescription(xml != null);
- if (xml != null) {
- ApiDescriptionProcessor.annotateApiSettings(null, apiDesc, xml);
- }
- } catch (IOException e) {
- abort("Unable to load .api_description file ", e); //$NON-NLS-1$
- }
- return apiDesc;
- }
-
- /**
- * Returns the names of all packages that originate from this bundle.
- * Does not include packages that originate from fragments or a host.
- *
- * @return local package names
- * @throws CoreException
- */
- protected Set getLocalPackageNames() throws CoreException {
- Set names = new HashSet();
- IApiTypeContainer[] containers = getApiTypeContainers();
- IApiComponent comp = null;
- for (int i = 0; i < containers.length; i++) {
- comp = (IApiComponent) containers[i].getAncestor(IApiElement.COMPONENT);
- if (comp != null && comp.getId().equals(getId())) {
- String[] packageNames = containers[i].getPackageNames();
- for (int j = 0; j < packageNames.length; j++) {
- names.add(packageNames[j]);
- }
- }
- }
- return names;
- }
-
-
- /**
- * Initializes the given API description based on package exports in the manifest.
- * The API description for a bundle only contains packages that originate from
- * this bundle (so a host will not contain API descriptions for packages that
- * originate from fragments). However, a host's API description will be represented
- * by a proxy that delegates to the host and all of its fragments to provide
- * a complete description of the host.
- *
- * @param apiDesc API description to initialize
- * @param bundle the bundle to load from
- * @param packages the complete set of packages names originating from the backing
- * component
- * @throws CoreException if an error occurs
- */
- public static void initializeApiDescription(IApiDescription apiDesc, BundleDescription bundle, Set packages) throws CoreException {
- Iterator iterator = packages.iterator();
- while (iterator.hasNext()) {
- String name = (String) iterator.next();
- apiDesc.setVisibility(Factory.packageDescriptor(name), VisibilityModifiers.PRIVATE);
- }
- // then process exported packages that originate from this bundle
- // considering host and fragment package exports
- List supplied = new ArrayList();
- ExportPackageDescription[] exportPackages = bundle.getExportPackages();
- addSuppliedPackages(packages, supplied, exportPackages);
- HostSpecification host = bundle.getHost();
- if (host != null) {
- BundleDescription[] hosts = host.getHosts();
- for (int i = 0; i < hosts.length; i++) {
- addSuppliedPackages(packages, supplied, hosts[i].getExportPackages());
- }
- }
- BundleDescription[] fragments = bundle.getFragments();
- for (int i = 0; i < fragments.length; i++) {
- addSuppliedPackages(packages, supplied, fragments[i].getExportPackages());
- }
-
- annotateExportedPackages(apiDesc, (ExportPackageDescription[]) supplied.toArray(new ExportPackageDescription[supplied.size()]));
- }
-
- /**
- * Adds package exports to the given list if the associated package originates
- * from this bundle.
- *
- * @param packages names of packages supplied by this bundle
- * @param supplied list to append package exports to
- * @param exportPackages package exports to consider
- */
- protected static void addSuppliedPackages(Set packages, List supplied, ExportPackageDescription[] exportPackages) {
- for (int i = 0; i < exportPackages.length; i++) {
- ExportPackageDescription pkg = exportPackages[i];
- String name = pkg.getName();
- if (name.equals(".")) { //$NON-NLS-1$
- // translate . to default package
- name = Util.DEFAULT_PACKAGE_NAME;
- }
- if (packages.contains(name)) {
- supplied.add(pkg);
- }
- }
- }
-
- /**
- * Annotates the API description with exported packages.
- *
- * @param apiDesc description to annotate
- * @param exportedPackages packages that are exported
- */
- protected static void annotateExportedPackages(IApiDescription apiDesc, ExportPackageDescription[] exportedPackages) {
- for(int i = 0; i < exportedPackages.length; i++) {
- ExportPackageDescription pkg = exportedPackages[i];
- boolean internal = ((Boolean) pkg.getDirective("x-internal")).booleanValue(); //$NON-NLS-1$
- String[] friends = (String[]) pkg.getDirective("x-friends"); //$NON-NLS-1$
- String pkgName = pkg.getName();
- if (pkgName.equals(".")) { //$NON-NLS-1$
- // default package
- pkgName = ""; //$NON-NLS-1$
- }
- IPackageDescriptor pkgDesc = Factory.packageDescriptor(pkgName);
- if(internal) {
- apiDesc.setVisibility(pkgDesc, VisibilityModifiers.PRIVATE);
- }
- if (friends != null) {
- apiDesc.setVisibility(pkgDesc, VisibilityModifiers.PRIVATE);
- for(int j = 0; j < friends.length; j++) {
- //annotate the api description for x-friends access levels
- apiDesc.setAccessLevel(
- Factory.componentDescriptor(friends[j]),
- Factory.packageDescriptor(pkgName),
- IApiAccess.FRIEND);
- }
- }
- if (!internal && friends == null) {
- //there could have been directives that have nothing to do with
- //visibility, so we need to add the package as API in that case
- apiDesc.setVisibility(pkgDesc, VisibilityModifiers.API);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.internal.AbstractApiComponent#createApiFilterStore()
- */
- protected IApiFilterStore createApiFilterStore() throws CoreException {
- //always return a new empty store since we do not support filtering from bundles
- return null;
- }
-
- /**
- * @see org.eclipse.pde.api.tools.internal.AbstractApiTypeContainer#createApiTypeContainers()
- */
- protected synchronized List createApiTypeContainers() throws CoreException {
- if (this.fBundleDescription == null) {
- baselineDisposed(getBaseline());
- }
- List containers = new ArrayList(5);
- try {
- List all = new ArrayList();
- // build the classpath from bundle and all fragments
- all.add(this);
- boolean considerFragments = true;
- if (Util.ORG_ECLIPSE_SWT.equals(getId())) {
- // if SWT is a project to be built/analyzed don't consider its fragments
- considerFragments = !isApiEnabled();
- }
- if (considerFragments) {
- BundleDescription[] fragments = fBundleDescription.getFragments();
- for (int i = 0; i < fragments.length; i++) {
- BundleDescription fragment = fragments[i];
- BundleApiComponent component = (BundleApiComponent) getBaseline().getApiComponent(fragment.getSymbolicName());
- if (component != null) {
- // force initialization of the fragment so we can retrieve its class file containers
- component.getApiTypeContainers();
- all.add(component);
- }
- }
- }
- Iterator iterator = all.iterator();
- Set entryNames = new HashSet(5);
- BundleApiComponent other = null;
- while (iterator.hasNext()) {
- BundleApiComponent component = (BundleApiComponent) iterator.next();
- String[] paths = getClasspathEntries(component.getManifest());
- for (int i = 0; i < paths.length; i++) {
- String path = paths[i];
- // don't re-process the same entry twice (except default entries ".")
- if (!(".".equals(path))) { //$NON-NLS-1$
- if (entryNames.contains(path)) {
- continue;
- }
- }
- IApiTypeContainer container = component.createApiTypeContainer(path);
- if (container == null) {
- for(Iterator iter = all.iterator(); iter.hasNext();) {
- other = (BundleApiComponent) iter.next();
- if (other != component) {
- container = other.createApiTypeContainer(path);
- }
- }
- }
- if (container != null) {
- containers.add(container);
- if (!(".".equals(path))) { //$NON-NLS-1$
- entryNames.add(path);
- }
- }
- }
- }
- } catch (BundleException e) {
- abort("Unable to parse bundle classpath", e); //$NON-NLS-1$
- } catch (IOException e) {
- abort("Unable to initialize class file containers", e); //$NON-NLS-1$
- }
- return containers;
- }
-
- /**
- * Returns whether this API component is enabled for API analysis by the API builder.
- *
- * @return whether this API component is enabled for API analysis by the API builder.
- */
- protected boolean isApiEnabled() {
- return false;
- }
-
- /**
- * Returns classpath entries defined in the given manifest.
- *
- * @param manifest
- * @return classpath entries as bundle relative paths
- * @throws BundleException
- */
- protected String[] getClasspathEntries(Dictionary manifest) throws BundleException {
- ManifestElement[] classpath = ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, (String) manifest.get(Constants.BUNDLE_CLASSPATH));
- String elements[] = null;
- if (classpath == null) {
- // default classpath is '.'
- elements = new String[]{"."}; //$NON-NLS-1$
- } else {
- elements = new String[classpath.length];
- for (int i = 0; i < classpath.length; i++) {
- elements[i] = classpath[i].getValue();
- }
- }
- return elements;
- }
-
- /**
- * Creates and returns an {@link IApiTypeContainer} at the specified path in
- * this bundle, or null
if the {@link IApiTypeContainer} does not
- * exist. The path is the name (path) of entries specified by the
- * Bundle-ClassPath:
header.
- *
- * @param path relative path to a class file container in this bundle
- * @return {@link IApiTypeContainer} or null
- * @exception IOException
- */
- protected IApiTypeContainer createApiTypeContainer(String path) throws IOException, CoreException {
- File bundle = new File(fLocation);
- if (bundle.isDirectory()) {
- // bundle is folder
- File entry = new File(bundle, path);
- if (entry.exists()) {
- if (entry.isFile()) {
- return new ArchiveApiTypeContainer(this, entry.getCanonicalPath());
- } else {
- return new DirectoryApiTypeContainer(this, entry.getCanonicalPath());
- }
- }
- } else {
- // bundle is jar'd
- ZipFile zip = null;
- try {
- if (path.equals(".")) { //$NON-NLS-1$
- return new ArchiveApiTypeContainer(this, fLocation);
- } else {
- //classpath element can be jar or folder
- //https://bugs.eclipse.org/bugs/show_bug.cgi?id=279729
- zip = new ZipFile(fLocation);
- ZipEntry entry = zip.getEntry(path);
- if (entry != null) {
- File tmpfolder = new File(System.getProperty("java.io.tmpdir")); //$NON-NLS-1$
- if(entry.isDirectory()) {
- //extract the dir and all children
- File dir = File.createTempFile(TMP_API_FILE_PREFIX, TMP_API_FILE_POSTFIX);
- dir.deleteOnExit();
- //hack to create a temp directory
- // see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4735419
- if(dir.delete()) {
- dir.mkdir();
- FileManager.getManager().recordTempFileRoot(dir.getCanonicalPath());
- }
- extractDirectory(zip, entry.getName(), dir);
- if(dir.isDirectory() && dir.exists()) {
- return new DirectoryApiTypeContainer(this, dir.getCanonicalPath());
- }
- }
- else {
- File file = extractEntry(zip, entry, tmpfolder);
- if(Util.isArchive(file.getName())) {
- File parent = file.getParentFile();
- if(!parent.equals(tmpfolder)) {
- FileManager.getManager().recordTempFileRoot(parent.getCanonicalPath());
- }
- else {
- FileManager.getManager().recordTempFileRoot(file.getCanonicalPath());
- }
- return new ArchiveApiTypeContainer(this, file.getCanonicalPath());
- }
- }
- }
- }
- } finally {
- if (zip != null) {
- zip.close();
- }
- }
- }
- return null;
- }
-
- /**
- * Extracts a directory from the archive given a path prefix for entries to retrieve.
- * null
can be passed in as a prefix, causing all entries to be be extracted from
- * the archive.
- *
- * @param zip the {@link ZipFile} to extract from
- * @param pathprefix the prefix'ing path to include for extraction
- * @param parent the parent directory to extract to
- * @throws IOException if the {@link ZipFile} cannot be read or extraction fails to write the file(s)
- */
- void extractDirectory(ZipFile zip, String pathprefix, File parent) throws IOException {
- Enumeration entries = zip.entries();
- String prefix = (pathprefix == null ? Util.EMPTY_STRING : pathprefix);
- ZipEntry entry = null;
- File file = null;
- while (entries.hasMoreElements()) {
- entry = (ZipEntry) entries.nextElement();
- if(entry.getName().startsWith(prefix)) {
- file = new File(parent, entry.getName());
- if (entry.isDirectory()) {
- file.mkdir();
- continue;
- }
- extractEntry(zip, entry, parent);
- }
- }
- }
-
- /**
- * Extracts a non-directory entry from a zip file and returns the File handle
- * @param zip the zip to extract from
- * @param entry the entry to extract
- * @param parent the parent directory to add the extracted entry to
- * @return the file handle to the extracted entry, null
otherwise
- * @throws IOException
- */
- File extractEntry(ZipFile zip, ZipEntry entry, File parent) throws IOException {
- InputStream inputStream = null;
- File file;
- FileOutputStream outputStream = null;
- try {
- inputStream = zip.getInputStream(entry);
- file = new File(parent, entry.getName());
- File lparent = file.getParentFile();
- if(!lparent.exists()) {
- lparent.mkdirs();
- }
- outputStream = new FileOutputStream(file);
- byte[] bytes = new byte[8096];
- while (inputStream.available() > 0) {
- int read = inputStream.read(bytes);
- if (read > 0) {
- outputStream.write(bytes, 0, read);
- }
- }
- } finally {
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch(IOException e) {
- ApiPlugin.log(e);
- }
- }
- if (outputStream != null) {
- try {
- outputStream.close();
- } catch(IOException e) {
- ApiPlugin.log(e);
- }
- }
- }
- return file;
- }
-
- /**
- * Parses a bunlde's manifest into a dictionary. The bundle may be in a jar
- * or in a directory at the specified location.
- *
- * @param bundleLocation root location of the bundle
- * @return bundle manifest dictionary or null
if none
- * @throws IOException if unable to parse
- */
- protected Map loadManifest(File bundleLocation) throws IOException {
- ZipFile jarFile = null;
- InputStream manifestStream = null;
- String extension = new Path(bundleLocation.getName()).getFileExtension();
- try {
- if (extension != null && extension.equals("jar") && bundleLocation.isFile()) { //$NON-NLS-1$
- jarFile = new ZipFile(bundleLocation, ZipFile.OPEN_READ);
- ZipEntry manifestEntry = jarFile.getEntry(JarFile.MANIFEST_NAME);
- if (manifestEntry != null) {
- manifestStream = jarFile.getInputStream(manifestEntry);
- }
- } else {
- File file = new File(bundleLocation, JarFile.MANIFEST_NAME);
- if (file.exists())
- manifestStream = new FileInputStream(file);
- }
- if (manifestStream == null) {
- return null;
- }
- return ManifestElement.parseBundleManifest(manifestStream, new Hashtable(10));
- } catch (BundleException e) {
- ApiPlugin.log(e);
- } finally {
- closingZipFileAndStream(manifestStream, jarFile);
- }
- return null;
- }
-
- /**
- * Reads and returns this bunlde's manifest in a Manifest object.
- * The bundle may be in a jar or in a directory at the specified location.
- *
- * @param bundleLocation root location of the bundle
- * @return manifest or null
if not present
- * @throws IOException if unable to parse
- */
- protected Manifest readManifest(File bundleLocation) throws IOException {
- ZipFile jarFile = null;
- InputStream manifestStream = null;
- try {
- String extension = new Path(bundleLocation.getName()).getFileExtension();
- if (extension != null && extension.equals("jar") && bundleLocation.isFile()) { //$NON-NLS-1$
- jarFile = new ZipFile(bundleLocation, ZipFile.OPEN_READ);
- ZipEntry manifestEntry = jarFile.getEntry(JarFile.MANIFEST_NAME);
- if (manifestEntry != null) {
- manifestStream = jarFile.getInputStream(manifestEntry);
- }
- } else {
- File file = new File(bundleLocation, JarFile.MANIFEST_NAME);
- if (file.exists())
- manifestStream = new FileInputStream(file);
- }
- if (manifestStream == null) {
- return null;
- }
- return new Manifest(manifestStream);
- } finally {
- closingZipFileAndStream(manifestStream, jarFile);
- }
- }
-
- void closingZipFileAndStream(InputStream stream, ZipFile jarFile) {
- try {
- if (stream != null) {
- stream.close();
- }
- } catch (IOException e) {
- ApiPlugin.log(e);
- }
- try {
- if (jarFile != null) {
- jarFile.close();
- }
- } catch (IOException e) {
- ApiPlugin.log(e);
- }
- }
-
- /**
- * Reads and returns the file contents corresponding to the given file name.
- * The bundle may be in a jar or in a directory at the specified location.
- *
- * @param xmlFileName the given file name
- * @param bundleLocation the root location of the bundle
- * @return the file contents or null
if not present
- */
- protected String readFileContents(String xmlFileName, File bundleLocation) {
- ZipFile jarFile = null;
- InputStream stream = null;
- try {
- String extension = new Path(bundleLocation.getName()).getFileExtension();
- if (extension != null && extension.equals("jar") && bundleLocation.isFile()) { //$NON-NLS-1$
- jarFile = new ZipFile(bundleLocation, ZipFile.OPEN_READ);
- ZipEntry manifestEntry = jarFile.getEntry(xmlFileName);
- if (manifestEntry != null) {
- stream = jarFile.getInputStream(manifestEntry);
- }
- } else {
- File file = new File(bundleLocation, xmlFileName);
- if (file.exists()) {
- stream = new FileInputStream(file);
- }
- }
- if (stream == null) {
- return null;
- }
- return new String(Util.getInputStreamAsCharArray(stream, -1, IApiCoreConstants.UTF_8));
- } catch(IOException e) {
- //TODO abort
- ApiPlugin.log(e);
- } finally {
- closingZipFileAndStream(stream, jarFile);
- }
- return null;
- }
-
- /**
- * Parses a bundle's .api_description XML into a string. The file may be in a jar
- * or in a directory at the specified location.
- *
- * @param bundleLocation root location of the bundle
- * @return API description XML as a string or null
if none
- * @throws IOException if unable to parse
- */
- protected String loadApiDescription(File bundleLocation) throws IOException {
- ZipFile jarFile = null;
- InputStream stream = null;
- String contents = null;
- try {
- String extension = new Path(bundleLocation.getName()).getFileExtension();
- if (extension != null && extension.equals("jar") && bundleLocation.isFile()) { //$NON-NLS-1$
- jarFile = new ZipFile(bundleLocation, ZipFile.OPEN_READ);
- ZipEntry manifestEntry = jarFile.getEntry(IApiCoreConstants.API_DESCRIPTION_XML_NAME);
- if (manifestEntry != null) {
- // new file is present
- stream = jarFile.getInputStream(manifestEntry);
- }
- } else {
- File file = new File(bundleLocation, IApiCoreConstants.API_DESCRIPTION_XML_NAME);
- if (file.exists()) {
- // use new file
- stream = new FileInputStream(file);
- }
- }
- if (stream == null) {
- return null;
- }
- char[] charArray = Util.getInputStreamAsCharArray(stream, -1, IApiCoreConstants.UTF_8);
- contents = new String(charArray);
- } finally {
- closingZipFileAndStream(stream, jarFile);
- }
- return contents;
- }
-
-
- /**
- * Returns a URL describing a file inside a bundle.
- *
- * @param bundleLocation root location of the bundle. May be a
- * directory or a file (jar)
- * @param filePath bundle relative path to desired file
- * @return URL to the file
- * @throws MalformedURLException
- */
- protected URL getFileInBundle(File bundleLocation, String filePath) throws MalformedURLException {
- String extension = new Path(bundleLocation.getName()).getFileExtension();
- StringBuffer urlSt = new StringBuffer();
- if (extension != null && extension.equals("jar") && bundleLocation.isFile()) { //$NON-NLS-1$
- urlSt.append("jar:file:"); //$NON-NLS-1$
- urlSt.append(bundleLocation.getAbsolutePath());
- urlSt.append("!/"); //$NON-NLS-1$
- urlSt.append(filePath);
- } else {
- urlSt.append("file:"); //$NON-NLS-1$
- urlSt.append(bundleLocation.getAbsolutePath());
- urlSt.append(File.separatorChar);
- urlSt.append(filePath);
- }
- return new URL(urlSt.toString());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.manifest.IApiComponent#getExecutionEnvironments()
- */
- public synchronized String[] getExecutionEnvironments() throws CoreException {
- if (this.fBundleDescription == null) {
- baselineDisposed(getBaseline());
- }
- return fBundleDescription.getExecutionEnvironments();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.manifest.IApiComponent#getId()
- */
- public final String getId() {
- return fSymbolicName;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.manifest.IApiComponent#getRequiredComponents()
- */
- public synchronized IRequiredComponentDescription[] getRequiredComponents() throws CoreException {
- if (this.fBundleDescription == null) {
- baselineDisposed(getBaseline());
- }
- BundleSpecification[] requiredBundles = fBundleDescription.getRequiredBundles();
- IRequiredComponentDescription[] req = new IRequiredComponentDescription[requiredBundles.length];
- for (int i = 0; i < requiredBundles.length; i++) {
- BundleSpecification bundle = requiredBundles[i];
- req[i] = new RequiredComponentDescription(bundle.getName(),
- new BundleVersionRange(bundle.getVersionRange()),
- bundle.isOptional(),
- bundle.isExported());
- }
- return req;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.manifest.IApiComponent#getVersion()
- */
- public synchronized String getVersion() {
- return fVersion.toString();
- }
-
- /**
- * Returns this component's bundle description.
- *
- * @return bundle description
- */
- public synchronized BundleDescription getBundleDescription() throws CoreException {
- if (this.fBundleDescription == null) {
- baselineDisposed(getBaseline());
- }
- return fBundleDescription;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- if (fBundleDescription != null) {
- try {
- StringBuffer buffer = new StringBuffer();
- buffer.append(fBundleDescription.toString());
- buffer.append(" - "); //$NON-NLS-1$
- buffer.append("[fragment: ").append(isFragment()).append("] "); //$NON-NLS-1$ //$NON-NLS-2$
- buffer.append("[host: ").append(fBundleDescription.getFragments().length > 0).append("] "); //$NON-NLS-1$ //$NON-NLS-2$
- buffer.append("[system bundle: ").append(isSystemComponent()).append("] "); //$NON-NLS-1$ //$NON-NLS-2$
- buffer.append("[source bundle: ").append(isSourceComponent()).append("] "); //$NON-NLS-1$ //$NON-NLS-2$
- return buffer.toString();
- }
- catch(CoreException ce) {}
- }
- return super.toString();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.model.component.IApiComponent#getLocation()
- */
- public String getLocation() {
- return fLocation;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.model.component.IApiComponent#isSystemComponent()
- */
- public boolean isSystemComponent() {
- return false;
- }
-
- /**
- * Returns a boolean option from the map or the default value if not present.
- *
- * @param options option map
- * @param optionName option name
- * @param defaultValue default value for option if not present
- * @return boolean value
- */
- protected boolean getBooleanOption(Map options, String optionName, boolean defaultValue) {
- Boolean optionB = (Boolean)options.get(optionName);
- if (optionB != null) {
- return optionB.booleanValue();
- }
- return defaultValue;
- }
-
- /* (non-Javadoc)
- * @see IApiComponent#isSourceComponent()
- */
- public synchronized boolean isSourceComponent() throws CoreException {
- if (this.fManifest == null) {
- baselineDisposed(getBaseline());
- }
- ManifestElement[] sourceBundle = null;
- try {
- sourceBundle = ManifestElement.parseHeader(IApiCoreConstants.ECLIPSE_SOURCE_BUNDLE, (String) fManifest.get(IApiCoreConstants.ECLIPSE_SOURCE_BUNDLE));
- } catch (BundleException e) {
- // ignore
- }
- if (sourceBundle != null) {
- // this is a source bundle with the new format
- return true;
- }
- // check for the old format
- String pluginXMLContents = readFileContents(IApiCoreConstants.PLUGIN_XML_NAME,new File(getLocation()));
- if (pluginXMLContents != null) {
- if (containsSourceExtensionPoint(pluginXMLContents)) {
- return true;
- }
- }
- // check if it contains a fragment.xml with the appropriate extension point
- pluginXMLContents = readFileContents(IApiCoreConstants.FRAGMENT_XML_NAME,new File(getLocation()));
- if (pluginXMLContents != null) {
- if (containsSourceExtensionPoint(pluginXMLContents)) {
- return true;
- }
- }
- // parse XML contents to find extension points
- return false;
- }
-
- /**
- * Check if the given source contains an source extension point.
- *
- * @param pluginXMLContents the given file contents
- * @return true if it contains a source extension point, false otherwise
- */
- private boolean containsSourceExtensionPoint(String pluginXMLContents) {
- SAXParserFactory factory = null;
- try {
- factory = SAXParserFactory.newInstance();
- } catch (FactoryConfigurationError e) {
- return false;
- }
- SAXParser saxParser = null;
- try {
- saxParser = factory.newSAXParser();
- } catch (ParserConfigurationException e) {
- // ignore
- } catch (SAXException e) {
- // ignore
- }
-
- if (saxParser == null) {
- return false;
- }
-
- // Parse
- InputSource inputSource = new InputSource(new BufferedReader(new StringReader(pluginXMLContents)));
- try {
- SourceDefaultHandler defaultHandler = new SourceDefaultHandler();
- saxParser.parse(inputSource, defaultHandler);
- return defaultHandler.isSource();
- } catch (SAXException e) {
- // ignore
- } catch (IOException e) {
- // ignore
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.IApiComponent#isFragment()
- */
- public synchronized boolean isFragment() throws CoreException {
- if (this.fBundleDescription == null) {
- baselineDisposed(getBaseline());
- }
- return fBundleDescription.getHost() != null;
- }
-
- /**
- * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent#getHost()
- */
- public synchronized IApiComponent getHost() throws CoreException {
- if (this.fBundleDescription == null) {
- baselineDisposed(getBaseline());
- }
- HostSpecification host = fBundleDescription.getHost();
- if(host != null) {
- return getBaseline().getApiComponent(host.getName());
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.IApiComponent#hasFragments()
- */
- public synchronized boolean hasFragments() throws CoreException {
- if (this.fBundleDescription == null) {
- baselineDisposed(getBaseline());
- }
- return fBundleDescription.getFragments().length != 0;
- }
-
- /**
- * Sets whether this bundle has an underlying API description file.
- *
- * @param hasApiDescription whether this bundle has an underlying API description file
- */
- protected void setHasApiDescription(boolean hasApiDescription) {
- fHasApiDescription = hasApiDescription;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.internal.provisional.IApiComponent#hasApiDescription()
- */
- public boolean hasApiDescription() {
- // ensure initialized
- try {
- getApiDescription();
- } catch (CoreException e) {
- }
- return fHasApiDescription;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent#getLowestEEs()
- */
- public String[] getLowestEEs() throws CoreException {
- if (this.lowestEEs != null) return this.lowestEEs;
- String[] temp = null;
- String[] executionEnvironments = this.getExecutionEnvironments();
- int length = executionEnvironments.length;
- switch(length) {
- case 0 :
- return null;
- case 1 :
- temp = new String[] { executionEnvironments[0] };
- break;
- default :
- int values = ProfileModifiers.NO_PROFILE_VALUE;
- for (int i = 0; i < length; i++) {
- values |= ProfileModifiers.getValue(executionEnvironments[i]);
- }
- if (ProfileModifiers.isJRE(values)) {
- if (ProfileModifiers.isJRE_1_1(values)) {
- temp = new String[] { ProfileModifiers.JRE_1_1_NAME };
- } else if (ProfileModifiers.isJ2SE_1_2(values)) {
- temp = new String[] { ProfileModifiers.J2SE_1_2_NAME };
- } else if (ProfileModifiers.isJ2SE_1_3(values)) {
- temp = new String[] { ProfileModifiers.J2SE_1_3_NAME };
- } else if (ProfileModifiers.isJ2SE_1_4(values)) {
- temp = new String[] { ProfileModifiers.J2SE_1_4_NAME };
- } else if (ProfileModifiers.isJ2SE_1_5(values)) {
- temp = new String[] { ProfileModifiers.J2SE_1_5_NAME };
- } else {
- // this is 1.6
- temp = new String[] { ProfileModifiers.JAVASE_1_6_NAME };
- }
- }
- if (ProfileModifiers.isCDC_Foundation(values)) {
- if (ProfileModifiers.isCDC_1_0_FOUNDATION_1_0(values)) {
- if (temp != null) {
- temp = new String[] { temp[0], ProfileModifiers.CDC_1_0_FOUNDATION_1_0_NAME };
- } else {
- temp = new String[] { ProfileModifiers.CDC_1_0_FOUNDATION_1_0_NAME };
- }
- } else {
- if (temp != null) {
- temp = new String[] { temp[0], ProfileModifiers.CDC_1_1_FOUNDATION_1_1_NAME };
- } else {
- temp = new String[] { ProfileModifiers.CDC_1_1_FOUNDATION_1_1_NAME };
- }
- }
- }
- if (ProfileModifiers.isOSGi(values)) {
- if (ProfileModifiers.isOSGI_MINIMUM_1_0(values)) {
- if (temp != null) {
- int tempLength = temp.length;
- System.arraycopy(temp, 0, (temp = new String[tempLength + 1]), 0, tempLength);
- temp[tempLength] = ProfileModifiers.OSGI_MINIMUM_1_0_NAME;
- } else {
- temp = new String[] { ProfileModifiers.OSGI_MINIMUM_1_0_NAME };
- }
- } else if (ProfileModifiers.isOSGI_MINIMUM_1_1(values)) {
- if (temp != null) {
- int tempLength = temp.length;
- System.arraycopy(temp, 0, (temp = new String[tempLength + 1]), 0, tempLength);
- temp[tempLength] = ProfileModifiers.OSGI_MINIMUM_1_1_NAME;
- } else {
- temp = new String[] { ProfileModifiers.OSGI_MINIMUM_1_1_NAME };
- }
- } else {
- // OSGI_MINIMUM_1_2
- if (temp != null) {
- int tempLength = temp.length;
- System.arraycopy(temp, 0, (temp = new String[tempLength + 1]), 0, tempLength);
- temp[tempLength] = ProfileModifiers.OSGI_MINIMUM_1_2_NAME;
- } else {
- temp = new String[] { ProfileModifiers.OSGI_MINIMUM_1_2_NAME };
- }
- }
- }
- }
- this.lowestEEs = temp;
- return temp;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent#getErrors()
- */
- public synchronized ResolverError[] getErrors() throws CoreException {
- ApiBaseline baseline = (ApiBaseline) getBaseline();
- if (this.fBundleDescription == null) {
- baselineDisposed(baseline);
- }
- if (baseline != null) {
- ResolverError[] resolverErrors = baseline.getState().getResolverErrors(this.fBundleDescription);
- if (resolverErrors.length == 0) {
- return null;
- }
- return resolverErrors;
- }
- return null;
- }
-
- /**
- * @param baseline the baseline that is disposed
- * @throws CoreException with the baseline disposed information
- */
- protected void baselineDisposed(IApiBaseline baseline) throws CoreException {
- throw new CoreException(
- new Status(
- IStatus.ERROR,
- ApiPlugin.PLUGIN_ID,
- ApiPlugin.REPORT_BASELINE_IS_DISPOSED,
- NLS.bind(Messages.BundleApiComponent_baseline_disposed, baseline.getName()),
- null));
- }
-}
Index: src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java
===================================================================
RCS file: src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java
diff -N src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,1303 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 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.model;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.service.resolver.BundleDescription;
+import org.eclipse.osgi.service.resolver.BundleSpecification;
+import org.eclipse.osgi.service.resolver.ExportPackageDescription;
+import org.eclipse.osgi.service.resolver.HostSpecification;
+import org.eclipse.osgi.service.resolver.ResolverError;
+import org.eclipse.osgi.service.resolver.State;
+import org.eclipse.osgi.service.resolver.StateObjectFactory;
+import org.eclipse.osgi.util.ManifestElement;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.pde.api.tools.internal.ApiBaselineManager;
+import org.eclipse.pde.api.tools.internal.ApiDescription;
+import org.eclipse.pde.api.tools.internal.ApiDescriptionProcessor;
+import org.eclipse.pde.api.tools.internal.BundleVersionRange;
+import org.eclipse.pde.api.tools.internal.CompositeApiDescription;
+import org.eclipse.pde.api.tools.internal.IApiCoreConstants;
+import org.eclipse.pde.api.tools.internal.RequiredComponentDescription;
+import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
+import org.eclipse.pde.api.tools.internal.provisional.Factory;
+import org.eclipse.pde.api.tools.internal.provisional.IApiAccess;
+import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
+import org.eclipse.pde.api.tools.internal.provisional.IApiFilterStore;
+import org.eclipse.pde.api.tools.internal.provisional.IRequiredComponentDescription;
+import org.eclipse.pde.api.tools.internal.provisional.ProfileModifiers;
+import org.eclipse.pde.api.tools.internal.provisional.VisibilityModifiers;
+import org.eclipse.pde.api.tools.internal.provisional.descriptors.IPackageDescriptor;
+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.model.IApiElement;
+import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;
+import org.eclipse.pde.api.tools.internal.util.FileManager;
+import org.eclipse.pde.api.tools.internal.util.SourceDefaultHandler;
+import org.eclipse.pde.api.tools.internal.util.Util;
+import org.eclipse.pde.internal.core.TargetWeaver;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * Implementation of an API component based on a bundle in the file system.
+ *
+ * @since 1.0.0
+ */
+public class BundleComponent extends Component {
+
+ static final String TMP_API_FILE_PREFIX = "api"; //$NON-NLS-1$
+ static final String TMP_API_FILE_POSTFIX = "tmp"; //$NON-NLS-1$
+
+ /**
+ * Dictionary parsed from MANIFEST.MF
+ */
+ private Dictionary fManifest;
+
+ /**
+ * Manifest headers that are maintained after {@link BundleDescription} creation.
+ * Only these headers are maintained in the manifest dictionary to reduce footprint.
+ */
+ private static final String[] MANIFEST_HEADERS = new String[] {
+ IApiCoreConstants.ECLIPSE_SOURCE_BUNDLE,
+ Constants.BUNDLE_CLASSPATH,
+ Constants.BUNDLE_NAME,
+ Constants.BUNDLE_VERSION
+ };
+
+ /**
+ * Whether there is an underlying .api_description file
+ */
+ private boolean fHasApiDescription = false;
+
+ /**
+ * Root location of component in the file system
+ */
+ private String fLocation;
+
+ /**
+ * Underlying bundle description (OSGi model of a bundle)
+ */
+ private BundleDescription fBundleDescription;
+
+ /**
+ * Symbolic name of this bundle
+ */
+ private String fSymbolicName = null;
+
+ /**
+ * Bundle version
+ */
+ private Version fVersion = null;
+
+ /**
+ * Cached value for the lowest EEs
+ */
+ private String[] lowestEEs;
+
+ /**
+ * Flag to know if this component is a binary bundle in the workspace
+ * i.e. an imported binary bundle
+ */
+ private boolean fWorkspaceBinary = false;
+
+ /**
+ * The id of this component
+ */
+ private long fBundleId = 0L;
+
+ /**
+ * Constructs a new API component from the specified location in the file system
+ * in the given profile.
+ *
+ * @param baseline owning API baseline
+ * @param location directory or jar file
+ * @param bundleid
+ * @exception CoreException if unable to create a component from the specified location
+ */
+ public BundleComponent(IApiBaseline baseline, String location, long bundleid) throws CoreException {
+ super(baseline);
+ fLocation = location;
+ fBundleId = bundleid;
+ fWorkspaceBinary = isBinary() && ApiBaselineManager.WORKSPACE_API_BASELINE_ID.equals(baseline.getName());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.descriptors.AbstractApiComponent#dispose()
+ */
+ public void dispose() {
+ try {
+ super.dispose();
+ } finally {
+ synchronized(this) {
+ fManifest = null;
+ fBundleDescription = null;
+ }
+ }
+ }
+
+ /**
+ * Returns this bundle's manifest as a dictionary.
+ *
+ * @return manifest dictionary
+ * @exception CoreException if something goes terribly wrong
+ */
+ protected synchronized Dictionary getManifest() throws CoreException {
+ if(fManifest == null) {
+ try {
+ fManifest = (Dictionary) loadManifest(new File(fLocation));
+ } catch (IOException e) {
+ abort("Unable to load manifest due to IO error", e); //$NON-NLS-1$
+ }
+ }
+ return fManifest;
+ }
+
+ /**
+ * Reduce the manifest to only contain required headers after {@link BundleDescription} creation.
+ */
+ protected synchronized void doManifestCompaction() {
+ Dictionary temp = fManifest;
+ fManifest = new Hashtable(MANIFEST_HEADERS.length, 1);
+ for (int i = 0; i < MANIFEST_HEADERS.length; i++) {
+ String header = MANIFEST_HEADERS[i];
+ Object value = temp.get(header);
+ if (value != null) {
+ fManifest.put(header, value);
+ }
+ }
+ }
+
+ /**
+ * Returns if the bundle at the specified location is a valid bundle or not.
+ * Validity is determined via the existence of a readable manifest file
+ * @param location
+ * @return true if the bundle at the given location is valid false otherwise
+ * @throws IOException
+ */
+ public boolean isValidBundle() throws CoreException {
+ Dictionary manifest = getManifest();
+ return manifest != null && (manifest.get(Constants.BUNDLE_NAME) != null && manifest.get(Constants.BUNDLE_VERSION) != null);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if(obj instanceof BundleComponent) {
+ BundleComponent comp = (BundleComponent) obj;
+ return getName().equals(comp.getName()) &&
+ getSymbolicName().equals(comp.getSymbolicName()) &&
+ getVersion().equals(comp.getVersion());
+ }
+ return false;
+ }
+
+ /**
+ * Initializes the component
+ * @throws CoreException on failure
+ */
+ protected synchronized void init() {
+ if(fBundleDescription != null) {
+ return;
+ }
+ try {
+ Dictionary manifest = getManifest();
+ if (isWorkspaceBinary()) {
+ // must account for bundles in development mode - look for class files in output
+ // folders rather than jars
+ TargetWeaver.weaveManifest(manifest);
+ }
+ fBundleDescription = getBundleDescription(manifest, fLocation, fBundleId);
+ if(fBundleDescription == null) {
+ ApiPlugin.log(new Status(
+ IStatus.ERROR,
+ ApiPlugin.PLUGIN_ID,
+ "Unable to resolve the BundleDescription for the component from: " + fLocation, //$NON-NLS-1$
+ null));
+ }
+ fSymbolicName = fBundleDescription.getSymbolicName();
+ fVersion = fBundleDescription.getVersion();
+ setName((String)manifest.get(Constants.BUNDLE_NAME));
+ } catch (BundleException e) {
+ ApiPlugin.log(new Status(
+ IStatus.ERROR,
+ ApiPlugin.PLUGIN_ID,
+ "Unable to create API component from specified location: " + fLocation, //$NON-NLS-1$
+ e));
+ }
+ catch (CoreException ce) {
+ ApiPlugin.log(ce);
+ }
+ // compact manifest after initialization - only keep used headers
+ doManifestCompaction();
+ }
+
+ /**
+ * Returns if this component is a a binary bundle in the workspace
+ * i.e. an imported binary bundle
+ * @return true if the component is a binary bundle in the workspace, false otherwise
+ */
+ public boolean isWorkspaceBinary() {
+ return fWorkspaceBinary;
+ }
+
+ /**
+ * Returns the {@link State} from the backing baseline
+ * @return the state from the backing {@link ApiBaseline}
+ */
+ protected State getState() {
+ return ((ApiBaseline)getBaseline()).getState();
+ }
+
+ /**
+ * Returns the {@link BundleDescription} for the given manifest + state or throws an exception, never
+ * returns null
+ * @param manifest
+ * @param location
+ * @param id
+ * @return the {@link BundleDescription} or throws an exception
+ * @throws BundleException
+ */
+ protected BundleDescription getBundleDescription(Dictionary manifest, String location, long id) throws BundleException {
+ State state = getState();
+ BundleDescription bundle = lookupBundle(state, manifest);
+ if(bundle != null) {
+ return bundle;
+ }
+ StateObjectFactory factory = StateObjectFactory.defaultFactory;
+ bundle = factory.createBundleDescription(state, manifest, fLocation, id);
+ state.addBundle(bundle);
+ return bundle;
+ }
+
+ /**
+ * Tries to look up the bundle described by the given manifest in the given state
+ * @param manifest
+ * @return the bundle for the given manifest, null
otherwise
+ */
+ protected BundleDescription lookupBundle(State state, Dictionary manifest) {
+ Version version = null;
+ try {
+ //just in case the version is not a number
+ String ver = (String)manifest.get(Constants.BUNDLE_VERSION);
+ version = ver != null ? new Version(ver) : null;
+ }
+ catch (NumberFormatException nfe) {
+ version = null;
+ }
+ return state.getBundle((String)manifest.get(Constants.BUNDLE_SYMBOLICNAME), version);
+ }
+
+ /**
+ * Returns whether this API component represents a binary bundle versus a project bundle.
+ *
+ * @return whether this API component represents a binary bundle
+ */
+ protected boolean isBinary() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.AbstractApiComponent#createApiDescription()
+ */
+ protected IApiDescription createApiDescription() throws CoreException {
+ BundleDescription[] fragments = getBundleDescription().getFragments();
+ if (fragments.length == 0) {
+ return createLocalApiDescription();
+ }
+ // build a composite description
+ IApiDescription[] descriptions = new IApiDescription[fragments.length + 1];
+ for (int i = 0; i < fragments.length; i++) {
+ BundleDescription fragment = fragments[i];
+ BundleComponent component = (BundleComponent) getBaseline().getApiComponent(fragment.getSymbolicName());
+ descriptions[i + 1] = component.getApiDescription();
+ }
+ descriptions[0] = createLocalApiDescription();
+ return new CompositeApiDescription(descriptions);
+ }
+
+ /**
+ * Creates and returns this component's API description based on packages
+ * supplied by this component, exported packages, and associated directives.
+ *
+ * @return API description
+ * @throws CoreException if unable to initialize
+ */
+ protected IApiDescription createLocalApiDescription() throws CoreException {
+ IApiDescription apiDesc = new ApiDescription(getSymbolicName());
+ // first mark all packages as internal
+ initializeApiDescription(apiDesc, getBundleDescription(), getLocalPackageNames());
+ try {
+ String xml = loadApiDescription(new File(fLocation));
+ setHasApiDescription(xml != null);
+ if (xml != null) {
+ ApiDescriptionProcessor.annotateApiSettings(null, apiDesc, xml);
+ }
+ } catch (IOException e) {
+ abort("Unable to load .api_description file ", e); //$NON-NLS-1$
+ }
+ return apiDesc;
+ }
+
+ /**
+ * Returns the names of all packages that originate from this bundle.
+ * Does not include packages that originate from fragments or a host.
+ *
+ * @return local package names
+ * @throws CoreException
+ */
+ protected Set getLocalPackageNames() throws CoreException {
+ Set names = new HashSet();
+ IApiTypeContainer[] containers = getApiTypeContainers();
+ IApiComponent comp = null;
+ for (int i = 0; i < containers.length; i++) {
+ comp = (IApiComponent) containers[i].getAncestor(IApiElement.COMPONENT);
+ if (comp != null && comp.getSymbolicName().equals(getSymbolicName())) {
+ String[] packageNames = containers[i].getPackageNames();
+ for (int j = 0; j < packageNames.length; j++) {
+ names.add(packageNames[j]);
+ }
+ }
+ }
+ return names;
+ }
+
+
+ /**
+ * Initializes the given API description based on package exports in the manifest.
+ * The API description for a bundle only contains packages that originate from
+ * this bundle (so a host will not contain API descriptions for packages that
+ * originate from fragments). However, a host's API description will be represented
+ * by a proxy that delegates to the host and all of its fragments to provide
+ * a complete description of the host.
+ *
+ * @param apiDesc API description to initialize
+ * @param bundle the bundle to load from
+ * @param packages the complete set of packages names originating from the backing
+ * component
+ * @throws CoreException if an error occurs
+ */
+ public static void initializeApiDescription(IApiDescription apiDesc, BundleDescription bundle, Set packages) throws CoreException {
+ Iterator iterator = packages.iterator();
+ while (iterator.hasNext()) {
+ String name = (String) iterator.next();
+ apiDesc.setVisibility(Factory.packageDescriptor(name), VisibilityModifiers.PRIVATE);
+ }
+ // then process exported packages that originate from this bundle
+ // considering host and fragment package exports
+ List supplied = new ArrayList();
+ ExportPackageDescription[] exportPackages = bundle.getExportPackages();
+ addSuppliedPackages(packages, supplied, exportPackages);
+ HostSpecification host = bundle.getHost();
+ if (host != null) {
+ BundleDescription[] hosts = host.getHosts();
+ for (int i = 0; i < hosts.length; i++) {
+ addSuppliedPackages(packages, supplied, hosts[i].getExportPackages());
+ }
+ }
+ BundleDescription[] fragments = bundle.getFragments();
+ for (int i = 0; i < fragments.length; i++) {
+ addSuppliedPackages(packages, supplied, fragments[i].getExportPackages());
+ }
+
+ annotateExportedPackages(apiDesc, (ExportPackageDescription[]) supplied.toArray(new ExportPackageDescription[supplied.size()]));
+ }
+
+ /**
+ * Adds package exports to the given list if the associated package originates
+ * from this bundle.
+ *
+ * @param packages names of packages supplied by this bundle
+ * @param supplied list to append package exports to
+ * @param exportPackages package exports to consider
+ */
+ protected static void addSuppliedPackages(Set packages, List supplied, ExportPackageDescription[] exportPackages) {
+ for (int i = 0; i < exportPackages.length; i++) {
+ ExportPackageDescription pkg = exportPackages[i];
+ String name = pkg.getName();
+ if (name.equals(".")) { //$NON-NLS-1$
+ // translate . to default package
+ name = Util.DEFAULT_PACKAGE_NAME;
+ }
+ if (packages.contains(name)) {
+ supplied.add(pkg);
+ }
+ }
+ }
+
+ /**
+ * Annotates the API description with exported packages.
+ *
+ * @param apiDesc description to annotate
+ * @param exportedPackages packages that are exported
+ */
+ protected static void annotateExportedPackages(IApiDescription apiDesc, ExportPackageDescription[] exportedPackages) {
+ for(int i = 0; i < exportedPackages.length; i++) {
+ ExportPackageDescription pkg = exportedPackages[i];
+ boolean internal = ((Boolean) pkg.getDirective("x-internal")).booleanValue(); //$NON-NLS-1$
+ String[] friends = (String[]) pkg.getDirective("x-friends"); //$NON-NLS-1$
+ String pkgName = pkg.getName();
+ if (pkgName.equals(".")) { //$NON-NLS-1$
+ // default package
+ pkgName = ""; //$NON-NLS-1$
+ }
+ IPackageDescriptor pkgDesc = Factory.packageDescriptor(pkgName);
+ if(internal) {
+ apiDesc.setVisibility(pkgDesc, VisibilityModifiers.PRIVATE);
+ }
+ if (friends != null) {
+ apiDesc.setVisibility(pkgDesc, VisibilityModifiers.PRIVATE);
+ for(int j = 0; j < friends.length; j++) {
+ //annotate the api description for x-friends access levels
+ apiDesc.setAccessLevel(
+ Factory.componentDescriptor(friends[j]),
+ Factory.packageDescriptor(pkgName),
+ IApiAccess.FRIEND);
+ }
+ }
+ if (!internal && friends == null) {
+ //there could have been directives that have nothing to do with
+ //visibility, so we need to add the package as API in that case
+ apiDesc.setVisibility(pkgDesc, VisibilityModifiers.API);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.AbstractApiComponent#createApiFilterStore()
+ */
+ protected IApiFilterStore createApiFilterStore() throws CoreException {
+ //always return a new empty store since we do not support filtering from bundles
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.pde.api.tools.internal.AbstractApiTypeContainer#createApiTypeContainers()
+ */
+ protected synchronized List createApiTypeContainers() throws CoreException {
+ if (fBundleDescription == null) {
+ baselineDisposed(getBaseline());
+ }
+ List containers = new ArrayList(5);
+ try {
+ List all = new ArrayList();
+ // build the classpath from bundle and all fragments
+ all.add(this);
+ boolean considerFragments = true;
+ if (Util.ORG_ECLIPSE_SWT.equals(getSymbolicName())) {
+ // if SWT is a project to be built/analyzed don't consider its fragments
+ considerFragments = !isApiEnabled();
+ }
+ if (considerFragments) {
+ BundleDescription[] fragments = fBundleDescription.getFragments();
+ for (int i = 0; i < fragments.length; i++) {
+ BundleDescription fragment = fragments[i];
+ BundleComponent component = (BundleComponent) getBaseline().getApiComponent(fragment.getSymbolicName());
+ if (component != null) {
+ // force initialization of the fragment so we can retrieve its class file containers
+ component.getApiTypeContainers();
+ all.add(component);
+ }
+ }
+ }
+ Iterator iterator = all.iterator();
+ Set entryNames = new HashSet(5);
+ BundleComponent other = null;
+ while (iterator.hasNext()) {
+ BundleComponent component = (BundleComponent) iterator.next();
+ String[] paths = getClasspathEntries(component.getManifest());
+ for (int i = 0; i < paths.length; i++) {
+ String path = paths[i];
+ // don't re-process the same entry twice (except default entries ".")
+ if (!(".".equals(path))) { //$NON-NLS-1$
+ if (entryNames.contains(path)) {
+ continue;
+ }
+ }
+ IApiTypeContainer container = component.createApiTypeContainer(path);
+ if (container == null) {
+ for(Iterator iter = all.iterator(); iter.hasNext();) {
+ other = (BundleComponent) iter.next();
+ if (other != component) {
+ container = other.createApiTypeContainer(path);
+ }
+ }
+ }
+ if (container != null) {
+ containers.add(container);
+ if (!(".".equals(path))) { //$NON-NLS-1$
+ entryNames.add(path);
+ }
+ }
+ }
+ }
+ } catch (BundleException e) {
+ abort("Unable to parse bundle classpath", e); //$NON-NLS-1$
+ } catch (IOException e) {
+ abort("Unable to initialize class file containers", e); //$NON-NLS-1$
+ }
+ return containers;
+ }
+
+ /**
+ * Returns whether this API component is enabled for API analysis by the API builder.
+ *
+ * @return whether this API component is enabled for API analysis by the API builder.
+ */
+ protected boolean isApiEnabled() {
+ return false;
+ }
+
+ /**
+ * Returns classpath entries defined in the given manifest.
+ *
+ * @param manifest
+ * @return classpath entries as bundle relative paths
+ * @throws BundleException
+ */
+ protected String[] getClasspathEntries(Dictionary manifest) throws BundleException {
+ ManifestElement[] classpath = ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, (String) manifest.get(Constants.BUNDLE_CLASSPATH));
+ String elements[] = null;
+ if (classpath == null) {
+ // default classpath is '.'
+ elements = new String[]{"."}; //$NON-NLS-1$
+ } else {
+ elements = new String[classpath.length];
+ for (int i = 0; i < classpath.length; i++) {
+ elements[i] = classpath[i].getValue();
+ }
+ }
+ return elements;
+ }
+
+ /**
+ * Creates and returns an {@link IApiTypeContainer} at the specified path in
+ * this bundle, or null
if the {@link IApiTypeContainer} does not
+ * exist. The path is the name (path) of entries specified by the
+ * Bundle-ClassPath:
header.
+ *
+ * @param path relative path to a class file container in this bundle
+ * @return {@link IApiTypeContainer} or null
+ * @exception IOException
+ */
+ protected IApiTypeContainer createApiTypeContainer(String path) throws IOException, CoreException {
+ File bundle = new File(fLocation);
+ if (bundle.isDirectory()) {
+ // bundle is folder
+ File entry = new File(bundle, path);
+ if (entry.exists()) {
+ if (entry.isFile()) {
+ return new ArchiveApiTypeContainer(this, entry.getCanonicalPath());
+ } else {
+ return new DirectoryApiTypeContainer(this, entry.getCanonicalPath());
+ }
+ }
+ } else {
+ // bundle is jar'd
+ ZipFile zip = null;
+ try {
+ if (path.equals(".")) { //$NON-NLS-1$
+ return new ArchiveApiTypeContainer(this, fLocation);
+ } else {
+ //classpath element can be jar or folder
+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=279729
+ zip = new ZipFile(fLocation);
+ ZipEntry entry = zip.getEntry(path);
+ if (entry != null) {
+ File tmpfolder = new File(System.getProperty("java.io.tmpdir")); //$NON-NLS-1$
+ if(entry.isDirectory()) {
+ //extract the dir and all children
+ File dir = File.createTempFile(TMP_API_FILE_PREFIX, TMP_API_FILE_POSTFIX);
+ dir.deleteOnExit();
+ //hack to create a temp directory
+ // see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4735419
+ if(dir.delete()) {
+ dir.mkdir();
+ FileManager.getManager().recordTempFileRoot(dir.getCanonicalPath());
+ }
+ extractDirectory(zip, entry.getName(), dir);
+ if(dir.isDirectory() && dir.exists()) {
+ return new DirectoryApiTypeContainer(this, dir.getCanonicalPath());
+ }
+ }
+ else {
+ File file = extractEntry(zip, entry, tmpfolder);
+ if(Util.isArchive(file.getName())) {
+ File parent = file.getParentFile();
+ if(!parent.equals(tmpfolder)) {
+ FileManager.getManager().recordTempFileRoot(parent.getCanonicalPath());
+ }
+ else {
+ FileManager.getManager().recordTempFileRoot(file.getCanonicalPath());
+ }
+ return new ArchiveApiTypeContainer(this, file.getCanonicalPath());
+ }
+ }
+ }
+ }
+ } finally {
+ if (zip != null) {
+ zip.close();
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Extracts a directory from the archive given a path prefix for entries to retrieve.
+ * null
can be passed in as a prefix, causing all entries to be be extracted from
+ * the archive.
+ *
+ * @param zip the {@link ZipFile} to extract from
+ * @param pathprefix the prefix'ing path to include for extraction
+ * @param parent the parent directory to extract to
+ * @throws IOException if the {@link ZipFile} cannot be read or extraction fails to write the file(s)
+ */
+ void extractDirectory(ZipFile zip, String pathprefix, File parent) throws IOException {
+ Enumeration entries = zip.entries();
+ String prefix = (pathprefix == null ? Util.EMPTY_STRING : pathprefix);
+ ZipEntry entry = null;
+ File file = null;
+ while (entries.hasMoreElements()) {
+ entry = (ZipEntry) entries.nextElement();
+ if(entry.getName().startsWith(prefix)) {
+ file = new File(parent, entry.getName());
+ if (entry.isDirectory()) {
+ file.mkdir();
+ continue;
+ }
+ extractEntry(zip, entry, parent);
+ }
+ }
+ }
+
+ /**
+ * Extracts a non-directory entry from a zip file and returns the File handle
+ * @param zip the zip to extract from
+ * @param entry the entry to extract
+ * @param parent the parent directory to add the extracted entry to
+ * @return the file handle to the extracted entry, null
otherwise
+ * @throws IOException
+ */
+ File extractEntry(ZipFile zip, ZipEntry entry, File parent) throws IOException {
+ InputStream inputStream = null;
+ File file;
+ FileOutputStream outputStream = null;
+ try {
+ inputStream = zip.getInputStream(entry);
+ file = new File(parent, entry.getName());
+ File lparent = file.getParentFile();
+ if(!lparent.exists()) {
+ lparent.mkdirs();
+ }
+ outputStream = new FileOutputStream(file);
+ byte[] bytes = new byte[8096];
+ while (inputStream.available() > 0) {
+ int read = inputStream.read(bytes);
+ if (read > 0) {
+ outputStream.write(bytes, 0, read);
+ }
+ }
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch(IOException e) {
+ ApiPlugin.log(e);
+ }
+ }
+ if (outputStream != null) {
+ try {
+ outputStream.close();
+ } catch(IOException e) {
+ ApiPlugin.log(e);
+ }
+ }
+ }
+ return file;
+ }
+
+ /**
+ * Parses a bunlde's manifest into a dictionary. The bundle may be in a jar
+ * or in a directory at the specified location.
+ *
+ * @param bundleLocation root location of the bundle
+ * @return bundle manifest dictionary or null
if none
+ * @throws IOException if unable to parse
+ */
+ protected Map loadManifest(File bundleLocation) throws IOException {
+ ZipFile jarFile = null;
+ InputStream manifestStream = null;
+ String extension = new Path(bundleLocation.getName()).getFileExtension();
+ try {
+ if (extension != null && extension.equals("jar") && bundleLocation.isFile()) { //$NON-NLS-1$
+ jarFile = new ZipFile(bundleLocation, ZipFile.OPEN_READ);
+ ZipEntry manifestEntry = jarFile.getEntry(JarFile.MANIFEST_NAME);
+ if (manifestEntry != null) {
+ manifestStream = jarFile.getInputStream(manifestEntry);
+ }
+ } else {
+ File file = new File(bundleLocation, JarFile.MANIFEST_NAME);
+ if (file.exists())
+ manifestStream = new FileInputStream(file);
+ }
+ if (manifestStream == null) {
+ return null;
+ }
+ return ManifestElement.parseBundleManifest(manifestStream, new Hashtable(10));
+ } catch (BundleException e) {
+ ApiPlugin.log(e);
+ } finally {
+ closingZipFileAndStream(manifestStream, jarFile);
+ }
+ return null;
+ }
+
+ /**
+ * Reads and returns this bunlde's manifest in a Manifest object.
+ * The bundle may be in a jar or in a directory at the specified location.
+ *
+ * @param bundleLocation root location of the bundle
+ * @return manifest or null
if not present
+ * @throws IOException if unable to parse
+ */
+ protected Manifest readManifest(File bundleLocation) throws IOException {
+ ZipFile jarFile = null;
+ InputStream manifestStream = null;
+ try {
+ String extension = new Path(bundleLocation.getName()).getFileExtension();
+ if (extension != null && extension.equals("jar") && bundleLocation.isFile()) { //$NON-NLS-1$
+ jarFile = new ZipFile(bundleLocation, ZipFile.OPEN_READ);
+ ZipEntry manifestEntry = jarFile.getEntry(JarFile.MANIFEST_NAME);
+ if (manifestEntry != null) {
+ manifestStream = jarFile.getInputStream(manifestEntry);
+ }
+ } else {
+ File file = new File(bundleLocation, JarFile.MANIFEST_NAME);
+ if (file.exists())
+ manifestStream = new FileInputStream(file);
+ }
+ if (manifestStream == null) {
+ return null;
+ }
+ return new Manifest(manifestStream);
+ } finally {
+ closingZipFileAndStream(manifestStream, jarFile);
+ }
+ }
+
+ void closingZipFileAndStream(InputStream stream, ZipFile jarFile) {
+ try {
+ if (stream != null) {
+ stream.close();
+ }
+ } catch (IOException e) {
+ ApiPlugin.log(e);
+ }
+ try {
+ if (jarFile != null) {
+ jarFile.close();
+ }
+ } catch (IOException e) {
+ ApiPlugin.log(e);
+ }
+ }
+
+ /**
+ * Reads and returns the file contents corresponding to the given file name.
+ * The bundle may be in a jar or in a directory at the specified location.
+ *
+ * @param xmlFileName the given file name
+ * @param bundleLocation the root location of the bundle
+ * @return the file contents or null
if not present
+ */
+ protected String readFileContents(String xmlFileName, File bundleLocation) {
+ ZipFile jarFile = null;
+ InputStream stream = null;
+ try {
+ String extension = new Path(bundleLocation.getName()).getFileExtension();
+ if (extension != null && extension.equals("jar") && bundleLocation.isFile()) { //$NON-NLS-1$
+ jarFile = new ZipFile(bundleLocation, ZipFile.OPEN_READ);
+ ZipEntry manifestEntry = jarFile.getEntry(xmlFileName);
+ if (manifestEntry != null) {
+ stream = jarFile.getInputStream(manifestEntry);
+ }
+ } else {
+ File file = new File(bundleLocation, xmlFileName);
+ if (file.exists()) {
+ stream = new FileInputStream(file);
+ }
+ }
+ if (stream == null) {
+ return null;
+ }
+ return new String(Util.getInputStreamAsCharArray(stream, -1, IApiCoreConstants.UTF_8));
+ } catch(IOException e) {
+ //TODO abort
+ ApiPlugin.log(e);
+ } finally {
+ closingZipFileAndStream(stream, jarFile);
+ }
+ return null;
+ }
+
+ /**
+ * Parses a bundle's .api_description XML into a string. The file may be in a jar
+ * or in a directory at the specified location.
+ *
+ * @param bundleLocation root location of the bundle
+ * @return API description XML as a string or null
if none
+ * @throws IOException if unable to parse
+ */
+ protected String loadApiDescription(File bundleLocation) throws IOException {
+ ZipFile jarFile = null;
+ InputStream stream = null;
+ String contents = null;
+ try {
+ String extension = new Path(bundleLocation.getName()).getFileExtension();
+ if (extension != null && extension.equals("jar") && bundleLocation.isFile()) { //$NON-NLS-1$
+ jarFile = new ZipFile(bundleLocation, ZipFile.OPEN_READ);
+ ZipEntry manifestEntry = jarFile.getEntry(IApiCoreConstants.API_DESCRIPTION_XML_NAME);
+ if (manifestEntry != null) {
+ // new file is present
+ stream = jarFile.getInputStream(manifestEntry);
+ }
+ } else {
+ File file = new File(bundleLocation, IApiCoreConstants.API_DESCRIPTION_XML_NAME);
+ if (file.exists()) {
+ // use new file
+ stream = new FileInputStream(file);
+ }
+ }
+ if (stream == null) {
+ return null;
+ }
+ char[] charArray = Util.getInputStreamAsCharArray(stream, -1, IApiCoreConstants.UTF_8);
+ contents = new String(charArray);
+ } finally {
+ closingZipFileAndStream(stream, jarFile);
+ }
+ return contents;
+ }
+
+
+ /**
+ * Returns a URL describing a file inside a bundle.
+ *
+ * @param bundleLocation root location of the bundle. May be a
+ * directory or a file (jar)
+ * @param filePath bundle relative path to desired file
+ * @return URL to the file
+ * @throws MalformedURLException
+ */
+ protected URL getFileInBundle(File bundleLocation, String filePath) throws MalformedURLException {
+ String extension = new Path(bundleLocation.getName()).getFileExtension();
+ StringBuffer urlSt = new StringBuffer();
+ if (extension != null && extension.equals("jar") && bundleLocation.isFile()) { //$NON-NLS-1$
+ urlSt.append("jar:file:"); //$NON-NLS-1$
+ urlSt.append(bundleLocation.getAbsolutePath());
+ urlSt.append("!/"); //$NON-NLS-1$
+ urlSt.append(filePath);
+ } else {
+ urlSt.append("file:"); //$NON-NLS-1$
+ urlSt.append(bundleLocation.getAbsolutePath());
+ urlSt.append(File.separatorChar);
+ urlSt.append(filePath);
+ }
+ return new URL(urlSt.toString());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.manifest.IApiComponent#getExecutionEnvironments()
+ */
+ public synchronized String[] getExecutionEnvironments() throws CoreException {
+ if (fBundleDescription == null) {
+ baselineDisposed(getBaseline());
+ }
+ return fBundleDescription.getExecutionEnvironments();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.manifest.IApiComponent#getSymbolicName()
+ */
+ public final String getSymbolicName() {
+ init();
+ return fSymbolicName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.manifest.IApiComponent#getRequiredComponents()
+ */
+ public synchronized IRequiredComponentDescription[] getRequiredComponents() throws CoreException {
+ if (fBundleDescription == null) {
+ baselineDisposed(getBaseline());
+ }
+ BundleSpecification[] requiredBundles = fBundleDescription.getRequiredBundles();
+ IRequiredComponentDescription[] req = new IRequiredComponentDescription[requiredBundles.length];
+ for (int i = 0; i < requiredBundles.length; i++) {
+ BundleSpecification bundle = requiredBundles[i];
+ req[i] = new RequiredComponentDescription(bundle.getName(),
+ new BundleVersionRange(bundle.getVersionRange()),
+ bundle.isOptional(),
+ bundle.isExported());
+ }
+ return req;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.manifest.IApiComponent#getVersion()
+ */
+ public synchronized String getVersion() {
+ init();
+ return fVersion.toString();
+ }
+
+ /**
+ * Returns this component's bundle description.
+ *
+ * @return bundle description
+ */
+ public synchronized BundleDescription getBundleDescription() throws CoreException {
+ init();
+ if (fBundleDescription == null) {
+ baselineDisposed(getBaseline());
+ }
+ return fBundleDescription;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ if (fBundleDescription != null) {
+ try {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(fBundleDescription.toString());
+ buffer.append(" - "); //$NON-NLS-1$
+ buffer.append("[fragment: ").append(isFragment()).append("] "); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append("[host: ").append(fBundleDescription.getFragments().length > 0).append("] "); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append("[system bundle: ").append(isSystemComponent()).append("] "); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append("[source bundle: ").append(isSourceComponent()).append("] "); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append("[dev bundle: ").append(fWorkspaceBinary).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
+ return buffer.toString();
+ }
+ catch(CoreException ce) {}
+ }
+ else {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Un-initialized Bundle Component"); //$NON-NLS-1$
+ buffer.append("[location: ").append(fLocation).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append("[dev bundle: ").append(fWorkspaceBinary).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
+ return buffer.toString();
+ }
+ return super.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.model.component.IApiComponent#getLocation()
+ */
+ public String getLocation() {
+ return fLocation;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.model.component.IApiComponent#isSystemComponent()
+ */
+ public boolean isSystemComponent() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see IApiComponent#isSourceComponent()
+ */
+ public synchronized boolean isSourceComponent() throws CoreException {
+ getManifest();
+ if (fManifest == null) {
+ baselineDisposed(getBaseline());
+ }
+ ManifestElement[] sourceBundle = null;
+ try {
+ sourceBundle = ManifestElement.parseHeader(IApiCoreConstants.ECLIPSE_SOURCE_BUNDLE, (String) fManifest.get(IApiCoreConstants.ECLIPSE_SOURCE_BUNDLE));
+ } catch (BundleException e) {
+ // ignore
+ }
+ if (sourceBundle != null) {
+ // this is a source bundle with the new format
+ return true;
+ }
+ // check for the old format
+ String pluginXMLContents = readFileContents(IApiCoreConstants.PLUGIN_XML_NAME,new File(getLocation()));
+ if (pluginXMLContents != null) {
+ if (containsSourceExtensionPoint(pluginXMLContents)) {
+ return true;
+ }
+ }
+ // check if it contains a fragment.xml with the appropriate extension point
+ pluginXMLContents = readFileContents(IApiCoreConstants.FRAGMENT_XML_NAME,new File(getLocation()));
+ if (pluginXMLContents != null) {
+ if (containsSourceExtensionPoint(pluginXMLContents)) {
+ return true;
+ }
+ }
+ // parse XML contents to find extension points
+ return false;
+ }
+
+ /**
+ * Check if the given source contains an source extension point.
+ *
+ * @param pluginXMLContents the given file contents
+ * @return true if it contains a source extension point, false otherwise
+ */
+ private boolean containsSourceExtensionPoint(String pluginXMLContents) {
+ SAXParserFactory factory = null;
+ try {
+ factory = SAXParserFactory.newInstance();
+ } catch (FactoryConfigurationError e) {
+ return false;
+ }
+ SAXParser saxParser = null;
+ try {
+ saxParser = factory.newSAXParser();
+ } catch (ParserConfigurationException e) {
+ // ignore
+ } catch (SAXException e) {
+ // ignore
+ }
+
+ if (saxParser == null) {
+ return false;
+ }
+
+ // Parse
+ InputSource inputSource = new InputSource(new BufferedReader(new StringReader(pluginXMLContents)));
+ try {
+ SourceDefaultHandler defaultHandler = new SourceDefaultHandler();
+ saxParser.parse(inputSource, defaultHandler);
+ return defaultHandler.isSource();
+ } catch (SAXException e) {
+ // ignore
+ } catch (IOException e) {
+ // ignore
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.IApiComponent#isFragment()
+ */
+ public synchronized boolean isFragment() throws CoreException {
+ init();
+ if (fBundleDescription == null) {
+ baselineDisposed(getBaseline());
+ }
+ return fBundleDescription.getHost() != null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.model.Component#getHost()
+ */
+ public synchronized IApiComponent getHost() throws CoreException {
+ init();
+ if (fBundleDescription == null) {
+ baselineDisposed(getBaseline());
+ }
+ HostSpecification host = fBundleDescription.getHost();
+ if(host != null) {
+ return getBaseline().getApiComponent(host.getName());
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.IApiComponent#hasFragments()
+ */
+ public synchronized boolean hasFragments() throws CoreException {
+ init();
+ if (fBundleDescription == null) {
+ baselineDisposed(getBaseline());
+ }
+ return fBundleDescription.getFragments().length != 0;
+ }
+
+ /**
+ * Sets whether this bundle has an underlying API description file.
+ *
+ * @param hasApiDescription whether this bundle has an underlying API description file
+ */
+ protected void setHasApiDescription(boolean hasApiDescription) {
+ fHasApiDescription = hasApiDescription;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.provisional.IApiComponent#hasApiDescription()
+ */
+ public boolean hasApiDescription() {
+ // ensure initialized
+ try {
+ getApiDescription();
+ } catch (CoreException e) {
+ }
+ return fHasApiDescription;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent#getLowestEEs()
+ */
+ public String[] getLowestEEs() throws CoreException {
+ if (lowestEEs != null) return lowestEEs;
+ String[] temp = null;
+ String[] executionEnvironments = getExecutionEnvironments();
+ int length = executionEnvironments.length;
+ switch(length) {
+ case 0 :
+ return null;
+ case 1 :
+ temp = new String[] { executionEnvironments[0] };
+ break;
+ default :
+ int values = ProfileModifiers.NO_PROFILE_VALUE;
+ for (int i = 0; i < length; i++) {
+ values |= ProfileModifiers.getValue(executionEnvironments[i]);
+ }
+ if (ProfileModifiers.isJRE(values)) {
+ if (ProfileModifiers.isJRE_1_1(values)) {
+ temp = new String[] { ProfileModifiers.JRE_1_1_NAME };
+ } else if (ProfileModifiers.isJ2SE_1_2(values)) {
+ temp = new String[] { ProfileModifiers.J2SE_1_2_NAME };
+ } else if (ProfileModifiers.isJ2SE_1_3(values)) {
+ temp = new String[] { ProfileModifiers.J2SE_1_3_NAME };
+ } else if (ProfileModifiers.isJ2SE_1_4(values)) {
+ temp = new String[] { ProfileModifiers.J2SE_1_4_NAME };
+ } else if (ProfileModifiers.isJ2SE_1_5(values)) {
+ temp = new String[] { ProfileModifiers.J2SE_1_5_NAME };
+ } else {
+ // this is 1.6
+ temp = new String[] { ProfileModifiers.JAVASE_1_6_NAME };
+ }
+ }
+ if (ProfileModifiers.isCDC_Foundation(values)) {
+ if (ProfileModifiers.isCDC_1_0_FOUNDATION_1_0(values)) {
+ if (temp != null) {
+ temp = new String[] { temp[0], ProfileModifiers.CDC_1_0_FOUNDATION_1_0_NAME };
+ } else {
+ temp = new String[] { ProfileModifiers.CDC_1_0_FOUNDATION_1_0_NAME };
+ }
+ } else {
+ if (temp != null) {
+ temp = new String[] { temp[0], ProfileModifiers.CDC_1_1_FOUNDATION_1_1_NAME };
+ } else {
+ temp = new String[] { ProfileModifiers.CDC_1_1_FOUNDATION_1_1_NAME };
+ }
+ }
+ }
+ if (ProfileModifiers.isOSGi(values)) {
+ if (ProfileModifiers.isOSGI_MINIMUM_1_0(values)) {
+ if (temp != null) {
+ int tempLength = temp.length;
+ System.arraycopy(temp, 0, (temp = new String[tempLength + 1]), 0, tempLength);
+ temp[tempLength] = ProfileModifiers.OSGI_MINIMUM_1_0_NAME;
+ } else {
+ temp = new String[] { ProfileModifiers.OSGI_MINIMUM_1_0_NAME };
+ }
+ } else if (ProfileModifiers.isOSGI_MINIMUM_1_1(values)) {
+ if (temp != null) {
+ int tempLength = temp.length;
+ System.arraycopy(temp, 0, (temp = new String[tempLength + 1]), 0, tempLength);
+ temp[tempLength] = ProfileModifiers.OSGI_MINIMUM_1_1_NAME;
+ } else {
+ temp = new String[] { ProfileModifiers.OSGI_MINIMUM_1_1_NAME };
+ }
+ } else {
+ // OSGI_MINIMUM_1_2
+ if (temp != null) {
+ int tempLength = temp.length;
+ System.arraycopy(temp, 0, (temp = new String[tempLength + 1]), 0, tempLength);
+ temp[tempLength] = ProfileModifiers.OSGI_MINIMUM_1_2_NAME;
+ } else {
+ temp = new String[] { ProfileModifiers.OSGI_MINIMUM_1_2_NAME };
+ }
+ }
+ }
+ }
+ lowestEEs = temp;
+ return temp;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent#getErrors()
+ */
+ public synchronized ResolverError[] getErrors() throws CoreException {
+ init();
+ ApiBaseline baseline = (ApiBaseline) getBaseline();
+ if (fBundleDescription == null) {
+ baselineDisposed(baseline);
+ }
+ if (baseline != null) {
+ ResolverError[] resolverErrors = baseline.getState().getResolverErrors(fBundleDescription);
+ if (resolverErrors.length == 0) {
+ return null;
+ }
+ return resolverErrors;
+ }
+ return null;
+ }
+
+ /**
+ * @param baseline the baseline that is disposed
+ * @throws CoreException with the baseline disposed information
+ */
+ protected void baselineDisposed(IApiBaseline baseline) throws CoreException {
+ throw new CoreException(
+ new Status(
+ IStatus.ERROR,
+ ApiPlugin.PLUGIN_ID,
+ ApiPlugin.REPORT_BASELINE_IS_DISPOSED,
+ NLS.bind(Messages.BundleApiComponent_baseline_disposed, baseline.getName()),
+ null));
+ }
+}
Index: src/org/eclipse/pde/api/tools/internal/model/Component.java
===================================================================
RCS file: src/org/eclipse/pde/api/tools/internal/model/Component.java
diff -N src/org/eclipse/pde/api/tools/internal/model/Component.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/pde/api/tools/internal/model/Component.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,192 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 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.model;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.pde.api.tools.internal.problems.ApiProblemFilter;
+import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
+import org.eclipse.pde.api.tools.internal.provisional.Factory;
+import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
+import org.eclipse.pde.api.tools.internal.provisional.IApiFilterStore;
+import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;
+import org.eclipse.pde.api.tools.internal.provisional.model.ApiTypeContainerVisitor;
+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.model.IApiElement;
+import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;
+import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
+import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemFilter;
+
+/**
+ * Common implementation of an API component as a composite class file container.
+ *
+ * @since 1.0.0
+ */
+public abstract class Component extends AbstractApiTypeContainer implements IApiComponent {
+ /**
+ * API description
+ */
+ private IApiDescription fApiDescription = null;
+
+ /**
+ * Api Filter store
+ */
+ private IApiFilterStore fFilterStore = null;
+
+ /**
+ * Constructs an API component in the given {@link IApiBaseline}.
+ *
+ * @param baseline the parent {@link IApiBaseline}
+ */
+ public Component(IApiBaseline baseline) {
+ super(baseline, IApiElement.COMPONENT, null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.model.component.IClassFileContainer#accept(org.eclipse.pde.api.tools.model.component.ClassFileContainerVisitor)
+ */
+ public void accept(ApiTypeContainerVisitor visitor) throws CoreException {
+ if (visitor.visit(this)) {
+ super.accept(visitor);
+ }
+ visitor.end(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent#getHost()
+ */
+ public IApiComponent getHost() throws CoreException {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent#getBaseline()
+ */
+ public IApiBaseline getBaseline() {
+ return (IApiBaseline) getAncestor(IApiElement.BASELINE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.model.component.IApiComponent#dispose()
+ */
+ public void dispose() {
+ try {
+ close();
+ } catch (CoreException e) {
+ ApiPlugin.log(e);
+ }
+ finally {
+ synchronized(this) {
+ fApiDescription = null;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.model.ApiElement#getApiComponent()
+ */
+ public IApiComponent getApiComponent() {
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.model.component.IApiComponent#getApiDescription()
+ */
+ public synchronized IApiDescription getApiDescription() throws CoreException {
+ if (fApiDescription == null) {
+ fApiDescription = createApiDescription();
+ }
+ return fApiDescription;
+ }
+
+ /**
+ * Returns whether this component has created an API description.
+ *
+ * @return whether this component has created an API description
+ */
+ protected synchronized boolean isApiDescriptionInitialized() {
+ return fApiDescription != null;
+ }
+
+ /**
+ * Returns if this component has created an API filter store
+ *
+ * @return true if a store has been created, false other wise
+ */
+ protected synchronized boolean hasApiFilterStore() {
+ return fFilterStore != null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.model.AbstractApiTypeContainer#getApiTypeContainers()
+ */
+ public synchronized IApiTypeContainer[] getApiTypeContainers() throws CoreException {
+ return super.getApiTypeContainers();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.model.AbstractApiTypeContainer#getApiTypeContainers()
+ */
+ public synchronized IApiTypeContainer[] getApiTypeContainers(String id) throws CoreException {
+ if (this.hasFragments()) {
+ return super.getApiTypeContainers(id);
+ } else {
+ return super.getApiTypeContainers();
+ }
+ }
+
+ /**
+ * Creates and returns the API description for this component.
+ *
+ * @return newly created API description for this component
+ */
+ protected abstract IApiDescription createApiDescription() throws CoreException;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.IApiComponent#getFilterStore()
+ */
+ public IApiFilterStore getFilterStore() throws CoreException {
+ if(fFilterStore == null) {
+ fFilterStore = createApiFilterStore();
+ }
+ return fFilterStore;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.provisional.IApiComponent#newProblemFilter(org.eclipse.pde.api.tools.internal.provisional.IApiProblem)
+ */
+ public IApiProblemFilter newProblemFilter(IApiProblem problem) throws CoreException {
+ //TODO either expose a way to make problems or change the method to accept the parts of a problem
+ return new ApiProblemFilter(getSymbolicName(), problem);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent#getHandle()
+ */
+ public IElementDescriptor getHandle() {
+ return Factory.componentDescriptor(this.getSymbolicName(), this.getVersion());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer#getContainerType()
+ */
+ public int getContainerType() {
+ return IApiTypeContainer.COMPONENT;
+ }
+
+ /**
+ * Lazily creates a new {@link IApiFilterStore} when it is requested
+ *
+ * @return the current {@link IApiFilterStore} for this component
+ * @throws CoreException
+ */
+ protected abstract IApiFilterStore createApiFilterStore() throws CoreException;
+}
Index: src/org/eclipse/pde/api/tools/internal/model/PluginProjectApiComponent.java
===================================================================
RCS file: src/org/eclipse/pde/api/tools/internal/model/PluginProjectApiComponent.java
diff -N src/org/eclipse/pde/api/tools/internal/model/PluginProjectApiComponent.java
--- src/org/eclipse/pde/api/tools/internal/model/PluginProjectApiComponent.java 21 Aug 2009 18:51:11 -0000 1.15
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,392 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.model;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.pde.api.tools.internal.ApiDescriptionManager;
-import org.eclipse.pde.api.tools.internal.ApiFilterStore;
-import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
-import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
-import org.eclipse.pde.api.tools.internal.provisional.IApiFilterStore;
-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.model.IApiTypeContainer;
-import org.eclipse.pde.api.tools.internal.util.Util;
-import org.eclipse.pde.core.build.IBuild;
-import org.eclipse.pde.core.build.IBuildEntry;
-import org.eclipse.pde.core.plugin.IPluginModelBase;
-import org.eclipse.pde.internal.core.build.WorkspaceBuildModel;
-
-/**
- * An API component for a plug-in project in the workspace.
- *
- * Note: this class requires a running workspace to be instantiated. - *
- * @since 1.0.0 - */ -public class PluginProjectApiComponent extends BundleApiComponent { - - /** - * Constant used for controlling tracing in the plug-in workspace component - */ - private static boolean DEBUG = Util.DEBUG; - - /** - * Method used for initializing tracing in the plug-in workspace component - */ - public static void setDebug(boolean debugValue) { - DEBUG = debugValue || Util.DEBUG; - } - - /** - * Associated Java project - */ - private IJavaProject fProject = null; - - /** - * Associated IPluginModelBase object - */ - private IPluginModelBase fModel = null; - - /** - * A cache of bundle class path entries to class file containers. - */ - private Map fPathToOutputContainers = null; - - /** - * A cache of output location paths to corresponding class file containers. - */ - private Map fOutputLocationToContainer = null; - - /** - * Constructs an API component for the given Java project in the specified profile. - * - * @param profile the owning profile - * @param location the given location of the component - * @param model the given model - * @param project java project - * @throws CoreException if unable to create the API component - */ - public PluginProjectApiComponent(IApiBaseline profile, String location, IPluginModelBase model) throws CoreException { - super(profile, location); - IPath path = new Path(location); - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.lastSegment()); - this.fProject = JavaCore.create(project); - this.fModel = model; - setName(fModel.getResourceString(super.getName())); - } - - /* (non-Javadoc) - * @see org.eclipse.pde.api.tools.internal.BundleApiComponent#isBinaryBundle() - */ - protected boolean isBinaryBundle() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.pde.api.tools.internal.BundleApiComponent#isApiEnabled() - */ - protected boolean isApiEnabled() { - return Util.isApiProject(fProject); - } - - /* (non-Javadoc) - * @see org.eclipse.pde.api.tools.internal.descriptors.AbstractApiComponent#dispose() - */ - public void dispose() { - try { - if(hasApiFilterStore()) { - getFilterStore().dispose(); - } - fModel = null; - if (fOutputLocationToContainer != null) { - fOutputLocationToContainer.clear(); - fOutputLocationToContainer = null; - } - if (fPathToOutputContainers != null) { - fPathToOutputContainers.clear(); - fPathToOutputContainers = null; - } - } - catch(CoreException ce) { - ApiPlugin.log(ce); - } - finally { - super.dispose(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.pde.api.tools.internal.BundleApiComponent#createLocalApiDescription() - */ - protected IApiDescription createLocalApiDescription() throws CoreException { - long time = System.currentTimeMillis(); - if(Util.isApiProject(getJavaProject())) { - setHasApiDescription(true); - } - IApiDescription apiDesc = ApiDescriptionManager.getDefault().getApiDescription(this, getBundleDescription()); - if (DEBUG) { - System.out.println("Time to create api description for: ["+fProject.getElementName()+"] " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - return apiDesc; - } - - /* (non-Javadoc) - * @see org.eclipse.pde.api.tools.internal.BundleApiComponent#createApiFilterStore() - */ - protected IApiFilterStore createApiFilterStore() throws CoreException { - long time = System.currentTimeMillis(); - IApiFilterStore store = new ApiFilterStore(getJavaProject()); - if (DEBUG) { - System.out.println("Time to create api filter store for: ["+fProject.getElementName()+"] " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - return store; - } - - /* (non-Javadoc) - * @see org.eclipse.pde.api.tools.internal.descriptors.BundleApiComponent#createClassFileContainers() - */ - protected synchronized List createApiTypeContainers() throws CoreException { - // first populate build.properties cache so we can create class file containers - // from bundle classpath entries - fPathToOutputContainers = new HashMap(4); - fOutputLocationToContainer = new HashMap(4); - if (fProject.exists() && fProject.getProject().isOpen()) { - IFile prop = fProject.getProject().getFile("build.properties"); //$NON-NLS-1$ - if (prop.exists()) { - WorkspaceBuildModel properties = new WorkspaceBuildModel(prop); - IBuild build = properties.getBuild(); - IBuildEntry entry = build.getEntry("custom"); //$NON-NLS-1$ - if (entry != null) { - String[] tokens = entry.getTokens(); - if (tokens.length == 1 && tokens[0].equals("true")) { //$NON-NLS-1$ - // hack : add the current output location for each classpath entries - IClasspathEntry[] classpathEntries = fProject.getRawClasspath(); - List containers = new ArrayList(); - for (int i = 0; i < classpathEntries.length; i++) { - IClasspathEntry classpathEntry = classpathEntries[i]; - switch(classpathEntry.getEntryKind()) { - case IClasspathEntry.CPE_SOURCE : - String containerPath = classpathEntry.getPath().removeFirstSegments(1).toString(); - IApiTypeContainer container = getApiTypeContainer(containerPath, this); - if (container != null && !containers.contains(container)) { - containers.add(container); - } - break; - case IClasspathEntry.CPE_VARIABLE : - classpathEntry = JavaCore.getResolvedClasspathEntry(classpathEntry); - //$FALL-THROUGH$ - case IClasspathEntry.CPE_LIBRARY : - IPath path = classpathEntry.getPath(); - if (Util.isArchive(path.lastSegment())) { - IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path); - if (resource != null) { - // jar inside the workspace - containers.add(new ArchiveApiTypeContainer(this, resource.getLocation().toOSString())); - } else { - // external jar - containers.add(new ArchiveApiTypeContainer(this, path.toOSString())); - } - } - break; - } - } - if (!containers.isEmpty()) { - IApiTypeContainer cfc = null; - if (containers.size() == 1) { - cfc = (IApiTypeContainer) containers.get(0); - } else { - cfc = new CompositeApiTypeContainer(this, containers); - } - fPathToOutputContainers.put(".", cfc); //$NON-NLS-1$ - } - } - } else { - IBuildEntry[] entries = build.getBuildEntries(); - int length = entries.length; - for (int i = 0; i < length; i++) { - IBuildEntry buildEntry = entries[i]; - if (buildEntry.getName().startsWith(IBuildEntry.JAR_PREFIX)) { - String jar = buildEntry.getName().substring(IBuildEntry.JAR_PREFIX.length()); - String[] tokens = buildEntry.getTokens(); - if (tokens.length == 1) { - IApiTypeContainer container = getApiTypeContainer(tokens[0], this); - if (container != null) { - fPathToOutputContainers.put(jar, container); - } - } else { - List containers = new ArrayList(); - for (int j = 0; j < tokens.length; j++) { - String currentToken = tokens[j]; - IApiTypeContainer container = getApiTypeContainer(currentToken, this); - if (container != null && !containers.contains(container)) { - containers.add(container); - } - } - if (!containers.isEmpty()) { - IApiTypeContainer cfc = null; - if (containers.size() == 1) { - cfc = (IApiTypeContainer) containers.get(0); - } else { - cfc = new CompositeApiTypeContainer(this, containers); - } - fPathToOutputContainers.put(jar, cfc); - } - } - } - } - } - } - return super.createApiTypeContainers(); - } - return Collections.EMPTY_LIST; - } - - /* (non-Javadoc) - * @see org.eclipse.pde.api.tools.internal.BundleApiComponent#createClassFileContainer(java.lang.String) - */ - protected IApiTypeContainer createApiTypeContainer(String path) throws IOException, CoreException { - if (this.fPathToOutputContainers == null) { - baselineDisposed(getBaseline()); - } - IApiTypeContainer container = (IApiTypeContainer) fPathToOutputContainers.get(path); - if (container == null) { - // could be a binary jar included in the plug-in, just look for it - container = findApiTypeContainer(path); - } - return container; - } - - /** - * Finds and returns an existing {@link IApiTypeContainer} at the specified location - * in this project, ornull
if none.
- *
- * @param location project relative path to the class file container
- * @return {@link IApiTypeContainer} or null
- */
- private IApiTypeContainer findApiTypeContainer(String location) {
- IResource res = fProject.getProject().findMember(new Path(location));
- if (res != null) {
- if (res.getType() == IResource.FILE) {
- return new ArchiveApiTypeContainer(this, res.getLocation().toOSString());
- } else {
- return new DirectoryApiTypeContainer(this, res.getLocation().toOSString());
- }
- }
- return null;
- }
-
- /**
- * Finds and returns an {@link IApiTypeContainer} for the specified
- * source folder, or null
if it does not exist. If the
- * source folder shares an output location with a previous source
- * folder, the output location is shared (a new one is not created).
- *
- * @param location project relative path to the source folder
- * @return {@link IApiTypeContainer} or null
- */
- private IApiTypeContainer getApiTypeContainer(String location, IApiComponent component) throws CoreException {
- if (this.fOutputLocationToContainer == null) {
- baselineDisposed(getBaseline());
- }
- IResource res = fProject.getProject().findMember(new Path(location));
- if (res != null) {
- IPackageFragmentRoot root = fProject.getPackageFragmentRoot(res);
- if (root.exists()) {
- if (root.getKind() == IPackageFragmentRoot.K_BINARY) {
- if (res.getType() == IResource.FOLDER) {
- // class file folder
- IPath location2 = res.getLocation();
- IApiTypeContainer cfc = (IApiTypeContainer) fOutputLocationToContainer.get(location2);
- if (cfc == null) {
- cfc = new FolderApiTypeContainer(component, (IContainer) res);
- fOutputLocationToContainer.put(location2, cfc);
- }
- return cfc;
- }
- } else {
- IClasspathEntry entry = root.getRawClasspathEntry();
- IPath outputLocation = entry.getOutputLocation();
- if (outputLocation == null) {
- outputLocation = fProject.getOutputLocation();
- }
- IApiTypeContainer cfc = (IApiTypeContainer) fOutputLocationToContainer.get(outputLocation);
- if (cfc == null) {
- IPath projectFullPath = fProject.getProject().getFullPath();
- IContainer container = null;
- if (projectFullPath.equals(outputLocation)) {
- // The project is its own output location
- container = fProject.getProject();
- } else {
- container = fProject.getProject().getWorkspace().getRoot().getFolder(outputLocation);
- }
- if (container.exists()) {
- cfc = new FolderApiTypeContainer(component, container);
- fOutputLocationToContainer.put(outputLocation, cfc);
- }
- }
- return cfc;
- }
- }
- }
- return null;
- }
-
- /**
- * Returns the Java project associated with this component.
- *
- * @return associated Java project
- */
- public IJavaProject getJavaProject() {
- return fProject;
- }
-
- /**
- * Returns the cached API type container for the given package fragment root, or null
- * if none. The given package fragment has to be a SOURCE package fragment - this method is only
- * used by the project API description to obtain a class file corresponding to a compilation unit
- * when tag scanning (to resolve signatures).
- *
- * @param root source package fragment root
- * @return API type container associated with the package fragment root, or null
- * if none
- */
- public IApiTypeContainer getTypeContainer(IPackageFragmentRoot root) throws CoreException {
- if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
- getApiTypeContainers(); // ensure initialized
- IResource resource = root.getResource();
- if (resource != null) {
- String location = resource.getProjectRelativePath().toString();
- return getApiTypeContainer(location, this);
- }
- }
- return null;
- }
-
-}
Index: src/org/eclipse/pde/api/tools/internal/model/ProjectComponent.java
===================================================================
RCS file: src/org/eclipse/pde/api/tools/internal/model/ProjectComponent.java
diff -N src/org/eclipse/pde/api/tools/internal/model/ProjectComponent.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/pde/api/tools/internal/model/ProjectComponent.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,402 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 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.model;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.osgi.service.resolver.BundleDescription;
+import org.eclipse.pde.api.tools.internal.ApiDescriptionManager;
+import org.eclipse.pde.api.tools.internal.ApiFilterStore;
+import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
+import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
+import org.eclipse.pde.api.tools.internal.provisional.IApiFilterStore;
+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.model.IApiTypeContainer;
+import org.eclipse.pde.api.tools.internal.util.Util;
+import org.eclipse.pde.core.build.IBuild;
+import org.eclipse.pde.core.build.IBuildEntry;
+import org.eclipse.pde.core.plugin.IPluginModelBase;
+import org.eclipse.pde.internal.core.build.WorkspaceBuildModel;
+import org.osgi.framework.BundleException;
+
+/**
+ * An API component for a plug-in project in the workspace.
+ * + * Note: this class requires a running workspace to be instantiated. + *
+ * @since 1.0.0 + */ +public class ProjectComponent extends BundleComponent { + + /** + * Constant used for controlling tracing in the plug-in workspace component + */ + private static boolean DEBUG = Util.DEBUG; + + /** + * Method used for initializing tracing in the plug-in workspace component + */ + public static void setDebug(boolean debugValue) { + DEBUG = debugValue || Util.DEBUG; + } + + /** + * Associated Java project + */ + private IJavaProject fProject = null; + + /** + * Associated IPluginModelBase object + */ + private IPluginModelBase fModel = null; + + /** + * A cache of bundle class path entries to class file containers. + */ + private Map fPathToOutputContainers = null; + + /** + * A cache of output location paths to corresponding class file containers. + */ + private Map fOutputLocationToContainer = null; + + /** + * Constructs an API component for the given Java project in the specified profile. + * + * @param baseline the owning API baseline + * @param location the given location of the component + * @param model the given model + * @param bundleid + * @throws CoreException if unable to create the API component + */ + public ProjectComponent(IApiBaseline baseline, String location, IPluginModelBase model, long bundleid) throws CoreException { + super(baseline, location, bundleid); + IPath path = new Path(location); + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.lastSegment()); + this.fProject = JavaCore.create(project); + this.fModel = model; + setName(fModel.getResourceString(super.getName())); + } + + /* (non-Javadoc) + * @see org.eclipse.pde.api.tools.internal.BundleApiComponent#isBinaryBundle() + */ + protected boolean isBinary() { + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.pde.api.tools.internal.model.BundleApiComponent#getBundleDescription(java.util.Dictionary, java.lang.String, long) + */ + protected BundleDescription getBundleDescription(Dictionary manifest, String location, long id) throws BundleException { + return fModel.getBundleDescription(); + } + + /* (non-Javadoc) + * @see org.eclipse.pde.api.tools.internal.BundleApiComponent#isApiEnabled() + */ + protected boolean isApiEnabled() { + return Util.isApiProject(fProject); + } + + /* (non-Javadoc) + * @see org.eclipse.pde.api.tools.internal.descriptors.AbstractApiComponent#dispose() + */ + public void dispose() { + try { + if(hasApiFilterStore()) { + getFilterStore().dispose(); + } + fModel = null; + if (fOutputLocationToContainer != null) { + fOutputLocationToContainer.clear(); + fOutputLocationToContainer = null; + } + if (fPathToOutputContainers != null) { + fPathToOutputContainers.clear(); + fPathToOutputContainers = null; + } + } + catch(CoreException ce) { + ApiPlugin.log(ce); + } + finally { + super.dispose(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.pde.api.tools.internal.BundleApiComponent#createLocalApiDescription() + */ + protected IApiDescription createLocalApiDescription() throws CoreException { + long time = System.currentTimeMillis(); + if(Util.isApiProject(getJavaProject())) { + setHasApiDescription(true); + } + IApiDescription apiDesc = ApiDescriptionManager.getDefault().getApiDescription(this, getBundleDescription()); + if (DEBUG) { + System.out.println("Time to create api description for: ["+fProject.getElementName()+"] " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + return apiDesc; + } + + /* (non-Javadoc) + * @see org.eclipse.pde.api.tools.internal.BundleApiComponent#createApiFilterStore() + */ + protected IApiFilterStore createApiFilterStore() throws CoreException { + long time = System.currentTimeMillis(); + IApiFilterStore store = new ApiFilterStore(getJavaProject()); + if (DEBUG) { + System.out.println("Time to create api filter store for: ["+fProject.getElementName()+"] " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + return store; + } + + /* (non-Javadoc) + * @see org.eclipse.pde.api.tools.internal.descriptors.BundleApiComponent#createClassFileContainers() + */ + protected synchronized List createApiTypeContainers() throws CoreException { + // first populate build.properties cache so we can create class file containers + // from bundle classpath entries + fPathToOutputContainers = new HashMap(4); + fOutputLocationToContainer = new HashMap(4); + if (fProject.exists() && fProject.getProject().isOpen()) { + IFile prop = fProject.getProject().getFile("build.properties"); //$NON-NLS-1$ + if (prop.exists()) { + WorkspaceBuildModel properties = new WorkspaceBuildModel(prop); + IBuild build = properties.getBuild(); + IBuildEntry entry = build.getEntry("custom"); //$NON-NLS-1$ + if (entry != null) { + String[] tokens = entry.getTokens(); + if (tokens.length == 1 && tokens[0].equals("true")) { //$NON-NLS-1$ + // hack : add the current output location for each classpath entries + IClasspathEntry[] classpathEntries = fProject.getRawClasspath(); + List containers = new ArrayList(); + for (int i = 0; i < classpathEntries.length; i++) { + IClasspathEntry classpathEntry = classpathEntries[i]; + switch(classpathEntry.getEntryKind()) { + case IClasspathEntry.CPE_SOURCE : + String containerPath = classpathEntry.getPath().removeFirstSegments(1).toString(); + IApiTypeContainer container = getApiTypeContainer(containerPath, this); + if (container != null && !containers.contains(container)) { + containers.add(container); + } + break; + case IClasspathEntry.CPE_VARIABLE : + classpathEntry = JavaCore.getResolvedClasspathEntry(classpathEntry); + //$FALL-THROUGH$ + case IClasspathEntry.CPE_LIBRARY : + IPath path = classpathEntry.getPath(); + if (Util.isArchive(path.lastSegment())) { + IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path); + if (resource != null) { + // jar inside the workspace + containers.add(new ArchiveApiTypeContainer(this, resource.getLocation().toOSString())); + } else { + // external jar + containers.add(new ArchiveApiTypeContainer(this, path.toOSString())); + } + } + break; + } + } + if (!containers.isEmpty()) { + IApiTypeContainer cfc = null; + if (containers.size() == 1) { + cfc = (IApiTypeContainer) containers.get(0); + } else { + cfc = new CompositeApiTypeContainer(this, containers); + } + fPathToOutputContainers.put(".", cfc); //$NON-NLS-1$ + } + } + } else { + IBuildEntry[] entries = build.getBuildEntries(); + int length = entries.length; + for (int i = 0; i < length; i++) { + IBuildEntry buildEntry = entries[i]; + if (buildEntry.getName().startsWith(IBuildEntry.JAR_PREFIX)) { + String jar = buildEntry.getName().substring(IBuildEntry.JAR_PREFIX.length()); + String[] tokens = buildEntry.getTokens(); + if (tokens.length == 1) { + IApiTypeContainer container = getApiTypeContainer(tokens[0], this); + if (container != null) { + fPathToOutputContainers.put(jar, container); + } + } else { + List containers = new ArrayList(); + for (int j = 0; j < tokens.length; j++) { + String currentToken = tokens[j]; + IApiTypeContainer container = getApiTypeContainer(currentToken, this); + if (container != null && !containers.contains(container)) { + containers.add(container); + } + } + if (!containers.isEmpty()) { + IApiTypeContainer cfc = null; + if (containers.size() == 1) { + cfc = (IApiTypeContainer) containers.get(0); + } else { + cfc = new CompositeApiTypeContainer(this, containers); + } + fPathToOutputContainers.put(jar, cfc); + } + } + } + } + } + } + return super.createApiTypeContainers(); + } + return Collections.EMPTY_LIST; + } + + /* (non-Javadoc) + * @see org.eclipse.pde.api.tools.internal.BundleApiComponent#createClassFileContainer(java.lang.String) + */ + protected IApiTypeContainer createApiTypeContainer(String path) throws IOException, CoreException { + if (this.fPathToOutputContainers == null) { + baselineDisposed(getBaseline()); + } + IApiTypeContainer container = (IApiTypeContainer) fPathToOutputContainers.get(path); + if (container == null) { + // could be a binary jar included in the plug-in, just look for it + container = findApiTypeContainer(path); + } + return container; + } + + /** + * Finds and returns an existing {@link IApiTypeContainer} at the specified location + * in this project, ornull
if none.
+ *
+ * @param location project relative path to the class file container
+ * @return {@link IApiTypeContainer} or null
+ */
+ private IApiTypeContainer findApiTypeContainer(String location) {
+ IResource res = fProject.getProject().findMember(new Path(location));
+ if (res != null) {
+ if (res.getType() == IResource.FILE) {
+ return new ArchiveApiTypeContainer(this, res.getLocation().toOSString());
+ } else {
+ return new DirectoryApiTypeContainer(this, res.getLocation().toOSString());
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Finds and returns an {@link IApiTypeContainer} for the specified
+ * source folder, or null
if it does not exist. If the
+ * source folder shares an output location with a previous source
+ * folder, the output location is shared (a new one is not created).
+ *
+ * @param location project relative path to the source folder
+ * @return {@link IApiTypeContainer} or null
+ */
+ private IApiTypeContainer getApiTypeContainer(String location, IApiComponent component) throws CoreException {
+ if (this.fOutputLocationToContainer == null) {
+ baselineDisposed(getBaseline());
+ }
+ IResource res = fProject.getProject().findMember(new Path(location));
+ if (res != null) {
+ IPackageFragmentRoot root = fProject.getPackageFragmentRoot(res);
+ if (root.exists()) {
+ if (root.getKind() == IPackageFragmentRoot.K_BINARY) {
+ if (res.getType() == IResource.FOLDER) {
+ // class file folder
+ IPath location2 = res.getLocation();
+ IApiTypeContainer cfc = (IApiTypeContainer) fOutputLocationToContainer.get(location2);
+ if (cfc == null) {
+ cfc = new FolderApiTypeContainer(component, (IContainer) res);
+ fOutputLocationToContainer.put(location2, cfc);
+ }
+ return cfc;
+ }
+ } else {
+ IClasspathEntry entry = root.getRawClasspathEntry();
+ IPath outputLocation = entry.getOutputLocation();
+ if (outputLocation == null) {
+ outputLocation = fProject.getOutputLocation();
+ }
+ IApiTypeContainer cfc = (IApiTypeContainer) fOutputLocationToContainer.get(outputLocation);
+ if (cfc == null) {
+ IPath projectFullPath = fProject.getProject().getFullPath();
+ IContainer container = null;
+ if (projectFullPath.equals(outputLocation)) {
+ // The project is its own output location
+ container = fProject.getProject();
+ } else {
+ container = fProject.getProject().getWorkspace().getRoot().getFolder(outputLocation);
+ }
+ if (container.exists()) {
+ cfc = new FolderApiTypeContainer(component, container);
+ fOutputLocationToContainer.put(outputLocation, cfc);
+ }
+ }
+ return cfc;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the Java project associated with this component.
+ *
+ * @return associated Java project
+ */
+ public IJavaProject getJavaProject() {
+ return fProject;
+ }
+
+ /**
+ * Returns the cached API type container for the given package fragment root, or null
+ * if none. The given package fragment has to be a SOURCE package fragment - this method is only
+ * used by the project API description to obtain a class file corresponding to a compilation unit
+ * when tag scanning (to resolve signatures).
+ *
+ * @param root source package fragment root
+ * @return API type container associated with the package fragment root, or null
+ * if none
+ */
+ public IApiTypeContainer getTypeContainer(IPackageFragmentRoot root) throws CoreException {
+ if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
+ getApiTypeContainers(); // ensure initialized
+ IResource resource = root.getResource();
+ if (resource != null) {
+ String location = resource.getProjectRelativePath().toString();
+ return getApiTypeContainer(location, this);
+ }
+ }
+ return null;
+ }
+
+}
Index: src/org/eclipse/pde/api/tools/internal/model/SystemLibraryApiComponent.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/SystemLibraryApiComponent.java,v
retrieving revision 1.5
diff -u -r1.5 SystemLibraryApiComponent.java
--- src/org/eclipse/pde/api/tools/internal/model/SystemLibraryApiComponent.java 9 Jan 2009 23:01:29 -0000 1.5
+++ src/org/eclipse/pde/api/tools/internal/model/SystemLibraryApiComponent.java 30 Nov 2009 15:41:47 -0000
@@ -31,7 +31,7 @@
*
* @since 1.0.0
*/
-public class SystemLibraryApiComponent extends AbstractApiComponent {
+public class SystemLibraryApiComponent extends Component {
/**
* Execution environment profile symbolic name.
@@ -84,7 +84,7 @@
* @see org.eclipse.pde.api.tools.internal.descriptors.AbstractApiComponent#createApiDescription()
*/
protected IApiDescription createApiDescription() throws CoreException {
- IApiDescription api = new ApiDescription(getId());
+ IApiDescription api = new ApiDescription(getSymbolicName());
for (int i = 0; i < fSystemPackages.length; i++) {
IPackageDescriptor pkg = Factory.packageDescriptor(fSystemPackages[i]);
api.setVisibility(pkg, VisibilityModifiers.API);
@@ -130,7 +130,7 @@
/* (non-Javadoc)
* @see org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent#getId()
*/
- public String getId() {
+ public String getSymbolicName() {
return fExecEnv[0];
}
Index: src/org/eclipse/pde/api/tools/internal/model/WorkspaceBaseline.java
===================================================================
RCS file: src/org/eclipse/pde/api/tools/internal/model/WorkspaceBaseline.java
diff -N src/org/eclipse/pde/api/tools/internal/model/WorkspaceBaseline.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/pde/api/tools/internal/model/WorkspaceBaseline.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.model;
+
+import java.util.Arrays;
+import java.util.HashSet;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.osgi.service.resolver.State;
+import org.eclipse.pde.api.tools.internal.ApiBaselineManager;
+import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
+import org.eclipse.pde.internal.core.PDECore;
+
+
+/**
+ * Describes the workspace baseline. Tracks the PDE model for the workspace
+ *
+ * @since 1.1
+ */
+public class WorkspaceBaseline extends ApiBaseline {
+
+ /**
+ * Constructor
+ */
+ public WorkspaceBaseline() {
+ super(ApiBaselineManager.WORKSPACE_API_BASELINE_ID);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.model.ApiBaseline#getState()
+ */
+ public State getState() {
+ return PDECore.getDefault().getModelManager().getState().getState();
+ }
+
+ /* (non-Javadoc)
+ * @see IApiBaseline#addApiComponents(org.eclipse.pde.api.tools.model.component.IApiComponent[], boolean)
+ */
+ public void addApiComponents(IApiComponent[] components) throws CoreException {
+ HashSet ees = new HashSet();
+ for (int i = 0; i < components.length; i++) {
+ BundleComponent component = (BundleComponent) components[i];
+ if (component.isSourceComponent()) {
+ continue;
+ }
+ addComponent(component);
+ ees.addAll(Arrays.asList(component.getExecutionEnvironments()));
+ }
+ resolveSystemLibrary(ees);
+ }
+}
Index: src/org/eclipse/pde/api/tools/internal/provisional/ApiPlugin.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/ApiPlugin.java,v
retrieving revision 1.58
diff -u -r1.58 ApiPlugin.java
--- src/org/eclipse/pde/api/tools/internal/provisional/ApiPlugin.java 15 Jul 2009 14:44:34 -0000 1.58
+++ src/org/eclipse/pde/api/tools/internal/provisional/ApiPlugin.java 30 Nov 2009 15:41:48 -0000
@@ -43,7 +43,7 @@
import org.eclipse.pde.api.tools.internal.builder.ReferenceResolver;
import org.eclipse.pde.api.tools.internal.comparator.ClassFileComparator;
import org.eclipse.pde.api.tools.internal.descriptors.ElementDescriptorImpl;
-import org.eclipse.pde.api.tools.internal.model.PluginProjectApiComponent;
+import org.eclipse.pde.api.tools.internal.model.ProjectComponent;
import org.eclipse.pde.api.tools.internal.provisional.comparator.ApiComparator;
import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemTypes;
import org.eclipse.pde.api.tools.internal.provisional.scanner.TagScanner;
@@ -587,7 +587,7 @@
}
option = Platform.getDebugOption(PLUGIN_WORKSPACE_COMPONENT_DEBUG);
if(option != null) {
- PluginProjectApiComponent.setDebug(option.equalsIgnoreCase(TRUE));
+ ProjectComponent.setDebug(option.equalsIgnoreCase(TRUE));
}
option = Platform.getDebugOption(API_PROFILE_MANAGER_DEBUG);
if(option != null) {
Index: src/org/eclipse/pde/api/tools/internal/provisional/comparator/ApiComparator.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/comparator/ApiComparator.java,v
retrieving revision 1.52
diff -u -r1.52 ApiComparator.java
--- src/org/eclipse/pde/api/tools/internal/provisional/comparator/ApiComparator.java 2 Sep 2009 21:15:07 -0000 1.52
+++ src/org/eclipse/pde/api/tools/internal/provisional/comparator/ApiComparator.java 30 Nov 2009 15:41:48 -0000
@@ -145,7 +145,7 @@
Util.updateMonitor(localmonitor);
IApiComponent apiComponent = apiComponents[i];
if (!apiComponent.isSystemComponent()) {
- String id = apiComponent.getId();
+ String id = apiComponent.getSymbolicName();
IApiComponent apiComponent2 = baseline.getApiComponent(id);
IDelta delta = null;
if (apiComponent2 == null) {
@@ -186,7 +186,7 @@
Util.updateMonitor(localmonitor);
IApiComponent apiComponent = apiComponents2[i];
if (!apiComponent.isSystemComponent()) {
- String id = apiComponent.getId();
+ String id = apiComponent.getSymbolicName();
if (!apiComponentsIds.contains(id)) {
// addition of an API component
globalDelta.add(
@@ -240,7 +240,7 @@
Util.updateMonitor(localmonitor, 1);
IDelta delta = null;
if (!component.isSystemComponent()) {
- String id = component.getId();
+ String id = component.getSymbolicName();
IApiComponent apiComponent2 = referenceBaseline.getApiComponent(id);
if (apiComponent2 == null) {
// report addition of an API component
@@ -313,10 +313,10 @@
IDelta.ADDED,
IDelta.API_COMPONENT,
null,
- component2.getId(),
+ component2.getSymbolicName(),
Util.getComponentVersionsId(component2));
} else if (component2 == null) {
- String referenceComponentId = referenceComponent.getId();
+ String referenceComponentId = referenceComponent.getSymbolicName();
return new Delta(
null,
IDelta.API_PROFILE_ELEMENT_TYPE,
@@ -330,7 +330,7 @@
if (referenceBaseline == null || baseline == null) {
throw new IllegalArgumentException("The baselines cannot be null"); //$NON-NLS-1$
}
- String referenceComponentId = referenceComponent.getId();
+ String referenceComponentId = referenceComponent.getSymbolicName();
final Delta globalDelta = new Delta();
// check the EE first
@@ -451,7 +451,7 @@
}
String typeName = typeRoot2.getTypeName();
IApiTypeRoot typeRoot = null;
- String id = component.getId();
+ String id = component.getSymbolicName();
if (Util.ORG_ECLIPSE_SWT.equals(id)) {
typeRoot = component.findTypeRoot(typeName);
} else {
@@ -737,7 +737,7 @@
final Delta globalDelta,
final IProgressMonitor monitor) throws CoreException {
final Set typeRootBaseLineNames = new HashSet();
- final String id = component.getId();
+ final String id = component.getSymbolicName();
IApiTypeContainer[] typeRootContainers = null;
IApiTypeContainer[] typeRootContainers2 = null;
final SubMonitor localmonitor = SubMonitor.convert(monitor, 4);
@@ -790,7 +790,7 @@
Util.updateMonitor(localmonitor);
IApiComponent p = providers[index];
if (!p.equals(component2)) {
- String id2 = p.getId();
+ String id2 = p.getSymbolicName();
if (Util.ORG_ECLIPSE_SWT.equals(id2)) {
typeRoot2 = p.findTypeRoot(typeName);
} else {
@@ -965,7 +965,7 @@
while (typeRoot2 == null && index < providers.length) {
IApiComponent p = providers[index];
if (!p.equals(component2)) {
- String id2 = p.getId();
+ String id2 = p.getSymbolicName();
if (Util.ORG_ECLIPSE_SWT.equals(id2)) {
typeRoot2 = p.findTypeRoot(typeName);
} else {
Index: src/org/eclipse/pde/api/tools/internal/provisional/comparator/CompareApiScopeVisitor.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/comparator/CompareApiScopeVisitor.java,v
retrieving revision 1.6
diff -u -r1.6 CompareApiScopeVisitor.java
--- src/org/eclipse/pde/api/tools/internal/provisional/comparator/CompareApiScopeVisitor.java 12 Aug 2009 14:21:38 -0000 1.6
+++ src/org/eclipse/pde/api/tools/internal/provisional/comparator/CompareApiScopeVisitor.java 30 Nov 2009 15:41:48 -0000
@@ -95,7 +95,7 @@
this.containsErrors = true;
return false;
}
- IApiComponent referenceComponent = this.referenceBaseline.getApiComponent(component.getId());
+ IApiComponent referenceComponent = this.referenceBaseline.getApiComponent(component.getSymbolicName());
if (referenceComponent != null && referenceComponent.getErrors() != null) {
this.containsErrors = true;
return false;
@@ -140,7 +140,7 @@
this.containsErrors = true;
return;
}
- IApiComponent referenceComponent = this.referenceBaseline.getApiComponent(apiComponent.getId());
+ IApiComponent referenceComponent = this.referenceBaseline.getApiComponent(apiComponent.getSymbolicName());
if (referenceComponent == null) return;
if (referenceComponent.getErrors() != null) {
this.containsErrors = true;
Index: src/org/eclipse/pde/api/tools/internal/provisional/model/IApiComponent.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/model/IApiComponent.java,v
retrieving revision 1.10
diff -u -r1.10 IApiComponent.java
--- src/org/eclipse/pde/api/tools/internal/provisional/model/IApiComponent.java 2 Sep 2009 21:15:07 -0000 1.10
+++ src/org/eclipse/pde/api/tools/internal/provisional/model/IApiComponent.java 30 Nov 2009 15:41:48 -0000
@@ -30,11 +30,11 @@
/**
* Returns this component's symbolic name. This is a handle-only
- * method - the component may not exist or ay be disposed.
+ * method - the component may not exist or may be disposed.
*
* @return component's symbolic name
*/
- public String getId();
+ public String getSymbolicName();
/**
* Returns this component's API description.
Index: src/org/eclipse/pde/api/tools/internal/provisional/search/ApiSearchEngine.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/search/ApiSearchEngine.java,v
retrieving revision 1.11
diff -u -r1.11 ApiSearchEngine.java
--- src/org/eclipse/pde/api/tools/internal/provisional/search/ApiSearchEngine.java 22 Oct 2009 15:57:56 -0000 1.11
+++ src/org/eclipse/pde/api/tools/internal/provisional/search/ApiSearchEngine.java 30 Nov 2009 15:41:48 -0000
@@ -304,11 +304,11 @@
MultiStatus mstatus = null;
for (int i = 0; i < scopeelements.length; i++) {
try {
- taskname = MessageFormat.format(SearchMessages.ApiSearchEngine_searching_project, new String[] {scopeelements[i].getApiComponent().getId(), fRequestorContext});
+ taskname = MessageFormat.format(SearchMessages.ApiSearchEngine_searching_project, new String[] {scopeelements[i].getApiComponent().getSymbolicName(), fRequestorContext});
localmonitor.setTaskName(taskname);
if(DEBUG) {
loopstart = System.currentTimeMillis();
- System.out.println("Searching "+scopeelements[i].getApiComponent().getId()+"..."); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println("Searching "+scopeelements[i].getApiComponent().getSymbolicName()+"..."); //$NON-NLS-1$ //$NON-NLS-2$
}
searchReferences(requestor, scopeelements[i], reporter, localmonitor.newChild(1));
localmonitor.setTaskName(taskname);
Index: src/org/eclipse/pde/api/tools/internal/search/UseSearchRequestor.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/UseSearchRequestor.java,v
retrieving revision 1.5
diff -u -r1.5 UseSearchRequestor.java
--- src/org/eclipse/pde/api/tools/internal/search/UseSearchRequestor.java 22 Oct 2009 15:57:57 -0000 1.5
+++ src/org/eclipse/pde/api/tools/internal/search/UseSearchRequestor.java 30 Nov 2009 15:41:48 -0000
@@ -114,7 +114,7 @@
if(pparts.length != 2) {
continue;
}
- if(container.getApiComponent().getId().equals(pparts[0])) {
+ if(container.getApiComponent().getSymbolicName().equals(pparts[0])) {
if(container.getName().endsWith(pparts[1])) {
return false;
}
@@ -133,7 +133,7 @@
IApiMember member = reference.getResolvedReference();
if(member != null) {
IApiComponent component = member.getApiComponent();
- if(!fComponentIds.contains(component.getId())) {
+ if(!fComponentIds.contains(component.getSymbolicName())) {
return false;
}
if(component.equals(reference.getMember().getApiComponent())) {
Index: src/org/eclipse/pde/api/tools/internal/search/XmlSearchReporter.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/XmlSearchReporter.java,v
retrieving revision 1.6
diff -u -r1.6 XmlSearchReporter.java
--- src/org/eclipse/pde/api/tools/internal/search/XmlSearchReporter.java 3 Nov 2009 20:25:33 -0000 1.6
+++ src/org/eclipse/pde/api/tools/internal/search/XmlSearchReporter.java 30 Nov 2009 15:41:48 -0000
@@ -96,7 +96,7 @@
*/
String getId(IApiComponent component) throws CoreException {
StringBuffer buffer = new StringBuffer();
- buffer.append(component.getId()).append(" ").append('(').append(component.getVersion()).append(')'); //$NON-NLS-1$
+ buffer.append(component.getSymbolicName()).append(" ").append('(').append(component.getVersion()).append(')'); //$NON-NLS-1$
return buffer.toString();
}
Index: src/org/eclipse/pde/api/tools/internal/util/Util.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java,v
retrieving revision 1.139
diff -u -r1.139 Util.java
--- src/org/eclipse/pde/api/tools/internal/util/Util.java 2 Sep 2009 21:15:07 -0000 1.139
+++ src/org/eclipse/pde/api/tools/internal/util/Util.java 30 Nov 2009 15:41:48 -0000
@@ -1965,7 +1965,7 @@
* @return API component + version identifier
*/
public static String getDeltaComponentVersionsId(IApiComponent component) {
- StringBuffer buffer = new StringBuffer(component.getId());
+ StringBuffer buffer = new StringBuffer(component.getSymbolicName());
String version = component.getVersion();
// remove the qualifier part
if (version != null) {
@@ -1995,7 +1995,7 @@
* @return API component + version identifier
*/
public static String getComponentVersionsId(IApiComponent component) {
- StringBuffer buffer = new StringBuffer(component.getId());
+ StringBuffer buffer = new StringBuffer(component.getSymbolicName());
String version = component.getVersion();
// remove the qualifier part
if (version != null) {
@@ -2202,7 +2202,7 @@
public static final Comparator componentsorter = new Comparator(){
public int compare(Object o1, Object o2) {
if(o1 instanceof IApiComponent && o2 instanceof IApiComponent) {
- return ((IApiComponent)o1).getId().compareTo(((IApiComponent)o2).getId());
+ return ((IApiComponent)o1).getSymbolicName().compareTo(((IApiComponent)o2).getSymbolicName());
}
if(o1 instanceof SkippedComponent && o2 instanceof SkippedComponent) {
return ((SkippedComponent)o1).getComponentId().compareTo(((SkippedComponent)o2).getComponentId());
@@ -2289,7 +2289,7 @@
pattern = Pattern.compile(componentname);
String componentid = null;
for (int j = 0, max2 = components.length; j < max2; j++) {
- componentid = components[j].getId();
+ componentid = components[j].getSymbolicName();
if (pattern.matcher(componentid).matches()) {
list.add(componentid);
}
Index: src_ant/org/eclipse/pde/api/tools/internal/tasks/APIToolsAnalysisTask.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/APIToolsAnalysisTask.java,v
retrieving revision 1.17
diff -u -r1.17 APIToolsAnalysisTask.java
--- src_ant/org/eclipse/pde/api/tools/internal/tasks/APIToolsAnalysisTask.java 5 Aug 2009 16:46:12 -0000 1.17
+++ src_ant/org/eclipse/pde/api/tools/internal/tasks/APIToolsAnalysisTask.java 30 Nov 2009 15:41:48 -0000
@@ -598,7 +598,7 @@
Set visitedApiComponentNames = new HashSet();
for (int i = 0; i < length; i++) {
IApiComponent apiComponent = apiComponents[i];
- String name = apiComponent.getId();
+ String name = apiComponent.getSymbolicName();
visitedApiComponentNames.add(name);
if (apiComponent.isSystemComponent()) {
continue;
@@ -644,7 +644,7 @@
IApiComponent[] baselineApiComponents = referenceBaseline.getApiComponents();
for (int i = 0, max = baselineApiComponents.length; i < max; i++) {
IApiComponent apiComponent = baselineApiComponents[i];
- String id = apiComponent.getId();
+ String id = apiComponent.getSymbolicName();
if (!visitedApiComponentNames.remove(id)) {
//remove component in the current baseline
IApiProblem problem = ApiProblemFactory.newApiProblem(id,
Index: src_ant/org/eclipse/pde/api/tools/internal/tasks/ApiMigrationTask.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/ApiMigrationTask.java,v
retrieving revision 1.4
diff -u -r1.4 ApiMigrationTask.java
--- src_ant/org/eclipse/pde/api/tools/internal/tasks/ApiMigrationTask.java 20 Oct 2009 18:49:23 -0000 1.4
+++ src_ant/org/eclipse/pde/api/tools/internal/tasks/ApiMigrationTask.java 30 Nov 2009 15:41:49 -0000
@@ -259,7 +259,7 @@
if(!allowresolve) {
ResolverError[] errors = component.getErrors();
if(errors != null) {
- this.notsearched.add(new SkippedComponent(component.getId(), component.getVersion(), errors));
+ this.notsearched.add(new SkippedComponent(component.getSymbolicName(), component.getVersion(), errors));
return false;
}
}
@@ -267,7 +267,7 @@
return false;
}
if(pattern != null) {
- return pattern.matcher(component.getId()).matches();
+ return pattern.matcher(component.getSymbolicName()).matches();
}
return true;
}
Index: src_ant/org/eclipse/pde/api/tools/internal/tasks/ApiUseTask.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/ApiUseTask.java,v
retrieving revision 1.17
diff -u -r1.17 ApiUseTask.java
--- src_ant/org/eclipse/pde/api/tools/internal/tasks/ApiUseTask.java 19 Nov 2009 15:45:42 -0000 1.17
+++ src_ant/org/eclipse/pde/api/tools/internal/tasks/ApiUseTask.java 30 Nov 2009 15:41:49 -0000
@@ -311,7 +311,7 @@
if(!allowresolve) {
ResolverError[] errors = component.getErrors();
if(errors != null) {
- this.notsearched.add(new SkippedComponent(component.getId(), component.getVersion(), errors));
+ this.notsearched.add(new SkippedComponent(component.getSymbolicName(), component.getVersion(), errors));
return false;
}
}
@@ -319,7 +319,7 @@
return false;
}
if(pattern != null) {
- return pattern.matcher(component.getId()).matches();
+ return pattern.matcher(component.getSymbolicName()).matches();
}
return true;
}
@@ -343,13 +343,13 @@
}
for (int i = 0; i < components.length; i++) {
if(acceptComponent(components[i], pattern, true)) {
- ids.add(components[i].getId());
+ ids.add(components[i].getSymbolicName());
}
if(acceptComponent(components[i], pattern2, false)) {
scope.add(components[i]);
}
else {
- this.notsearched.add(new SkippedComponent(components[i].getId(), components[i].getVersion(), components[i].getErrors()));
+ this.notsearched.add(new SkippedComponent(components[i].getSymbolicName(), components[i].getVersion(), components[i].getErrors()));
}
}
}
Index: src_ant/org/eclipse/pde/api/tools/internal/tasks/CompareTask.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/CompareTask.java,v
retrieving revision 1.11
diff -u -r1.11 CompareTask.java
--- src_ant/org/eclipse/pde/api/tools/internal/tasks/CompareTask.java 12 Aug 2009 14:21:38 -0000 1.11
+++ src_ant/org/eclipse/pde/api/tools/internal/tasks/CompareTask.java 30 Nov 2009 15:41:49 -0000
@@ -107,7 +107,7 @@
pattern = Pattern.compile(componentName);
for (int j = 0, max2 = apiComponents.length; j < max2; j++) {
IApiComponent apiComponent = apiComponents[j];
- String componentId = apiComponent.getId();
+ String componentId = apiComponent.getSymbolicName();
Matcher matcher = pattern.matcher(componentId);
if (matcher.matches()) {
scope.addElement(apiComponent);
#P org.eclipse.pde.api.tools.tests
Index: src/org/eclipse/pde/api/tools/model/tests/ApiBaselineTests.java
===================================================================
RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/ApiBaselineTests.java,v
retrieving revision 1.4
diff -u -r1.4 ApiBaselineTests.java
--- src/org/eclipse/pde/api/tools/model/tests/ApiBaselineTests.java 14 Apr 2009 18:51:55 -0000 1.4
+++ src/org/eclipse/pde/api/tools/model/tests/ApiBaselineTests.java 30 Nov 2009 15:41:50 -0000
@@ -148,7 +148,7 @@
private void validateComponent(IApiBaseline baseline, String id, String name, String version, String environment, List