mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Check for Reorder changes in the IPathEntry settings,.
This commit is contained in:
parent
1df94abba2
commit
1aeedbdee2
6 changed files with 73 additions and 40 deletions
|
@ -1,3 +1,13 @@
|
|||
2004-03-18 Alain Magloire
|
||||
|
||||
Check for IPathEntry reorder changes.
|
||||
|
||||
* model/org/eclipse/cdt/core/model/ICElementDelta.java
|
||||
* model/org/eclipse/cdt/internal/core/model/CContainerInfo.java
|
||||
* model/org/eclipse/cdt/internal/core/model/CProjectInfoInfo.java
|
||||
* model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
|
||||
* model/org/eclipse/cdt/internal/core/model/SetPathEntriesOperation.java
|
||||
|
||||
2004-03-18 Alain Magloire
|
||||
|
||||
Change in the hierarchy of the core Model:
|
||||
|
|
|
@ -129,7 +129,11 @@ public interface ICElementDelta {
|
|||
*/
|
||||
public int F_CHANGED_PATHENTRY_PROJECT = 0x04000;
|
||||
|
||||
//public int F_PATHENTRY_REORDER = 0x040000;
|
||||
/**
|
||||
* Reordering of the path entries.
|
||||
*/
|
||||
public int F_PATHENTRY_REORDER = 0x040000;
|
||||
|
||||
//public int F_SUPER_TYPES = 0x080000;
|
||||
|
||||
/**
|
||||
|
|
|
@ -54,8 +54,8 @@ public class CContainerInfo extends OpenableInfo {
|
|||
|
||||
if (resources != null) {
|
||||
CModelManager factory = CModelManager.getDefault();
|
||||
ICElement[] children = getChildren();
|
||||
for (int i = 0; i < resources.length; i++) {
|
||||
ICElement[] children = getChildren();
|
||||
boolean found = false;
|
||||
for (int j = 0; j < children.length; j++) {
|
||||
IResource r = children[j].getResource();
|
||||
|
|
|
@ -79,13 +79,13 @@ class CProjectInfo extends CContainerInfo {
|
|||
|
||||
if (resources != null) {
|
||||
CModelManager factory = CModelManager.getDefault();
|
||||
ICElement[] children;
|
||||
if (root == null) {
|
||||
children = getChildren();
|
||||
} else {
|
||||
children = root.getChildren();
|
||||
}
|
||||
for (int i = 0; i < resources.length; i++) {
|
||||
ICElement[] children;
|
||||
if (root == null) {
|
||||
children = getChildren();
|
||||
} else {
|
||||
children = root.getChildren();
|
||||
}
|
||||
boolean found = false;
|
||||
for (int j = 0; j < children.length; j++) {
|
||||
IResource r = children[j].getResource();
|
||||
|
|
|
@ -418,44 +418,57 @@ public class PathEntryManager {
|
|||
public ICElementDelta[] generatePathEntryDeltas(ICProject cproject, IPathEntry[] oldEntries, IPathEntry[] newEntries) {
|
||||
ArrayList list = new ArrayList();
|
||||
CModelManager manager = CModelManager.getDefault();
|
||||
boolean needToUpdateDependents = false;
|
||||
boolean hasDelta = false;
|
||||
|
||||
// Sanity checks
|
||||
if (oldEntries == null) {
|
||||
oldEntries = new IPathEntry[0];
|
||||
}
|
||||
if (newEntries == null) {
|
||||
newEntries = new IPathEntry[0];
|
||||
}
|
||||
|
||||
// Check the removed entries.
|
||||
if (oldEntries != null) {
|
||||
for (int i = 0; i < oldEntries.length; i++) {
|
||||
boolean found = false;
|
||||
if (newEntries != null) {
|
||||
for (int j = 0; j < newEntries.length; j++) {
|
||||
if (oldEntries[i].equals(newEntries[j])) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < oldEntries.length; i++) {
|
||||
boolean found = false;
|
||||
for (int j = 0; j < newEntries.length; j++) {
|
||||
if (oldEntries[i].equals(newEntries[j])) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
// Was it deleted.
|
||||
if (!found) {
|
||||
ICElementDelta delta = makePathEntryDelta(cproject, oldEntries[i], true);
|
||||
if (delta != null) {
|
||||
list.add(delta);
|
||||
}
|
||||
}
|
||||
// Was it deleted.
|
||||
if (!found) {
|
||||
ICElementDelta delta = makePathEntryDelta(cproject, oldEntries[i], true);
|
||||
if (delta != null) {
|
||||
list.add(delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check the new entries.
|
||||
if (newEntries != null) {
|
||||
for (int i = 0; i < newEntries.length; i++) {
|
||||
boolean found = false;
|
||||
if (oldEntries != null) {
|
||||
for (int j = 0; j < oldEntries.length; j++) {
|
||||
if (newEntries[i].equals(oldEntries[j])) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < newEntries.length; i++) {
|
||||
boolean found = false;
|
||||
for (int j = 0; j < oldEntries.length; j++) {
|
||||
if (newEntries[i].equals(oldEntries[j])) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
// is it new?
|
||||
if (!found) {
|
||||
ICElementDelta delta = makePathEntryDelta(cproject, newEntries[i], false);
|
||||
}
|
||||
// is it new?
|
||||
if (!found) {
|
||||
ICElementDelta delta = makePathEntryDelta(cproject, newEntries[i], false);
|
||||
if (delta != null) {
|
||||
list.add(delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for reorder
|
||||
if (list.size() == 0 && oldEntries.length == newEntries.length) {
|
||||
for (int i = 0; i < newEntries.length; i++) {
|
||||
if (!newEntries[i].equals(oldEntries[i])) {
|
||||
ICElementDelta delta = makePathEntryDelta(cproject, null, false);
|
||||
if (delta != null) {
|
||||
list.add(delta);
|
||||
}
|
||||
|
@ -474,7 +487,10 @@ public class PathEntryManager {
|
|||
int kind = entry.getEntryKind();
|
||||
ICElement celement = null;
|
||||
int flag = 0;
|
||||
if (kind == IPathEntry.CDT_SOURCE) {
|
||||
if (entry == null) {
|
||||
celement = cproject;
|
||||
flag = ICElementDelta.F_PATHENTRY_REORDER;
|
||||
} else if (kind == IPathEntry.CDT_SOURCE) {
|
||||
ISourceEntry source = (ISourceEntry) entry;
|
||||
IPath path = source.getPath();
|
||||
celement = CoreModel.getDefault().create(path);
|
||||
|
|
|
@ -53,13 +53,16 @@ public class SetPathEntriesOperation extends CModelOperation {
|
|||
// project reference updated - may throw an exception if unable to write .cdtproject file
|
||||
updateProjectReferencesIfNecessary();
|
||||
PathEntryManager mgr = PathEntryManager.getDefault();
|
||||
mgr.saveRawPathEntries(cproject, newRawEntries);
|
||||
hasModifiedResource = true;
|
||||
IPathEntry[] newResolvedEntries = mgr.getResolvedPathEntries(cproject);
|
||||
ICElementDelta[] deltas = mgr.generatePathEntryDeltas(cproject, oldResolvedEntries, newResolvedEntries);
|
||||
for (int i = 0; i < deltas.length; i++) {
|
||||
addDelta(deltas[i]);
|
||||
}
|
||||
// Only save when necessary
|
||||
if (deltas.length > 0) {
|
||||
mgr.saveRawPathEntries(cproject, newRawEntries);
|
||||
}
|
||||
done();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue