org.eclipse.core.resources.mapping.ResourceTraversal Java Examples

The following examples show how to use org.eclipse.core.resources.mapping.ResourceTraversal. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaElementResourceMapping.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static ResourceTraversal[] getRemotePackageFragmentTraversals(IPackageFragment pack, RemoteResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
	ArrayList<ResourceTraversal> res= new ArrayList<ResourceTraversal>();
	IContainer container= (IContainer)pack.getResource();
	
	if (container != null) {
		res.add(new ResourceTraversal(new IResource[] {container}, IResource.DEPTH_ONE, 0));
		IResource[] remoteMembers= context.fetchRemoteMembers(container, monitor);
		if (remoteMembers == null) {
			remoteMembers= context.fetchMembers(container, monitor);
		}
		if (remoteMembers != null) {
			for (int i= 0; i < remoteMembers.length; i++) {
				IResource member= remoteMembers[i];
				if (member instanceof IFolder
						&& JavaConventionsUtil.validatePackageName(member.getName(), pack).getSeverity() == IStatus.ERROR) {
					res.add(new ResourceTraversal(new IResource[] { member }, IResource.DEPTH_INFINITE, 0));
				}
			}
		}
	}
	return res.toArray(new ResourceTraversal[res.size()]);
}
 
Example #2
Source File: JavaElementResourceMapping.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static ResourceTraversal[] getPackageFragmentTraversals(IPackageFragment pack) throws CoreException {
	ArrayList<ResourceTraversal> res= new ArrayList<ResourceTraversal>();
	IContainer container= (IContainer)pack.getResource();
	
	if (container != null) {
		res.add(new ResourceTraversal(new IResource[] { container }, IResource.DEPTH_ONE, 0));
		if (pack.exists()) { // folder may not exist any more, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=269167
			Object[] nonJavaResources= pack.getNonJavaResources();
			for (int i= 0; i < nonJavaResources.length; i++) {
				Object resource= nonJavaResources[i];
				if (resource instanceof IFolder) {
					res.add(new ResourceTraversal(new IResource[] { (IResource)resource }, IResource.DEPTH_INFINITE, 0));
				}
			}
		}
	}

	return res.toArray(new ResourceTraversal[res.size()]);
}
 
Example #3
Source File: JavaElementResourceMapping.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static ResourceTraversal[] getPackageFragmentTraversals(IPackageFragment pack) throws CoreException {
	ArrayList<ResourceTraversal> res= new ArrayList<>();
	IContainer container= (IContainer)pack.getResource();

	if (container != null) {
		res.add(new ResourceTraversal(new IResource[] { container }, IResource.DEPTH_ONE, 0));
		if (pack.exists()) { // folder may not exist any more, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=269167
			Object[] nonJavaResources= pack.getNonJavaResources();
			for (int i= 0; i < nonJavaResources.length; i++) {
				Object resource= nonJavaResources[i];
				if (resource instanceof IFolder) {
					res.add(new ResourceTraversal(new IResource[] { (IResource)resource }, IResource.DEPTH_INFINITE, 0));
				}
			}
		}
	}

	return res.toArray(new ResourceTraversal[res.size()]);
}
 
Example #4
Source File: JavaElementResourceMapping.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static ResourceTraversal[] getRemotePackageFragmentTraversals(IPackageFragment pack, RemoteResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
	ArrayList<ResourceTraversal> res= new ArrayList<>();
	IContainer container= (IContainer)pack.getResource();

	if (container != null) {
		res.add(new ResourceTraversal(new IResource[] {container}, IResource.DEPTH_ONE, 0));
		IResource[] remoteMembers= context.fetchRemoteMembers(container, monitor);
		if (remoteMembers == null) {
			remoteMembers= context.fetchMembers(container, monitor);
		}
		if (remoteMembers != null) {
			for (int i= 0; i < remoteMembers.length; i++) {
				IResource member= remoteMembers[i];
				if (member instanceof IFolder
						&& JavaConventionsUtil.validatePackageName(member.getName(), pack).getSeverity() == IStatus.ERROR) {
					res.add(new ResourceTraversal(new IResource[] { member }, IResource.DEPTH_INFINITE, 0));
				}
			}
		}
	}
	return res.toArray(new ResourceTraversal[res.size()]);
}
 
Example #5
Source File: TeamAction.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the selected resources.
 * 
 * @return the selected resources
 */
protected IResource[] getSelectedResources() {
	ArrayList resourceArray = new ArrayList();
	IResource[] resources = (IResource[])getSelectedResources(IResource.class);
	for (int i = 0; i < resources.length; i++) resourceArray.add(resources[i]);
	ResourceMapping[] resourceMappings = (ResourceMapping[])getSelectedAdaptables(selection, ResourceMapping.class);
	for (int i = 0; i < resourceMappings.length; i++) {
		ResourceMapping resourceMapping = (ResourceMapping)resourceMappings[i];
		try {
			ResourceTraversal[] traversals = resourceMapping.getTraversals(null, null);
			for (int j = 0; j < traversals.length; j++) {
				IResource[] traversalResources = traversals[j].getResources();
				for (int k = 0; k < traversalResources.length; k++) {
					if (!resourceArray.contains(traversalResources[k]))
						resourceArray.add(traversalResources[k]);
				}
			}
		} catch (CoreException e) {
			SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
		}
	}		
	IResource[] selectedResources = new IResource[resourceArray.size()];
	resourceArray.toArray(selectedResources);
	return selectedResources;
}
 
Example #6
Source File: JavaElementResourceMapping.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
	IJavaProject[] projects= fJavaModel.getJavaProjects();
	ResourceTraversal[] result= new ResourceTraversal[projects.length];
	for (int i= 0; i < projects.length; i++) {
		result[i]= new ResourceTraversal(new IResource[] {projects[i].getProject()}, IResource.DEPTH_INFINITE, 0);
	}
	return result;
}
 
Example #7
Source File: JavaSynchronizationContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the resource traversals for the element.
 *
 * @param element
 *            the element to get the resource traversals
 * @return the resource traversals
 */
static ResourceTraversal[] getResourceTraversals(final Object element) {
	final ResourceMapping mapping= getResourceMapping(element);
	if (mapping != null)
		try {
			return mapping.getTraversals(ResourceMappingContext.LOCAL_CONTEXT, new NullProgressMonitor());
		} catch (final CoreException exception) {
			JavaPlugin.log(exception);
		}
	return new ResourceTraversal[0];
}
 
Example #8
Source File: JavaElementResourceMapping.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
	List<ResourceTraversal> result= new ArrayList<ResourceTraversal>();
	if (context instanceof RemoteResourceMappingContext) {
		for (int i= 0; i < fFragments.length; i++) {
			result.addAll(Arrays.asList(getRemotePackageFragmentTraversals(fFragments[i], (RemoteResourceMappingContext)context, monitor)));
		}
	} else {
		for (int i= 0; i < fFragments.length; i++) {
			result.addAll(Arrays.asList(getPackageFragmentTraversals(fFragments[i])));
		}
	}
	return result.toArray(new ResourceTraversal[result.size()]);
}
 
Example #9
Source File: JavaElementResourceMapping.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
	if (context instanceof RemoteResourceMappingContext) {
		return getRemotePackageFragmentTraversals(fPack, (RemoteResourceMappingContext)context, monitor);
	} else {
		return getPackageFragmentTraversals(fPack);
	}
}
 
Example #10
Source File: JavaElementResourceMapping.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
	IJavaProject[] projects= fJavaModel.getJavaProjects();
	ResourceTraversal[] result= new ResourceTraversal[projects.length];
	for (int i= 0; i < projects.length; i++) {
		result[i]= new ResourceTraversal(new IResource[] {projects[i].getProject()}, IResource.DEPTH_INFINITE, 0);
	}
	return result;
}
 
Example #11
Source File: ResourceUtils.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public static IResource[] getResourcesFrom(ResourceMapping mapping) {
   	List<IResource> resources = new ArrayList<IResource>();
	try {
		ResourceTraversal[] traversals = mapping.getTraversals(null, null);
		for (ResourceTraversal traversal : traversals) {
			resources.addAll(Arrays.asList(traversal.getResources()));
		}
	} catch (CoreException e) {
		LogHelper.logError(e);
	}
	return resources.toArray(new IResource[0]);
}
 
Example #12
Source File: JavaElementResourceMapping.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
	List<ResourceTraversal> result= new ArrayList<>();
	if (context instanceof RemoteResourceMappingContext) {
		for (int i= 0; i < fFragments.length; i++) {
			result.addAll(Arrays.asList(getRemotePackageFragmentTraversals(fFragments[i], (RemoteResourceMappingContext)context, monitor)));
		}
	} else {
		for (int i= 0; i < fFragments.length; i++) {
			result.addAll(Arrays.asList(getPackageFragmentTraversals(fFragments[i])));
		}
	}
	return result.toArray(new ResourceTraversal[result.size()]);
}
 
Example #13
Source File: JavaElementResourceMapping.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
	if (context instanceof RemoteResourceMappingContext) {
		return getRemotePackageFragmentTraversals(fPack, (RemoteResourceMappingContext)context, monitor);
	} else {
		return getPackageFragmentTraversals(fPack);
	}
}
 
Example #14
Source File: SimpleResourceMapping.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public ResourceTraversal[] getTraversals(
		ResourceMappingContext context,
		IProgressMonitor monitor) throws CoreException {
	return new ResourceTraversal[]{new ResourceTraversal(new IResource[]{r}, IResource.DEPTH_ONE, IResource.NONE)};
}
 
Example #15
Source File: JavaElementResourceMapping.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
	return new ResourceTraversal[] {
		new ResourceTraversal(new IResource[] {fClassFile.getResource()}, IResource.DEPTH_ONE, 0)
	};
}
 
Example #16
Source File: JavaElementResourceMapping.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
	return new ResourceTraversal[] {
		new ResourceTraversal(new IResource[] {fProject.getProject()}, IResource.DEPTH_INFINITE, 0)
	};
}
 
Example #17
Source File: JavaElementResourceMapping.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
	return new ResourceTraversal[] {
		new ResourceTraversal(new IResource[] {fRoot.getResource()}, IResource.DEPTH_INFINITE, 0)
	};
}
 
Example #18
Source File: JavaElementResourceMapping.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
	return new ResourceTraversal[] {
		new ResourceTraversal(new IResource[] {fUnit.getResource()}, IResource.DEPTH_ONE, 0)
	};
}
 
Example #19
Source File: JavaElementResourceMapping.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
	return new ResourceTraversal[] {
		new ResourceTraversal(new IResource[] {fRoot.getResource()}, IResource.DEPTH_INFINITE, 0)
	};
}
 
Example #20
Source File: JavaElementResourceMapping.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
	return new ResourceTraversal[] {
		new ResourceTraversal(new IResource[] {fUnit.getResource()}, IResource.DEPTH_ONE, 0)
	};
}
 
Example #21
Source File: JavaElementResourceMapping.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
	return new ResourceTraversal[] {
		new ResourceTraversal(new IResource[] {fClassFile.getResource()}, IResource.DEPTH_ONE, 0)
	};
}
 
Example #22
Source File: JavaElementResourceMapping.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
	return new ResourceTraversal[] {
		new ResourceTraversal(new IResource[] {fProject.getProject()}, IResource.DEPTH_INFINITE, 0)
	};
}
 
Example #23
Source File: HierarchicalDecorationContext.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
	return new ResourceTraversal[] {
		new ResourceTraversal(new IResource[] {fPack.getResource()}, IResource.DEPTH_INFINITE, 0)
	};
}
 
Example #24
Source File: JavaResourceMapping.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ResourceTraversal[] getTraversals(final ResourceMappingContext context, final IProgressMonitor monitor) {
	return new ResourceTraversal[] { new ResourceTraversal(new IResource[] { fResource }, IResource.DEPTH_INFINITE, IResource.NONE) };
}
 
Example #25
Source File: WorkingSetAdapter.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public ResourceTraversal[] getTraversals(final ResourceMappingContext context, final IProgressMonitor monitor)
		throws CoreException {

	return new ResourceTraversal[] { new ResourceTraversal(getProjects(), DEPTH_INFINITE, 0) };
}
 
Example #26
Source File: JavaSynchronizationContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected ResourceTraversal[] getTraversals(final ISynchronizationContext context, final Object object) {
	return getResourceTraversals(object);
}