Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 268985
Collapse All | Expand All

(-)src/org/eclipse/pde/api/tools/internal/provisional/search/ApiSearchEngine.java (-2 / +3 lines)
Lines 30-35 Link Here
30
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
30
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
31
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
31
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
32
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
32
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
33
import org.eclipse.pde.api.tools.internal.provisional.model.IApiScope;
33
import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;
34
import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;
34
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeRoot;
35
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeRoot;
35
import org.eclipse.pde.api.tools.internal.search.SearchMessages;
36
import org.eclipse.pde.api.tools.internal.search.SearchMessages;
Lines 274-280 Link Here
274
		if(baseline == null || reporter == null || requestor == null) {
275
		if(baseline == null || reporter == null || requestor == null) {
275
			return;
276
			return;
276
		}
277
		}
277
		IApiSearchScope scope = requestor.getScope();
278
		IApiScope scope = requestor.getScope();
278
		if(scope == null) {
279
		if(scope == null) {
279
			return;
280
			return;
280
		}
281
		}
Lines 285-291 Link Here
285
		if(requestor.includesInternal() && !requestor.includesAPI()) {
286
		if(requestor.includesInternal() && !requestor.includesAPI()) {
286
			fRequestorContext = SearchMessages.ApiSearchEngine_internal;
287
			fRequestorContext = SearchMessages.ApiSearchEngine_internal;
287
		}
288
		}
288
		IApiElement[] scopeelements = scope.getScope();
289
		IApiElement[] scopeelements = scope.getApiElements();
289
		SubMonitor localmonitor = SubMonitor.convert(monitor, 
290
		SubMonitor localmonitor = SubMonitor.convert(monitor, 
290
				MessageFormat.format(SearchMessages.ApiSearchEngine_searching_projects, new String[] {fRequestorContext}), scopeelements.length*2+1);
291
				MessageFormat.format(SearchMessages.ApiSearchEngine_searching_projects, new String[] {fRequestorContext}), scopeelements.length*2+1);
291
		try {
292
		try {
(-)src/org/eclipse/pde/api/tools/internal/provisional/search/IApiSearchRequestor.java (-3 / +18 lines)
Lines 13-18 Link Here
13
import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
13
import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
14
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
14
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
15
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
15
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
16
import org.eclipse.pde.api.tools.internal.provisional.model.IApiScope;
16
17
17
/**
18
/**
18
 * A default search requestor to use for API tools
19
 * A default search requestor to use for API tools
Lines 45-55 Link Here
45
	public static final int INCLUDE_NON_API_ENABLED_PROJECTS = 0x0004;
46
	public static final int INCLUDE_NON_API_ENABLED_PROJECTS = 0x0004;
46
	
47
	
47
	/**
48
	/**
48
	 * Returns the {@link IApiSearchScope} to be searched
49
	 * Search mask that determines if unresolved {@link IReference}s should be included in results.
49
	 * 
50
	 * 
50
	 * @return the {@link IApiSearchScope} to be searched
51
	 * @see 
51
	 */
52
	 */
52
	public IApiSearchScope getScope();
53
	public static final int INCLUDE_UNRESOLVED_REFERENCES = 0x0008;
54
	
55
	/**
56
	 * Returns the {@link IApiScope} to be searched
57
	 * 
58
	 * @return the {@link IApiScope} to be searched
59
	 */
60
	public IApiScope getScope();
53
	
61
	
54
	/**
62
	/**
55
	 * Returns whether this requestor cares about the given {@link IApiComponent} or not.
63
	 * Returns whether this requestor cares about the given {@link IApiComponent} or not.
Lines 113-116 Link Here
113
	 * @return true if non-API projects should be considered in the scope false otherwise
121
	 * @return true if non-API projects should be considered in the scope false otherwise
114
	 */
122
	 */
115
	public boolean includesNonApiProjects();
123
	public boolean includesNonApiProjects();
124
	
125
	/**
126
	 * Returns true if any {@link IReference}s that can not be resolved will still be included in the search results
127
	 * 
128
	 * @return true if unresolved {@link IReference}s should be included in the search results
129
	 */
130
	public boolean includesUnresolvedReferences();
116
}
131
}
(-)src/org/eclipse/pde/api/tools/internal/provisional/search/IApiSearchScope.java (-39 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.api.tools.internal.provisional.search;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
15
16
/**
17
 * An {@link ApiSearchScope} is used  by an {@link IApiSearchRequestor} to denote what
18
 * {@link org.eclipse.pde.api.tools.internal.provisional.model.IApiElement}s should be 
19
 * searched for any given invocation of an {@link ApiSearchEngine}
20
 * 
21
 * @since 1.0.0
22
 */
23
public interface IApiSearchScope {
24
	
25
	/**
26
	 * Returns the {@link IApiElement}s to be considered during a search.
27
	 * 
28
	 * @return the {@link IApiElement}s to search
29
	 */
30
	public IApiElement[] getScope() throws CoreException;
31
	
32
	/**
33
	 * Returns if this scope encloses the given element
34
	 * 
35
	 * @param element
36
	 * @return true if this scope encloses the given element, false otherwise
37
	 */
38
	public boolean encloses(IApiElement element) throws CoreException;
39
}
(-)src/org/eclipse/pde/api/tools/internal/provisional/model/IApiScope.java (-7 / +16 lines)
Lines 14-30 Link Here
14
14
15
/**
15
/**
16
 * Describes a set of {@link IApiElement}.
16
 * Describes a set of {@link IApiElement}.
17
 * <p>The api elements can be of the following types:</p>
18
 * <ul>
19
 * <li>{@link IApiElement#BASELINE}</li>
20
 * <li>{@link IApiElement#COMPONENT}</li>
21
 * <li>{@link IApiElement#API_TYPE_CONTAINER}</li>
22
 * <li>{@link IApiElement#API_TYPE_ROOT}</li>
23
 * </ul>
24
 * 
17
 * 
25
 * @since 1.1.0
18
 * @since 1.1.0
26
 */
19
 */
27
public interface IApiScope {
20
public interface IApiScope {
21
	
22
	/**
23
	 * Adds the given {@link IApiElement} to the scope
24
	 * 
25
	 * @param newelements
26
	 */
27
	public void addElement(IApiElement newelement);
28
	
28
	/**
29
	/**
29
	 * Returns all API elements contained within this scope
30
	 * Returns all API elements contained within this scope
30
	 * 
31
	 * 
Lines 39-42 Link Here
39
	 * @exception CoreException if unable to visit this scope
40
	 * @exception CoreException if unable to visit this scope
40
	 */
41
	 */
41
	void accept(ApiScopeVisitor visitor) throws CoreException;
42
	void accept(ApiScopeVisitor visitor) throws CoreException;
43
	
44
	/**
45
	 * Returns if this scope encloses the given element
46
	 * 
47
	 * @param element
48
	 * @return true if this scope encloses the given element, false otherwise
49
	 */
50
	public boolean encloses(IApiElement element) throws CoreException;
42
}
51
}
(-)src/org/eclipse/pde/api/tools/internal/search/ApiUseSearchScope.java (-68 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.api.tools.internal.search;
12
13
import java.util.ArrayList;
14
import java.util.Iterator;
15
import java.util.List;
16
17
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
18
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
19
import org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchScope;
20
21
/**
22
 * Default implementation of {@link IApiSearchScope}
23
 * 
24
 * @since 1.0.0
25
 */
26
public class ApiUseSearchScope implements IApiSearchScope {
27
28
	/**
29
	 * The raw list of elements in this scope
30
	 */
31
	private List fElements = null;
32
	
33
	/**
34
	 * Constructor
35
	 * @param elements
36
	 */
37
	public ApiUseSearchScope(IApiElement[] elements) {
38
		fElements = new ArrayList(elements.length);
39
		for(int i = 0; i < elements.length; i++) {
40
			fElements.add(elements[i]);
41
		}
42
	}
43
	
44
	/* (non-Javadoc)
45
	 * @see org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchScope#getScope()
46
	 */
47
	public IApiElement[] getScope() {
48
		return (IApiElement[]) fElements.toArray(new IApiComponent[fElements.size()]);
49
	}
50
51
	/* (non-Javadoc)
52
	 * @see org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchScope#encloses(org.eclipse.pde.api.tools.internal.provisional.model.IApiElement)
53
	 */
54
	public boolean encloses(IApiElement element) {
55
		if(element != null) {
56
			IApiComponent component = element.getApiComponent();
57
			IApiComponent enclosing = null;
58
			for(Iterator iter = fElements.iterator(); iter.hasNext();) {
59
				enclosing = ((IApiElement)iter.next()).getApiComponent();
60
				if(component.equals(enclosing)) {
61
					return true;
62
				}
63
			}
64
		}
65
		return false;
66
	}
67
68
}
(-)src/org/eclipse/pde/api/tools/internal/search/ApiUseSearchRequestor.java (-20 / +26 lines)
Lines 12-29 Link Here
12
12
13
import java.util.Comparator;
13
import java.util.Comparator;
14
import java.util.Set;
14
import java.util.Set;
15
import java.util.TreeSet;
16
15
17
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
19
import org.eclipse.pde.api.tools.internal.provisional.IApiAnnotations;
17
import org.eclipse.pde.api.tools.internal.provisional.IApiAnnotations;
20
import org.eclipse.pde.api.tools.internal.provisional.VisibilityModifiers;
18
import org.eclipse.pde.api.tools.internal.provisional.VisibilityModifiers;
21
import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
19
import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
20
import org.eclipse.pde.api.tools.internal.provisional.comparator.ApiScope;
22
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
21
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
23
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
22
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
24
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
23
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
24
import org.eclipse.pde.api.tools.internal.provisional.model.IApiScope;
25
import org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchRequestor;
25
import org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchRequestor;
26
import org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchScope;
27
26
28
/**
27
/**
29
 * Default implementation of an {@link IApiSearchRequestor} to use with the
28
 * Default implementation of an {@link IApiSearchRequestor} to use with the
Lines 48-54 Link Here
48
	/**
47
	/**
49
	 * The search scope for this requestor
48
	 * The search scope for this requestor
50
	 */
49
	 */
51
	private IApiSearchScope fScope = null;
50
	private IApiScope fScope = null;
52
	
51
	
53
	/**
52
	/**
54
	 * Default comparator that orders {@link IApiComponent} by their ID 
53
	 * Default comparator that orders {@link IApiComponent} by their ID 
Lines 97-102 Link Here
97
	 * @see org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchRequestor#acceptReference(org.eclipse.pde.api.tools.internal.provisional.builder.IReference)
96
	 * @see org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchRequestor#acceptReference(org.eclipse.pde.api.tools.internal.provisional.builder.IReference)
98
	 */
97
	 */
99
	public boolean acceptReference(IReference reference) {
98
	public boolean acceptReference(IReference reference) {
99
		if(includesUnresolvedReferences()) {
100
			return true;
101
		}
100
		try {
102
		try {
101
			IApiMember member = reference.getResolvedReference();
103
			IApiMember member = reference.getResolvedReference();
102
			if(member != null) {
104
			if(member != null) {
Lines 107-131 Link Here
107
				if(component.equals(reference.getMember().getApiComponent())) {
109
				if(component.equals(reference.getMember().getApiComponent())) {
108
					return false;
110
					return false;
109
				}
111
				}
110
				if(fSearchMask > 0) {
112
				if(includesAPI() && includesInternal()) {
111
					if(includesAPI() && includesInternal()) {
113
					return true;
114
				}
115
				IApiAnnotations annots = component.getApiDescription().resolveAnnotations(member.getHandle());
116
				if(annots != null) {
117
					int vis = annots.getVisibility();
118
					if(VisibilityModifiers.isAPI(vis) && includesAPI()) {
112
						return true;
119
						return true;
113
					}
120
					}
114
					IApiAnnotations annots = component.getApiDescription().resolveAnnotations(member.getHandle());
121
					else if(VisibilityModifiers.isPrivate(vis) && includesInternal()) {
115
					if(annots != null) {
122
						return true;
116
						int vis = annots.getVisibility();
117
						if(VisibilityModifiers.isAPI(vis) && includesAPI()) {
118
							return true;
119
						}
120
						else if(VisibilityModifiers.isPrivate(vis) && includesInternal()) {
121
							return true;
122
						}
123
					}
123
					}
124
				}
124
				}
125
			}
125
			}
126
		}
126
		}
127
		catch(CoreException ce) {
127
		catch(CoreException ce) {
128
			ApiPlugin.log(ce);
128
			//ApiPlugin.log(ce);
129
		}
129
		}
130
		return false;
130
		return false;
131
	}
131
	}
Lines 144-161 Link Here
144
	 */
144
	 */
145
	private void prepareScope(IApiElement[] elements) {
145
	private void prepareScope(IApiElement[] elements) {
146
		if(elements != null) {
146
		if(elements != null) {
147
			TreeSet comps = new TreeSet(componentsorter);
147
			fScope = new ApiScope();
148
			for(int i = 0; i < elements.length; i++) {
148
			for(int i = 0; i < elements.length; i++) {
149
				comps.add(elements[i].getApiComponent());
149
				fScope.addElement(elements[i].getApiComponent());
150
			}
150
			}
151
			fScope = new ApiUseSearchScope((IApiComponent[]) comps.toArray(new IApiComponent[comps.size()]));
152
		}
151
		}
153
	}
152
	}
154
	
153
	
155
	/* (non-Javadoc)
154
	/* (non-Javadoc)
156
	 * @see org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchRequestor#getScope()
155
	 * @see org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchRequestor#getScope()
157
	 */
156
	 */
158
	public IApiSearchScope getScope() {
157
	public IApiScope getScope() {
159
		return fScope;
158
		return fScope;
160
	}
159
	}
161
	
160
	
Lines 179-182 Link Here
179
	public boolean includesNonApiProjects() {
178
	public boolean includesNonApiProjects() {
180
		return (fSearchMask & INCLUDE_NON_API_ENABLED_PROJECTS) > 0;
179
		return (fSearchMask & INCLUDE_NON_API_ENABLED_PROJECTS) > 0;
181
	}
180
	}
181
	
182
	/* (non-Javadoc)
183
	 * @see org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchRequestor#includesUnresolvedReferences()
184
	 */
185
	public boolean includesUnresolvedReferences() {
186
		return (fSearchMask & INCLUDE_UNRESOLVED_REFERENCES) > 0;
187
	}
182
}
188
}
(-)src_ant/org/eclipse/pde/api/tools/internal/tasks/CompareTask.java (-4 / +4 lines)
Lines 94-100 Link Here
94
			IApiComponent[] apiComponents = currentBaseline.getApiComponents();
94
			IApiComponent[] apiComponents = currentBaseline.getApiComponents();
95
			String[] componentsNames = this.componentsList.split(","); //$NON-NLS-1$
95
			String[] componentsNames = this.componentsList.split(","); //$NON-NLS-1$
96
			if (componentsNames.length == 0) {
96
			if (componentsNames.length == 0) {
97
				scope.add(currentBaseline);
97
				scope.addElement(currentBaseline);
98
			} else {
98
			} else {
99
				for (int i = 0, max = componentsNames.length; i < max; i++) {
99
				for (int i = 0, max = componentsNames.length; i < max; i++) {
100
					String componentName = componentsNames[i];
100
					String componentName = componentsNames[i];
Lines 110-116 Link Here
110
								String componentId = apiComponent.getId();
110
								String componentId = apiComponent.getId();
111
								Matcher matcher = pattern.matcher(componentId);
111
								Matcher matcher = pattern.matcher(componentId);
112
								if (matcher.matches()) {
112
								if (matcher.matches()) {
113
									scope.add(apiComponent);
113
									scope.addElement(apiComponent);
114
								}
114
								}
115
							}
115
							}
116
						} catch (PatternSyntaxException e) {
116
						} catch (PatternSyntaxException e) {
Lines 121-133 Link Here
121
					} else {
121
					} else {
122
						IApiComponent apiComponent = currentBaseline.getApiComponent(componentName);
122
						IApiComponent apiComponent = currentBaseline.getApiComponent(componentName);
123
						if (apiComponent != null) {
123
						if (apiComponent != null) {
124
							scope.add(apiComponent);
124
							scope.addElement(apiComponent);
125
						}
125
						}
126
					}
126
					}
