1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-07 00:05:53 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2011-05-24 03:33:09 +00:00
parent b4b606edc1
commit d42416a53b

View file

@ -81,10 +81,8 @@ import org.eclipse.core.runtime.jobs.Job;
/** /**
* @author alain * @author alain
*
*/ */
public class PathEntryManager implements IPathEntryStoreListener, IElementChangedListener { public class PathEntryManager implements IPathEntryStoreListener, IElementChangedListener {
// PathEntry extension // PathEntry extension
public final static String PATHENTRY_STORE_ID = "PathEntryStore"; //$NON-NLS-1$ public final static String PATHENTRY_STORE_ID = "PathEntryStore"; //$NON-NLS-1$
public final static String PATHENTRY_STORE_UNIQ_ID = CCorePlugin.PLUGIN_ID + "." + PATHENTRY_STORE_ID; //$NON-NLS-1$ public final static String PATHENTRY_STORE_UNIQ_ID = CCorePlugin.PLUGIN_ID + "." + PATHENTRY_STORE_ID; //$NON-NLS-1$
@ -395,10 +393,10 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
int count = resPath.segmentCount(); int count = resPath.segmentCount();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
IPath newPath = resPath.removeLastSegments(i); IPath newPath = resPath.removeLastSegments(i);
for (IPathEntry entrie : entries) { for (IPathEntry entry : entries) {
IPath otherPath = entrie.getPath(); IPath otherPath = entry.getPath();
if (newPath.equals(otherPath)) { if (newPath.equals(otherPath)) {
entryList.add(entrie); entryList.add(entry);
} }
} }
} }
@ -482,9 +480,9 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
private IPathEntry[] getCachedResolvedPathEntries(ArrayList<IPathEntry> resolvedListEntries, ICProject cproject) throws CModelException { private IPathEntry[] getCachedResolvedPathEntries(ArrayList<IPathEntry> resolvedListEntries, ICProject cproject) throws CModelException {
IPathEntry[] entries = resolvedListEntries.toArray(NO_PATHENTRIES); IPathEntry[] entries = resolvedListEntries.toArray(NO_PATHENTRIES);
boolean hasContainerExtension = false; boolean hasContainerExtension = false;
for (IPathEntry entrie : entries) { for (IPathEntry entry : entries) {
if (entrie.getEntryKind() == IPathEntry.CDT_CONTAINER) { if (entry.getEntryKind() == IPathEntry.CDT_CONTAINER) {
IContainerEntry centry = (IContainerEntry)entrie; IContainerEntry centry = (IContainerEntry)entry;
IPathEntryContainer container = getPathEntryContainer(centry, cproject); IPathEntryContainer container = getPathEntryContainer(centry, cproject);
if (container instanceof IPathEntryContainerExtension) { if (container instanceof IPathEntryContainerExtension) {
hasContainerExtension = true; hasContainerExtension = true;
@ -502,8 +500,8 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
if (container != null) { if (container != null) {
IPathEntry[] containerEntries = container.getPathEntries(); IPathEntry[] containerEntries = container.getPathEntries();
if (containerEntries != null) { if (containerEntries != null) {
for (IPathEntry containerEntrie : containerEntries) { for (IPathEntry containerEntry : containerEntries) {
IPathEntry newEntry = PathEntryUtil.cloneEntryAndExpand(projectPath, containerEntrie); IPathEntry newEntry = PathEntryUtil.cloneEntryAndExpand(projectPath, containerEntry);
listEntries.add(newEntry); listEntries.add(newEntry);
} }
} }
@ -563,8 +561,8 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
IPathEntry[] containerEntries = container.getPathEntries(); IPathEntry[] containerEntries = container.getPathEntries();
List<IPathEntry> resolvedList = new ArrayList<IPathEntry>(); List<IPathEntry> resolvedList = new ArrayList<IPathEntry>();
if (containerEntries != null) { if (containerEntries != null) {
for (IPathEntry containerEntrie : containerEntries) { for (IPathEntry containerEntry : containerEntries) {
IPathEntry newEntry = PathEntryUtil.cloneEntryAndExpand(projectPath, containerEntrie); IPathEntry newEntry = PathEntryUtil.cloneEntryAndExpand(projectPath, containerEntry);
resolvedEntries.add(newEntry); resolvedEntries.add(newEntry);
resolvedList.add(newEntry); resolvedList.add(newEntry);
} }
@ -594,8 +592,8 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
if (!status.isOK()) { if (!status.isOK()) {
problemList.add(status); problemList.add(status);
} }
for (IPathEntry finalEntrie : finalEntries) { for (IPathEntry finalEntry : finalEntries) {
status = PathEntryUtil.validatePathEntry(cproject, finalEntrie, true, false); status = PathEntryUtil.validatePathEntry(cproject, finalEntry, true, false);
if (!status.isOK()) { if (!status.isOK()) {
problemList.add(status); problemList.add(status);
} }
@ -866,10 +864,10 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
public String[] projectPrerequisites(IPathEntry[] entries) throws CModelException { public String[] projectPrerequisites(IPathEntry[] entries) throws CModelException {
if (entries != null) { if (entries != null) {
ArrayList<String> prerequisites = new ArrayList<String>(); ArrayList<String> prerequisites = new ArrayList<String>();
for (IPathEntry entrie : entries) { for (IPathEntry entry : entries) {
if (entrie.getEntryKind() == IPathEntry.CDT_PROJECT) { if (entry.getEntryKind() == IPathEntry.CDT_PROJECT) {
IProjectEntry entry = (IProjectEntry)entrie; IProjectEntry projectEntry = (IProjectEntry) entry;
prerequisites.add(entry.getPath().lastSegment()); prerequisites.add(projectEntry.getPath().lastSegment());
} }
} }
int size = prerequisites.size(); int size = prerequisites.size();
@ -890,13 +888,11 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
ArrayList<IPathEntry> list = new ArrayList<IPathEntry>(entries.length); ArrayList<IPathEntry> list = new ArrayList<IPathEntry>(entries.length);
IPath projectPath = cproject.getPath(); IPath projectPath = cproject.getPath();
for (IPathEntry entrie : entries) { for (IPathEntry pathEntry : entries) {
IPathEntry entry; int kind = pathEntry.getEntryKind();
int kind = entrie.getEntryKind();
// translate the project prefix. // translate the project prefix.
IPath resourcePath = entrie.getPath(); IPath resourcePath = pathEntry.getPath();
if (resourcePath == null) { if (resourcePath == null) {
resourcePath = Path.EMPTY; resourcePath = Path.EMPTY;
} }
@ -918,9 +914,10 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} }
// Specifics to the entries // Specifics to the entries
IPathEntry entry;
switch (kind) { switch (kind) {
case IPathEntry.CDT_INCLUDE : { case IPathEntry.CDT_INCLUDE: {
IIncludeEntry include = (IIncludeEntry)entrie; IIncludeEntry include = (IIncludeEntry)pathEntry;
IPath baseRef = include.getBaseReference(); IPath baseRef = include.getBaseReference();
if (baseRef == null || baseRef.isEmpty()) { if (baseRef == null || baseRef.isEmpty()) {
entry = CoreModel.newIncludeEntry(resourcePath, include.getBasePath(), include.getIncludePath(), entry = CoreModel.newIncludeEntry(resourcePath, include.getBasePath(), include.getIncludePath(),
@ -930,15 +927,15 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} }
break; break;
} }
case IPathEntry.CDT_INCLUDE_FILE : { case IPathEntry.CDT_INCLUDE_FILE: {
IIncludeFileEntry includeFile = (IIncludeFileEntry)entrie; IIncludeFileEntry includeFile = (IIncludeFileEntry)pathEntry;
entry = CoreModel.newIncludeFileEntry(resourcePath, includeFile.getBasePath(), entry = CoreModel.newIncludeFileEntry(resourcePath, includeFile.getBasePath(),
includeFile.getBaseReference(), includeFile.getIncludeFilePath(), includeFile.getBaseReference(), includeFile.getIncludeFilePath(),
includeFile.getExclusionPatterns(), includeFile.isExported()); includeFile.getExclusionPatterns(), includeFile.isExported());
break; break;
} }
case IPathEntry.CDT_LIBRARY : { case IPathEntry.CDT_LIBRARY: {
ILibraryEntry library = (ILibraryEntry)entrie; ILibraryEntry library = (ILibraryEntry)pathEntry;
IPath sourcePath = library.getSourceAttachmentPath(); IPath sourcePath = library.getSourceAttachmentPath();
if (sourcePath != null) { if (sourcePath != null) {
// translate to project relative from absolute // translate to project relative from absolute
@ -959,8 +956,8 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} }
break; break;
} }
case IPathEntry.CDT_MACRO : { case IPathEntry.CDT_MACRO: {
IMacroEntry macro = (IMacroEntry)entrie; IMacroEntry macro = (IMacroEntry)pathEntry;
IPath baseRef = macro.getBaseReference(); IPath baseRef = macro.getBaseReference();
if (baseRef == null || baseRef.isEmpty()) { if (baseRef == null || baseRef.isEmpty()) {
entry = CoreModel.newMacroEntry(resourcePath, macro.getMacroName(), macro.getMacroValue(), entry = CoreModel.newMacroEntry(resourcePath, macro.getMacroName(), macro.getMacroValue(),
@ -970,33 +967,33 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} }
break; break;
} }
case IPathEntry.CDT_MACRO_FILE : { case IPathEntry.CDT_MACRO_FILE: {
IMacroFileEntry macro = (IMacroFileEntry)entrie; IMacroFileEntry macro = (IMacroFileEntry)pathEntry;
entry = CoreModel.newMacroFileEntry(resourcePath, macro.getBasePath(), entry = CoreModel.newMacroFileEntry(resourcePath, macro.getBasePath(),
macro.getBaseReference(), macro.getMacroFilePath(), macro.getBaseReference(), macro.getMacroFilePath(),
macro.getExclusionPatterns(), macro.isExported()); macro.getExclusionPatterns(), macro.isExported());
break; break;
} }
case IPathEntry.CDT_OUTPUT : { case IPathEntry.CDT_OUTPUT: {
IOutputEntry out = (IOutputEntry)entrie; IOutputEntry out = (IOutputEntry)pathEntry;
entry = CoreModel.newOutputEntry(resourcePath, out.getExclusionPatterns()); entry = CoreModel.newOutputEntry(resourcePath, out.getExclusionPatterns());
break; break;
} }
case IPathEntry.CDT_PROJECT : { case IPathEntry.CDT_PROJECT: {
IProjectEntry projEntry = (IProjectEntry)entrie; IProjectEntry projEntry = (IProjectEntry)pathEntry;
entry = CoreModel.newProjectEntry(projEntry.getPath(), projEntry.isExported()); entry = CoreModel.newProjectEntry(projEntry.getPath(), projEntry.isExported());
break; break;
} }
case IPathEntry.CDT_SOURCE : { case IPathEntry.CDT_SOURCE: {
ISourceEntry source = (ISourceEntry)entrie; ISourceEntry source = (ISourceEntry)pathEntry;
entry = CoreModel.newSourceEntry(resourcePath, source.getExclusionPatterns()); entry = CoreModel.newSourceEntry(resourcePath, source.getExclusionPatterns());
break; break;
} }
case IPathEntry.CDT_CONTAINER : case IPathEntry.CDT_CONTAINER:
entry = CoreModel.newContainerEntry(entrie.getPath(), entrie.isExported()); entry = CoreModel.newContainerEntry(pathEntry.getPath(), pathEntry.isExported());
break; break;
default : default:
entry = entrie; entry = pathEntry;
} }
list.add(entry); list.add(entry);
} }
@ -1071,17 +1068,17 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} }
// Check the removed entries. // Check the removed entries.
for (IPathEntry oldEntrie : oldEntries) { for (IPathEntry oldEntry : oldEntries) {
boolean found = false; boolean found = false;
for (IPathEntry newEntrie : newEntries) { for (IPathEntry newEntrie : newEntries) {
if (oldEntrie.equals(newEntrie)) { if (oldEntry.equals(newEntrie)) {
found = true; found = true;
break; break;
} }
} }
// Was it deleted. // Was it deleted.
if (!found) { if (!found) {
ICElementDelta delta = makePathEntryDelta(cproject, oldEntrie, true); ICElementDelta delta = makePathEntryDelta(cproject, oldEntry, true);
if (delta != null) { if (delta != null) {
list.add(delta); list.add(delta);
} }
@ -1089,17 +1086,17 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} }
// Check the new entries. // Check the new entries.
for (IPathEntry newEntrie : newEntries) { for (IPathEntry newEntry : newEntries) {
boolean found = false; boolean found = false;
for (IPathEntry oldEntrie : oldEntries) { for (IPathEntry oldEntry : oldEntries) {
if (newEntrie.equals(oldEntrie)) { if (newEntry.equals(oldEntry)) {
found = true; found = true;
break; break;
} }
} }
// is it new? // is it new?
if (!found) { if (!found) {
ICElementDelta delta = makePathEntryDelta(cproject, newEntrie, false); ICElementDelta delta = makePathEntryDelta(cproject, newEntry, false);
if (delta != null) { if (delta != null) {
list.add(delta); list.add(delta);
} }
@ -1141,25 +1138,25 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} else { } else {
int kind = entry.getEntryKind(); int kind = entry.getEntryKind();
switch (kind) { switch (kind) {
case IPathEntry.CDT_SOURCE : { case IPathEntry.CDT_SOURCE: {
ISourceEntry source = (ISourceEntry)entry; ISourceEntry source = (ISourceEntry)entry;
IPath path = source.getPath(); IPath path = source.getPath();
celement = CoreModel.getDefault().create(path); celement = CoreModel.getDefault().create(path);
flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_SOURCE : ICElementDelta.F_ADDED_PATHENTRY_SOURCE; flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_SOURCE : ICElementDelta.F_ADDED_PATHENTRY_SOURCE;
break; break;
} }
case IPathEntry.CDT_LIBRARY : { case IPathEntry.CDT_LIBRARY: {
celement = cproject; celement = cproject;
flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY : ICElementDelta.F_ADDED_PATHENTRY_LIBRARY; flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY : ICElementDelta.F_ADDED_PATHENTRY_LIBRARY;
break; break;
} }
case IPathEntry.CDT_PROJECT : { case IPathEntry.CDT_PROJECT: {
//IProjectEntry pentry = (IProjectEntry) entry; //IProjectEntry pentry = (IProjectEntry) entry;
celement = cproject; celement = cproject;
flag = ICElementDelta.F_CHANGED_PATHENTRY_PROJECT; flag = ICElementDelta.F_CHANGED_PATHENTRY_PROJECT;
break; break;
} }
case IPathEntry.CDT_INCLUDE : { case IPathEntry.CDT_INCLUDE: {
IIncludeEntry include = (IIncludeEntry)entry; IIncludeEntry include = (IIncludeEntry)entry;
IPath path = include.getPath(); IPath path = include.getPath();
celement = CoreModel.getDefault().create(path); celement = CoreModel.getDefault().create(path);
@ -1173,7 +1170,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
flag = ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE; flag = ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE;
break; break;
} }
case IPathEntry.CDT_MACRO : { case IPathEntry.CDT_MACRO: {
IMacroEntry macro = (IMacroEntry)entry; IMacroEntry macro = (IMacroEntry)entry;
IPath path = macro.getPath(); IPath path = macro.getPath();
celement = CoreModel.getDefault().create(path); celement = CoreModel.getDefault().create(path);
@ -1187,7 +1184,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
flag = ICElementDelta.F_CHANGED_PATHENTRY_MACRO; flag = ICElementDelta.F_CHANGED_PATHENTRY_MACRO;
break; break;
} }
case IPathEntry.CDT_CONTAINER : { case IPathEntry.CDT_CONTAINER: {
//IContainerEntry container = (IContainerEntry) entry; //IContainerEntry container = (IContainerEntry) entry;
//celement = cproject; //celement = cproject;
//SHOULD NOT BE HERE Container are resolved. //SHOULD NOT BE HERE Container are resolved.
@ -1345,8 +1342,8 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
IMarker[] markers = project.findMarkers(ICModelMarker.PATHENTRY_PROBLEM_MARKER, false, IResource.DEPTH_ZERO); IMarker[] markers = project.findMarkers(ICModelMarker.PATHENTRY_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
if (markers != null && markers.length > 0) { if (markers != null && markers.length > 0) {
ArrayList<ICModelStatus> problemList = new ArrayList<ICModelStatus>(); ArrayList<ICModelStatus> problemList = new ArrayList<ICModelStatus>();
for (IPathEntry entrie : entries) { for (IPathEntry entry : entries) {
ICModelStatus status = PathEntryUtil.validatePathEntry(project2, entrie, true, false); ICModelStatus status = PathEntryUtil.validatePathEntry(project2, entry, true, false);
if (!status.isOK()) { if (!status.isOK()) {
problemList.add(status); problemList.add(status);
} }
@ -1426,7 +1423,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} }
/** /**
* The sourceroot been deleted update the path entries * The source root been deleted update the path entries
* @param sourceRoot * @param sourceRoot
* @throws CModelException * @throws CModelException
*/ */
@ -1466,7 +1463,6 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} }
} }
public ICModelStatus validatePathEntry(ICProject cProject, IPathEntry[] entries) { public ICModelStatus validatePathEntry(ICProject cProject, IPathEntry[] entries) {
return PathEntryUtil.validatePathEntry(cProject, entries); return PathEntryUtil.validatePathEntry(cProject, entries);
} }
@ -1475,5 +1471,4 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
boolean recurseInContainers) { boolean recurseInContainers) {
return PathEntryUtil.validatePathEntry(cProject, entry, checkSourceAttachment, recurseInContainers); return PathEntryUtil.validatePathEntry(cProject, entry, checkSourceAttachment, recurseInContainers);
} }
} }