Bug 462437 - Enhancement: getAllResourcesInScope
Summary: Enhancement: getAllResourcesInScope
Status: CLOSED WONTFIX
Alias: None
Product: Sphinx
Classification: Automotive
Component: Compare & Merge IDE Integration (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-18 04:20 EDT by Andreas Graf CLA
Modified: 2024-05-07 00:51 EDT (History)
1 user (show)

See Also:


Attachments
ScopingAwareContentTreeIterator (2.83 KB, application/octet-stream)
2015-03-18 04:31 EDT, Andreas Graf CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Graf CLA 2015-03-18 04:20:06 EDT
We have many usecases where we need only the direct Resources in Scope of an object, but the transitive hull. (E.g., if we have project dependencies A->B->C) and we want "allResourcesInScope" on A, it should return all resources from A, B and C. (not only A and B).

We have a helper class draft, but it might make sense to put something like this in ScopingResourceSet? (Helper class operates on IProject, please adjust to your needs).

	public static List<Resource>  getAllResourcesInScope(IProject project) {
		TransactionalEditingDomain editingDomain = SphinxUtil.getEditingDomain(project); // Not needed if moving to Scoping Resource Set
		ResourceSet resourceSet = editingDomain.getResourceSet();
		if (resourceSet instanceof ScopingResourceSet) {
			ScopingResourceSet srs = (ScopingResourceSet) resourceSet;
				LinkedHashSet<Resource> hashSet = new LinkedHashSet<Resource>(srs.getResourcesInScope(project));
				boolean modified = true;
				while(modified) {
					modified = false;
					List<Resource> nextRun = new ArrayList<Resource>();
					
					for(Resource r : hashSet ) {
						nextRun.addAll(srs.getResourcesInScope(r));
					}
					modified = hashSet.addAll(nextRun);
				}
				return new ArrayList<Resource>(hashSet);
		} else {
			return resourceSet.getResources();
		}
	}
Comment 1 Andreas Graf CLA 2015-03-18 04:29:07 EDT
another small contribution (in attachement), is a content tree iterator that takes scoping into account.
Comment 2 Andreas Graf CLA 2015-03-18 04:31:46 EDT
Created attachment 251681 [details]
ScopingAwareContentTreeIterator

An implementation of a content tree iterator that is aware of the (transitive) scopes.
Comment 3 Balazs Grill CLA 2024-05-07 00:51:11 EDT
Closed stale issue before migration