mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
refactoring.
This commit is contained in:
parent
97c1e621cd
commit
dcf729b3ca
6 changed files with 124 additions and 61 deletions
|
@ -16,9 +16,11 @@ import junit.framework.TestSuite;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
||||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
|
import org.eclipse.cdt.core.model.IContainerEntry;
|
||||||
import org.eclipse.cdt.core.model.IPathEntry;
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IElementChangedListener;
|
import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||||
|
import org.eclipse.cdt.core.model.IPathEntryContainer;
|
||||||
import org.eclipse.cdt.testplugin.CProjectHelper;
|
import org.eclipse.cdt.testplugin.CProjectHelper;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
|
@ -26,6 +28,7 @@ import org.eclipse.core.resources.IWorkspaceDescription;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
@ -50,7 +53,7 @@ public class CPathEntryTest extends TestCase {
|
||||||
int flags = delta.getFlags();
|
int flags = delta.getFlags();
|
||||||
int kind = delta.getKind();
|
int kind = delta.getKind();
|
||||||
if (kind == ICElementDelta.CHANGED ) {
|
if (kind == ICElementDelta.CHANGED ) {
|
||||||
if ((flags & ICElementDelta.F_ADDED_TO_CPATHENTRY) != 0) {
|
if ((flags & ICElementDelta.F_ADDED_TO_PATHENTRY) != 0) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +145,8 @@ public class CPathEntryTest extends TestCase {
|
||||||
entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null);
|
entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null);
|
||||||
testProject.setRawPathEntries(entries, new NullProgressMonitor());
|
testProject.setRawPathEntries(entries, new NullProgressMonitor());
|
||||||
entries = testProject.getResolvedPathEntries();
|
entries = testProject.getResolvedPathEntries();
|
||||||
assertTrue("Tree cpathenties", entries.length == 3);
|
assertTrue("Expecting 3 pathentries", entries.length == 3);
|
||||||
|
testProject.setRawPathEntries(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************************************************************
|
/*******************************************************************************************************************************
|
||||||
|
@ -152,19 +156,57 @@ public class CPathEntryTest extends TestCase {
|
||||||
*/
|
*/
|
||||||
public void testCPathEntriesDelta() throws CoreException {
|
public void testCPathEntriesDelta() throws CoreException {
|
||||||
ICProject testProject;
|
ICProject testProject;
|
||||||
testProject = CProjectHelper.createCProject("cpathtest2", "none");
|
testProject = CProjectHelper.createCProject("cpathtest", "none");
|
||||||
if (testProject == null) {
|
if (testProject == null) {
|
||||||
fail("Unable to create project");
|
fail("Unable to create project");
|
||||||
}
|
}
|
||||||
|
CProjectHelper.addSourceContainer(testProject, "foo");
|
||||||
IPathEntry[] entries = new IPathEntry[3];
|
IPathEntry[] entries = new IPathEntry[3];
|
||||||
entries[0] = CoreModel.newIncludeEntry(new Path("cpathtest"), new Path("/usr/include"), true);
|
entries[0] = CoreModel.newIncludeEntry(new Path("cpathtest"), new Path("/usr/include"), true);
|
||||||
entries[1] = CoreModel.newIncludeEntry(new Path("cpaththest/foo.c"), new Path("/usr/include"), true);
|
entries[1] = CoreModel.newIncludeEntry(new Path("cpaththest/foo"), new Path("/usr/include"), true);
|
||||||
entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null);
|
entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null);
|
||||||
final int count = 0;
|
|
||||||
CElementListener listener = new CElementListener();
|
CElementListener listener = new CElementListener();
|
||||||
CoreModel.getDefault().addElementChangedListener(listener);
|
CoreModel.getDefault().addElementChangedListener(listener);
|
||||||
testProject.setRawPathEntries(entries, new NullProgressMonitor());
|
testProject.setRawPathEntries(entries, new NullProgressMonitor());
|
||||||
entries = testProject.getResolvedPathEntries();
|
entries = testProject.getResolvedPathEntries();
|
||||||
assertTrue("Tree cpathenties", listener.count == 2);
|
CoreModel.getDefault().removeElementChangedListener(listener);
|
||||||
|
testProject.setRawPathEntries(null, null);
|
||||||
|
assertTrue("Expecting 3 pathEntries deltas", listener.count >= 1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* Check the IPathEntryContainer.
|
||||||
|
*/
|
||||||
|
public void testPathEntryContainer() throws CoreException {
|
||||||
|
ICProject testProject;
|
||||||
|
testProject = CProjectHelper.createCProject("cpathtest", "none");
|
||||||
|
if (testProject == null) {
|
||||||
|
fail("Unable to create project");
|
||||||
|
}
|
||||||
|
final IPath containerID = new Path("Testing/Container");
|
||||||
|
IContainerEntry containerEntry = CoreModel.newContainerEntry(containerID);
|
||||||
|
IPathEntryContainer container = new IPathEntryContainer() {
|
||||||
|
|
||||||
|
public IPathEntry[] getPathEntries() {
|
||||||
|
IPathEntry[] entries = new IPathEntry[3];
|
||||||
|
entries[0] = CoreModel.newIncludeEntry(new Path("cpathtest"), new Path("/usr/include"), true);
|
||||||
|
entries[1] = CoreModel.newIncludeEntry(new Path("cpaththest/foo.c"), new Path("/usr/include"), true);
|
||||||
|
entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null);
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return "Testing container"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPath getPath() {
|
||||||
|
return containerID;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
CoreModel.getDefault().setRawPathEntries(testProject, new IPathEntry[]{containerEntry}, new NullProgressMonitor());
|
||||||
|
CoreModel.getDefault().setPathEntryContainer(new ICProject[]{testProject}, container, new NullProgressMonitor());
|
||||||
|
IPathEntry[] entries = testProject.getResolvedPathEntries();
|
||||||
|
assertTrue("Expecting 3 pathentries from container", entries.length == 3);
|
||||||
|
}
|
||||||
|
}
|
|
@ -621,7 +621,7 @@ public class CoreModel {
|
||||||
* @see IPathEntry
|
* @see IPathEntry
|
||||||
*/
|
*/
|
||||||
public IPathEntry[] getResolvedClasspathEntries(ICProject cproject) throws CModelException {
|
public IPathEntry[] getResolvedClasspathEntries(ICProject cproject) throws CModelException {
|
||||||
return pathEntryManager.getRawPathEntries(cproject);
|
return pathEntryManager.getResolvedPathEntries(cproject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -103,12 +103,12 @@ public interface ICElementDelta {
|
||||||
/**
|
/**
|
||||||
* A cpathEntry was added for this resource.
|
* A cpathEntry was added for this resource.
|
||||||
*/
|
*/
|
||||||
public int F_ADDED_TO_CPATHENTRY = 0x0040;
|
public int F_ADDED_TO_PATHENTRY = 0x0040;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A cpathEtnry was remove for this resource.
|
* A cpathEtnry was remove for this resource.
|
||||||
*/
|
*/
|
||||||
public int F_REMOVED_FROM_CPATHENTRY = 0x0080;
|
public int F_REMOVED_FROM_PATHENTRY = 0x0080;
|
||||||
|
|
||||||
//public int F_CLASSPATH_REORDER = 0x0100;
|
//public int F_CLASSPATH_REORDER = 0x0100;
|
||||||
//public int F_SUPER_TYPES = 0x0800;
|
//public int F_SUPER_TYPES = 0x0800;
|
||||||
|
|
|
@ -492,6 +492,11 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
||||||
execute();
|
execute();
|
||||||
} finally {
|
} finally {
|
||||||
registerDeltas();
|
registerDeltas();
|
||||||
|
// Fire if we change somethings
|
||||||
|
if (!hasModifiedResource()) {
|
||||||
|
CModelManager manager= CModelManager.getDefault();
|
||||||
|
manager.fire();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ import org.eclipse.cdt.core.model.ISourceEntry;
|
||||||
import org.eclipse.cdt.core.model.PathEntryContainerInitializer;
|
import org.eclipse.cdt.core.model.PathEntryContainerInitializer;
|
||||||
import org.eclipse.cdt.internal.core.CharOperation;
|
import org.eclipse.cdt.internal.core.CharOperation;
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.IExtension;
|
import org.eclipse.core.runtime.IExtension;
|
||||||
|
@ -89,7 +88,7 @@ public class PathEntryManager {
|
||||||
*/
|
*/
|
||||||
public static HashMap Containers = new HashMap(5);
|
public static HashMap Containers = new HashMap(5);
|
||||||
|
|
||||||
HashMap projectMap = new HashMap();
|
HashMap resolvedMap = new HashMap();
|
||||||
|
|
||||||
private static PathEntryManager pathEntryManager;
|
private static PathEntryManager pathEntryManager;
|
||||||
|
|
||||||
|
@ -107,7 +106,7 @@ public class PathEntryManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPathEntry[] getResolvedPathEntries(ICProject cproject) throws CModelException {
|
public IPathEntry[] getResolvedPathEntries(ICProject cproject) throws CModelException {
|
||||||
IPathEntry[] entries = (IPathEntry[]) projectMap.get(cproject);
|
IPathEntry[] entries = (IPathEntry[]) resolvedMap.get(cproject);
|
||||||
if (entries == null) {
|
if (entries == null) {
|
||||||
entries = getRawPathEntries(cproject);
|
entries = getRawPathEntries(cproject);
|
||||||
ArrayList list = new ArrayList();
|
ArrayList list = new ArrayList();
|
||||||
|
@ -121,9 +120,7 @@ public class PathEntryManager {
|
||||||
IPathEntry[] containerEntries = container.getPathEntries();
|
IPathEntry[] containerEntries = container.getPathEntries();
|
||||||
if (containerEntries != null) {
|
if (containerEntries != null) {
|
||||||
for (int j = 0; j < containerEntries.length; j++) {
|
for (int j = 0; j < containerEntries.length; j++) {
|
||||||
if (entry.isExported()) {
|
list.add(containerEntries[i]);
|
||||||
list.add(containerEntries[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +130,7 @@ public class PathEntryManager {
|
||||||
}
|
}
|
||||||
entries = new IPathEntry[list.size()];
|
entries = new IPathEntry[list.size()];
|
||||||
list.toArray(entries);
|
list.toArray(entries);
|
||||||
projectMap.put(cproject, entries);
|
resolvedMap.put(cproject, entries);
|
||||||
}
|
}
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
@ -142,6 +139,7 @@ public class PathEntryManager {
|
||||||
try {
|
try {
|
||||||
SetPathEntriesOperation op = new SetPathEntriesOperation(cproject, getRawPathEntries(cproject), newEntries);
|
SetPathEntriesOperation op = new SetPathEntriesOperation(cproject, getRawPathEntries(cproject), newEntries);
|
||||||
CModelManager.getDefault().runOperation(op, monitor);
|
CModelManager.getDefault().runOperation(op, monitor);
|
||||||
|
resolvedMap.put(cproject, null);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
throw new CModelException(e);
|
throw new CModelException(e);
|
||||||
}
|
}
|
||||||
|
@ -173,10 +171,11 @@ public class PathEntryManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPath containerPath = newContainer.getPath();
|
IPath containerPath = (newContainer == null) ? new Path("") : newContainer.getPath();
|
||||||
final int projectLength = affectedProjects.length;
|
final int projectLength = affectedProjects.length;
|
||||||
final ICProject[] modifiedProjects = new ICProject[projectLength];
|
final ICProject[] modifiedProjects = new ICProject[projectLength];
|
||||||
System.arraycopy(affectedProjects, 0, modifiedProjects, 0, projectLength);
|
System.arraycopy(affectedProjects, 0, modifiedProjects, 0, projectLength);
|
||||||
|
final IPathEntry[][] oldResolvedEntries = new IPathEntry[projectLength][];
|
||||||
|
|
||||||
// filter out unmodified project containers
|
// filter out unmodified project containers
|
||||||
int remaining = 0;
|
int remaining = 0;
|
||||||
|
@ -189,16 +188,14 @@ public class PathEntryManager {
|
||||||
ICProject affectedProject = affectedProjects[i];
|
ICProject affectedProject = affectedProjects[i];
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
if (CoreModel.getDefault().hasCCNature(affectedProject.getProject())) {
|
IPathEntry[] rawPath = getRawPathEntries(affectedProject);
|
||||||
IPathEntry[] rawPath = affectedProject.getRawPathEntries();
|
for (int j = 0, cpLength = rawPath.length; j < cpLength; j++) {
|
||||||
for (int j = 0, cpLength = rawPath.length; j < cpLength; j++) {
|
IPathEntry entry = rawPath[j];
|
||||||
IPathEntry entry = rawPath[j];
|
if (entry.getEntryKind() == IPathEntry.CDT_CONTAINER) {
|
||||||
if (entry.getEntryKind() == IPathEntry.CDT_CONTAINER) {
|
IContainerEntry cont = (IContainerEntry) entry;
|
||||||
IContainerEntry cont = (IContainerEntry) entry;
|
if (cont.getPath().equals(containerPath)) {
|
||||||
if (cont.getPath().equals(containerPath)) {
|
found = true;
|
||||||
found = true;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,11 +205,12 @@ public class PathEntryManager {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
IPathEntryContainer oldContainer = containerGet(affectedProject, containerPath);
|
IPathEntryContainer oldContainer = containerGet(affectedProject, containerPath);
|
||||||
if (oldContainer != null && oldContainer.equals(newContainer)) {
|
if (oldContainer != null && newContainer != null && oldContainer.equals(newContainer)) {
|
||||||
modifiedProjects[i] = null; // filter out this project - container did not change
|
modifiedProjects[i] = null; // filter out this project - container did not change
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
remaining++;
|
remaining++;
|
||||||
|
oldResolvedEntries[i] = (IPathEntry[])resolvedMap.get(affectedProject);
|
||||||
containerPut(affectedProject, containerPath, newContainer);
|
containerPut(affectedProject, containerPath, newContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,11 +221,11 @@ public class PathEntryManager {
|
||||||
|
|
||||||
// trigger model refresh
|
// trigger model refresh
|
||||||
try {
|
try {
|
||||||
//final boolean canChangeResources = !ResourcesPlugin.getWorkspace().isTreeLocked();
|
CoreModel.run(new IWorkspaceRunnable() {
|
||||||
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
|
||||||
public void run(IProgressMonitor progressMonitor) throws CoreException {
|
public void run(IProgressMonitor progressMonitor) throws CoreException {
|
||||||
|
boolean shouldFire = false;
|
||||||
|
CModelManager mgr = CModelManager.getDefault();
|
||||||
for (int i = 0; i < projectLength; i++) {
|
for (int i = 0; i < projectLength; i++) {
|
||||||
|
|
||||||
if (progressMonitor != null && progressMonitor.isCanceled()) {
|
if (progressMonitor != null && progressMonitor.isCanceled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -235,8 +233,21 @@ public class PathEntryManager {
|
||||||
if (affectedProject == null) {
|
if (affectedProject == null) {
|
||||||
continue; // was filtered out
|
continue; // was filtered out
|
||||||
}
|
}
|
||||||
// force a refresh of the affected project (will compute deltas)
|
|
||||||
affectedProject.setRawPathEntries(affectedProject.getRawPathEntries(), progressMonitor);
|
IPathEntry[] newEntries = getResolvedPathEntries(affectedProject);
|
||||||
|
ICElementDelta[] deltas = generatePathEntryDeltas(affectedProject,
|
||||||
|
oldResolvedEntries[i], newEntries);
|
||||||
|
if (deltas.length > 0) {
|
||||||
|
shouldFire = true;
|
||||||
|
for (int j = 0; j < deltas.length; j++) {
|
||||||
|
mgr.registerCModelDelta(deltas[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//affectedProject.setRawPathEntries(affectedProject.getRawPathEntries(), progressMonitor);
|
||||||
|
}
|
||||||
|
if (shouldFire) {
|
||||||
|
mgr.fire();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, monitor);
|
}, monitor);
|
||||||
|
@ -352,22 +363,24 @@ public class PathEntryManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] projectPrerequisites(IPathEntry[] entries) throws CModelException {
|
public String[] projectPrerequisites(IPathEntry[] entries) throws CModelException {
|
||||||
ArrayList prerequisites = new ArrayList();
|
if (entries != null) {
|
||||||
for (int i = 0, length = entries.length; i < length; i++) {
|
ArrayList prerequisites = new ArrayList();
|
||||||
if (entries[i].getEntryKind() == IPathEntry.CDT_PROJECT) {
|
for (int i = 0, length = entries.length; i < length; i++) {
|
||||||
IProjectEntry entry = (IProjectEntry)entries[i];
|
if (entries[i].getEntryKind() == IPathEntry.CDT_PROJECT) {
|
||||||
prerequisites.add(entry.getProjectPath().lastSegment());
|
IProjectEntry entry = (IProjectEntry)entries[i];
|
||||||
|
prerequisites.add(entry.getProjectPath().lastSegment());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int size = prerequisites.size();
|
||||||
|
if (size != 0) {
|
||||||
|
String[] result = new String[size];
|
||||||
|
prerequisites.toArray(result);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
int size = prerequisites.size();
|
|
||||||
if (size != 0) {
|
|
||||||
String[] result = new String[size];
|
|
||||||
prerequisites.toArray(result);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
return NO_PREREQUISITES;
|
return NO_PREREQUISITES;
|
||||||
}
|
}
|
||||||
public ICElementDelta[] saveRawPathEntries(ICProject cproject, IPathEntry[] oldEntries, IPathEntry[] newEntries) throws CModelException {
|
public void saveRawPathEntries(ICProject cproject, IPathEntry[] oldEntries, IPathEntry[] newEntries) throws CModelException {
|
||||||
try {
|
try {
|
||||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(cproject.getProject());
|
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(cproject.getProject());
|
||||||
Element rootElement = descriptor.getProjectData(PATH_ENTRY_ID);
|
Element rootElement = descriptor.getProjectData(PATH_ENTRY_ID);
|
||||||
|
@ -383,16 +396,14 @@ public class PathEntryManager {
|
||||||
// Serialize the include paths
|
// Serialize the include paths
|
||||||
Document doc = rootElement.getOwnerDocument();
|
Document doc = rootElement.getOwnerDocument();
|
||||||
encodePathEntries(cproject.getPath(), doc, rootElement, newEntries);
|
encodePathEntries(cproject.getPath(), doc, rootElement, newEntries);
|
||||||
descriptor.saveProjectData();
|
|
||||||
}
|
}
|
||||||
|
descriptor.saveProjectData();
|
||||||
return generatePathEntryDeltas(cproject, oldEntries, newEntries);
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
throw new CModelException(e);
|
throw new CModelException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICElementDelta[] generatePathEntryDeltas(ICProject cproject, IPathEntry[] oldEntries, IPathEntry[] newEntries) {
|
public ICElementDelta[] generatePathEntryDeltas(ICProject cproject, IPathEntry[] oldEntries, IPathEntry[] newEntries) {
|
||||||
ArrayList list = new ArrayList();
|
ArrayList list = new ArrayList();
|
||||||
CModelManager manager = CModelManager.getDefault();
|
CModelManager manager = CModelManager.getDefault();
|
||||||
boolean needToUpdateDependents = false;
|
boolean needToUpdateDependents = false;
|
||||||
|
@ -402,16 +413,18 @@ public class PathEntryManager {
|
||||||
if (oldEntries != null) {
|
if (oldEntries != null) {
|
||||||
for (int i = 0; i < oldEntries.length; i++) {
|
for (int i = 0; i < oldEntries.length; i++) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (int j = 0; j < newEntries.length; j++) {
|
if (newEntries != null) {
|
||||||
if (oldEntries[i].equals(newEntries[j])) {
|
for (int j = 0; j < newEntries.length; j++) {
|
||||||
found = true;
|
if (oldEntries[i].equals(newEntries[j])) {
|
||||||
break;
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Was it deleted.
|
// Was it deleted.
|
||||||
if (!found) {
|
if (!found) {
|
||||||
ICElementDelta delta =
|
ICElementDelta delta =
|
||||||
makePathEntryDelta(cproject, oldEntries[i], ICElementDelta.F_REMOVED_FROM_CPATHENTRY);
|
makePathEntryDelta(cproject, oldEntries[i], ICElementDelta.F_REMOVED_FROM_PATHENTRY);
|
||||||
if (delta != null) {
|
if (delta != null) {
|
||||||
list.add(delta);
|
list.add(delta);
|
||||||
}
|
}
|
||||||
|
@ -422,16 +435,18 @@ public class PathEntryManager {
|
||||||
if (newEntries != null) {
|
if (newEntries != null) {
|
||||||
for (int i = 0; i < newEntries.length; i++) {
|
for (int i = 0; i < newEntries.length; i++) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (int j = 0; j < oldEntries.length; j++) {
|
if (oldEntries != null) {
|
||||||
if (newEntries[i].equals(oldEntries[j])) {
|
for (int j = 0; j < oldEntries.length; j++) {
|
||||||
found = true;
|
if (newEntries[i].equals(oldEntries[j])) {
|
||||||
break;
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// is it new?
|
// is it new?
|
||||||
if (!found) {
|
if (!found) {
|
||||||
ICElementDelta delta =
|
ICElementDelta delta =
|
||||||
makePathEntryDelta(cproject, newEntries[i], ICElementDelta.F_ADDED_TO_CPATHENTRY);
|
makePathEntryDelta(cproject, newEntries[i], ICElementDelta.F_ADDED_TO_PATHENTRY);
|
||||||
if (delta != null) {
|
if (delta != null) {
|
||||||
list.add(delta);
|
list.add(delta);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,8 @@ public class SetPathEntriesOperation extends CModelOperation {
|
||||||
// project reference updated - may throw an exception if unable to write .cdtproject file
|
// project reference updated - may throw an exception if unable to write .cdtproject file
|
||||||
updateProjectReferencesIfNecessary();
|
updateProjectReferencesIfNecessary();
|
||||||
PathEntryManager mgr = PathEntryManager.getDefault();
|
PathEntryManager mgr = PathEntryManager.getDefault();
|
||||||
ICElementDelta[] deltas = mgr.saveRawPathEntries(cproject, oldEntries, newEntries);
|
mgr.saveRawPathEntries(cproject, oldEntries, newEntries);
|
||||||
|
ICElementDelta[] deltas = mgr.generatePathEntryDeltas(cproject, oldEntries, newEntries);
|
||||||
for (int i = 0; i < deltas.length; i++) {
|
for (int i = 0; i < deltas.length; i++) {
|
||||||
addDelta(deltas[i]);
|
addDelta(deltas[i]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue