Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the project component api baseline to lookup the component #1539

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apitools/org.eclipse.pde.api.tools/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.pde.api.tools;singleton:=true
Bundle-Version: 1.3.600.qualifier
Bundle-Version: 1.3.700.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ public synchronized static ApiDescriptionManager getManager() {
public synchronized IApiDescription getApiDescription(ProjectComponent component, BundleDescription bundle) {
IJavaProject project = component.getJavaProject();
ProjectApiDescription description = (ProjectApiDescription) fDescriptions.get(project);
if (description == null) {
if (description == null || description.baseline != component.getBaseline()) {
if (Util.isApiProject(project)) {
description = new ProjectApiDescription(project);
description = new ProjectApiDescription(project, component.getBaseline());
} else {
description = new NonApiProjectDescription(project);
description = new NonApiProjectDescription(project, component.getBaseline());
}
try {
restoreDescription(project, description);
} catch (CoreException e) {
ApiPlugin.log(e.getStatus());
description = new ProjectApiDescription(project);
description = new ProjectApiDescription(project, component.getBaseline());
}
fDescriptions.put(project, description);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline;

/**
* An API description for a project that does not have an API Tools nature.
Expand All @@ -26,9 +27,11 @@ public class NonApiProjectDescription extends ProjectApiDescription {

/**
* Constructs API description for the given project.
*
* @param baseline
*/
public NonApiProjectDescription(IJavaProject project) {
super(project);
NonApiProjectDescription(IJavaProject project, IApiBaseline baseline) {
super(project, baseline);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public class ProjectApiDescription extends ApiDescription {
*/
private volatile boolean fInSynch;

/**
* this holds the baseline this description is currently connected to
*/
IApiBaseline baseline;

/**
* A node for a package.
*/
Expand Down Expand Up @@ -328,10 +333,13 @@ public String toString() {

/**
* Constructs a new API description for the given project API component.
*
* @param baseline the baseline this description should be connected with
*/
public ProjectApiDescription(IJavaProject project) {
ProjectApiDescription(IJavaProject project, IApiBaseline baseline) {
super(project.getElementName());
fProject = project;
this.baseline = baseline;
}

@Override
Expand Down Expand Up @@ -527,12 +535,12 @@ ManifestNode newNode(ManifestNode parent, IElementDescriptor element, int vis, i
*/
void refreshPackages() {
if (fRefreshingInProgress) {
logPackafesRefresh();
logPackagesRefresh();
return;
}
synchronized (this) {
if (fRefreshingInProgress) {
logPackafesRefresh();
logPackagesRefresh();
return;
}
// check if in synch
Expand Down Expand Up @@ -569,7 +577,7 @@ void refreshPackages() {
}
}

private void logPackafesRefresh() {
private void logPackagesRefresh() {
if (ApiPlugin.DEBUG_API_DESCRIPTION) {
StringBuilder buffer = new StringBuilder();
buffer.append("Refreshing manifest node: "); //$NON-NLS-1$
Expand Down Expand Up @@ -706,8 +714,14 @@ public String toString() {
* @return API component
* @exception CoreException if the API component cannot be located
*/
private ProjectComponent getApiComponent() throws CoreException {
IApiBaseline baseline = ApiBaselineManager.getManager().getWorkspaceBaseline();
private synchronized ProjectComponent getApiComponent() throws CoreException {
if (baseline == null || baseline.isDisposed()) {
baseline = ApiBaselineManager.getManager().getWorkspaceBaseline();
}
return getApiComponent(baseline);
}

private ProjectComponent getApiComponent(IApiBaseline baseline) throws CoreException {
ProjectComponent component = (ProjectComponent) baseline.getApiComponent(getJavaProject().getProject());
if (component == null) {
throw new CoreException(Status.error("Unable to resolve project API component for API description")); //$NON-NLS-1$
Expand Down
Loading