127
				}
127
				}
128
			}
128
			}
129
		} else {
129
		} else {
130
			scope.add(currentBaseline);
130
			scope.addElement(currentBaseline);
131
		}
131
		}
132
		try {
132
		try {
133
			delta = ApiComparator.compare(scope, referenceBaseline, this.visibilityModifiers);
133
			delta = ApiComparator.compare(scope, referenceBaseline, this.visibilityModifiers);
(-)src/org/eclipse/pde/api/tools/internal/provisional/comparator/ApiScope.java (-7 / +30 lines)
Lines 11-16 Link Here
11
package org.eclipse.pde.api.tools.internal.provisional.comparator;
11
package org.eclipse.pde.api.tools.internal.provisional.comparator;
12
12
13
import java.util.HashSet;
13
import java.util.HashSet;
14
import java.util.Iterator;
14
import java.util.Set;
15
import java.util.Set;
15
16
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
Lines 37-43 Link Here
37
	/**
38
	/**
38
	 * Contains all API elements of this scope
39
	 * Contains all API elements of this scope
39
	 */
40
	 */
40
	Set apiElements;
41
	Set elements;
41
42
42
	/* (non-Javadoc)
43
	/* (non-Javadoc)
43
	 * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiScope#accept(org.eclipse.pde.api.tools.internal.provisional.model.ApiScopeVisitor)
44
	 * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiScope#accept(org.eclipse.pde.api.tools.internal.provisional.model.ApiScopeVisitor)
Lines 84-101 Link Here
84
		}
85
		}
85
	}
86
	}
86
87
87
	public void add(IApiElement apiElement) {
88
	/* (non-Javadoc)
88
		if (this.apiElements == null) {
89
	 * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiScope#addElement(org.eclipse.pde.api.tools.internal.provisional.model.IApiElement)
89
			this.apiElements = new HashSet();
90
	 */
91
	public void addElement(IApiElement newelement) {
92
		if (this.elements == null) {
93
			this.elements = new HashSet();
90
		}
94
		}
91
		this.apiElements.add(apiElement);
95
		this.elements.add(newelement);
92
	}
96
	}
93
97
94
	/* (non-Javadoc)
98
	/* (non-Javadoc)
99
	 * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiScope#encloses(org.eclipse.pde.api.tools.internal.provisional.model.IApiElement)
100
	 */
101
	public boolean encloses(IApiElement element) {
102
		if(element != null) {
103
			IApiComponent component = element.getApiComponent();
104
			IApiComponent enclosing = null;
105
			for(Iterator iter = this.elements.iterator(); iter.hasNext();) {
106
				enclosing = ((IApiElement)iter.next()).getApiComponent();
107
				if(component.equals(enclosing)) {
108
					return true;
109
				}
110
			}
111
		}
112
		return false;
113
	}
114
	
115
	/* (non-Javadoc)
95
	 * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiScope#getApiElement()
116
	 * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiScope#getApiElement()
96
	 */
117
	 */
97
	public IApiElement[] getApiElements() {
118
	public IApiElement[] getApiElements() {
98
		if (this.apiElements == null || this.apiElements.size() == 0) return NO_ELEMENTS;
119
		if (this.elements == null || this.elements.size() == 0) {
99
		return (IApiElement[]) this.apiElements.toArray(new IApiElement[this.apiElements.size()]);
120
			return NO_ELEMENTS;
121
		}
122
		return (IApiElement[]) this.elements.toArray(new IApiElement[this.elements.size()]);
100
	}
123
	}
101
}
124
}
(-)src/org/eclipse/pde/api/tools/search/tests/TestRequestor.java (-8 / +13 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.api.tools.search.tests;
11
package org.eclipse.pde.api.tools.search.tests;
12
12
13
import java.util.ArrayList;
14
import java.util.HashSet;
13
import java.util.HashSet;
15
14
16
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
Lines 18-30 Link Here
18
import org.eclipse.pde.api.tools.internal.provisional.IApiAnnotations;
17
import org.eclipse.pde.api.tools.internal.provisional.IApiAnnotations;
19
import org.eclipse.pde.api.tools.internal.provisional.VisibilityModifiers;
18
import org.eclipse.pde.api.tools.internal.provisional.VisibilityModifiers;
20
import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
19
import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
20
import org.eclipse.pde.api.tools.internal.provisional.comparator.ApiScope;
21
import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline;
21
import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline;
22
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
22
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
23
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
23
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
24
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
24
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
25
import org.eclipse.pde.api.tools.internal.provisional.model.IApiScope;
25
import org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchRequestor;
26
import org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchRequestor;
26
import org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchScope;
27
import org.eclipse.pde.api.tools.internal.search.ApiUseSearchScope;
28
import org.eclipse.pde.api.tools.internal.util.Util;
27
import org.eclipse.pde.api.tools.internal.util.Util;
29
28
30
/**
29
/**
Lines 38-44 Link Here
38
	private int searchmask = 0;
37
	private int searchmask = 0;
39
	private HashSet<String> excluded = new HashSet<String>();
38
	private HashSet<String> excluded = new HashSet<String>();
40
	private SearchTest test = null;
39
	private SearchTest test = null;
41
	private IApiSearchScope scope = null;
40
	private IApiScope scope = null;
42
	
41
	
43
	/**
42
	/**
44
	 * Constructor
43
	 * Constructor
Lines 121-144 Link Here
121
	/* (non-Javadoc)
120
	/* (non-Javadoc)
122
	 * @see org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchRequestor#getScope()
121
	 * @see org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchRequestor#getScope()
123
	 */
122
	 */
124
	public IApiSearchScope getScope() {
123
	public IApiScope getScope() {
125
		if(this.scopebaseline == null) {
124
		if(this.scopebaseline == null) {
126
			return null;
125
			return null;
127
		}
126
		}
128
		if(this.scope == null) {
127
		if(this.scope == null) {
129
			try {
128
			try {
130
				IApiComponent[] comps = this.scopebaseline.getApiComponents();
129
				IApiComponent[] comps = this.scopebaseline.getApiComponents();
131
				ArrayList<IApiComponent> clist = new ArrayList<IApiComponent>(comps.length);
130
				this.scope = new ApiScope();
132
				for (int i = 0; i < comps.length; i++) {
131
				for (int i = 0; i < comps.length; i++) {
133
					if(comps[i].isSystemComponent()) {
132
					if(comps[i].isSystemComponent()) {
134
						//never include system libraries in the tests
133
						//never include system libraries in the tests
135
						continue;
134
						continue;
136
					}
135
					}
137
					if(acceptComponent0(comps[i])) {
136
					if(acceptComponent0(comps[i])) {
138
						clist.add(comps[i]);
137
						this.scope.addElement(comps[i]);
139
					}
138
					}
140
				}
139
				}
141
				this.scope = new ApiUseSearchScope(clist.toArray(new IApiComponent[clist.size()]));
142
			}
140
			}
143
			catch(Exception e) {
141
			catch(Exception e) {
144
				this.test.reportFailure(e.getMessage());
142
				this.test.reportFailure(e.getMessage());
Lines 199-204 Link Here
199
		return (this.searchmask & INCLUDE_NON_API_ENABLED_PROJECTS) > 0;
197
		return (this.searchmask & INCLUDE_NON_API_ENABLED_PROJECTS) > 0;
200
	}
198
	}
201
	
199
	
200
	/* (non-Javadoc)
201
	 * @see org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchRequestor#includesUnresolvedReferences()
202
	 */
203
	public boolean includesUnresolvedReferences() {
204
		return (this.searchmask & INCLUDE_UNRESOLVED_REFERENCES) > 0;
205
	}
206
	
202
	/**
207
	/**
203
	 * Sets the {@link IApiBaseline} to derive the scope from
208
	 * Sets the {@link IApiBaseline} to derive the scope from
204
	 * @param baseline
209
	 * @param baseline
(-)src/org/eclipse/pde/api/tools/comparator/tests/ApiScopeDeltaTests.java (-7 / +7 lines)
Lines 60-66 Link Here
60
		IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME);
60
		IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME);
61
		assertNotNull("no api component", afterApiComponent);
61
		assertNotNull("no api component", afterApiComponent);
62
		ApiScope scope = new ApiScope();
62
		ApiScope scope = new ApiScope();
63
		scope.add(after);
63
		scope.addElement(after);
64
		IApiElement[] apiElement = scope.getApiElements();
64
		IApiElement[] apiElement = scope.getApiElements();
65
		assertEquals("Empty", 1, apiElement.length);
65
		assertEquals("Empty", 1, apiElement.length);
66
		IDelta delta = ApiComparator.compare(scope, before, VisibilityModifiers.API);
66
		IDelta delta = ApiComparator.compare(scope, before, VisibilityModifiers.API);
Lines 87-93 Link Here
87
		ApiScope scope = new ApiScope();
87
		ApiScope scope = new ApiScope();
88
		IApiComponent[] apiComponents = after.getApiComponents();
88
		IApiComponent[] apiComponents = after.getApiComponents();
89
		for (int i = 0, max = apiComponents.length; i < max; i++) {
89
		for (int i = 0, max = apiComponents.length; i < max; i++) {
90
			scope.add(apiComponents[i]);
90
			scope.addElement(apiComponents[i]);
91
		}
91
		}
92
		IDelta delta = ApiComparator.compare(scope, before, VisibilityModifiers.API, true);
92
		IDelta delta = ApiComparator.compare(scope, before, VisibilityModifiers.API, true);
93
		assertNotNull("No delta", delta);
93
		assertNotNull("No delta", delta);
Lines 116-122 Link Here
116
			IApiTypeContainer[] apiTypeContainers = apiComponents[i].getApiTypeContainers();
116
			IApiTypeContainer[] apiTypeContainers = apiComponents[i].getApiTypeContainers();
117
			for (int j = 0; j < apiTypeContainers.length; j++) {
117
			for (int j = 0; j < apiTypeContainers.length; j++) {
118
				IApiTypeContainer iApiTypeContainer = apiTypeContainers[j];
118
				IApiTypeContainer iApiTypeContainer = apiTypeContainers[j];
119
				scope.add(iApiTypeContainer);
119
				scope.addElement(iApiTypeContainer);
120
			}
120
			}
121
		}
121
		}
122
		IDelta delta = ApiComparator.compare(scope, before, VisibilityModifiers.API, true);
122
		IDelta delta = ApiComparator.compare(scope, before, VisibilityModifiers.API, true);
Lines 151-157 Link Here
151
			}
151
			}
152
		}
152
		}
153
		if (root != null) {
153
		if (root != null) {
154
			scope.add(root);
154
			scope.addElement(root);
155
		}
155
		}
156
		IDelta delta = ApiComparator.compare(scope, before, VisibilityModifiers.API, true);
156
		IDelta delta = ApiComparator.compare(scope, before, VisibilityModifiers.API, true);
157
		assertNotNull("No delta", delta);
157
		assertNotNull("No delta", delta);
Lines 190-196 Link Here
190
			IApiType structure = root.getStructure();
190
			IApiType structure = root.getStructure();
191
			IApiMethod[] methods = structure.getMethods();
191
			IApiMethod[] methods = structure.getMethods();
192
			for (int i = 0, max = methods.length; i < max; i++) {
192
			for (int i = 0, max = methods.length; i < max; i++) {
193
				scope.add(methods[i]);
193
				scope.addElement(methods[i]);
194
			}
194
			}
195
		}
195
		}
196
		try {
196
		try {
Lines 212-218 Link Here
212
		IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME);
212
		IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME);
213
		assertNotNull("no api component", afterApiComponent);
213
		assertNotNull("no api component", afterApiComponent);
214
		ApiScope scope = new ApiScope();
214
		ApiScope scope = new ApiScope();
215
		scope.add(after);
215
		scope.addElement(after);
216
		IDelta delta = ApiComparator.compare(scope, before, VisibilityModifiers.API);
216
		IDelta delta = ApiComparator.compare(scope, before, VisibilityModifiers.API);
217
		assertNotNull("No delta", delta);
217
		assertNotNull("No delta", delta);
218
		assertTrue("Not NO_DELTA", delta == ApiComparator.NO_DELTA);
218
		assertTrue("Not NO_DELTA", delta == ApiComparator.NO_DELTA);
Lines 229-235 Link Here
229
		IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME);
229
		IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME);
230
		assertNotNull("no api component", afterApiComponent);
230
		assertNotNull("no api component", afterApiComponent);
231
		ApiScope scope = new ApiScope();
231
		ApiScope scope = new ApiScope();
232
		scope.add(after);
232
		scope.addElement(after);
233
		try {
233
		try {
234
			ApiComparator.compare((IApiScope) null, before, VisibilityModifiers.API);
234
			ApiComparator.compare((IApiScope) null, before, VisibilityModifiers.API);
235
			assertFalse("Should not be there", true);
235
			assertFalse("Should not be there", true);
(-)src/org/eclipse/pde/api/tools/ui/internal/wizards/CompareOperation.java (-3 / +3 lines)
Lines 169-175 Link Here
169
						case IJavaElement.JAVA_PROJECT:
169
						case IJavaElement.JAVA_PROJECT:
170
							IApiComponent apiComponent = workspaceBaseline.getApiComponent(javaProject.getElementName());
170
							IApiComponent apiComponent = workspaceBaseline.getApiComponent(javaProject.getElementName());
171
							if (apiComponent != null) {
171
							if (apiComponent != null) {
172
								scope.add(apiComponent);
172
								scope.addElement(apiComponent);
173
							}
173
							}
174
							break;
174
							break;
175
					}
175
					}
Lines 225-231 Link Here
225
		try {
225
		try {
226
			IApiTypeRoot typeRoot = apiComponent.findTypeRoot(classFile.getType().getFullyQualifiedName());
226
			IApiTypeRoot typeRoot = apiComponent.findTypeRoot(classFile.getType().getFullyQualifiedName());
227
			if (typeRoot != null) {
227
			if (typeRoot != null) {
228
				scope.add(typeRoot);
228
				scope.addElement(typeRoot);
229
			}
229
			}
230
		} catch (CoreException e) {
230
		} catch (CoreException e) {
231
			ApiPlugin.log(e);
231
			ApiPlugin.log(e);
Lines 238-244 Link Here
238
			try {
238
			try {
239
				IApiTypeRoot typeRoot = component.findTypeRoot(types[i].getFullyQualifiedName());
239
				IApiTypeRoot typeRoot = component.findTypeRoot(types[i].getFullyQualifiedName());
240
				if (typeRoot != null) {
240
				if (typeRoot != null) {
241
					scope.add(typeRoot);
241
					scope.addElement(typeRoot);
242
				}
242
				}
243
			} catch (CoreException e) {
243
			} catch (CoreException e) {
244
				ApiPlugin.log(e);
244
				ApiPlugin.log(e);

Return to bug 268985