All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.core.internal.resources.mapping.SimpleResourceMapping Maven / Gradle / Ivy

Go to download

AspectJ tools most notably contains the AspectJ compiler (AJC). AJC applies aspects to Java classes during compilation, fully replacing Javac for plain Java classes and also compiling native AspectJ or annotation-based @AspectJ syntax. Furthermore, AJC can weave aspects into existing class files in a post-compile binary weaving step. This library is a superset of AspectJ weaver and hence also of AspectJ runtime.

There is a newer version: 1.9.22.1
Show newest version
/*******************************************************************************
 * Copyright (c) 2005, 2014 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.core.internal.resources.mapping;

import org.eclipse.core.resources.*;
import org.eclipse.core.resources.mapping.*;
import org.eclipse.core.runtime.IProgressMonitor;

/**
 * A simple resource mapping for converting IResource to ResourceMapping.
 * It uses the resource as the model object and traverses deeply.
 *
 * @since 3.1
 */
public class SimpleResourceMapping extends ResourceMapping {
	private final IResource resource;

	public SimpleResourceMapping(IResource resource) {
		this.resource = resource;
	}

	@Override
	public boolean contains(ResourceMapping mapping) {
		if (mapping.getModelProviderId().equals(this.getModelProviderId())) {
			Object object = mapping.getModelObject();
			if (object instanceof IResource) {
				IResource other = (IResource) object;
				return resource.getFullPath().isPrefixOf(other.getFullPath());
			}
			if (object instanceof ShallowContainer) {
				ShallowContainer sc = (ShallowContainer) object;
				IResource other = sc.getResource();
				return resource.getFullPath().isPrefixOf(other.getFullPath());
			}
		}
		return false;
	}

	@Override
	public Object getModelObject() {
		return resource;
	}

	@Override
	public String getModelProviderId() {
		return ModelProvider.RESOURCE_MODEL_PROVIDER_ID;
	}

	@Override
	public IProject[] getProjects() {
		if (resource.getType() == IResource.ROOT)
			return ((IWorkspaceRoot) resource).getProjects();
		return new IProject[] {resource.getProject()};
	}

	@Override
	public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) {
		if (resource.getType() == IResource.ROOT) {
			return new ResourceTraversal[] {new ResourceTraversal(((IWorkspaceRoot) resource).getProjects(), IResource.DEPTH_INFINITE, IResource.NONE)};
		}
		return new ResourceTraversal[] {new ResourceTraversal(new IResource[] {resource}, IResource.DEPTH_INFINITE, IResource.NONE)};
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy