Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
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.
/*******************************************************************************
* Copyright (c) 2000, 2015 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
* [email protected] - fix for bug 156082
* Bert Vingerhoets - fix for bug 169975
* Serge Beauchamp (Freescale Semiconductor) - [229633] Fix Concurency Exception
* Sergey Prigogin (Google) - [338010] Resource.createLink() does not preserve symbolic links
* Lars Vogel - Bug 473427
*******************************************************************************/
package org.eclipse.core.internal.resources;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.internal.events.ILifecycleListener;
import org.eclipse.core.internal.events.LifecycleEvent;
import org.eclipse.core.internal.localstore.FileSystemResourceManager;
import org.eclipse.core.internal.utils.FileUtil;
import org.eclipse.core.internal.utils.Messages;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osgi.util.NLS;
/**
* An alias is a resource that occupies the same file system location as another
* resource in the workspace. When a resource is modified in a way that affects
* the file on disk, all aliases need to be updated. This class is used to
* maintain data structures for quickly computing the set of aliases for a given
* resource, and for efficiently updating all aliases when a resource changes on
* disk.
*
* The approach for computing aliases is optimized for alias-free workspaces and
* alias-free projects. That is, if the workspace contains no aliases, then
* updating should be very quick. If a resource is changed in a project that
* contains no aliases, it should also be very fast.
*
* The data structures maintained by the alias manager can be seen as a cache,
* that is, they store no information that cannot be recomputed from other
* available information. On shutdown, the alias manager discards all state; on
* startup, the alias manager eagerly rebuilds its state. The reasoning is
* that it's better to incur this cost on startup than on the first attempt to
* modify a resource. After startup, the state is updated incrementally on the
* following occasions:
* - when projects are deleted, opened, closed, or moved
* - when linked resources are created, deleted, or moved.
*/
public class AliasManager implements IManager, ILifecycleListener, IResourceChangeListener {
class FindAliasesDoit implements Consumer {
private final int aliasType;
private final IPath searchPath;
public FindAliasesDoit(IResource aliasResource) {
this.aliasType = aliasResource.getType();
this.searchPath = aliasResource.getFullPath();
}
@Override
public void accept(IResource match) {
//don't record the resource we're computing aliases against as a match
if (match.getFullPath().isPrefixOf(searchPath))
return;
IPath aliasPath = null;
switch (match.getType()) {
case IResource.PROJECT :
//first check if there is a linked resource that blocks the project location
if (suffix.segmentCount() > 0) {
IResource testResource = ((IProject) match).findMember(suffix.segment(0));
if (testResource != null && testResource.isLinked())
return;
}
//there is an alias under this project
aliasPath = match.getFullPath().append(suffix);
break;
case IResource.FOLDER :
aliasPath = match.getFullPath().append(suffix);
break;
case IResource.FILE :
if (suffix.segmentCount() == 0)
aliasPath = match.getFullPath();
break;
}
if (aliasPath != null)
if (aliasType == IResource.FILE) {
aliases.add(workspace.getRoot().getFile(aliasPath));
} else {
if (aliasPath.segmentCount() == 1)
aliases.add(workspace.getRoot().getProject(aliasPath.lastSegment()));
else
aliases.add(workspace.getRoot().getFolder(aliasPath));
}
}
}
/**
* Maintains a mapping of FileStore->IResource, such that multiple resources
* mapped from the same location are tolerated.
*/
class LocationMap {
/**
* Map of FileStore->IResource OR FileStore->ArrayList of (IResource)
*/
private final SortedMap map = new TreeMap<>(IFileStore::compareTo);
/**
* Adds the given resource to the map, keyed by the given location.
* Returns true if a new entry was added, and false otherwise.
*/
public boolean add(IFileStore location, IResource resource) {
Object oldValue = map.get(location);
if (oldValue == null) {
map.put(location, resource);
return true;
}
if (oldValue instanceof IResource) {
if (resource.equals(oldValue))
return false;//duplicate
ArrayList